mirror of
https://github.com/freqtrade/freqtrade.git
synced 2024-11-15 04:33:57 +00:00
2696 lines
128 KiB
HTML
2696 lines
128 KiB
HTML
|
|
<!doctype html>
|
|
<html lang="en" class="no-js">
|
|
<head>
|
|
|
|
<meta charset="utf-8">
|
|
<meta name="viewport" content="width=device-width,initial-scale=1">
|
|
|
|
|
|
|
|
<link rel="canonical" href="https://www.freqtrade.io/2023.5/hyperopt/">
|
|
|
|
|
|
<link rel="prev" href="../backtesting/">
|
|
|
|
|
|
<link rel="next" href="../freqai/">
|
|
|
|
<link rel="icon" href="../images/logo.png">
|
|
<meta name="generator" content="mkdocs-1.4.3, mkdocs-material-9.1.14">
|
|
|
|
|
|
|
|
<title>Hyperopt - Freqtrade</title>
|
|
|
|
|
|
|
|
<link rel="stylesheet" href="../assets/stylesheets/main.85bb2934.min.css">
|
|
|
|
|
|
<link rel="stylesheet" href="../assets/stylesheets/palette.a6bdf11c.min.css">
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
|
|
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Roboto:300,300i,400,400i,700,700i%7CRoboto+Mono:400,400i,700,700i&display=fallback">
|
|
<style>:root{--md-text-font:"Roboto";--md-code-font:"Roboto Mono"}</style>
|
|
|
|
|
|
|
|
<link rel="stylesheet" href="../stylesheets/ft.extra.css">
|
|
|
|
<script>__md_scope=new URL("..",location),__md_hash=e=>[...e].reduce((e,_)=>(e<<5)-e+_.charCodeAt(0),0),__md_get=(e,_=localStorage,t=__md_scope)=>JSON.parse(_.getItem(t.pathname+"."+e)),__md_set=(e,_,t=localStorage,a=__md_scope)=>{try{t.setItem(a.pathname+"."+e,JSON.stringify(_))}catch(e){}}</script>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
</head>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<body dir="ltr" data-md-color-scheme="default" data-md-color-primary="blue-grey" data-md-color-accent="tear">
|
|
|
|
|
|
|
|
<script>var palette=__md_get("__palette");if(palette&&"object"==typeof palette.color)for(var key of Object.keys(palette.color))document.body.setAttribute("data-md-color-"+key,palette.color[key])</script>
|
|
|
|
<input class="md-toggle" data-md-toggle="drawer" type="checkbox" id="__drawer" autocomplete="off">
|
|
<input class="md-toggle" data-md-toggle="search" type="checkbox" id="__search" autocomplete="off">
|
|
<label class="md-overlay" for="__drawer"></label>
|
|
<div data-md-component="skip">
|
|
|
|
|
|
<a href="#hyperopt" class="md-skip">
|
|
Skip to content
|
|
</a>
|
|
|
|
</div>
|
|
<div data-md-component="announce">
|
|
|
|
</div>
|
|
|
|
<div data-md-color-scheme="default" data-md-component="outdated" hidden>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<header class="md-header md-header--shadow" data-md-component="header">
|
|
<nav class="md-header__inner md-grid" aria-label="Header">
|
|
<a href=".." title="Freqtrade" class="md-header__button md-logo" aria-label="Freqtrade" data-md-component="logo">
|
|
|
|
<img src="../images/logo.png" alt="logo">
|
|
|
|
</a>
|
|
<label class="md-header__button md-icon" for="__drawer">
|
|
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M3 6h18v2H3V6m0 5h18v2H3v-2m0 5h18v2H3v-2Z"/></svg>
|
|
</label>
|
|
<div class="md-header__title" data-md-component="header-title">
|
|
<div class="md-header__ellipsis">
|
|
<div class="md-header__topic">
|
|
<span class="md-ellipsis">
|
|
Freqtrade
|
|
</span>
|
|
</div>
|
|
<div class="md-header__topic" data-md-component="header-topic">
|
|
<span class="md-ellipsis">
|
|
|
|
Hyperopt
|
|
|
|
</span>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
|
|
<form class="md-header__option" data-md-component="palette">
|
|
|
|
|
|
|
|
|
|
<input class="md-option" data-md-color-media="" data-md-color-scheme="default" data-md-color-primary="blue-grey" data-md-color-accent="tear" aria-label="Switch to dark mode" type="radio" name="__palette" id="__palette_1">
|
|
|
|
<label class="md-header__button md-icon" title="Switch to dark mode" for="__palette_2" hidden>
|
|
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M17 6H7c-3.31 0-6 2.69-6 6s2.69 6 6 6h10c3.31 0 6-2.69 6-6s-2.69-6-6-6zm0 10H7c-2.21 0-4-1.79-4-4s1.79-4 4-4h10c2.21 0 4 1.79 4 4s-1.79 4-4 4zM7 9c-1.66 0-3 1.34-3 3s1.34 3 3 3 3-1.34 3-3-1.34-3-3-3z"/></svg>
|
|
</label>
|
|
|
|
|
|
|
|
|
|
|
|
<input class="md-option" data-md-color-media="" data-md-color-scheme="slate" data-md-color-primary="blue-grey" data-md-color-accent="tear" aria-label="Switch to light mode" type="radio" name="__palette" id="__palette_2">
|
|
|
|
<label class="md-header__button md-icon" title="Switch to light mode" for="__palette_1" hidden>
|
|
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M17 7H7a5 5 0 0 0-5 5 5 5 0 0 0 5 5h10a5 5 0 0 0 5-5 5 5 0 0 0-5-5m0 8a3 3 0 0 1-3-3 3 3 0 0 1 3-3 3 3 0 0 1 3 3 3 3 0 0 1-3 3Z"/></svg>
|
|
</label>
|
|
|
|
|
|
</form>
|
|
|
|
|
|
|
|
|
|
<label class="md-header__button md-icon" for="__search">
|
|
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M9.5 3A6.5 6.5 0 0 1 16 9.5c0 1.61-.59 3.09-1.56 4.23l.27.27h.79l5 5-1.5 1.5-5-5v-.79l-.27-.27A6.516 6.516 0 0 1 9.5 16 6.5 6.5 0 0 1 3 9.5 6.5 6.5 0 0 1 9.5 3m0 2C7 5 5 7 5 9.5S7 14 9.5 14 14 12 14 9.5 12 5 9.5 5Z"/></svg>
|
|
</label>
|
|
<div class="md-search" data-md-component="search" role="dialog">
|
|
<label class="md-search__overlay" for="__search"></label>
|
|
<div class="md-search__inner" role="search">
|
|
<form class="md-search__form" name="search">
|
|
<input type="text" class="md-search__input" name="query" aria-label="Search" placeholder="Search" autocapitalize="off" autocorrect="off" autocomplete="off" spellcheck="false" data-md-component="search-query" required>
|
|
<label class="md-search__icon md-icon" for="__search">
|
|
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M9.5 3A6.5 6.5 0 0 1 16 9.5c0 1.61-.59 3.09-1.56 4.23l.27.27h.79l5 5-1.5 1.5-5-5v-.79l-.27-.27A6.516 6.516 0 0 1 9.5 16 6.5 6.5 0 0 1 3 9.5 6.5 6.5 0 0 1 9.5 3m0 2C7 5 5 7 5 9.5S7 14 9.5 14 14 12 14 9.5 12 5 9.5 5Z"/></svg>
|
|
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M20 11v2H8l5.5 5.5-1.42 1.42L4.16 12l7.92-7.92L13.5 5.5 8 11h12Z"/></svg>
|
|
</label>
|
|
<nav class="md-search__options" aria-label="Search">
|
|
|
|
<a href="javascript:void(0)" class="md-search__icon md-icon" title="Share" aria-label="Share" data-clipboard data-clipboard-text="" data-md-component="search-share" tabindex="-1">
|
|
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M18 16.08c-.76 0-1.44.3-1.96.77L8.91 12.7c.05-.23.09-.46.09-.7 0-.24-.04-.47-.09-.7l7.05-4.11c.54.5 1.25.81 2.04.81a3 3 0 0 0 3-3 3 3 0 0 0-3-3 3 3 0 0 0-3 3c0 .24.04.47.09.7L8.04 9.81C7.5 9.31 6.79 9 6 9a3 3 0 0 0-3 3 3 3 0 0 0 3 3c.79 0 1.5-.31 2.04-.81l7.12 4.15c-.05.21-.08.43-.08.66 0 1.61 1.31 2.91 2.92 2.91 1.61 0 2.92-1.3 2.92-2.91A2.92 2.92 0 0 0 18 16.08Z"/></svg>
|
|
</a>
|
|
|
|
<button type="reset" class="md-search__icon md-icon" title="Clear" aria-label="Clear" tabindex="-1">
|
|
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M19 6.41 17.59 5 12 10.59 6.41 5 5 6.41 10.59 12 5 17.59 6.41 19 12 13.41 17.59 19 19 17.59 13.41 12 19 6.41Z"/></svg>
|
|
</button>
|
|
</nav>
|
|
|
|
</form>
|
|
<div class="md-search__output">
|
|
<div class="md-search__scrollwrap" data-md-scrollfix>
|
|
<div class="md-search-result" data-md-component="search-result">
|
|
<div class="md-search-result__meta">
|
|
Initializing search
|
|
</div>
|
|
<ol class="md-search-result__list" role="presentation"></ol>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
|
|
<div class="md-header__source">
|
|
<a href="https://github.com/freqtrade/freqtrade" title="Go to repository" class="md-source" data-md-component="source">
|
|
<div class="md-source__icon md-icon">
|
|
|
|
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 448 512"><!--! Font Awesome Free 6.4.0 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free (Icons: CC BY 4.0, Fonts: SIL OFL 1.1, Code: MIT License) Copyright 2023 Fonticons, Inc.--><path d="M439.55 236.05 244 40.45a28.87 28.87 0 0 0-40.81 0l-40.66 40.63 51.52 51.52c27.06-9.14 52.68 16.77 43.39 43.68l49.66 49.66c34.23-11.8 61.18 31 35.47 56.69-26.49 26.49-70.21-2.87-56-37.34L240.22 199v121.85c25.3 12.54 22.26 41.85 9.08 55a34.34 34.34 0 0 1-48.55 0c-17.57-17.6-11.07-46.91 11.25-56v-123c-20.8-8.51-24.6-30.74-18.64-45L142.57 101 8.45 235.14a28.86 28.86 0 0 0 0 40.81l195.61 195.6a28.86 28.86 0 0 0 40.8 0l194.69-194.69a28.86 28.86 0 0 0 0-40.81z"/></svg>
|
|
</div>
|
|
<div class="md-source__repository">
|
|
GitHub
|
|
</div>
|
|
</a>
|
|
</div>
|
|
|
|
</nav>
|
|
|
|
</header>
|
|
|
|
<div class="md-container" data-md-component="container">
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<main class="md-main" data-md-component="main">
|
|
<div class="md-main__inner md-grid">
|
|
|
|
|
|
<!-- Main navigation -->
|
|
|
|
|
|
<div class="md-sidebar md-sidebar--primary" data-md-component="sidebar" data-md-type="navigation" >
|
|
<div class="md-sidebar__scrollwrap">
|
|
<div class="md-sidebar__inner">
|
|
|
|
|
|
|
|
<nav class="md-nav md-nav--primary" aria-label="Navigation" data-md-level="0">
|
|
<label class="md-nav__title" for="__drawer">
|
|
<a href=".." title="Freqtrade" class="md-nav__button md-logo" aria-label="Freqtrade" data-md-component="logo">
|
|
|
|
<img src="../images/logo.png" alt="logo">
|
|
|
|
</a>
|
|
Freqtrade
|
|
</label>
|
|
|
|
<div class="md-nav__source">
|
|
<a href="https://github.com/freqtrade/freqtrade" title="Go to repository" class="md-source" data-md-component="source">
|
|
<div class="md-source__icon md-icon">
|
|
|
|
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 448 512"><!--! Font Awesome Free 6.4.0 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free (Icons: CC BY 4.0, Fonts: SIL OFL 1.1, Code: MIT License) Copyright 2023 Fonticons, Inc.--><path d="M439.55 236.05 244 40.45a28.87 28.87 0 0 0-40.81 0l-40.66 40.63 51.52 51.52c27.06-9.14 52.68 16.77 43.39 43.68l49.66 49.66c34.23-11.8 61.18 31 35.47 56.69-26.49 26.49-70.21-2.87-56-37.34L240.22 199v121.85c25.3 12.54 22.26 41.85 9.08 55a34.34 34.34 0 0 1-48.55 0c-17.57-17.6-11.07-46.91 11.25-56v-123c-20.8-8.51-24.6-30.74-18.64-45L142.57 101 8.45 235.14a28.86 28.86 0 0 0 0 40.81l195.61 195.6a28.86 28.86 0 0 0 40.8 0l194.69-194.69a28.86 28.86 0 0 0 0-40.81z"/></svg>
|
|
</div>
|
|
<div class="md-source__repository">
|
|
GitHub
|
|
</div>
|
|
</a>
|
|
</div>
|
|
|
|
<ul class="md-nav__list" data-md-scrollfix>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<li class="md-nav__item">
|
|
<a href=".." class="md-nav__link">
|
|
Home
|
|
</a>
|
|
</li>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<li class="md-nav__item">
|
|
<a href="../docker_quickstart/" class="md-nav__link">
|
|
Quickstart with Docker
|
|
</a>
|
|
</li>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<li class="md-nav__item md-nav__item--nested">
|
|
|
|
|
|
|
|
|
|
<input class="md-nav__toggle md-toggle " type="checkbox" id="__nav_3" >
|
|
|
|
|
|
|
|
<label class="md-nav__link" for="__nav_3" id="__nav_3_label" tabindex="0">
|
|
Installation
|
|
<span class="md-nav__icon md-icon"></span>
|
|
</label>
|
|
|
|
<nav class="md-nav" data-md-level="1" aria-labelledby="__nav_3_label" aria-expanded="false">
|
|
<label class="md-nav__title" for="__nav_3">
|
|
<span class="md-nav__icon md-icon"></span>
|
|
Installation
|
|
</label>
|
|
<ul class="md-nav__list" data-md-scrollfix>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<li class="md-nav__item">
|
|
<a href="../installation/" class="md-nav__link">
|
|
Linux/MacOS/Raspberry
|
|
</a>
|
|
</li>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<li class="md-nav__item">
|
|
<a href="../windows_installation/" class="md-nav__link">
|
|
Windows
|
|
</a>
|
|
</li>
|
|
|
|
|
|
|
|
|
|
</ul>
|
|
</nav>
|
|
</li>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<li class="md-nav__item">
|
|
<a href="../bot-basics/" class="md-nav__link">
|
|
Freqtrade Basics
|
|
</a>
|
|
</li>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<li class="md-nav__item">
|
|
<a href="../configuration/" class="md-nav__link">
|
|
Configuration
|
|
</a>
|
|
</li>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<li class="md-nav__item">
|
|
<a href="../strategy-customization/" class="md-nav__link">
|
|
Strategy Customization
|
|
</a>
|
|
</li>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<li class="md-nav__item">
|
|
<a href="../strategy-callbacks/" class="md-nav__link">
|
|
Strategy Callbacks
|
|
</a>
|
|
</li>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<li class="md-nav__item">
|
|
<a href="../stoploss/" class="md-nav__link">
|
|
Stoploss
|
|
</a>
|
|
</li>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<li class="md-nav__item">
|
|
<a href="../plugins/" class="md-nav__link">
|
|
Plugins
|
|
</a>
|
|
</li>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<li class="md-nav__item">
|
|
<a href="../bot-usage/" class="md-nav__link">
|
|
Start the bot
|
|
</a>
|
|
</li>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<li class="md-nav__item md-nav__item--nested">
|
|
|
|
|
|
|
|
|
|
<input class="md-nav__toggle md-toggle " type="checkbox" id="__nav_11" >
|
|
|
|
|
|
|
|
<label class="md-nav__link" for="__nav_11" id="__nav_11_label" tabindex="0">
|
|
Control the bot
|
|
<span class="md-nav__icon md-icon"></span>
|
|
</label>
|
|
|
|
<nav class="md-nav" data-md-level="1" aria-labelledby="__nav_11_label" aria-expanded="false">
|
|
<label class="md-nav__title" for="__nav_11">
|
|
<span class="md-nav__icon md-icon"></span>
|
|
Control the bot
|
|
</label>
|
|
<ul class="md-nav__list" data-md-scrollfix>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<li class="md-nav__item">
|
|
<a href="../telegram-usage/" class="md-nav__link">
|
|
Telegram
|
|
</a>
|
|
</li>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<li class="md-nav__item">
|
|
<a href="../rest-api/" class="md-nav__link">
|
|
REST API & FreqUI
|
|
</a>
|
|
</li>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<li class="md-nav__item">
|
|
<a href="../webhook-config/" class="md-nav__link">
|
|
Web Hook
|
|
</a>
|
|
</li>
|
|
|
|
|
|
|
|
|
|
</ul>
|
|
</nav>
|
|
</li>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<li class="md-nav__item">
|
|
<a href="../data-download/" class="md-nav__link">
|
|
Data Downloading
|
|
</a>
|
|
</li>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<li class="md-nav__item">
|
|
<a href="../backtesting/" class="md-nav__link">
|
|
Backtesting
|
|
</a>
|
|
</li>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<li class="md-nav__item md-nav__item--active">
|
|
|
|
<input class="md-nav__toggle md-toggle" type="checkbox" id="__toc">
|
|
|
|
|
|
|
|
|
|
|
|
<label class="md-nav__link md-nav__link--active" for="__toc">
|
|
Hyperopt
|
|
<span class="md-nav__icon md-icon"></span>
|
|
</label>
|
|
|
|
<a href="./" class="md-nav__link md-nav__link--active">
|
|
Hyperopt
|
|
</a>
|
|
|
|
|
|
|
|
<nav class="md-nav md-nav--secondary" aria-label="Table of contents">
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<label class="md-nav__title" for="__toc">
|
|
<span class="md-nav__icon md-icon"></span>
|
|
Table of contents
|
|
</label>
|
|
<ul class="md-nav__list" data-md-component="toc" data-md-scrollfix>
|
|
|
|
<li class="md-nav__item">
|
|
<a href="#install-hyperopt-dependencies" class="md-nav__link">
|
|
Install hyperopt dependencies
|
|
</a>
|
|
|
|
<nav class="md-nav" aria-label="Install hyperopt dependencies">
|
|
<ul class="md-nav__list">
|
|
|
|
<li class="md-nav__item">
|
|
<a href="#docker" class="md-nav__link">
|
|
Docker
|
|
</a>
|
|
|
|
</li>
|
|
|
|
<li class="md-nav__item">
|
|
<a href="#easy-installation-script-setupsh-manual-installation" class="md-nav__link">
|
|
Easy installation script (setup.sh) / Manual installation
|
|
</a>
|
|
|
|
</li>
|
|
|
|
</ul>
|
|
</nav>
|
|
|
|
</li>
|
|
|
|
<li class="md-nav__item">
|
|
<a href="#hyperopt-command-reference" class="md-nav__link">
|
|
Hyperopt command reference
|
|
</a>
|
|
|
|
<nav class="md-nav" aria-label="Hyperopt command reference">
|
|
<ul class="md-nav__list">
|
|
|
|
<li class="md-nav__item">
|
|
<a href="#hyperopt-checklist" class="md-nav__link">
|
|
Hyperopt checklist
|
|
</a>
|
|
|
|
</li>
|
|
|
|
<li class="md-nav__item">
|
|
<a href="#hyperopt-execution-logic" class="md-nav__link">
|
|
Hyperopt execution logic
|
|
</a>
|
|
|
|
</li>
|
|
|
|
<li class="md-nav__item">
|
|
<a href="#configure-your-guards-and-triggers" class="md-nav__link">
|
|
Configure your Guards and Triggers
|
|
</a>
|
|
|
|
<nav class="md-nav" aria-label="Configure your Guards and Triggers">
|
|
<ul class="md-nav__list">
|
|
|
|
<li class="md-nav__item">
|
|
<a href="#exit-signal-optimization" class="md-nav__link">
|
|
Exit signal optimization
|
|
</a>
|
|
|
|
</li>
|
|
|
|
</ul>
|
|
</nav>
|
|
|
|
</li>
|
|
|
|
</ul>
|
|
</nav>
|
|
|
|
</li>
|
|
|
|
<li class="md-nav__item">
|
|
<a href="#solving-a-mystery" class="md-nav__link">
|
|
Solving a Mystery
|
|
</a>
|
|
|
|
<nav class="md-nav" aria-label="Solving a Mystery">
|
|
<ul class="md-nav__list">
|
|
|
|
<li class="md-nav__item">
|
|
<a href="#defining-indicators-to-be-used" class="md-nav__link">
|
|
Defining indicators to be used
|
|
</a>
|
|
|
|
</li>
|
|
|
|
<li class="md-nav__item">
|
|
<a href="#hyperoptable-parameters" class="md-nav__link">
|
|
Hyperoptable parameters
|
|
</a>
|
|
|
|
</li>
|
|
|
|
</ul>
|
|
</nav>
|
|
|
|
</li>
|
|
|
|
<li class="md-nav__item">
|
|
<a href="#parameter-types" class="md-nav__link">
|
|
Parameter types
|
|
</a>
|
|
|
|
</li>
|
|
|
|
<li class="md-nav__item">
|
|
<a href="#optimizing-an-indicator-parameter" class="md-nav__link">
|
|
Optimizing an indicator parameter
|
|
</a>
|
|
|
|
</li>
|
|
|
|
<li class="md-nav__item">
|
|
<a href="#optimizing-protections" class="md-nav__link">
|
|
Optimizing protections
|
|
</a>
|
|
|
|
<nav class="md-nav" aria-label="Optimizing protections">
|
|
<ul class="md-nav__list">
|
|
|
|
<li class="md-nav__item">
|
|
<a href="#migrating-from-previous-property-setups" class="md-nav__link">
|
|
Migrating from previous property setups
|
|
</a>
|
|
|
|
</li>
|
|
|
|
<li class="md-nav__item">
|
|
<a href="#optimizing-max_entry_position_adjustment" class="md-nav__link">
|
|
Optimizing max_entry_position_adjustment
|
|
</a>
|
|
|
|
</li>
|
|
|
|
</ul>
|
|
</nav>
|
|
|
|
</li>
|
|
|
|
<li class="md-nav__item">
|
|
<a href="#loss-functions" class="md-nav__link">
|
|
Loss-functions
|
|
</a>
|
|
|
|
</li>
|
|
|
|
<li class="md-nav__item">
|
|
<a href="#execute-hyperopt" class="md-nav__link">
|
|
Execute Hyperopt
|
|
</a>
|
|
|
|
<nav class="md-nav" aria-label="Execute Hyperopt">
|
|
<ul class="md-nav__list">
|
|
|
|
<li class="md-nav__item">
|
|
<a href="#execute-hyperopt-with-different-historical-data-source" class="md-nav__link">
|
|
Execute Hyperopt with different historical data source
|
|
</a>
|
|
|
|
</li>
|
|
|
|
<li class="md-nav__item">
|
|
<a href="#running-hyperopt-with-a-smaller-test-set" class="md-nav__link">
|
|
Running Hyperopt with a smaller test-set
|
|
</a>
|
|
|
|
</li>
|
|
|
|
<li class="md-nav__item">
|
|
<a href="#running-hyperopt-with-smaller-search-space" class="md-nav__link">
|
|
Running Hyperopt with Smaller Search Space
|
|
</a>
|
|
|
|
</li>
|
|
|
|
</ul>
|
|
</nav>
|
|
|
|
</li>
|
|
|
|
<li class="md-nav__item">
|
|
<a href="#understand-the-hyperopt-result" class="md-nav__link">
|
|
Understand the Hyperopt Result
|
|
</a>
|
|
|
|
<nav class="md-nav" aria-label="Understand the Hyperopt Result">
|
|
<ul class="md-nav__list">
|
|
|
|
<li class="md-nav__item">
|
|
<a href="#automatic-parameter-application-to-the-strategy" class="md-nav__link">
|
|
Automatic parameter application to the strategy
|
|
</a>
|
|
|
|
</li>
|
|
|
|
<li class="md-nav__item">
|
|
<a href="#understand-hyperopt-roi-results" class="md-nav__link">
|
|
Understand Hyperopt ROI results
|
|
</a>
|
|
|
|
<nav class="md-nav" aria-label="Understand Hyperopt ROI results">
|
|
<ul class="md-nav__list">
|
|
|
|
<li class="md-nav__item">
|
|
<a href="#default-roi-search-space" class="md-nav__link">
|
|
Default ROI Search Space
|
|
</a>
|
|
|
|
</li>
|
|
|
|
</ul>
|
|
</nav>
|
|
|
|
</li>
|
|
|
|
<li class="md-nav__item">
|
|
<a href="#understand-hyperopt-stoploss-results" class="md-nav__link">
|
|
Understand Hyperopt Stoploss results
|
|
</a>
|
|
|
|
<nav class="md-nav" aria-label="Understand Hyperopt Stoploss results">
|
|
<ul class="md-nav__list">
|
|
|
|
<li class="md-nav__item">
|
|
<a href="#default-stoploss-search-space" class="md-nav__link">
|
|
Default Stoploss Search Space
|
|
</a>
|
|
|
|
</li>
|
|
|
|
</ul>
|
|
</nav>
|
|
|
|
</li>
|
|
|
|
<li class="md-nav__item">
|
|
<a href="#understand-hyperopt-trailing-stop-results" class="md-nav__link">
|
|
Understand Hyperopt Trailing Stop results
|
|
</a>
|
|
|
|
<nav class="md-nav" aria-label="Understand Hyperopt Trailing Stop results">
|
|
<ul class="md-nav__list">
|
|
|
|
<li class="md-nav__item">
|
|
<a href="#default-trailing-stop-search-space" class="md-nav__link">
|
|
Default Trailing Stop Search Space
|
|
</a>
|
|
|
|
</li>
|
|
|
|
</ul>
|
|
</nav>
|
|
|
|
</li>
|
|
|
|
<li class="md-nav__item">
|
|
<a href="#reproducible-results" class="md-nav__link">
|
|
Reproducible results
|
|
</a>
|
|
|
|
</li>
|
|
|
|
</ul>
|
|
</nav>
|
|
|
|
</li>
|
|
|
|
<li class="md-nav__item">
|
|
<a href="#output-formatting" class="md-nav__link">
|
|
Output formatting
|
|
</a>
|
|
|
|
</li>
|
|
|
|
<li class="md-nav__item">
|
|
<a href="#position-stacking-and-disabling-max-market-positions" class="md-nav__link">
|
|
Position stacking and disabling max market positions
|
|
</a>
|
|
|
|
</li>
|
|
|
|
<li class="md-nav__item">
|
|
<a href="#out-of-memory-errors" class="md-nav__link">
|
|
Out of Memory errors
|
|
</a>
|
|
|
|
</li>
|
|
|
|
<li class="md-nav__item">
|
|
<a href="#the-objective-has-been-evaluated-at-this-point-before" class="md-nav__link">
|
|
The objective has been evaluated at this point before.
|
|
</a>
|
|
|
|
</li>
|
|
|
|
<li class="md-nav__item">
|
|
<a href="#show-details-of-hyperopt-results" class="md-nav__link">
|
|
Show details of Hyperopt results
|
|
</a>
|
|
|
|
</li>
|
|
|
|
<li class="md-nav__item">
|
|
<a href="#validate-backtesting-results" class="md-nav__link">
|
|
Validate backtesting results
|
|
</a>
|
|
|
|
</li>
|
|
|
|
</ul>
|
|
|
|
</nav>
|
|
|
|
</li>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<li class="md-nav__item md-nav__item--nested">
|
|
|
|
|
|
|
|
|
|
<input class="md-nav__toggle md-toggle " type="checkbox" id="__nav_15" >
|
|
|
|
|
|
|
|
<label class="md-nav__link" for="__nav_15" id="__nav_15_label" tabindex="0">
|
|
FreqAI
|
|
<span class="md-nav__icon md-icon"></span>
|
|
</label>
|
|
|
|
<nav class="md-nav" data-md-level="1" aria-labelledby="__nav_15_label" aria-expanded="false">
|
|
<label class="md-nav__title" for="__nav_15">
|
|
<span class="md-nav__icon md-icon"></span>
|
|
FreqAI
|
|
</label>
|
|
<ul class="md-nav__list" data-md-scrollfix>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<li class="md-nav__item">
|
|
<a href="../freqai/" class="md-nav__link">
|
|
Introduction
|
|
</a>
|
|
</li>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<li class="md-nav__item">
|
|
<a href="../freqai-configuration/" class="md-nav__link">
|
|
Configuration
|
|
</a>
|
|
</li>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<li class="md-nav__item">
|
|
<a href="../freqai-parameter-table/" class="md-nav__link">
|
|
Parameter table
|
|
</a>
|
|
</li>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<li class="md-nav__item">
|
|
<a href="../freqai-feature-engineering/" class="md-nav__link">
|
|
Feature engineering
|
|
</a>
|
|
</li>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<li class="md-nav__item">
|
|
<a href="../freqai-running/" class="md-nav__link">
|
|
Running FreqAI
|
|
</a>
|
|
</li>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<li class="md-nav__item">
|
|
<a href="../freqai-reinforcement-learning/" class="md-nav__link">
|
|
Reinforcement Learning
|
|
</a>
|
|
</li>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<li class="md-nav__item">
|
|
<a href="../freqai-developers/" class="md-nav__link">
|
|
Developer guide
|
|
</a>
|
|
</li>
|
|
|
|
|
|
|
|
|
|
</ul>
|
|
</nav>
|
|
</li>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<li class="md-nav__item">
|
|
<a href="../leverage/" class="md-nav__link">
|
|
Short / Leverage
|
|
</a>
|
|
</li>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<li class="md-nav__item">
|
|
<a href="../utils/" class="md-nav__link">
|
|
Utility Sub-commands
|
|
</a>
|
|
</li>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<li class="md-nav__item">
|
|
<a href="../plotting/" class="md-nav__link">
|
|
Plotting
|
|
</a>
|
|
</li>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<li class="md-nav__item">
|
|
<a href="../exchanges/" class="md-nav__link">
|
|
Exchange-specific Notes
|
|
</a>
|
|
</li>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<li class="md-nav__item md-nav__item--nested">
|
|
|
|
|
|
|
|
|
|
<input class="md-nav__toggle md-toggle " type="checkbox" id="__nav_20" >
|
|
|
|
|
|
|
|
<label class="md-nav__link" for="__nav_20" id="__nav_20_label" tabindex="0">
|
|
Data Analysis
|
|
<span class="md-nav__icon md-icon"></span>
|
|
</label>
|
|
|
|
<nav class="md-nav" data-md-level="1" aria-labelledby="__nav_20_label" aria-expanded="false">
|
|
<label class="md-nav__title" for="__nav_20">
|
|
<span class="md-nav__icon md-icon"></span>
|
|
Data Analysis
|
|
</label>
|
|
<ul class="md-nav__list" data-md-scrollfix>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<li class="md-nav__item">
|
|
<a href="../data-analysis/" class="md-nav__link">
|
|
Jupyter Notebooks
|
|
</a>
|
|
</li>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<li class="md-nav__item">
|
|
<a href="../strategy_analysis_example/" class="md-nav__link">
|
|
Strategy analysis
|
|
</a>
|
|
</li>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<li class="md-nav__item">
|
|
<a href="../advanced-backtesting/" class="md-nav__link">
|
|
Backtest analysis
|
|
</a>
|
|
</li>
|
|
|
|
|
|
|
|
|
|
</ul>
|
|
</nav>
|
|
</li>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<li class="md-nav__item md-nav__item--nested">
|
|
|
|
|
|
|
|
|
|
<input class="md-nav__toggle md-toggle " type="checkbox" id="__nav_21" >
|
|
|
|
|
|
|
|
<label class="md-nav__link" for="__nav_21" id="__nav_21_label" tabindex="0">
|
|
Advanced Topics
|
|
<span class="md-nav__icon md-icon"></span>
|
|
</label>
|
|
|
|
<nav class="md-nav" data-md-level="1" aria-labelledby="__nav_21_label" aria-expanded="false">
|
|
<label class="md-nav__title" for="__nav_21">
|
|
<span class="md-nav__icon md-icon"></span>
|
|
Advanced Topics
|
|
</label>
|
|
<ul class="md-nav__list" data-md-scrollfix>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<li class="md-nav__item">
|
|
<a href="../advanced-setup/" class="md-nav__link">
|
|
Advanced Post-installation Tasks
|
|
</a>
|
|
</li>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<li class="md-nav__item">
|
|
<a href="../trade-object/" class="md-nav__link">
|
|
Trade Object
|
|
</a>
|
|
</li>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<li class="md-nav__item">
|
|
<a href="../strategy-advanced/" class="md-nav__link">
|
|
Advanced Strategy
|
|
</a>
|
|
</li>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<li class="md-nav__item">
|
|
<a href="../advanced-hyperopt/" class="md-nav__link">
|
|
Advanced Hyperopt
|
|
</a>
|
|
</li>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<li class="md-nav__item">
|
|
<a href="../producer-consumer/" class="md-nav__link">
|
|
Producer/Consumer mode
|
|
</a>
|
|
</li>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<li class="md-nav__item">
|
|
<a href="../edge/" class="md-nav__link">
|
|
Edge Positioning
|
|
</a>
|
|
</li>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<li class="md-nav__item">
|
|
<a href="../sandbox-testing/" class="md-nav__link">
|
|
Sandbox Testing
|
|
</a>
|
|
</li>
|
|
|
|
|
|
|
|
|
|
</ul>
|
|
</nav>
|
|
</li>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<li class="md-nav__item">
|
|
<a href="../faq/" class="md-nav__link">
|
|
FAQ
|
|
</a>
|
|
</li>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<li class="md-nav__item">
|
|
<a href="../sql_cheatsheet/" class="md-nav__link">
|
|
SQL Cheat-sheet
|
|
</a>
|
|
</li>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<li class="md-nav__item">
|
|
<a href="../strategy_migration/" class="md-nav__link">
|
|
Strategy migration
|
|
</a>
|
|
</li>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<li class="md-nav__item">
|
|
<a href="../updating/" class="md-nav__link">
|
|
Updating Freqtrade
|
|
</a>
|
|
</li>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<li class="md-nav__item">
|
|
<a href="../deprecated/" class="md-nav__link">
|
|
Deprecated Features
|
|
</a>
|
|
</li>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<li class="md-nav__item">
|
|
<a href="../developer/" class="md-nav__link">
|
|
Contributors Guide
|
|
</a>
|
|
</li>
|
|
|
|
|
|
|
|
</ul>
|
|
</nav>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
|
|
<!-- Table of contents -->
|
|
|
|
|
|
<div class="md-sidebar md-sidebar--secondary" data-md-component="sidebar" data-md-type="toc" >
|
|
<div class="md-sidebar__scrollwrap">
|
|
<div class="md-sidebar__inner">
|
|
|
|
|
|
<nav class="md-nav md-nav--secondary" aria-label="Table of contents">
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<label class="md-nav__title" for="__toc">
|
|
<span class="md-nav__icon md-icon"></span>
|
|
Table of contents
|
|
</label>
|
|
<ul class="md-nav__list" data-md-component="toc" data-md-scrollfix>
|
|
|
|
<li class="md-nav__item">
|
|
<a href="#install-hyperopt-dependencies" class="md-nav__link">
|
|
Install hyperopt dependencies
|
|
</a>
|
|
|
|
<nav class="md-nav" aria-label="Install hyperopt dependencies">
|
|
<ul class="md-nav__list">
|
|
|
|
<li class="md-nav__item">
|
|
<a href="#docker" class="md-nav__link">
|
|
Docker
|
|
</a>
|
|
|
|
</li>
|
|
|
|
<li class="md-nav__item">
|
|
<a href="#easy-installation-script-setupsh-manual-installation" class="md-nav__link">
|
|
Easy installation script (setup.sh) / Manual installation
|
|
</a>
|
|
|
|
</li>
|
|
|
|
</ul>
|
|
</nav>
|
|
|
|
</li>
|
|
|
|
<li class="md-nav__item">
|
|
<a href="#hyperopt-command-reference" class="md-nav__link">
|
|
Hyperopt command reference
|
|
</a>
|
|
|
|
<nav class="md-nav" aria-label="Hyperopt command reference">
|
|
<ul class="md-nav__list">
|
|
|
|
<li class="md-nav__item">
|
|
<a href="#hyperopt-checklist" class="md-nav__link">
|
|
Hyperopt checklist
|
|
</a>
|
|
|
|
</li>
|
|
|
|
<li class="md-nav__item">
|
|
<a href="#hyperopt-execution-logic" class="md-nav__link">
|
|
Hyperopt execution logic
|
|
</a>
|
|
|
|
</li>
|
|
|
|
<li class="md-nav__item">
|
|
<a href="#configure-your-guards-and-triggers" class="md-nav__link">
|
|
Configure your Guards and Triggers
|
|
</a>
|
|
|
|
<nav class="md-nav" aria-label="Configure your Guards and Triggers">
|
|
<ul class="md-nav__list">
|
|
|
|
<li class="md-nav__item">
|
|
<a href="#exit-signal-optimization" class="md-nav__link">
|
|
Exit signal optimization
|
|
</a>
|
|
|
|
</li>
|
|
|
|
</ul>
|
|
</nav>
|
|
|
|
</li>
|
|
|
|
</ul>
|
|
</nav>
|
|
|
|
</li>
|
|
|
|
<li class="md-nav__item">
|
|
<a href="#solving-a-mystery" class="md-nav__link">
|
|
Solving a Mystery
|
|
</a>
|
|
|
|
<nav class="md-nav" aria-label="Solving a Mystery">
|
|
<ul class="md-nav__list">
|
|
|
|
<li class="md-nav__item">
|
|
<a href="#defining-indicators-to-be-used" class="md-nav__link">
|
|
Defining indicators to be used
|
|
</a>
|
|
|
|
</li>
|
|
|
|
<li class="md-nav__item">
|
|
<a href="#hyperoptable-parameters" class="md-nav__link">
|
|
Hyperoptable parameters
|
|
</a>
|
|
|
|
</li>
|
|
|
|
</ul>
|
|
</nav>
|
|
|
|
</li>
|
|
|
|
<li class="md-nav__item">
|
|
<a href="#parameter-types" class="md-nav__link">
|
|
Parameter types
|
|
</a>
|
|
|
|
</li>
|
|
|
|
<li class="md-nav__item">
|
|
<a href="#optimizing-an-indicator-parameter" class="md-nav__link">
|
|
Optimizing an indicator parameter
|
|
</a>
|
|
|
|
</li>
|
|
|
|
<li class="md-nav__item">
|
|
<a href="#optimizing-protections" class="md-nav__link">
|
|
Optimizing protections
|
|
</a>
|
|
|
|
<nav class="md-nav" aria-label="Optimizing protections">
|
|
<ul class="md-nav__list">
|
|
|
|
<li class="md-nav__item">
|
|
<a href="#migrating-from-previous-property-setups" class="md-nav__link">
|
|
Migrating from previous property setups
|
|
</a>
|
|
|
|
</li>
|
|
|
|
<li class="md-nav__item">
|
|
<a href="#optimizing-max_entry_position_adjustment" class="md-nav__link">
|
|
Optimizing max_entry_position_adjustment
|
|
</a>
|
|
|
|
</li>
|
|
|
|
</ul>
|
|
</nav>
|
|
|
|
</li>
|
|
|
|
<li class="md-nav__item">
|
|
<a href="#loss-functions" class="md-nav__link">
|
|
Loss-functions
|
|
</a>
|
|
|
|
</li>
|
|
|
|
<li class="md-nav__item">
|
|
<a href="#execute-hyperopt" class="md-nav__link">
|
|
Execute Hyperopt
|
|
</a>
|
|
|
|
<nav class="md-nav" aria-label="Execute Hyperopt">
|
|
<ul class="md-nav__list">
|
|
|
|
<li class="md-nav__item">
|
|
<a href="#execute-hyperopt-with-different-historical-data-source" class="md-nav__link">
|
|
Execute Hyperopt with different historical data source
|
|
</a>
|
|
|
|
</li>
|
|
|
|
<li class="md-nav__item">
|
|
<a href="#running-hyperopt-with-a-smaller-test-set" class="md-nav__link">
|
|
Running Hyperopt with a smaller test-set
|
|
</a>
|
|
|
|
</li>
|
|
|
|
<li class="md-nav__item">
|
|
<a href="#running-hyperopt-with-smaller-search-space" class="md-nav__link">
|
|
Running Hyperopt with Smaller Search Space
|
|
</a>
|
|
|
|
</li>
|
|
|
|
</ul>
|
|
</nav>
|
|
|
|
</li>
|
|
|
|
<li class="md-nav__item">
|
|
<a href="#understand-the-hyperopt-result" class="md-nav__link">
|
|
Understand the Hyperopt Result
|
|
</a>
|
|
|
|
<nav class="md-nav" aria-label="Understand the Hyperopt Result">
|
|
<ul class="md-nav__list">
|
|
|
|
<li class="md-nav__item">
|
|
<a href="#automatic-parameter-application-to-the-strategy" class="md-nav__link">
|
|
Automatic parameter application to the strategy
|
|
</a>
|
|
|
|
</li>
|
|
|
|
<li class="md-nav__item">
|
|
<a href="#understand-hyperopt-roi-results" class="md-nav__link">
|
|
Understand Hyperopt ROI results
|
|
</a>
|
|
|
|
<nav class="md-nav" aria-label="Understand Hyperopt ROI results">
|
|
<ul class="md-nav__list">
|
|
|
|
<li class="md-nav__item">
|
|
<a href="#default-roi-search-space" class="md-nav__link">
|
|
Default ROI Search Space
|
|
</a>
|
|
|
|
</li>
|
|
|
|
</ul>
|
|
</nav>
|
|
|
|
</li>
|
|
|
|
<li class="md-nav__item">
|
|
<a href="#understand-hyperopt-stoploss-results" class="md-nav__link">
|
|
Understand Hyperopt Stoploss results
|
|
</a>
|
|
|
|
<nav class="md-nav" aria-label="Understand Hyperopt Stoploss results">
|
|
<ul class="md-nav__list">
|
|
|
|
<li class="md-nav__item">
|
|
<a href="#default-stoploss-search-space" class="md-nav__link">
|
|
Default Stoploss Search Space
|
|
</a>
|
|
|
|
</li>
|
|
|
|
</ul>
|
|
</nav>
|
|
|
|
</li>
|
|
|
|
<li class="md-nav__item">
|
|
<a href="#understand-hyperopt-trailing-stop-results" class="md-nav__link">
|
|
Understand Hyperopt Trailing Stop results
|
|
</a>
|
|
|
|
<nav class="md-nav" aria-label="Understand Hyperopt Trailing Stop results">
|
|
<ul class="md-nav__list">
|
|
|
|
<li class="md-nav__item">
|
|
<a href="#default-trailing-stop-search-space" class="md-nav__link">
|
|
Default Trailing Stop Search Space
|
|
</a>
|
|
|
|
</li>
|
|
|
|
</ul>
|
|
</nav>
|
|
|
|
</li>
|
|
|
|
<li class="md-nav__item">
|
|
<a href="#reproducible-results" class="md-nav__link">
|
|
Reproducible results
|
|
</a>
|
|
|
|
</li>
|
|
|
|
</ul>
|
|
</nav>
|
|
|
|
</li>
|
|
|
|
<li class="md-nav__item">
|
|
<a href="#output-formatting" class="md-nav__link">
|
|
Output formatting
|
|
</a>
|
|
|
|
</li>
|
|
|
|
<li class="md-nav__item">
|
|
<a href="#position-stacking-and-disabling-max-market-positions" class="md-nav__link">
|
|
Position stacking and disabling max market positions
|
|
</a>
|
|
|
|
</li>
|
|
|
|
<li class="md-nav__item">
|
|
<a href="#out-of-memory-errors" class="md-nav__link">
|
|
Out of Memory errors
|
|
</a>
|
|
|
|
</li>
|
|
|
|
<li class="md-nav__item">
|
|
<a href="#the-objective-has-been-evaluated-at-this-point-before" class="md-nav__link">
|
|
The objective has been evaluated at this point before.
|
|
</a>
|
|
|
|
</li>
|
|
|
|
<li class="md-nav__item">
|
|
<a href="#show-details-of-hyperopt-results" class="md-nav__link">
|
|
Show details of Hyperopt results
|
|
</a>
|
|
|
|
</li>
|
|
|
|
<li class="md-nav__item">
|
|
<a href="#validate-backtesting-results" class="md-nav__link">
|
|
Validate backtesting results
|
|
</a>
|
|
|
|
</li>
|
|
|
|
</ul>
|
|
|
|
</nav>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
|
|
|
|
<div class="md-content" data-md-component="content">
|
|
<article class="md-content__inner md-typeset">
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<h1 id="hyperopt">Hyperopt<a class="headerlink" href="#hyperopt" title="Permanent link">¶</a></h1>
|
|
<p>This page explains how to tune your strategy by finding the optimal
|
|
parameters, a process called hyperparameter optimization. The bot uses algorithms included in the <code>scikit-optimize</code> package to accomplish this.
|
|
The search will burn all your CPU cores, make your laptop sound like a fighter jet and still take a long time.</p>
|
|
<p>In general, the search for best parameters starts with a few random combinations (see <a href="#reproducible-results">below</a> for more details) and then uses Bayesian search with a ML regressor algorithm (currently ExtraTreesRegressor) to quickly find a combination of parameters in the search hyperspace that minimizes the value of the <a href="#loss-functions">loss function</a>.</p>
|
|
<p>Hyperopt requires historic data to be available, just as backtesting does (hyperopt runs backtesting many times with different parameters).
|
|
To learn how to get data for the pairs and exchange you're interested in, head over to the <a href="../data-download/">Data Downloading</a> section of the documentation.</p>
|
|
<div class="admonition bug">
|
|
<p class="admonition-title">Bug</p>
|
|
<p>Hyperopt can crash when used with only 1 CPU Core as found out in <a href="https://github.com/freqtrade/freqtrade/issues/1133">Issue #1133</a></p>
|
|
</div>
|
|
<div class="admonition note">
|
|
<p class="admonition-title">Note</p>
|
|
<p>Since 2021.4 release you no longer have to write a separate hyperopt class, but can configure the parameters directly in the strategy.
|
|
The legacy method is still supported, but it is no longer the recommended way of setting up hyperopt.
|
|
The legacy documentation is available at <a href="../advanced-hyperopt/#legacy-hyperopt">Legacy Hyperopt</a>.</p>
|
|
</div>
|
|
<h2 id="install-hyperopt-dependencies">Install hyperopt dependencies<a class="headerlink" href="#install-hyperopt-dependencies" title="Permanent link">¶</a></h2>
|
|
<p>Since Hyperopt dependencies are not needed to run the bot itself, are heavy, can not be easily built on some platforms (like Raspberry PI), they are not installed by default. Before you run Hyperopt, you need to install the corresponding dependencies, as described in this section below.</p>
|
|
<div class="admonition note">
|
|
<p class="admonition-title">Note</p>
|
|
<p>Since Hyperopt is a resource intensive process, running it on a Raspberry Pi is not recommended nor supported.</p>
|
|
</div>
|
|
<h3 id="docker">Docker<a class="headerlink" href="#docker" title="Permanent link">¶</a></h3>
|
|
<p>The docker-image includes hyperopt dependencies, no further action needed.</p>
|
|
<h3 id="easy-installation-script-setupsh-manual-installation">Easy installation script (setup.sh) / Manual installation<a class="headerlink" href="#easy-installation-script-setupsh-manual-installation" title="Permanent link">¶</a></h3>
|
|
<div class="highlight"><pre><span></span><code><span class="nb">source</span><span class="w"> </span>.env/bin/activate
|
|
pip<span class="w"> </span>install<span class="w"> </span>-r<span class="w"> </span>requirements-hyperopt.txt
|
|
</code></pre></div>
|
|
<h2 id="hyperopt-command-reference">Hyperopt command reference<a class="headerlink" href="#hyperopt-command-reference" title="Permanent link">¶</a></h2>
|
|
<div class="highlight"><pre><span></span><code>usage: freqtrade hyperopt [-h] [-v] [--logfile FILE] [-V] [-c PATH] [-d PATH]
|
|
[--userdir PATH] [-s NAME] [--strategy-path PATH]
|
|
[--recursive-strategy-search] [--freqaimodel NAME]
|
|
[--freqaimodel-path PATH] [-i TIMEFRAME]
|
|
[--timerange TIMERANGE]
|
|
[--data-format-ohlcv {json,jsongz,hdf5}]
|
|
[--max-open-trades INT]
|
|
[--stake-amount STAKE_AMOUNT] [--fee FLOAT]
|
|
[-p PAIRS [PAIRS ...]] [--hyperopt-path PATH]
|
|
[--eps] [--dmmp] [--enable-protections]
|
|
[--dry-run-wallet DRY_RUN_WALLET]
|
|
[--timeframe-detail TIMEFRAME_DETAIL] [-e INT]
|
|
[--spaces {all,buy,sell,roi,stoploss,trailing,protection,trades,default} [{all,buy,sell,roi,stoploss,trailing,protection,trades,default} ...]]
|
|
[--print-all] [--no-color] [--print-json] [-j JOBS]
|
|
[--random-state INT] [--min-trades INT]
|
|
[--hyperopt-loss NAME] [--disable-param-export]
|
|
[--ignore-missing-spaces] [--analyze-per-epoch]
|
|
|
|
optional arguments:
|
|
-h, --help show this help message and exit
|
|
-i TIMEFRAME, --timeframe TIMEFRAME
|
|
Specify timeframe (`1m`, `5m`, `30m`, `1h`, `1d`).
|
|
--timerange TIMERANGE
|
|
Specify what timerange of data to use.
|
|
--data-format-ohlcv {json,jsongz,hdf5}
|
|
Storage format for downloaded candle (OHLCV) data.
|
|
(default: `json`).
|
|
--max-open-trades INT
|
|
Override the value of the `max_open_trades`
|
|
configuration setting.
|
|
--stake-amount STAKE_AMOUNT
|
|
Override the value of the `stake_amount` configuration
|
|
setting.
|
|
--fee FLOAT Specify fee ratio. Will be applied twice (on trade
|
|
entry and exit).
|
|
-p PAIRS [PAIRS ...], --pairs PAIRS [PAIRS ...]
|
|
Limit command to these pairs. Pairs are space-
|
|
separated.
|
|
--hyperopt-path PATH Specify additional lookup path for Hyperopt Loss
|
|
functions.
|
|
--eps, --enable-position-stacking
|
|
Allow buying the same pair multiple times (position
|
|
stacking).
|
|
--dmmp, --disable-max-market-positions
|
|
Disable applying `max_open_trades` during backtest
|
|
(same as setting `max_open_trades` to a very high
|
|
number).
|
|
--enable-protections, --enableprotections
|
|
Enable protections for backtesting.Will slow
|
|
backtesting down by a considerable amount, but will
|
|
include configured protections
|
|
--dry-run-wallet DRY_RUN_WALLET, --starting-balance DRY_RUN_WALLET
|
|
Starting balance, used for backtesting / hyperopt and
|
|
dry-runs.
|
|
--timeframe-detail TIMEFRAME_DETAIL
|
|
Specify detail timeframe for backtesting (`1m`, `5m`,
|
|
`30m`, `1h`, `1d`).
|
|
-e INT, --epochs INT Specify number of epochs (default: 100).
|
|
--spaces {all,buy,sell,roi,stoploss,trailing,protection,trades,default} [{all,buy,sell,roi,stoploss,trailing,protection,trades,default} ...]
|
|
Specify which parameters to hyperopt. Space-separated
|
|
list.
|
|
--print-all Print all results, not only the best ones.
|
|
--no-color Disable colorization of hyperopt results. May be
|
|
useful if you are redirecting output to a file.
|
|
--print-json Print output in JSON format.
|
|
-j JOBS, --job-workers JOBS
|
|
The number of concurrently running jobs for
|
|
hyperoptimization (hyperopt worker processes). If -1
|
|
(default), all CPUs are used, for -2, all CPUs but one
|
|
are used, etc. If 1 is given, no parallel computing
|
|
code is used at all.
|
|
--random-state INT Set random state to some positive integer for
|
|
reproducible hyperopt results.
|
|
--min-trades INT Set minimal desired number of trades for evaluations
|
|
in the hyperopt optimization path (default: 1).
|
|
--hyperopt-loss NAME, --hyperoptloss NAME
|
|
Specify the class name of the hyperopt loss function
|
|
class (IHyperOptLoss). Different functions can
|
|
generate completely different results, since the
|
|
target for optimization is different. Built-in
|
|
Hyperopt-loss-functions are:
|
|
ShortTradeDurHyperOptLoss, OnlyProfitHyperOptLoss,
|
|
SharpeHyperOptLoss, SharpeHyperOptLossDaily,
|
|
SortinoHyperOptLoss, SortinoHyperOptLossDaily,
|
|
CalmarHyperOptLoss, MaxDrawDownHyperOptLoss,
|
|
MaxDrawDownRelativeHyperOptLoss,
|
|
ProfitDrawDownHyperOptLoss
|
|
--disable-param-export
|
|
Disable automatic hyperopt parameter export.
|
|
--ignore-missing-spaces, --ignore-unparameterized-spaces
|
|
Suppress errors for any requested Hyperopt spaces that
|
|
do not contain any parameters.
|
|
--analyze-per-epoch Run populate_indicators once per epoch.
|
|
|
|
Common arguments:
|
|
-v, --verbose Verbose mode (-vv for more, -vvv to get all messages).
|
|
--logfile FILE Log to the file specified. Special values are:
|
|
'syslog', 'journald'. See the documentation for more
|
|
details.
|
|
-V, --version show program's version number and exit
|
|
-c PATH, --config PATH
|
|
Specify configuration file (default:
|
|
`userdir/config.json` or `config.json` whichever
|
|
exists). Multiple --config options may be used. Can be
|
|
set to `-` to read config from stdin.
|
|
-d PATH, --datadir PATH
|
|
Path to directory with historical backtesting data.
|
|
--userdir PATH, --user-data-dir PATH
|
|
Path to userdata directory.
|
|
|
|
Strategy arguments:
|
|
-s NAME, --strategy NAME
|
|
Specify strategy class name which will be used by the
|
|
bot.
|
|
--strategy-path PATH Specify additional strategy lookup path.
|
|
--recursive-strategy-search
|
|
Recursively search for a strategy in the strategies
|
|
folder.
|
|
--freqaimodel NAME Specify a custom freqaimodels.
|
|
--freqaimodel-path PATH
|
|
Specify additional lookup path for freqaimodels.
|
|
</code></pre></div>
|
|
<h3 id="hyperopt-checklist">Hyperopt checklist<a class="headerlink" href="#hyperopt-checklist" title="Permanent link">¶</a></h3>
|
|
<p>Checklist on all tasks / possibilities in hyperopt</p>
|
|
<p>Depending on the space you want to optimize, only some of the below are required:</p>
|
|
<ul>
|
|
<li>define parameters with <code>space='buy'</code> - for entry signal optimization</li>
|
|
<li>define parameters with <code>space='sell'</code> - for exit signal optimization</li>
|
|
</ul>
|
|
<div class="admonition note">
|
|
<p class="admonition-title">Note</p>
|
|
<p><code>populate_indicators</code> needs to create all indicators any of the spaces may use, otherwise hyperopt will not work.</p>
|
|
</div>
|
|
<p>Rarely you may also need to create a <a href="../advanced-hyperopt/#overriding-pre-defined-spaces">nested class</a> named <code>HyperOpt</code> and implement</p>
|
|
<ul>
|
|
<li><code>roi_space</code> - for custom ROI optimization (if you need the ranges for the ROI parameters in the optimization hyperspace that differ from default)</li>
|
|
<li><code>generate_roi_table</code> - for custom ROI optimization (if you need the ranges for the values in the ROI table that differ from default or the number of entries (steps) in the ROI table which differs from the default 4 steps)</li>
|
|
<li><code>stoploss_space</code> - for custom stoploss optimization (if you need the range for the stoploss parameter in the optimization hyperspace that differs from default)</li>
|
|
<li><code>trailing_space</code> - for custom trailing stop optimization (if you need the ranges for the trailing stop parameters in the optimization hyperspace that differ from default)</li>
|
|
<li><code>max_open_trades_space</code> - for custom max_open_trades optimization (if you need the ranges for the max_open_trades parameter in the optimization hyperspace that differ from default)</li>
|
|
</ul>
|
|
<div class="admonition tip">
|
|
<p class="admonition-title">Quickly optimize ROI, stoploss and trailing stoploss</p>
|
|
<p>You can quickly optimize the spaces <code>roi</code>, <code>stoploss</code> and <code>trailing</code> without changing anything in your strategy.</p>
|
|
<div class="highlight"><pre><span></span><code><span class="c1"># Have a working strategy at hand.</span>
|
|
freqtrade<span class="w"> </span>hyperopt<span class="w"> </span>--hyperopt-loss<span class="w"> </span>SharpeHyperOptLossDaily<span class="w"> </span>--spaces<span class="w"> </span>roi<span class="w"> </span>stoploss<span class="w"> </span>trailing<span class="w"> </span>--strategy<span class="w"> </span>MyWorkingStrategy<span class="w"> </span>--config<span class="w"> </span>config.json<span class="w"> </span>-e<span class="w"> </span><span class="m">100</span>
|
|
</code></pre></div>
|
|
</div>
|
|
<h3 id="hyperopt-execution-logic">Hyperopt execution logic<a class="headerlink" href="#hyperopt-execution-logic" title="Permanent link">¶</a></h3>
|
|
<p>Hyperopt will first load your data into memory and will then run <code>populate_indicators()</code> once per Pair to generate all indicators, unless <code>--analyze-per-epoch</code> is specified.</p>
|
|
<p>Hyperopt will then spawn into different processes (number of processors, or <code>-j <n></code>), and run backtesting over and over again, changing the parameters that are part of the <code>--spaces</code> defined.</p>
|
|
<p>For every new set of parameters, freqtrade will run first <code>populate_entry_trend()</code> followed by <code>populate_exit_trend()</code>, and then run the regular backtesting process to simulate trades.</p>
|
|
<p>After backtesting, the results are passed into the <a href="#loss-functions">loss function</a>, which will evaluate if this result was better or worse than previous results.<br />
|
|
Based on the loss function result, hyperopt will determine the next set of parameters to try in the next round of backtesting.</p>
|
|
<h3 id="configure-your-guards-and-triggers">Configure your Guards and Triggers<a class="headerlink" href="#configure-your-guards-and-triggers" title="Permanent link">¶</a></h3>
|
|
<p>There are two places you need to change in your strategy file to add a new buy hyperopt for testing:</p>
|
|
<ul>
|
|
<li>Define the parameters at the class level hyperopt shall be optimizing.</li>
|
|
<li>Within <code>populate_entry_trend()</code> - use defined parameter values instead of raw constants.</li>
|
|
</ul>
|
|
<p>There you have two different types of indicators: 1. <code>guards</code> and 2. <code>triggers</code>.</p>
|
|
<ol>
|
|
<li>Guards are conditions like "never buy if ADX < 10", or never buy if current price is over EMA10.</li>
|
|
<li>Triggers are ones that actually trigger buy in specific moment, like "buy when EMA5 crosses over EMA10" or "buy when close price touches lower Bollinger band".</li>
|
|
</ol>
|
|
<div class="admonition hint">
|
|
<p class="admonition-title">Guards and Triggers</p>
|
|
<p>Technically, there is no difference between Guards and Triggers.<br />
|
|
However, this guide will make this distinction to make it clear that signals should not be "sticking".
|
|
Sticking signals are signals that are active for multiple candles. This can lead into entering a signal late (right before the signal disappears - which means that the chance of success is a lot lower than right at the beginning).</p>
|
|
</div>
|
|
<p>Hyper-optimization will, for each epoch round, pick one trigger and possibly multiple guards.</p>
|
|
<h4 id="exit-signal-optimization">Exit signal optimization<a class="headerlink" href="#exit-signal-optimization" title="Permanent link">¶</a></h4>
|
|
<p>Similar to the entry-signal above, exit-signals can also be optimized.
|
|
Place the corresponding settings into the following methods</p>
|
|
<ul>
|
|
<li>Define the parameters at the class level hyperopt shall be optimizing, either naming them <code>sell_*</code>, or by explicitly defining <code>space='sell'</code>.</li>
|
|
<li>Within <code>populate_exit_trend()</code> - use defined parameter values instead of raw constants.</li>
|
|
</ul>
|
|
<p>The configuration and rules are the same than for buy signals.</p>
|
|
<h2 id="solving-a-mystery">Solving a Mystery<a class="headerlink" href="#solving-a-mystery" title="Permanent link">¶</a></h2>
|
|
<p>Let's say you are curious: should you use MACD crossings or lower Bollinger Bands to trigger your long entries.
|
|
And you also wonder should you use RSI or ADX to help with those decisions.
|
|
If you decide to use RSI or ADX, which values should I use for them?</p>
|
|
<p>So let's use hyperparameter optimization to solve this mystery.</p>
|
|
<h3 id="defining-indicators-to-be-used">Defining indicators to be used<a class="headerlink" href="#defining-indicators-to-be-used" title="Permanent link">¶</a></h3>
|
|
<p>We start by calculating the indicators our strategy is going to use.</p>
|
|
<div class="highlight"><pre><span></span><code><span class="k">class</span> <span class="nc">MyAwesomeStrategy</span><span class="p">(</span><span class="n">IStrategy</span><span class="p">):</span>
|
|
|
|
<span class="k">def</span> <span class="nf">populate_indicators</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">dataframe</span><span class="p">:</span> <span class="n">DataFrame</span><span class="p">,</span> <span class="n">metadata</span><span class="p">:</span> <span class="nb">dict</span><span class="p">)</span> <span class="o">-></span> <span class="n">DataFrame</span><span class="p">:</span>
|
|
<span class="w"> </span><span class="sd">"""</span>
|
|
<span class="sd"> Generate all indicators used by the strategy</span>
|
|
<span class="sd"> """</span>
|
|
<span class="n">dataframe</span><span class="p">[</span><span class="s1">'adx'</span><span class="p">]</span> <span class="o">=</span> <span class="n">ta</span><span class="o">.</span><span class="n">ADX</span><span class="p">(</span><span class="n">dataframe</span><span class="p">)</span>
|
|
<span class="n">dataframe</span><span class="p">[</span><span class="s1">'rsi'</span><span class="p">]</span> <span class="o">=</span> <span class="n">ta</span><span class="o">.</span><span class="n">RSI</span><span class="p">(</span><span class="n">dataframe</span><span class="p">)</span>
|
|
<span class="n">macd</span> <span class="o">=</span> <span class="n">ta</span><span class="o">.</span><span class="n">MACD</span><span class="p">(</span><span class="n">dataframe</span><span class="p">)</span>
|
|
<span class="n">dataframe</span><span class="p">[</span><span class="s1">'macd'</span><span class="p">]</span> <span class="o">=</span> <span class="n">macd</span><span class="p">[</span><span class="s1">'macd'</span><span class="p">]</span>
|
|
<span class="n">dataframe</span><span class="p">[</span><span class="s1">'macdsignal'</span><span class="p">]</span> <span class="o">=</span> <span class="n">macd</span><span class="p">[</span><span class="s1">'macdsignal'</span><span class="p">]</span>
|
|
<span class="n">dataframe</span><span class="p">[</span><span class="s1">'macdhist'</span><span class="p">]</span> <span class="o">=</span> <span class="n">macd</span><span class="p">[</span><span class="s1">'macdhist'</span><span class="p">]</span>
|
|
|
|
<span class="n">bollinger</span> <span class="o">=</span> <span class="n">ta</span><span class="o">.</span><span class="n">BBANDS</span><span class="p">(</span><span class="n">dataframe</span><span class="p">,</span> <span class="n">timeperiod</span><span class="o">=</span><span class="mi">20</span><span class="p">,</span> <span class="n">nbdevup</span><span class="o">=</span><span class="mf">2.0</span><span class="p">,</span> <span class="n">nbdevdn</span><span class="o">=</span><span class="mf">2.0</span><span class="p">)</span>
|
|
<span class="n">dataframe</span><span class="p">[</span><span class="s1">'bb_lowerband'</span><span class="p">]</span> <span class="o">=</span> <span class="n">bollinger</span><span class="p">[</span><span class="s1">'lowerband'</span><span class="p">]</span>
|
|
<span class="n">dataframe</span><span class="p">[</span><span class="s1">'bb_middleband'</span><span class="p">]</span> <span class="o">=</span> <span class="n">bollinger</span><span class="p">[</span><span class="s1">'middleband'</span><span class="p">]</span>
|
|
<span class="n">dataframe</span><span class="p">[</span><span class="s1">'bb_upperband'</span><span class="p">]</span> <span class="o">=</span> <span class="n">bollinger</span><span class="p">[</span><span class="s1">'upperband'</span><span class="p">]</span>
|
|
<span class="k">return</span> <span class="n">dataframe</span>
|
|
</code></pre></div>
|
|
<h3 id="hyperoptable-parameters">Hyperoptable parameters<a class="headerlink" href="#hyperoptable-parameters" title="Permanent link">¶</a></h3>
|
|
<p>We continue to define hyperoptable parameters:</p>
|
|
<div class="highlight"><pre><span></span><code><span class="k">class</span> <span class="nc">MyAwesomeStrategy</span><span class="p">(</span><span class="n">IStrategy</span><span class="p">):</span>
|
|
<span class="n">buy_adx</span> <span class="o">=</span> <span class="n">DecimalParameter</span><span class="p">(</span><span class="mi">20</span><span class="p">,</span> <span class="mi">40</span><span class="p">,</span> <span class="n">decimals</span><span class="o">=</span><span class="mi">1</span><span class="p">,</span> <span class="n">default</span><span class="o">=</span><span class="mf">30.1</span><span class="p">,</span> <span class="n">space</span><span class="o">=</span><span class="s2">"buy"</span><span class="p">)</span>
|
|
<span class="n">buy_rsi</span> <span class="o">=</span> <span class="n">IntParameter</span><span class="p">(</span><span class="mi">20</span><span class="p">,</span> <span class="mi">40</span><span class="p">,</span> <span class="n">default</span><span class="o">=</span><span class="mi">30</span><span class="p">,</span> <span class="n">space</span><span class="o">=</span><span class="s2">"buy"</span><span class="p">)</span>
|
|
<span class="n">buy_adx_enabled</span> <span class="o">=</span> <span class="n">BooleanParameter</span><span class="p">(</span><span class="n">default</span><span class="o">=</span><span class="kc">True</span><span class="p">,</span> <span class="n">space</span><span class="o">=</span><span class="s2">"buy"</span><span class="p">)</span>
|
|
<span class="n">buy_rsi_enabled</span> <span class="o">=</span> <span class="n">CategoricalParameter</span><span class="p">([</span><span class="kc">True</span><span class="p">,</span> <span class="kc">False</span><span class="p">],</span> <span class="n">default</span><span class="o">=</span><span class="kc">False</span><span class="p">,</span> <span class="n">space</span><span class="o">=</span><span class="s2">"buy"</span><span class="p">)</span>
|
|
<span class="n">buy_trigger</span> <span class="o">=</span> <span class="n">CategoricalParameter</span><span class="p">([</span><span class="s2">"bb_lower"</span><span class="p">,</span> <span class="s2">"macd_cross_signal"</span><span class="p">],</span> <span class="n">default</span><span class="o">=</span><span class="s2">"bb_lower"</span><span class="p">,</span> <span class="n">space</span><span class="o">=</span><span class="s2">"buy"</span><span class="p">)</span>
|
|
</code></pre></div>
|
|
<p>The above definition says: I have five parameters I want to randomly combine to find the best combination.<br />
|
|
<code>buy_rsi</code> is an integer parameter, which will be tested between 20 and 40. This space has a size of 20.<br />
|
|
<code>buy_adx</code> is a decimal parameter, which will be evaluated between 20 and 40 with 1 decimal place (so values are 20.1, 20.2, ...). This space has a size of 200.<br />
|
|
Then we have three category variables. First two are either <code>True</code> or <code>False</code>.
|
|
We use these to either enable or disable the ADX and RSI guards.
|
|
The last one we call <code>trigger</code> and use it to decide which buy trigger we want to use.</p>
|
|
<div class="admonition note">
|
|
<p class="admonition-title">Parameter space assignment</p>
|
|
<p>Parameters must either be assigned to a variable named <code>buy_*</code> or <code>sell_*</code> - or contain <code>space='buy'</code> | <code>space='sell'</code> to be assigned to a space correctly.
|
|
If no parameter is available for a space, you'll receive the error that no space was found when running hyperopt.<br />
|
|
Parameters with unclear space (e.g. <code>adx_period = IntParameter(4, 24, default=14)</code> - no explicit nor implicit space) will not be detected and will therefore be ignored.</p>
|
|
</div>
|
|
<p>So let's write the buy strategy using these values:</p>
|
|
<div class="highlight"><pre><span></span><code> <span class="k">def</span> <span class="nf">populate_entry_trend</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">dataframe</span><span class="p">:</span> <span class="n">DataFrame</span><span class="p">,</span> <span class="n">metadata</span><span class="p">:</span> <span class="nb">dict</span><span class="p">)</span> <span class="o">-></span> <span class="n">DataFrame</span><span class="p">:</span>
|
|
<span class="n">conditions</span> <span class="o">=</span> <span class="p">[]</span>
|
|
<span class="c1"># GUARDS AND TRENDS</span>
|
|
<span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">buy_adx_enabled</span><span class="o">.</span><span class="n">value</span><span class="p">:</span>
|
|
<span class="n">conditions</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">dataframe</span><span class="p">[</span><span class="s1">'adx'</span><span class="p">]</span> <span class="o">></span> <span class="bp">self</span><span class="o">.</span><span class="n">buy_adx</span><span class="o">.</span><span class="n">value</span><span class="p">)</span>
|
|
<span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">buy_rsi_enabled</span><span class="o">.</span><span class="n">value</span><span class="p">:</span>
|
|
<span class="n">conditions</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">dataframe</span><span class="p">[</span><span class="s1">'rsi'</span><span class="p">]</span> <span class="o"><</span> <span class="bp">self</span><span class="o">.</span><span class="n">buy_rsi</span><span class="o">.</span><span class="n">value</span><span class="p">)</span>
|
|
|
|
<span class="c1"># TRIGGERS</span>
|
|
<span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">buy_trigger</span><span class="o">.</span><span class="n">value</span> <span class="o">==</span> <span class="s1">'bb_lower'</span><span class="p">:</span>
|
|
<span class="n">conditions</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">dataframe</span><span class="p">[</span><span class="s1">'close'</span><span class="p">]</span> <span class="o"><</span> <span class="n">dataframe</span><span class="p">[</span><span class="s1">'bb_lowerband'</span><span class="p">])</span>
|
|
<span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">buy_trigger</span><span class="o">.</span><span class="n">value</span> <span class="o">==</span> <span class="s1">'macd_cross_signal'</span><span class="p">:</span>
|
|
<span class="n">conditions</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">qtpylib</span><span class="o">.</span><span class="n">crossed_above</span><span class="p">(</span>
|
|
<span class="n">dataframe</span><span class="p">[</span><span class="s1">'macd'</span><span class="p">],</span> <span class="n">dataframe</span><span class="p">[</span><span class="s1">'macdsignal'</span><span class="p">]</span>
|
|
<span class="p">))</span>
|
|
|
|
<span class="c1"># Check that volume is not 0</span>
|
|
<span class="n">conditions</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">dataframe</span><span class="p">[</span><span class="s1">'volume'</span><span class="p">]</span> <span class="o">></span> <span class="mi">0</span><span class="p">)</span>
|
|
|
|
<span class="k">if</span> <span class="n">conditions</span><span class="p">:</span>
|
|
<span class="n">dataframe</span><span class="o">.</span><span class="n">loc</span><span class="p">[</span>
|
|
<span class="n">reduce</span><span class="p">(</span><span class="k">lambda</span> <span class="n">x</span><span class="p">,</span> <span class="n">y</span><span class="p">:</span> <span class="n">x</span> <span class="o">&</span> <span class="n">y</span><span class="p">,</span> <span class="n">conditions</span><span class="p">),</span>
|
|
<span class="s1">'enter_long'</span><span class="p">]</span> <span class="o">=</span> <span class="mi">1</span>
|
|
|
|
<span class="k">return</span> <span class="n">dataframe</span>
|
|
</code></pre></div>
|
|
<p>Hyperopt will now call <code>populate_entry_trend()</code> many times (<code>epochs</code>) with different value combinations.<br />
|
|
It will use the given historical data and simulate buys based on the buy signals generated with the above function.<br />
|
|
Based on the results, hyperopt will tell you which parameter combination produced the best results (based on the configured <a href="#loss-functions">loss function</a>).</p>
|
|
<div class="admonition note">
|
|
<p class="admonition-title">Note</p>
|
|
<p>The above setup expects to find ADX, RSI and Bollinger Bands in the populated indicators.
|
|
When you want to test an indicator that isn't used by the bot currently, remember to
|
|
add it to the <code>populate_indicators()</code> method in your strategy or hyperopt file.</p>
|
|
</div>
|
|
<h2 id="parameter-types">Parameter types<a class="headerlink" href="#parameter-types" title="Permanent link">¶</a></h2>
|
|
<p>There are four parameter types each suited for different purposes.</p>
|
|
<ul>
|
|
<li><code>IntParameter</code> - defines an integral parameter with upper and lower boundaries of search space.</li>
|
|
<li><code>DecimalParameter</code> - defines a floating point parameter with a limited number of decimals (default 3). Should be preferred instead of <code>RealParameter</code> in most cases.</li>
|
|
<li><code>RealParameter</code> - defines a floating point parameter with upper and lower boundaries and no precision limit. Rarely used as it creates a space with a near infinite number of possibilities.</li>
|
|
<li><code>CategoricalParameter</code> - defines a parameter with a predetermined number of choices.</li>
|
|
<li><code>BooleanParameter</code> - Shorthand for <code>CategoricalParameter([True, False])</code> - great for "enable" parameters.</li>
|
|
</ul>
|
|
<div class="admonition tip">
|
|
<p class="admonition-title">Disabling parameter optimization</p>
|
|
<p>Each parameter takes two boolean parameters:
|
|
* <code>load</code> - when set to <code>False</code> it will not load values configured in <code>buy_params</code> and <code>sell_params</code>.
|
|
* <code>optimize</code> - when set to <code>False</code> parameter will not be included in optimization process.
|
|
Use these parameters to quickly prototype various ideas.</p>
|
|
</div>
|
|
<div class="admonition warning">
|
|
<p class="admonition-title">Warning</p>
|
|
<p>Hyperoptable parameters cannot be used in <code>populate_indicators</code> - as hyperopt does not recalculate indicators for each epoch, so the starting value would be used in this case.</p>
|
|
</div>
|
|
<h2 id="optimizing-an-indicator-parameter">Optimizing an indicator parameter<a class="headerlink" href="#optimizing-an-indicator-parameter" title="Permanent link">¶</a></h2>
|
|
<p>Assuming you have a simple strategy in mind - a EMA cross strategy (2 Moving averages crossing) - and you'd like to find the ideal parameters for this strategy.
|
|
By default, we assume a stoploss of 5% - and a take-profit (<code>minimal_roi</code>) of 10% - which means freqtrade will sell the trade once 10% profit has been reached.</p>
|
|
<div class="highlight"><pre><span></span><code><span class="kn">from</span> <span class="nn">pandas</span> <span class="kn">import</span> <span class="n">DataFrame</span>
|
|
<span class="kn">from</span> <span class="nn">functools</span> <span class="kn">import</span> <span class="n">reduce</span>
|
|
|
|
<span class="kn">import</span> <span class="nn">talib.abstract</span> <span class="k">as</span> <span class="nn">ta</span>
|
|
|
|
<span class="kn">from</span> <span class="nn">freqtrade.strategy</span> <span class="kn">import</span> <span class="p">(</span><span class="n">BooleanParameter</span><span class="p">,</span> <span class="n">CategoricalParameter</span><span class="p">,</span> <span class="n">DecimalParameter</span><span class="p">,</span>
|
|
<span class="n">IStrategy</span><span class="p">,</span> <span class="n">IntParameter</span><span class="p">)</span>
|
|
<span class="kn">import</span> <span class="nn">freqtrade.vendor.qtpylib.indicators</span> <span class="k">as</span> <span class="nn">qtpylib</span>
|
|
|
|
<span class="k">class</span> <span class="nc">MyAwesomeStrategy</span><span class="p">(</span><span class="n">IStrategy</span><span class="p">):</span>
|
|
<span class="n">stoploss</span> <span class="o">=</span> <span class="o">-</span><span class="mf">0.05</span>
|
|
<span class="n">timeframe</span> <span class="o">=</span> <span class="s1">'15m'</span>
|
|
<span class="n">minimal_roi</span> <span class="o">=</span> <span class="p">{</span>
|
|
<span class="s2">"0"</span><span class="p">:</span> <span class="mf">0.10</span>
|
|
<span class="p">}</span>
|
|
<span class="c1"># Define the parameter spaces</span>
|
|
<span class="n">buy_ema_short</span> <span class="o">=</span> <span class="n">IntParameter</span><span class="p">(</span><span class="mi">3</span><span class="p">,</span> <span class="mi">50</span><span class="p">,</span> <span class="n">default</span><span class="o">=</span><span class="mi">5</span><span class="p">)</span>
|
|
<span class="n">buy_ema_long</span> <span class="o">=</span> <span class="n">IntParameter</span><span class="p">(</span><span class="mi">15</span><span class="p">,</span> <span class="mi">200</span><span class="p">,</span> <span class="n">default</span><span class="o">=</span><span class="mi">50</span><span class="p">)</span>
|
|
|
|
|
|
<span class="k">def</span> <span class="nf">populate_indicators</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">dataframe</span><span class="p">:</span> <span class="n">DataFrame</span><span class="p">,</span> <span class="n">metadata</span><span class="p">:</span> <span class="nb">dict</span><span class="p">)</span> <span class="o">-></span> <span class="n">DataFrame</span><span class="p">:</span>
|
|
<span class="w"> </span><span class="sd">"""Generate all indicators used by the strategy"""</span>
|
|
|
|
<span class="c1"># Calculate all ema_short values</span>
|
|
<span class="k">for</span> <span class="n">val</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">buy_ema_short</span><span class="o">.</span><span class="n">range</span><span class="p">:</span>
|
|
<span class="n">dataframe</span><span class="p">[</span><span class="sa">f</span><span class="s1">'ema_short_</span><span class="si">{</span><span class="n">val</span><span class="si">}</span><span class="s1">'</span><span class="p">]</span> <span class="o">=</span> <span class="n">ta</span><span class="o">.</span><span class="n">EMA</span><span class="p">(</span><span class="n">dataframe</span><span class="p">,</span> <span class="n">timeperiod</span><span class="o">=</span><span class="n">val</span><span class="p">)</span>
|
|
|
|
<span class="c1"># Calculate all ema_long values</span>
|
|
<span class="k">for</span> <span class="n">val</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">buy_ema_long</span><span class="o">.</span><span class="n">range</span><span class="p">:</span>
|
|
<span class="n">dataframe</span><span class="p">[</span><span class="sa">f</span><span class="s1">'ema_long_</span><span class="si">{</span><span class="n">val</span><span class="si">}</span><span class="s1">'</span><span class="p">]</span> <span class="o">=</span> <span class="n">ta</span><span class="o">.</span><span class="n">EMA</span><span class="p">(</span><span class="n">dataframe</span><span class="p">,</span> <span class="n">timeperiod</span><span class="o">=</span><span class="n">val</span><span class="p">)</span>
|
|
|
|
<span class="k">return</span> <span class="n">dataframe</span>
|
|
|
|
<span class="k">def</span> <span class="nf">populate_entry_trend</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">dataframe</span><span class="p">:</span> <span class="n">DataFrame</span><span class="p">,</span> <span class="n">metadata</span><span class="p">:</span> <span class="nb">dict</span><span class="p">)</span> <span class="o">-></span> <span class="n">DataFrame</span><span class="p">:</span>
|
|
<span class="n">conditions</span> <span class="o">=</span> <span class="p">[]</span>
|
|
<span class="n">conditions</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">qtpylib</span><span class="o">.</span><span class="n">crossed_above</span><span class="p">(</span>
|
|
<span class="n">dataframe</span><span class="p">[</span><span class="sa">f</span><span class="s1">'ema_short_</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">buy_ema_short</span><span class="o">.</span><span class="n">value</span><span class="si">}</span><span class="s1">'</span><span class="p">],</span> <span class="n">dataframe</span><span class="p">[</span><span class="sa">f</span><span class="s1">'ema_long_</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">buy_ema_long</span><span class="o">.</span><span class="n">value</span><span class="si">}</span><span class="s1">'</span><span class="p">]</span>
|
|
<span class="p">))</span>
|
|
|
|
<span class="c1"># Check that volume is not 0</span>
|
|
<span class="n">conditions</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">dataframe</span><span class="p">[</span><span class="s1">'volume'</span><span class="p">]</span> <span class="o">></span> <span class="mi">0</span><span class="p">)</span>
|
|
|
|
<span class="k">if</span> <span class="n">conditions</span><span class="p">:</span>
|
|
<span class="n">dataframe</span><span class="o">.</span><span class="n">loc</span><span class="p">[</span>
|
|
<span class="n">reduce</span><span class="p">(</span><span class="k">lambda</span> <span class="n">x</span><span class="p">,</span> <span class="n">y</span><span class="p">:</span> <span class="n">x</span> <span class="o">&</span> <span class="n">y</span><span class="p">,</span> <span class="n">conditions</span><span class="p">),</span>
|
|
<span class="s1">'enter_long'</span><span class="p">]</span> <span class="o">=</span> <span class="mi">1</span>
|
|
<span class="k">return</span> <span class="n">dataframe</span>
|
|
|
|
<span class="k">def</span> <span class="nf">populate_exit_trend</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">dataframe</span><span class="p">:</span> <span class="n">DataFrame</span><span class="p">,</span> <span class="n">metadata</span><span class="p">:</span> <span class="nb">dict</span><span class="p">)</span> <span class="o">-></span> <span class="n">DataFrame</span><span class="p">:</span>
|
|
<span class="n">conditions</span> <span class="o">=</span> <span class="p">[]</span>
|
|
<span class="n">conditions</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">qtpylib</span><span class="o">.</span><span class="n">crossed_above</span><span class="p">(</span>
|
|
<span class="n">dataframe</span><span class="p">[</span><span class="sa">f</span><span class="s1">'ema_long_</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">buy_ema_long</span><span class="o">.</span><span class="n">value</span><span class="si">}</span><span class="s1">'</span><span class="p">],</span> <span class="n">dataframe</span><span class="p">[</span><span class="sa">f</span><span class="s1">'ema_short_</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">buy_ema_short</span><span class="o">.</span><span class="n">value</span><span class="si">}</span><span class="s1">'</span><span class="p">]</span>
|
|
<span class="p">))</span>
|
|
|
|
<span class="c1"># Check that volume is not 0</span>
|
|
<span class="n">conditions</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">dataframe</span><span class="p">[</span><span class="s1">'volume'</span><span class="p">]</span> <span class="o">></span> <span class="mi">0</span><span class="p">)</span>
|
|
|
|
<span class="k">if</span> <span class="n">conditions</span><span class="p">:</span>
|
|
<span class="n">dataframe</span><span class="o">.</span><span class="n">loc</span><span class="p">[</span>
|
|
<span class="n">reduce</span><span class="p">(</span><span class="k">lambda</span> <span class="n">x</span><span class="p">,</span> <span class="n">y</span><span class="p">:</span> <span class="n">x</span> <span class="o">&</span> <span class="n">y</span><span class="p">,</span> <span class="n">conditions</span><span class="p">),</span>
|
|
<span class="s1">'exit_long'</span><span class="p">]</span> <span class="o">=</span> <span class="mi">1</span>
|
|
<span class="k">return</span> <span class="n">dataframe</span>
|
|
</code></pre></div>
|
|
<p>Breaking it down:</p>
|
|
<p>Using <code>self.buy_ema_short.range</code> will return a range object containing all entries between the Parameters low and high value.
|
|
In this case (<code>IntParameter(3, 50, default=5)</code>), the loop would run for all numbers between 3 and 50 (<code>[3, 4, 5, ... 49, 50]</code>).
|
|
By using this in a loop, hyperopt will generate 48 new columns (<code>['buy_ema_3', 'buy_ema_4', ... , 'buy_ema_50']</code>).</p>
|
|
<p>Hyperopt itself will then use the selected value to create the buy and sell signals.</p>
|
|
<p>While this strategy is most likely too simple to provide consistent profit, it should serve as an example how optimize indicator parameters.</p>
|
|
<div class="admonition note">
|
|
<p class="admonition-title">Note</p>
|
|
<p><code>self.buy_ema_short.range</code> will act differently between hyperopt and other modes. For hyperopt, the above example may generate 48 new columns, however for all other modes (backtesting, dry/live), it will only generate the column for the selected value. You should therefore avoid using the resulting column with explicit values (values other than <code>self.buy_ema_short.value</code>).</p>
|
|
</div>
|
|
<div class="admonition note">
|
|
<p class="admonition-title">Note</p>
|
|
<p><code>range</code> property may also be used with <code>DecimalParameter</code> and <code>CategoricalParameter</code>. <code>RealParameter</code> does not provide this property due to infinite search space.</p>
|
|
</div>
|
|
<details class="hint">
|
|
<summary>Performance tip</summary>
|
|
<p>During normal hyperopting, indicators are calculated once and supplied to each epoch, linearly increasing RAM usage as a factor of increasing cores. As this also has performance implications, hyperopt provides <code>--analyze-per-epoch</code> which will move the execution of <code>populate_indicators()</code> to the epoch process, calculating a single value per parameter per epoch instead of using the <code>.range</code> functionality. In this case, <code>.range</code> functionality will only return the actually used value. This will reduce RAM usage, but increase CPU usage. However, your hyperopting run will be less likely to fail due to Out Of Memory (OOM) issues.</p>
|
|
<p>In either case, you should try to use space ranges as small as possible this will improve CPU/RAM usage in both scenarios.</p>
|
|
</details>
|
|
<h2 id="optimizing-protections">Optimizing protections<a class="headerlink" href="#optimizing-protections" title="Permanent link">¶</a></h2>
|
|
<p>Freqtrade can also optimize protections. How you optimize protections is up to you, and the following should be considered as example only.</p>
|
|
<p>The strategy will simply need to define the "protections" entry as property returning a list of protection configurations.</p>
|
|
<div class="highlight"><pre><span></span><code><span class="kn">from</span> <span class="nn">pandas</span> <span class="kn">import</span> <span class="n">DataFrame</span>
|
|
<span class="kn">from</span> <span class="nn">functools</span> <span class="kn">import</span> <span class="n">reduce</span>
|
|
|
|
<span class="kn">import</span> <span class="nn">talib.abstract</span> <span class="k">as</span> <span class="nn">ta</span>
|
|
|
|
<span class="kn">from</span> <span class="nn">freqtrade.strategy</span> <span class="kn">import</span> <span class="p">(</span><span class="n">BooleanParameter</span><span class="p">,</span> <span class="n">CategoricalParameter</span><span class="p">,</span> <span class="n">DecimalParameter</span><span class="p">,</span>
|
|
<span class="n">IStrategy</span><span class="p">,</span> <span class="n">IntParameter</span><span class="p">)</span>
|
|
<span class="kn">import</span> <span class="nn">freqtrade.vendor.qtpylib.indicators</span> <span class="k">as</span> <span class="nn">qtpylib</span>
|
|
|
|
<span class="k">class</span> <span class="nc">MyAwesomeStrategy</span><span class="p">(</span><span class="n">IStrategy</span><span class="p">):</span>
|
|
<span class="n">stoploss</span> <span class="o">=</span> <span class="o">-</span><span class="mf">0.05</span>
|
|
<span class="n">timeframe</span> <span class="o">=</span> <span class="s1">'15m'</span>
|
|
<span class="c1"># Define the parameter spaces</span>
|
|
<span class="n">cooldown_lookback</span> <span class="o">=</span> <span class="n">IntParameter</span><span class="p">(</span><span class="mi">2</span><span class="p">,</span> <span class="mi">48</span><span class="p">,</span> <span class="n">default</span><span class="o">=</span><span class="mi">5</span><span class="p">,</span> <span class="n">space</span><span class="o">=</span><span class="s2">"protection"</span><span class="p">,</span> <span class="n">optimize</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span>
|
|
<span class="n">stop_duration</span> <span class="o">=</span> <span class="n">IntParameter</span><span class="p">(</span><span class="mi">12</span><span class="p">,</span> <span class="mi">200</span><span class="p">,</span> <span class="n">default</span><span class="o">=</span><span class="mi">5</span><span class="p">,</span> <span class="n">space</span><span class="o">=</span><span class="s2">"protection"</span><span class="p">,</span> <span class="n">optimize</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span>
|
|
<span class="n">use_stop_protection</span> <span class="o">=</span> <span class="n">BooleanParameter</span><span class="p">(</span><span class="n">default</span><span class="o">=</span><span class="kc">True</span><span class="p">,</span> <span class="n">space</span><span class="o">=</span><span class="s2">"protection"</span><span class="p">,</span> <span class="n">optimize</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span>
|
|
|
|
|
|
<span class="nd">@property</span>
|
|
<span class="k">def</span> <span class="nf">protections</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
|
|
<span class="n">prot</span> <span class="o">=</span> <span class="p">[]</span>
|
|
|
|
<span class="n">prot</span><span class="o">.</span><span class="n">append</span><span class="p">({</span>
|
|
<span class="s2">"method"</span><span class="p">:</span> <span class="s2">"CooldownPeriod"</span><span class="p">,</span>
|
|
<span class="s2">"stop_duration_candles"</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">cooldown_lookback</span><span class="o">.</span><span class="n">value</span>
|
|
<span class="p">})</span>
|
|
<span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">use_stop_protection</span><span class="o">.</span><span class="n">value</span><span class="p">:</span>
|
|
<span class="n">prot</span><span class="o">.</span><span class="n">append</span><span class="p">({</span>
|
|
<span class="s2">"method"</span><span class="p">:</span> <span class="s2">"StoplossGuard"</span><span class="p">,</span>
|
|
<span class="s2">"lookback_period_candles"</span><span class="p">:</span> <span class="mi">24</span> <span class="o">*</span> <span class="mi">3</span><span class="p">,</span>
|
|
<span class="s2">"trade_limit"</span><span class="p">:</span> <span class="mi">4</span><span class="p">,</span>
|
|
<span class="s2">"stop_duration_candles"</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">stop_duration</span><span class="o">.</span><span class="n">value</span><span class="p">,</span>
|
|
<span class="s2">"only_per_pair"</span><span class="p">:</span> <span class="kc">False</span>
|
|
<span class="p">})</span>
|
|
|
|
<span class="k">return</span> <span class="n">prot</span>
|
|
|
|
<span class="k">def</span> <span class="nf">populate_indicators</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">dataframe</span><span class="p">:</span> <span class="n">DataFrame</span><span class="p">,</span> <span class="n">metadata</span><span class="p">:</span> <span class="nb">dict</span><span class="p">)</span> <span class="o">-></span> <span class="n">DataFrame</span><span class="p">:</span>
|
|
<span class="c1"># ...</span>
|
|
</code></pre></div>
|
|
<p>You can then run hyperopt as follows:
|
|
<code>freqtrade hyperopt --hyperopt-loss SharpeHyperOptLossDaily --strategy MyAwesomeStrategy --spaces protection</code></p>
|
|
<div class="admonition note">
|
|
<p class="admonition-title">Note</p>
|
|
<p>The protection space is not part of the default space, and is only available with the Parameters Hyperopt interface, not with the legacy hyperopt interface (which required separate hyperopt files).
|
|
Freqtrade will also automatically change the "--enable-protections" flag if the protection space is selected.</p>
|
|
</div>
|
|
<div class="admonition warning">
|
|
<p class="admonition-title">Warning</p>
|
|
<p>If protections are defined as property, entries from the configuration will be ignored.
|
|
It is therefore recommended to not define protections in the configuration.</p>
|
|
</div>
|
|
<h3 id="migrating-from-previous-property-setups">Migrating from previous property setups<a class="headerlink" href="#migrating-from-previous-property-setups" title="Permanent link">¶</a></h3>
|
|
<p>A migration from a previous setup is pretty simple, and can be accomplished by converting the protections entry to a property.
|
|
In simple terms, the following configuration will be converted to the below.</p>
|
|
<div class="highlight"><pre><span></span><code><span class="k">class</span> <span class="nc">MyAwesomeStrategy</span><span class="p">(</span><span class="n">IStrategy</span><span class="p">):</span>
|
|
<span class="n">protections</span> <span class="o">=</span> <span class="p">[</span>
|
|
<span class="p">{</span>
|
|
<span class="s2">"method"</span><span class="p">:</span> <span class="s2">"CooldownPeriod"</span><span class="p">,</span>
|
|
<span class="s2">"stop_duration_candles"</span><span class="p">:</span> <span class="mi">4</span>
|
|
<span class="p">}</span>
|
|
<span class="p">]</span>
|
|
</code></pre></div>
|
|
<p>Result</p>
|
|
<div class="highlight"><pre><span></span><code><span class="k">class</span> <span class="nc">MyAwesomeStrategy</span><span class="p">(</span><span class="n">IStrategy</span><span class="p">):</span>
|
|
|
|
<span class="nd">@property</span>
|
|
<span class="k">def</span> <span class="nf">protections</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
|
|
<span class="k">return</span> <span class="p">[</span>
|
|
<span class="p">{</span>
|
|
<span class="s2">"method"</span><span class="p">:</span> <span class="s2">"CooldownPeriod"</span><span class="p">,</span>
|
|
<span class="s2">"stop_duration_candles"</span><span class="p">:</span> <span class="mi">4</span>
|
|
<span class="p">}</span>
|
|
<span class="p">]</span>
|
|
</code></pre></div>
|
|
<p>You will then obviously also change potential interesting entries to parameters to allow hyper-optimization.</p>
|
|
<h3 id="optimizing-max_entry_position_adjustment">Optimizing <code>max_entry_position_adjustment</code><a class="headerlink" href="#optimizing-max_entry_position_adjustment" title="Permanent link">¶</a></h3>
|
|
<p>While <code>max_entry_position_adjustment</code> is not a separate space, it can still be used in hyperopt by using the property approach shown above.</p>
|
|
<div class="highlight"><pre><span></span><code><span class="kn">from</span> <span class="nn">pandas</span> <span class="kn">import</span> <span class="n">DataFrame</span>
|
|
<span class="kn">from</span> <span class="nn">functools</span> <span class="kn">import</span> <span class="n">reduce</span>
|
|
|
|
<span class="kn">import</span> <span class="nn">talib.abstract</span> <span class="k">as</span> <span class="nn">ta</span>
|
|
|
|
<span class="kn">from</span> <span class="nn">freqtrade.strategy</span> <span class="kn">import</span> <span class="p">(</span><span class="n">BooleanParameter</span><span class="p">,</span> <span class="n">CategoricalParameter</span><span class="p">,</span> <span class="n">DecimalParameter</span><span class="p">,</span>
|
|
<span class="n">IStrategy</span><span class="p">,</span> <span class="n">IntParameter</span><span class="p">)</span>
|
|
<span class="kn">import</span> <span class="nn">freqtrade.vendor.qtpylib.indicators</span> <span class="k">as</span> <span class="nn">qtpylib</span>
|
|
|
|
<span class="k">class</span> <span class="nc">MyAwesomeStrategy</span><span class="p">(</span><span class="n">IStrategy</span><span class="p">):</span>
|
|
<span class="n">stoploss</span> <span class="o">=</span> <span class="o">-</span><span class="mf">0.05</span>
|
|
<span class="n">timeframe</span> <span class="o">=</span> <span class="s1">'15m'</span>
|
|
|
|
<span class="c1"># Define the parameter spaces</span>
|
|
<span class="n">max_epa</span> <span class="o">=</span> <span class="n">CategoricalParameter</span><span class="p">([</span><span class="o">-</span><span class="mi">1</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="mi">1</span><span class="p">,</span> <span class="mi">3</span><span class="p">,</span> <span class="mi">5</span><span class="p">,</span> <span class="mi">10</span><span class="p">],</span> <span class="n">default</span><span class="o">=</span><span class="mi">1</span><span class="p">,</span> <span class="n">space</span><span class="o">=</span><span class="s2">"buy"</span><span class="p">,</span> <span class="n">optimize</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span>
|
|
|
|
<span class="nd">@property</span>
|
|
<span class="k">def</span> <span class="nf">max_entry_position_adjustment</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
|
|
<span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">max_epa</span><span class="o">.</span><span class="n">value</span>
|
|
|
|
|
|
<span class="k">def</span> <span class="nf">populate_indicators</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">dataframe</span><span class="p">:</span> <span class="n">DataFrame</span><span class="p">,</span> <span class="n">metadata</span><span class="p">:</span> <span class="nb">dict</span><span class="p">)</span> <span class="o">-></span> <span class="n">DataFrame</span><span class="p">:</span>
|
|
<span class="c1"># ...</span>
|
|
</code></pre></div>
|
|
<details class="tip">
|
|
<summary>Using <code>IntParameter</code></summary>
|
|
<p>You can also use the <code>IntParameter</code> for this optimization, but you must explicitly return an integer:
|
|
<div class="highlight"><pre><span></span><code><span class="n">max_epa</span> <span class="o">=</span> <span class="n">IntParameter</span><span class="p">(</span><span class="o">-</span><span class="mi">1</span><span class="p">,</span> <span class="mi">10</span><span class="p">,</span> <span class="n">default</span><span class="o">=</span><span class="mi">1</span><span class="p">,</span> <span class="n">space</span><span class="o">=</span><span class="s2">"buy"</span><span class="p">,</span> <span class="n">optimize</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span>
|
|
|
|
<span class="nd">@property</span>
|
|
<span class="k">def</span> <span class="nf">max_entry_position_adjustment</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
|
|
<span class="k">return</span> <span class="nb">int</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">max_epa</span><span class="o">.</span><span class="n">value</span><span class="p">)</span>
|
|
</code></pre></div></p>
|
|
</details>
|
|
<h2 id="loss-functions">Loss-functions<a class="headerlink" href="#loss-functions" title="Permanent link">¶</a></h2>
|
|
<p>Each hyperparameter tuning requires a target. This is usually defined as a loss function (sometimes also called objective function), which should decrease for more desirable results, and increase for bad results.</p>
|
|
<p>A loss function must be specified via the <code>--hyperopt-loss <Class-name></code> argument (or optionally via the configuration under the <code>"hyperopt_loss"</code> key).
|
|
This class should be in its own file within the <code>user_data/hyperopts/</code> directory.</p>
|
|
<p>Currently, the following loss functions are builtin:</p>
|
|
<ul>
|
|
<li><code>ShortTradeDurHyperOptLoss</code> - (default legacy Freqtrade hyperoptimization loss function) - Mostly for short trade duration and avoiding losses.</li>
|
|
<li><code>OnlyProfitHyperOptLoss</code> - takes only amount of profit into consideration.</li>
|
|
<li><code>SharpeHyperOptLoss</code> - optimizes Sharpe Ratio calculated on trade returns relative to standard deviation.</li>
|
|
<li><code>SharpeHyperOptLossDaily</code> - optimizes Sharpe Ratio calculated on <strong>daily</strong> trade returns relative to standard deviation.</li>
|
|
<li><code>SortinoHyperOptLoss</code> - optimizes Sortino Ratio calculated on trade returns relative to <strong>downside</strong> standard deviation.</li>
|
|
<li><code>SortinoHyperOptLossDaily</code> - optimizes Sortino Ratio calculated on <strong>daily</strong> trade returns relative to <strong>downside</strong> standard deviation.</li>
|
|
<li><code>MaxDrawDownHyperOptLoss</code> - Optimizes Maximum absolute drawdown.</li>
|
|
<li><code>MaxDrawDownRelativeHyperOptLoss</code> - Optimizes both maximum absolute drawdown while also adjusting for maximum relative drawdown.</li>
|
|
<li><code>CalmarHyperOptLoss</code> - Optimizes Calmar Ratio calculated on trade returns relative to max drawdown.</li>
|
|
<li><code>ProfitDrawDownHyperOptLoss</code> - Optimizes by max Profit & min Drawdown objective. <code>DRAWDOWN_MULT</code> variable within the hyperoptloss file can be adjusted to be stricter or more flexible on drawdown purposes.</li>
|
|
</ul>
|
|
<p>Creation of a custom loss function is covered in the <a href="../advanced-hyperopt/">Advanced Hyperopt</a> part of the documentation.</p>
|
|
<h2 id="execute-hyperopt">Execute Hyperopt<a class="headerlink" href="#execute-hyperopt" title="Permanent link">¶</a></h2>
|
|
<p>Once you have updated your hyperopt configuration you can run it.
|
|
Because hyperopt tries a lot of combinations to find the best parameters it will take time to get a good result.</p>
|
|
<p>We strongly recommend to use <code>screen</code> or <code>tmux</code> to prevent any connection loss.</p>
|
|
<div class="highlight"><pre><span></span><code>freqtrade<span class="w"> </span>hyperopt<span class="w"> </span>--config<span class="w"> </span>config.json<span class="w"> </span>--hyperopt-loss<span class="w"> </span><hyperoptlossname><span class="w"> </span>--strategy<span class="w"> </span><strategyname><span class="w"> </span>-e<span class="w"> </span><span class="m">500</span><span class="w"> </span>--spaces<span class="w"> </span>all
|
|
</code></pre></div>
|
|
<p>The <code>-e</code> option will set how many evaluations hyperopt will do. Since hyperopt uses Bayesian search, running too many epochs at once may not produce greater results. Experience has shown that best results are usually not improving much after 500-1000 epochs.<br />
|
|
Doing multiple runs (executions) with a few 1000 epochs and different random state will most likely produce different results.</p>
|
|
<p>The <code>--spaces all</code> option determines that all possible parameters should be optimized. Possibilities are listed below.</p>
|
|
<div class="admonition note">
|
|
<p class="admonition-title">Note</p>
|
|
<p>Hyperopt will store hyperopt results with the timestamp of the hyperopt start time.
|
|
Reading commands (<code>hyperopt-list</code>, <code>hyperopt-show</code>) can use <code>--hyperopt-filename <filename></code> to read and display older hyperopt results.
|
|
You can find a list of filenames with <code>ls -l user_data/hyperopt_results/</code>.</p>
|
|
</div>
|
|
<h3 id="execute-hyperopt-with-different-historical-data-source">Execute Hyperopt with different historical data source<a class="headerlink" href="#execute-hyperopt-with-different-historical-data-source" title="Permanent link">¶</a></h3>
|
|
<p>If you would like to hyperopt parameters using an alternate historical data set that
|
|
you have on-disk, use the <code>--datadir PATH</code> option. By default, hyperopt uses data from directory <code>user_data/data</code>.</p>
|
|
<h3 id="running-hyperopt-with-a-smaller-test-set">Running Hyperopt with a smaller test-set<a class="headerlink" href="#running-hyperopt-with-a-smaller-test-set" title="Permanent link">¶</a></h3>
|
|
<p>Use the <code>--timerange</code> argument to change how much of the test-set you want to use.
|
|
For example, to use one month of data, pass <code>--timerange 20210101-20210201</code> (from january 2021 - february 2021) to the hyperopt call.</p>
|
|
<p>Full command:</p>
|
|
<div class="highlight"><pre><span></span><code>freqtrade<span class="w"> </span>hyperopt<span class="w"> </span>--strategy<span class="w"> </span><strategyname><span class="w"> </span>--timerange<span class="w"> </span><span class="m">20210101</span>-20210201
|
|
</code></pre></div>
|
|
<h3 id="running-hyperopt-with-smaller-search-space">Running Hyperopt with Smaller Search Space<a class="headerlink" href="#running-hyperopt-with-smaller-search-space" title="Permanent link">¶</a></h3>
|
|
<p>Use the <code>--spaces</code> option to limit the search space used by hyperopt.
|
|
Letting Hyperopt optimize everything is a huuuuge search space.
|
|
Often it might make more sense to start by just searching for initial buy algorithm.
|
|
Or maybe you just want to optimize your stoploss or roi table for that awesome new buy strategy you have.</p>
|
|
<p>Legal values are:</p>
|
|
<ul>
|
|
<li><code>all</code>: optimize everything</li>
|
|
<li><code>buy</code>: just search for a new buy strategy</li>
|
|
<li><code>sell</code>: just search for a new sell strategy</li>
|
|
<li><code>roi</code>: just optimize the minimal profit table for your strategy</li>
|
|
<li><code>stoploss</code>: search for the best stoploss value</li>
|
|
<li><code>trailing</code>: search for the best trailing stop values</li>
|
|
<li><code>trades</code>: search for the best max open trades values</li>
|
|
<li><code>protection</code>: search for the best protection parameters (read the <a href="#optimizing-protections">protections section</a> on how to properly define these)</li>
|
|
<li><code>default</code>: <code>all</code> except <code>trailing</code> and <code>protection</code></li>
|
|
<li>space-separated list of any of the above values for example <code>--spaces roi stoploss</code></li>
|
|
</ul>
|
|
<p>The default Hyperopt Search Space, used when no <code>--space</code> command line option is specified, does not include the <code>trailing</code> hyperspace. We recommend you to run optimization for the <code>trailing</code> hyperspace separately, when the best parameters for other hyperspaces were found, validated and pasted into your custom strategy.</p>
|
|
<h2 id="understand-the-hyperopt-result">Understand the Hyperopt Result<a class="headerlink" href="#understand-the-hyperopt-result" title="Permanent link">¶</a></h2>
|
|
<p>Once Hyperopt is completed you can use the result to update your strategy.
|
|
Given the following result from hyperopt:</p>
|
|
<div class="highlight"><pre><span></span><code>Best result:
|
|
|
|
44/100: 135 trades. Avg profit 0.57%. Total profit 0.03871918 BTC (0.7722%). Avg duration 180.4 mins. Objective: 1.94367
|
|
|
|
# Buy hyperspace params:
|
|
buy_params = {
|
|
'buy_adx': 44,
|
|
'buy_rsi': 29,
|
|
'buy_adx_enabled': False,
|
|
'buy_rsi_enabled': True,
|
|
'buy_trigger': 'bb_lower'
|
|
}
|
|
</code></pre></div>
|
|
<p>You should understand this result like:</p>
|
|
<ul>
|
|
<li>The buy trigger that worked best was <code>bb_lower</code>.</li>
|
|
<li>You should not use ADX because <code>'buy_adx_enabled': False</code>.</li>
|
|
<li>You should <strong>consider</strong> using the RSI indicator (<code>'buy_rsi_enabled': True</code>) and the best value is <code>29.0</code> (<code>'buy_rsi': 29.0</code>)</li>
|
|
</ul>
|
|
<h3 id="automatic-parameter-application-to-the-strategy">Automatic parameter application to the strategy<a class="headerlink" href="#automatic-parameter-application-to-the-strategy" title="Permanent link">¶</a></h3>
|
|
<p>When using Hyperoptable parameters, the result of your hyperopt-run will be written to a json file next to your strategy (so for <code>MyAwesomeStrategy.py</code>, the file would be <code>MyAwesomeStrategy.json</code>).<br />
|
|
This file is also updated when using the <code>hyperopt-show</code> sub-command, unless <code>--disable-param-export</code> is provided to either of the 2 commands.</p>
|
|
<p>Your strategy class can also contain these results explicitly. Simply copy hyperopt results block and paste them at class level, replacing old parameters (if any). New parameters will automatically be loaded next time strategy is executed.</p>
|
|
<p>Transferring your whole hyperopt result to your strategy would then look like:</p>
|
|
<div class="highlight"><pre><span></span><code><span class="k">class</span> <span class="nc">MyAwesomeStrategy</span><span class="p">(</span><span class="n">IStrategy</span><span class="p">):</span>
|
|
<span class="c1"># Buy hyperspace params:</span>
|
|
<span class="n">buy_params</span> <span class="o">=</span> <span class="p">{</span>
|
|
<span class="s1">'buy_adx'</span><span class="p">:</span> <span class="mi">44</span><span class="p">,</span>
|
|
<span class="s1">'buy_rsi'</span><span class="p">:</span> <span class="mi">29</span><span class="p">,</span>
|
|
<span class="s1">'buy_adx_enabled'</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span>
|
|
<span class="s1">'buy_rsi_enabled'</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span>
|
|
<span class="s1">'buy_trigger'</span><span class="p">:</span> <span class="s1">'bb_lower'</span>
|
|
<span class="p">}</span>
|
|
</code></pre></div>
|
|
<div class="admonition note">
|
|
<p class="admonition-title">Note</p>
|
|
<p>Values in the configuration file will overwrite Parameter-file level parameters - and both will overwrite parameters within the strategy.
|
|
The prevalence is therefore: config > parameter file > strategy <code>*_params</code> > parameter default</p>
|
|
</div>
|
|
<h3 id="understand-hyperopt-roi-results">Understand Hyperopt ROI results<a class="headerlink" href="#understand-hyperopt-roi-results" title="Permanent link">¶</a></h3>
|
|
<p>If you are optimizing ROI (i.e. if optimization search-space contains 'all', 'default' or 'roi'), your result will look as follows and include a ROI table:</p>
|
|
<div class="highlight"><pre><span></span><code>Best result:
|
|
|
|
44/100: 135 trades. Avg profit 0.57%. Total profit 0.03871918 BTC (0.7722%). Avg duration 180.4 mins. Objective: 1.94367
|
|
|
|
# ROI table:
|
|
minimal_roi = {
|
|
0: 0.10674,
|
|
21: 0.09158,
|
|
78: 0.03634,
|
|
118: 0
|
|
}
|
|
</code></pre></div>
|
|
<p>In order to use this best ROI table found by Hyperopt in backtesting and for live trades/dry-run, copy-paste it as the value of the <code>minimal_roi</code> attribute of your custom strategy:</p>
|
|
<div class="highlight"><pre><span></span><code> # Minimal ROI designed for the strategy.
|
|
# This attribute will be overridden if the config file contains "minimal_roi"
|
|
minimal_roi = {
|
|
0: 0.10674,
|
|
21: 0.09158,
|
|
78: 0.03634,
|
|
118: 0
|
|
}
|
|
</code></pre></div>
|
|
<p>As stated in the comment, you can also use it as the value of the <code>minimal_roi</code> setting in the configuration file.</p>
|
|
<h4 id="default-roi-search-space">Default ROI Search Space<a class="headerlink" href="#default-roi-search-space" title="Permanent link">¶</a></h4>
|
|
<p>If you are optimizing ROI, Freqtrade creates the 'roi' optimization hyperspace for you -- it's the hyperspace of components for the ROI tables. By default, each ROI table generated by the Freqtrade consists of 4 rows (steps). Hyperopt implements adaptive ranges for ROI tables with ranges for values in the ROI steps that depend on the timeframe used. By default the values vary in the following ranges (for some of the most used timeframes, values are rounded to 3 digits after the decimal point):</p>
|
|
<table>
|
|
<thead>
|
|
<tr>
|
|
<th># step</th>
|
|
<th>1m</th>
|
|
<th></th>
|
|
<th>5m</th>
|
|
<th></th>
|
|
<th>1h</th>
|
|
<th></th>
|
|
<th>1d</th>
|
|
<th></th>
|
|
</tr>
|
|
</thead>
|
|
<tbody>
|
|
<tr>
|
|
<td>1</td>
|
|
<td>0</td>
|
|
<td>0.011...0.119</td>
|
|
<td>0</td>
|
|
<td>0.03...0.31</td>
|
|
<td>0</td>
|
|
<td>0.068...0.711</td>
|
|
<td>0</td>
|
|
<td>0.121...1.258</td>
|
|
</tr>
|
|
<tr>
|
|
<td>2</td>
|
|
<td>2...8</td>
|
|
<td>0.007...0.042</td>
|
|
<td>10...40</td>
|
|
<td>0.02...0.11</td>
|
|
<td>120...480</td>
|
|
<td>0.045...0.252</td>
|
|
<td>2880...11520</td>
|
|
<td>0.081...0.446</td>
|
|
</tr>
|
|
<tr>
|
|
<td>3</td>
|
|
<td>4...20</td>
|
|
<td>0.003...0.015</td>
|
|
<td>20...100</td>
|
|
<td>0.01...0.04</td>
|
|
<td>240...1200</td>
|
|
<td>0.022...0.091</td>
|
|
<td>5760...28800</td>
|
|
<td>0.040...0.162</td>
|
|
</tr>
|
|
<tr>
|
|
<td>4</td>
|
|
<td>6...44</td>
|
|
<td>0.0</td>
|
|
<td>30...220</td>
|
|
<td>0.0</td>
|
|
<td>360...2640</td>
|
|
<td>0.0</td>
|
|
<td>8640...63360</td>
|
|
<td>0.0</td>
|
|
</tr>
|
|
</tbody>
|
|
</table>
|
|
<p>These ranges should be sufficient in most cases. The minutes in the steps (ROI dict keys) are scaled linearly depending on the timeframe used. The ROI values in the steps (ROI dict values) are scaled logarithmically depending on the timeframe used.</p>
|
|
<p>If you have the <code>generate_roi_table()</code> and <code>roi_space()</code> methods in your custom hyperopt, remove them in order to utilize these adaptive ROI tables and the ROI hyperoptimization space generated by Freqtrade by default.</p>
|
|
<p>Override the <code>roi_space()</code> method if you need components of the ROI tables to vary in other ranges. Override the <code>generate_roi_table()</code> and <code>roi_space()</code> methods and implement your own custom approach for generation of the ROI tables during hyperoptimization if you need a different structure of the ROI tables or other amount of rows (steps).</p>
|
|
<p>A sample for these methods can be found in the <a href="../advanced-hyperopt/#overriding-pre-defined-spaces">overriding pre-defined spaces section</a>.</p>
|
|
<div class="admonition note">
|
|
<p class="admonition-title">Reduced search space</p>
|
|
<p>To limit the search space further, Decimals are limited to 3 decimal places (a precision of 0.001). This is usually sufficient, every value more precise than this will usually result in overfitted results. You can however <a href="../advanced-hyperopt/#pverriding-pre-defined-spaces">overriding pre-defined spaces</a> to change this to your needs.</p>
|
|
</div>
|
|
<h3 id="understand-hyperopt-stoploss-results">Understand Hyperopt Stoploss results<a class="headerlink" href="#understand-hyperopt-stoploss-results" title="Permanent link">¶</a></h3>
|
|
<p>If you are optimizing stoploss values (i.e. if optimization search-space contains 'all', 'default' or 'stoploss'), your result will look as follows and include stoploss:</p>
|
|
<div class="highlight"><pre><span></span><code>Best result:
|
|
|
|
44/100: 135 trades. Avg profit 0.57%. Total profit 0.03871918 BTC (0.7722%). Avg duration 180.4 mins. Objective: 1.94367
|
|
|
|
# Buy hyperspace params:
|
|
buy_params = {
|
|
'buy_adx': 44,
|
|
'buy_rsi': 29,
|
|
'buy_adx_enabled': False,
|
|
'buy_rsi_enabled': True,
|
|
'buy_trigger': 'bb_lower'
|
|
}
|
|
|
|
stoploss: -0.27996
|
|
</code></pre></div>
|
|
<p>In order to use this best stoploss value found by Hyperopt in backtesting and for live trades/dry-run, copy-paste it as the value of the <code>stoploss</code> attribute of your custom strategy:</p>
|
|
<div class="highlight"><pre><span></span><code> <span class="c1"># Optimal stoploss designed for the strategy</span>
|
|
<span class="c1"># This attribute will be overridden if the config file contains "stoploss"</span>
|
|
<span class="n">stoploss</span> <span class="o">=</span> <span class="o">-</span><span class="mf">0.27996</span>
|
|
</code></pre></div>
|
|
<p>As stated in the comment, you can also use it as the value of the <code>stoploss</code> setting in the configuration file.</p>
|
|
<h4 id="default-stoploss-search-space">Default Stoploss Search Space<a class="headerlink" href="#default-stoploss-search-space" title="Permanent link">¶</a></h4>
|
|
<p>If you are optimizing stoploss values, Freqtrade creates the 'stoploss' optimization hyperspace for you. By default, the stoploss values in that hyperspace vary in the range -0.35...-0.02, which is sufficient in most cases.</p>
|
|
<p>If you have the <code>stoploss_space()</code> method in your custom hyperopt file, remove it in order to utilize Stoploss hyperoptimization space generated by Freqtrade by default.</p>
|
|
<p>Override the <code>stoploss_space()</code> method and define the desired range in it if you need stoploss values to vary in other range during hyperoptimization. A sample for this method can be found in the <a href="../advanced-hyperopt/#overriding-pre-defined-spaces">overriding pre-defined spaces section</a>.</p>
|
|
<div class="admonition note">
|
|
<p class="admonition-title">Reduced search space</p>
|
|
<p>To limit the search space further, Decimals are limited to 3 decimal places (a precision of 0.001). This is usually sufficient, every value more precise than this will usually result in overfitted results. You can however <a href="../advanced-hyperopt/#pverriding-pre-defined-spaces">overriding pre-defined spaces</a> to change this to your needs.</p>
|
|
</div>
|
|
<h3 id="understand-hyperopt-trailing-stop-results">Understand Hyperopt Trailing Stop results<a class="headerlink" href="#understand-hyperopt-trailing-stop-results" title="Permanent link">¶</a></h3>
|
|
<p>If you are optimizing trailing stop values (i.e. if optimization search-space contains 'all' or 'trailing'), your result will look as follows and include trailing stop parameters:</p>
|
|
<div class="highlight"><pre><span></span><code>Best result:
|
|
|
|
45/100: 606 trades. Avg profit 1.04%. Total profit 0.31555614 BTC ( 630.48%). Avg duration 150.3 mins. Objective: -1.10161
|
|
|
|
# Trailing stop:
|
|
trailing_stop = True
|
|
trailing_stop_positive = 0.02001
|
|
trailing_stop_positive_offset = 0.06038
|
|
trailing_only_offset_is_reached = True
|
|
</code></pre></div>
|
|
<p>In order to use these best trailing stop parameters found by Hyperopt in backtesting and for live trades/dry-run, copy-paste them as the values of the corresponding attributes of your custom strategy:</p>
|
|
<div class="highlight"><pre><span></span><code> <span class="c1"># Trailing stop</span>
|
|
<span class="c1"># These attributes will be overridden if the config file contains corresponding values.</span>
|
|
<span class="n">trailing_stop</span> <span class="o">=</span> <span class="kc">True</span>
|
|
<span class="n">trailing_stop_positive</span> <span class="o">=</span> <span class="mf">0.02001</span>
|
|
<span class="n">trailing_stop_positive_offset</span> <span class="o">=</span> <span class="mf">0.06038</span>
|
|
<span class="n">trailing_only_offset_is_reached</span> <span class="o">=</span> <span class="kc">True</span>
|
|
</code></pre></div>
|
|
<p>As stated in the comment, you can also use it as the values of the corresponding settings in the configuration file.</p>
|
|
<h4 id="default-trailing-stop-search-space">Default Trailing Stop Search Space<a class="headerlink" href="#default-trailing-stop-search-space" title="Permanent link">¶</a></h4>
|
|
<p>If you are optimizing trailing stop values, Freqtrade creates the 'trailing' optimization hyperspace for you. By default, the <code>trailing_stop</code> parameter is always set to True in that hyperspace, the value of the <code>trailing_only_offset_is_reached</code> vary between True and False, the values of the <code>trailing_stop_positive</code> and <code>trailing_stop_positive_offset</code> parameters vary in the ranges 0.02...0.35 and 0.01...0.1 correspondingly, which is sufficient in most cases.</p>
|
|
<p>Override the <code>trailing_space()</code> method and define the desired range in it if you need values of the trailing stop parameters to vary in other ranges during hyperoptimization. A sample for this method can be found in the <a href="../advanced-hyperopt/#overriding-pre-defined-spaces">overriding pre-defined spaces section</a>.</p>
|
|
<div class="admonition note">
|
|
<p class="admonition-title">Reduced search space</p>
|
|
<p>To limit the search space further, Decimals are limited to 3 decimal places (a precision of 0.001). This is usually sufficient, every value more precise than this will usually result in overfitted results. You can however <a href="../advanced-hyperopt/#overriding-pre-defined-spaces">overriding pre-defined spaces</a> to change this to your needs.</p>
|
|
</div>
|
|
<h3 id="reproducible-results">Reproducible results<a class="headerlink" href="#reproducible-results" title="Permanent link">¶</a></h3>
|
|
<p>The search for optimal parameters starts with a few (currently 30) random combinations in the hyperspace of parameters, random Hyperopt epochs. These random epochs are marked with an asterisk character (<code>*</code>) in the first column in the Hyperopt output.</p>
|
|
<p>The initial state for generation of these random values (random state) is controlled by the value of the <code>--random-state</code> command line option. You can set it to some arbitrary value of your choice to obtain reproducible results.</p>
|
|
<p>If you have not set this value explicitly in the command line options, Hyperopt seeds the random state with some random value for you. The random state value for each Hyperopt run is shown in the log, so you can copy and paste it into the <code>--random-state</code> command line option to repeat the set of the initial random epochs used.</p>
|
|
<p>If you have not changed anything in the command line options, configuration, timerange, Strategy and Hyperopt classes, historical data and the Loss Function -- you should obtain same hyper-optimization results with same random state value used.</p>
|
|
<h2 id="output-formatting">Output formatting<a class="headerlink" href="#output-formatting" title="Permanent link">¶</a></h2>
|
|
<p>By default, hyperopt prints colorized results -- epochs with positive profit are printed in the green color. This highlighting helps you find epochs that can be interesting for later analysis. Epochs with zero total profit or with negative profits (losses) are printed in the normal color. If you do not need colorization of results (for instance, when you are redirecting hyperopt output to a file) you can switch colorization off by specifying the <code>--no-color</code> option in the command line.</p>
|
|
<p>You can use the <code>--print-all</code> command line option if you would like to see all results in the hyperopt output, not only the best ones. When <code>--print-all</code> is used, current best results are also colorized by default -- they are printed in bold (bright) style. This can also be switched off with the <code>--no-color</code> command line option.</p>
|
|
<div class="admonition note">
|
|
<p class="admonition-title">Windows and color output</p>
|
|
<p>Windows does not support color-output natively, therefore it is automatically disabled. To have color-output for hyperopt running under windows, please consider using WSL.</p>
|
|
</div>
|
|
<h2 id="position-stacking-and-disabling-max-market-positions">Position stacking and disabling max market positions<a class="headerlink" href="#position-stacking-and-disabling-max-market-positions" title="Permanent link">¶</a></h2>
|
|
<p>In some situations, you may need to run Hyperopt (and Backtesting) with the
|
|
<code>--eps</code>/<code>--enable-position-staking</code> and <code>--dmmp</code>/<code>--disable-max-market-positions</code> arguments.</p>
|
|
<p>By default, hyperopt emulates the behavior of the Freqtrade Live Run/Dry Run, where only one
|
|
open trade is allowed for every traded pair. The total number of trades open for all pairs
|
|
is also limited by the <code>max_open_trades</code> setting. During Hyperopt/Backtesting this may lead to
|
|
some potential trades to be hidden (or masked) by previously open trades.</p>
|
|
<p>The <code>--eps</code>/<code>--enable-position-stacking</code> argument allows emulation of buying the same pair multiple times,
|
|
while <code>--dmmp</code>/<code>--disable-max-market-positions</code> disables applying <code>max_open_trades</code>
|
|
during Hyperopt/Backtesting (which is equal to setting <code>max_open_trades</code> to a very high
|
|
number).</p>
|
|
<div class="admonition note">
|
|
<p class="admonition-title">Note</p>
|
|
<p>Dry/live runs will <strong>NOT</strong> use position stacking - therefore it does make sense to also validate the strategy without this as it's closer to reality.</p>
|
|
</div>
|
|
<p>You can also enable position stacking in the configuration file by explicitly setting
|
|
<code>"position_stacking"=true</code>.</p>
|
|
<h2 id="out-of-memory-errors">Out of Memory errors<a class="headerlink" href="#out-of-memory-errors" title="Permanent link">¶</a></h2>
|
|
<p>As hyperopt consumes a lot of memory (the complete data needs to be in memory once per parallel backtesting process), it's likely that you run into "out of memory" errors.
|
|
To combat these, you have multiple options:</p>
|
|
<ul>
|
|
<li>Reduce the amount of pairs.</li>
|
|
<li>Reduce the timerange used (<code>--timerange <timerange></code>).</li>
|
|
<li>Avoid using <code>--timeframe-detail</code> (this loads a lot of additional data into memory).</li>
|
|
<li>Reduce the number of parallel processes (<code>-j <n></code>).</li>
|
|
<li>Increase the memory of your machine.</li>
|
|
<li>Use <code>--analyze-per-epoch</code> if you're using a lot of parameters with <code>.range</code> functionality.</li>
|
|
</ul>
|
|
<h2 id="the-objective-has-been-evaluated-at-this-point-before">The objective has been evaluated at this point before.<a class="headerlink" href="#the-objective-has-been-evaluated-at-this-point-before" title="Permanent link">¶</a></h2>
|
|
<p>If you see <code>The objective has been evaluated at this point before.</code> - then this is a sign that your space has been exhausted, or is close to that.
|
|
Basically all points in your space have been hit (or a local minima has been hit) - and hyperopt does no longer find points in the multi-dimensional space it did not try yet.
|
|
Freqtrade tries to counter the "local minima" problem by using new, randomized points in this case.</p>
|
|
<p>Example:</p>
|
|
<div class="highlight"><pre><span></span><code><span class="n">buy_ema_short</span> <span class="o">=</span> <span class="n">IntParameter</span><span class="p">(</span><span class="mi">5</span><span class="p">,</span> <span class="mi">20</span><span class="p">,</span> <span class="n">default</span><span class="o">=</span><span class="mi">10</span><span class="p">,</span> <span class="n">space</span><span class="o">=</span><span class="s2">"buy"</span><span class="p">,</span> <span class="n">optimize</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span>
|
|
<span class="c1"># This is the only parameter in the buy space</span>
|
|
</code></pre></div>
|
|
<p>The <code>buy_ema_short</code> space has 15 possible values (<code>5, 6, ... 19, 20</code>). If you now run hyperopt for the buy space, hyperopt will only have 15 values to try before running out of options.
|
|
Your epochs should therefore be aligned to the possible values - or you should be ready to interrupt a run if you norice a lot of <code>The objective has been evaluated at this point before.</code> warnings.</p>
|
|
<h2 id="show-details-of-hyperopt-results">Show details of Hyperopt results<a class="headerlink" href="#show-details-of-hyperopt-results" title="Permanent link">¶</a></h2>
|
|
<p>After you run Hyperopt for the desired amount of epochs, you can later list all results for analysis, select only best or profitable once, and show the details for any of the epochs previously evaluated. This can be done with the <code>hyperopt-list</code> and <code>hyperopt-show</code> sub-commands. The usage of these sub-commands is described in the <a href="../utils/#list-hyperopt-results">Utils</a> chapter.</p>
|
|
<h2 id="validate-backtesting-results">Validate backtesting results<a class="headerlink" href="#validate-backtesting-results" title="Permanent link">¶</a></h2>
|
|
<p>Once the optimized strategy has been implemented into your strategy, you should backtest this strategy to make sure everything is working as expected.</p>
|
|
<p>To achieve same the results (number of trades, their durations, profit, etc.) as during Hyperopt, please use the same configuration and parameters (timerange, timeframe, ...) used for hyperopt <code>--dmmp</code>/<code>--disable-max-market-positions</code> and <code>--eps</code>/<code>--enable-position-stacking</code> for Backtesting.</p>
|
|
<p>Should results not match, please double-check to make sure you transferred all conditions correctly.
|
|
Pay special care to the stoploss, max_open_trades and trailing stoploss parameters, as these are often set in configuration files, which override changes to the strategy.
|
|
You should also carefully review the log of your backtest to ensure that there were no parameters inadvertently set by the configuration (like <code>stoploss</code>, <code>max_open_trades</code> or <code>trailing_stop</code>).</p>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
</article>
|
|
</div>
|
|
|
|
|
|
</div>
|
|
|
|
<button type="button" class="md-top md-icon" data-md-component="top" hidden>
|
|
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M13 20h-2V8l-5.5 5.5-1.42-1.42L12 4.16l7.92 7.92-1.42 1.42L13 8v12Z"/></svg>
|
|
Back to top
|
|
</button>
|
|
|
|
</main>
|
|
|
|
|
|
<footer class="md-footer">
|
|
|
|
|
|
|
|
<nav class="md-footer__inner md-grid" aria-label="Footer" >
|
|
|
|
|
|
<a href="../backtesting/" class="md-footer__link md-footer__link--prev" aria-label="Previous: Backtesting" rel="prev">
|
|
<div class="md-footer__button md-icon">
|
|
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M20 11v2H8l5.5 5.5-1.42 1.42L4.16 12l7.92-7.92L13.5 5.5 8 11h12Z"/></svg>
|
|
</div>
|
|
<div class="md-footer__title">
|
|
<span class="md-footer__direction">
|
|
Previous
|
|
</span>
|
|
<div class="md-ellipsis">
|
|
Backtesting
|
|
</div>
|
|
</div>
|
|
</a>
|
|
|
|
|
|
|
|
<a href="../freqai/" class="md-footer__link md-footer__link--next" aria-label="Next: Introduction" rel="next">
|
|
<div class="md-footer__title">
|
|
<span class="md-footer__direction">
|
|
Next
|
|
</span>
|
|
<div class="md-ellipsis">
|
|
Introduction
|
|
</div>
|
|
</div>
|
|
<div class="md-footer__button md-icon">
|
|
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M4 11v2h12l-5.5 5.5 1.42 1.42L19.84 12l-7.92-7.92L10.5 5.5 16 11H4Z"/></svg>
|
|
</div>
|
|
</a>
|
|
|
|
</nav>
|
|
|
|
|
|
<div class="md-footer-meta md-typeset">
|
|
<div class="md-footer-meta__inner md-grid">
|
|
<div class="md-copyright">
|
|
|
|
|
|
Made with
|
|
<a href="https://squidfunk.github.io/mkdocs-material/" target="_blank" rel="noopener">
|
|
Material for MkDocs
|
|
</a>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
</div>
|
|
</footer>
|
|
|
|
|
|
<!-- Place this tag in your head or just before your close body tag. -->
|
|
<script async defer src="https://buttons.github.io/buttons.js"></script>
|
|
<script src="https://code.jquery.com/jquery-3.4.1.min.js"
|
|
integrity="sha256-CSXorXvZcTkaix6Yvo6HppcZGetbYMGWSFlBw8HfCJo=" crossorigin="anonymous"></script>
|
|
|
|
|
|
</div>
|
|
<div class="md-dialog" data-md-component="dialog">
|
|
<div class="md-dialog__inner md-typeset"></div>
|
|
</div>
|
|
|
|
<script id="__config" type="application/json">{"base": "..", "features": ["content.code.annotate", "search.share", "content.code.copy", "navigation.top", "navigation.footer"], "search": "../assets/javascripts/workers/search.208ed371.min.js", "translations": {"clipboard.copied": "Copied to clipboard", "clipboard.copy": "Copy to clipboard", "search.result.more.one": "1 more on this page", "search.result.more.other": "# more on this page", "search.result.none": "No matching documents", "search.result.one": "1 matching document", "search.result.other": "# matching documents", "search.result.placeholder": "Type to start searching", "search.result.term.missing": "Missing", "select.version": "Select version"}, "version": {"provider": "mike"}}</script>
|
|
|
|
|
|
<script src="../assets/javascripts/bundle.b4d07000.min.js"></script>
|
|
|
|
<script src="../javascripts/config.js"></script>
|
|
|
|
<script src="https://polyfill.io/v3/polyfill.min.js?features=es6"></script>
|
|
|
|
<script src="https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-mml-chtml.js"></script>
|
|
|
|
|
|
</body>
|
|
</html> |