mirror of
https://github.com/freqtrade/freqtrade.git
synced 2024-11-10 18:23:55 +00:00
1724 lines
73 KiB
HTML
1724 lines
73 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/2021.6/hyperopt/">
|
|
|
|
<link rel="icon" href="../images/logo.png">
|
|
<meta name="generator" content="mkdocs-1.2.1, mkdocs-material-7.1.8">
|
|
|
|
|
|
|
|
<title>Hyperopt - Freqtrade</title>
|
|
|
|
|
|
|
|
<link rel="stylesheet" href="../assets/stylesheets/main.ca7ac06f.min.css">
|
|
|
|
|
|
<link rel="stylesheet" href="../assets/stylesheets/palette.f1a3b89f.min.css">
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
|
|
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Roboto:300,400,400i,700%7CRoboto+Mono&display=fallback">
|
|
<style>:root{--md-text-font-family:"Roboto";--md-code-font-family:"Roboto Mono"}</style>
|
|
|
|
|
|
|
|
|
|
<link rel="stylesheet" href="../stylesheets/ft.extra.css">
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
</head>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<body dir="ltr" data-md-color-scheme="default" data-md-color-primary="blue-grey" data-md-color-accent="tear">
|
|
|
|
|
|
<script>function __prefix(e){return new URL("..",location).pathname+"."+e}function __get(e,t=localStorage){return JSON.parse(t.getItem(__prefix(e)))}</script>
|
|
|
|
<script>var palette=__get("__palette");if(null!==palette&&"object"==typeof palette.color)for(var key in 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>
|
|
|
|
<header class="md-header" 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="M7 10a2 2 0 0 1 2 2 2 2 0 0 1-2 2 2 2 0 0 1-2-2 2 2 0 0 1 2-2m10-3a5 5 0 0 1 5 5 5 5 0 0 1-5 5H7a5 5 0 0 1-5-5 5 5 0 0 1 5-5h10M7 9a3 3 0 0 0-3 3 3 3 0 0 0 3 3h10a3 3 0 0 0 3-3 3 3 0 0 0-3-3H7z"/></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 dark mode" type="radio" name="__palette" id="__palette_2">
|
|
|
|
<label class="md-header__button md-icon" title="Switch to dark mode" for="__palette_1" hidden>
|
|
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M7 10a2 2 0 0 1 2 2 2 2 0 0 1-2 2 2 2 0 0 1-2-2 2 2 0 0 1 2-2m10-3a5 5 0 0 1 5 5 5 5 0 0 1-5 5H7a5 5 0 0 1-5-5 5 5 0 0 1 5-5h10M7 9a3 3 0 0 0-3 3 3 3 0 0 0 3 3h10a3 3 0 0 0 3-3 3 3 0 0 0-3-3H7z"/></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" data-md-state="active" 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>
|
|
<button type="reset" class="md-search__icon md-icon" 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>
|
|
</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"></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"><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 id="widget-wrapper">
|
|
|
|
</div>
|
|
<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"><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" data-md-toggle="__nav_3" type="checkbox" id="__nav_3" >
|
|
|
|
<label class="md-nav__link" for="__nav_3">
|
|
Installation
|
|
<span class="md-nav__icon md-icon"></span>
|
|
</label>
|
|
<nav class="md-nav" aria-label="Installation" data-md-level="1">
|
|
<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="../plugins/" class="md-nav__link">
|
|
Plugins
|
|
</a>
|
|
</li>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<li class="md-nav__item">
|
|
<a href="../stoploss/" class="md-nav__link">
|
|
Stoploss
|
|
</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" data-md-toggle="__nav_10" type="checkbox" id="__nav_10" >
|
|
|
|
<label class="md-nav__link" for="__nav_10">
|
|
Control the bot
|
|
<span class="md-nav__icon md-icon"></span>
|
|
</label>
|
|
<nav class="md-nav" aria-label="Control the bot" data-md-level="1">
|
|
<label class="md-nav__title" for="__nav_10">
|
|
<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" data-md-toggle="toc" 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>
|
|
|
|
</ul>
|
|
</nav>
|
|
|
|
</li>
|
|
|
|
</ul>
|
|
|
|
</nav>
|
|
|
|
</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 md-nav__item--nested">
|
|
|
|
|
|
<input class="md-nav__toggle md-toggle" data-md-toggle="__nav_16" type="checkbox" id="__nav_16" >
|
|
|
|
<label class="md-nav__link" for="__nav_16">
|
|
Data Analysis
|
|
<span class="md-nav__icon md-icon"></span>
|
|
</label>
|
|
<nav class="md-nav" aria-label="Data Analysis" data-md-level="1">
|
|
<label class="md-nav__title" for="__nav_16">
|
|
<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>
|
|
|
|
|
|
|
|
</ul>
|
|
</nav>
|
|
</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" data-md-toggle="__nav_18" type="checkbox" id="__nav_18" >
|
|
|
|
<label class="md-nav__link" for="__nav_18">
|
|
Advanced Topics
|
|
<span class="md-nav__icon md-icon"></span>
|
|
</label>
|
|
<nav class="md-nav" aria-label="Advanced Topics" data-md-level="1">
|
|
<label class="md-nav__title" for="__nav_18">
|
|
<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="../edge/" class="md-nav__link">
|
|
Edge Positioning
|
|
</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="../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="../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>
|
|
|
|
</ul>
|
|
</nav>
|
|
|
|
</li>
|
|
|
|
</ul>
|
|
|
|
</nav>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
|
|
<div class="md-content" data-md-component="content">
|
|
<article class="md-content__inner md-typeset">
|
|
|
|
|
|
<a href="https://github.com/freqtrade/freqtrade/edit/master/docs/hyperopt.md" title="Edit this page" class="md-content__button md-icon">
|
|
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M20.71 7.04c.39-.39.39-1.04 0-1.41l-2.34-2.34c-.37-.39-1.02-.39-1.41 0l-1.84 1.83 3.75 3.75M3 17.25V21h3.75L17.81 9.93l-3.75-3.75L3 17.25z"/></svg>
|
|
</a>
|
|
|
|
|
|
<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>
|
|
<p><code>bash
|
|
source .env/bin/activate
|
|
pip install -r requirements-hyperopt.txt</code></p>
|
|
<h2 id="hyperopt-command-reference">Hyperopt command reference<a class="headerlink" href="#hyperopt-command-reference" title="Permanent link">¶</a></h2>
|
|
<p>```
|
|
usage: freqtrade hyperopt [-h] [-v] [--logfile FILE] [-V] [-c PATH] [-d PATH]
|
|
[--userdir PATH] [-s NAME] [--strategy-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 NAME]
|
|
[--hyperopt-path PATH] [--eps] [--dmmp]
|
|
[--enable-protections]
|
|
[--dry-run-wallet DRY_RUN_WALLET] [-e INT]
|
|
[--spaces {all,buy,sell,roi,stoploss,trailing,default} [{all,buy,sell,roi,stoploss,trailing,default} ...]]
|
|
[--print-all] [--no-color] [--print-json] [-j JOBS]
|
|
[--random-state INT] [--min-trades INT]
|
|
[--hyperopt-loss NAME]</p>
|
|
<p>optional arguments:
|
|
-h, --help show this help message and exit
|
|
-i TIMEFRAME, --timeframe TIMEFRAME, --ticker-interval TIMEFRAME
|
|
Specify timeframe (<code>1m</code>, <code>5m</code>, <code>30m</code>, <code>1h</code>, <code>1d</code>).
|
|
--timerange TIMERANGE
|
|
Specify what timerange of data to use.
|
|
--data-format-ohlcv {json,jsongz,hdf5}
|
|
Storage format for downloaded candle (OHLCV) data.
|
|
(default: <code>None</code>).
|
|
--max-open-trades INT
|
|
Override the value of the <code>max_open_trades</code>
|
|
configuration setting.
|
|
--stake-amount STAKE_AMOUNT
|
|
Override the value of the <code>stake_amount</code> 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 NAME Specify hyperopt class name which will be used by the
|
|
bot.
|
|
--hyperopt-path PATH Specify additional lookup path for Hyperopt and
|
|
Hyperopt Loss functions.
|
|
--eps, --enable-position-stacking
|
|
Allow buying the same pair multiple times (position
|
|
stacking).
|
|
--dmmp, --disable-max-market-positions
|
|
Disable applying <code>max_open_trades</code> during backtest
|
|
(same as setting <code>max_open_trades</code> 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.
|
|
-e INT, --epochs INT Specify number of epochs (default: 100).
|
|
--spaces {all,buy,sell,roi,stoploss,trailing,default} [{all,buy,sell,roi,stoploss,trailing,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</p>
|
|
<p>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:
|
|
<code>userdir/config.json</code> or <code>config.json</code> whichever
|
|
exists). Multiple --config options may be used. Can be
|
|
set to <code>-</code> 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.</p>
|
|
<p>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.</p>
|
|
<p>```</p>
|
|
<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 buy signal optimization</li>
|
|
<li>define parameters with <code>space='sell'</code> - for sell 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>
|
|
</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>
|
|
<p>``` bash</p>
|
|
<h1 id="have-a-working-strategy-at-hand">Have a working strategy at hand.<a class="headerlink" href="#have-a-working-strategy-at-hand" title="Permanent link">¶</a></h1>
|
|
<p>freqtrade hyperopt --hyperopt-loss SharpeHyperOptLossDaily --spaces roi stoploss trailing --strategy MyWorkingStrategy --config config.json -e 100
|
|
```</p>
|
|
</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.</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_buy_trend()</code> followed by <code>populate_sell_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_buy_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 buying 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="sell-optimization">Sell optimization<a class="headerlink" href="#sell-optimization" title="Permanent link">¶</a></h4>
|
|
<p>Similar to the buy-signal above, sell-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_sell_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 buys.
|
|
And you also wonder should you use RSI or ADX to help with those buy 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>
|
|
<p>``` python
|
|
class MyAwesomeStrategy(IStrategy):</p>
|
|
<div class="codehilite"><pre><span></span><code>def populate_indicators(self, dataframe: DataFrame, metadata: dict) -> DataFrame:
|
|
"""
|
|
Generate all indicators used by the strategy
|
|
"""
|
|
dataframe['adx'] = ta.ADX(dataframe)
|
|
dataframe['rsi'] = ta.RSI(dataframe)
|
|
macd = ta.MACD(dataframe)
|
|
dataframe['macd'] = macd['macd']
|
|
dataframe['macdsignal'] = macd['macdsignal']
|
|
dataframe['macdhist'] = macd['macdhist']
|
|
|
|
bollinger = ta.BBANDS(dataframe, timeperiod=20, nbdevup=2.0, nbdevdn=2.0)
|
|
dataframe['bb_lowerband'] = bollinger['lowerband']
|
|
dataframe['bb_middleband'] = bollinger['middleband']
|
|
dataframe['bb_upperband'] = bollinger['upperband']
|
|
return dataframe
|
|
</code></pre></div>
|
|
|
|
<p>```</p>
|
|
<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>
|
|
<p><code>python
|
|
class MyAwesomeStrategy(IStrategy):
|
|
buy_adx = DecimalParameter(20, 40, decimals=1, default=30.1, space="buy")
|
|
buy_rsi = IntParameter(20, 40, default=30, space="buy")
|
|
buy_adx_enabled = CategoricalParameter([True, False], default=True, space="buy")
|
|
buy_rsi_enabled = CategoricalParameter([True, False], default=False, space="buy")
|
|
buy_trigger = CategoricalParameter(["bb_lower", "macd_cross_signal"], default="bb_lower", space="buy")</code></p>
|
|
<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.</p>
|
|
</div>
|
|
<p>So let's write the buy strategy using these values:</p>
|
|
<p>```python
|
|
def populate_buy_trend(self, dataframe: DataFrame, metadata: dict) -> DataFrame:
|
|
conditions = []
|
|
# GUARDS AND TRENDS
|
|
if self.buy_adx_enabled.value:
|
|
conditions.append(dataframe['adx'] > self.buy_adx.value)
|
|
if self.buy_rsi_enabled.value:
|
|
conditions.append(dataframe['rsi'] < self.buy_rsi.value)</p>
|
|
<div class="codehilite"><pre><span></span><code> # TRIGGERS
|
|
if self.buy_trigger.value == 'bb_lower':
|
|
conditions.append(dataframe['close'] < dataframe['bb_lowerband'])
|
|
if self.buy_trigger.value == 'macd_cross_signal':
|
|
conditions.append(qtpylib.crossed_above(
|
|
dataframe['macd'], dataframe['macdsignal']
|
|
))
|
|
|
|
# Check that volume is not 0
|
|
conditions.append(dataframe['volume'] > 0)
|
|
|
|
if conditions:
|
|
dataframe.loc[
|
|
reduce(lambda x, y: x & y, conditions),
|
|
'buy'] = 1
|
|
|
|
return dataframe
|
|
</code></pre></div>
|
|
|
|
<p>```</p>
|
|
<p>Hyperopt will now call <code>populate_buy_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>
|
|
</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>
|
|
<h3 id="optimizing-an-indicator-parameter">Optimizing an indicator parameter<a class="headerlink" href="#optimizing-an-indicator-parameter" title="Permanent link">¶</a></h3>
|
|
<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.</p>
|
|
<p>``` python
|
|
from pandas import DataFrame
|
|
from functools import reduce</p>
|
|
<p>import talib.abstract as ta</p>
|
|
<p>from freqtrade.strategy import IStrategy
|
|
from freqtrade.strategy import CategoricalParameter, DecimalParameter, IntParameter
|
|
import freqtrade.vendor.qtpylib.indicators as qtpylib</p>
|
|
<p>class MyAwesomeStrategy(IStrategy):
|
|
stoploss = -0.05
|
|
timeframe = '15m'
|
|
# Define the parameter spaces
|
|
buy_ema_short = IntParameter(3, 50, default=5)
|
|
buy_ema_long = IntParameter(15, 200, default=50)</p>
|
|
<div class="codehilite"><pre><span></span><code>def populate_indicators(self, dataframe: DataFrame, metadata: dict) -> DataFrame:
|
|
"""Generate all indicators used by the strategy"""
|
|
|
|
# Calculate all ema_short values
|
|
for val in self.buy_ema_short.range:
|
|
dataframe[f'ema_short_{val}'] = ta.EMA(dataframe, timeperiod=val)
|
|
|
|
# Calculate all ema_long values
|
|
for val in self.buy_ema_long.range:
|
|
dataframe[f'ema_long_{val}'] = ta.EMA(dataframe, timeperiod=val)
|
|
|
|
return dataframe
|
|
|
|
def populate_buy_trend(self, dataframe: DataFrame, metadata: dict) -> DataFrame:
|
|
conditions = []
|
|
conditions.append(qtpylib.crossed_above(
|
|
dataframe[f'ema_short_{self.buy_ema_short.value}'], dataframe[f'ema_long_{self.buy_ema_long.value}']
|
|
))
|
|
|
|
# Check that volume is not 0
|
|
conditions.append(dataframe['volume'] > 0)
|
|
|
|
if conditions:
|
|
dataframe.loc[
|
|
reduce(lambda x, y: x & y, conditions),
|
|
'buy'] = 1
|
|
return dataframe
|
|
|
|
def populate_sell_trend(self, dataframe: DataFrame, metadata: dict) -> DataFrame:
|
|
conditions = []
|
|
conditions.append(qtpylib.crossed_above(
|
|
dataframe[f'ema_long_{self.buy_ema_long.value}'], dataframe[f'ema_short_{self.buy_ema_short.value}']
|
|
))
|
|
|
|
# Check that volume is not 0
|
|
conditions.append(dataframe['volume'] > 0)
|
|
|
|
if conditions:
|
|
dataframe.loc[
|
|
reduce(lambda x, y: x & y, conditions),
|
|
'sell'] = 1
|
|
return dataframe
|
|
</code></pre></div>
|
|
|
|
<p>```</p>
|
|
<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>
|
|
<details class="hint">
|
|
<summary>Performance tip</summary>
|
|
<p>By doing the calculation of all possible indicators in <code>populate_indicators()</code>, the calculation of the indicator happens only once for every parameter.<br />
|
|
While this may slow down the hyperopt startup speed, the overall performance will increase as the Hyperopt execution itself may pick the same value for multiple epochs (changing other values).
|
|
You should however try to use space ranges as small as possible. Every new column will require more memory, and every possibility hyperopt can try will increase the search space.</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> (which 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>
|
|
</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>
|
|
<p><code>bash
|
|
freqtrade hyperopt --config config.json --hyperopt-loss <hyperoptlossname> --strategy <strategyname> -e 500 --spaces all</code></p>
|
|
<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>
|
|
<p><code>bash
|
|
freqtrade hyperopt --hyperopt <hyperoptname> --strategy <strategyname> --timerange 20210101-20210201</code></p>
|
|
<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>default</code>: <code>all</code> except <code>trailing</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>
|
|
<p>```
|
|
Best result:</p>
|
|
<div class="codehilite"><pre><span></span><code>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>```</p>
|
|
<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>
|
|
<p>Your strategy class can immediately take advantage of these results. 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>
|
|
<p><code>python
|
|
class MyAwesomeStrategy(IStrategy):
|
|
# Buy hyperspace params:
|
|
buy_params = {
|
|
'buy_adx': 44,
|
|
'buy_rsi': 29,
|
|
'buy_adx_enabled': False,
|
|
'buy_rsi_enabled': True,
|
|
'buy_trigger': 'bb_lower'
|
|
}</code></p>
|
|
<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>
|
|
<p>```
|
|
Best result:</p>
|
|
<div class="codehilite"><pre><span></span><code>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>```</p>
|
|
<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>
|
|
<p><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></p>
|
|
<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 file, 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 <a href="https://github.com/freqtrade/freqtrade/blob/develop/freqtrade/templates/sample_hyperopt_advanced.py">sample_hyperopt_advanced.py</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>
|
|
<p>```
|
|
Best result:</p>
|
|
<div class="codehilite"><pre><span></span><code>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>```</p>
|
|
<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>
|
|
<p><code>python
|
|
# Optimal stoploss designed for the strategy
|
|
# This attribute will be overridden if the config file contains "stoploss"
|
|
stoploss = -0.27996</code></p>
|
|
<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 <a href="https://github.com/freqtrade/freqtrade/blob/develop/freqtrade/templates/sample_hyperopt_advanced.py">user_data/hyperopts/sample_hyperopt_advanced.py</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>
|
|
<p>```
|
|
Best result:</p>
|
|
<div class="codehilite"><pre><span></span><code>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>```</p>
|
|
<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>
|
|
<p><code>python
|
|
# Trailing stop
|
|
# These attributes will be overridden if the config file contains corresponding values.
|
|
trailing_stop = True
|
|
trailing_stop_positive = 0.02001
|
|
trailing_stop_positive_offset = 0.06038
|
|
trailing_only_offset_is_reached = True</code></p>
|
|
<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 <a href="https://github.com/freqtrade/freqtrade/blob/develop/freqtrade/templates/sample_hyperopt_advanced.py">user_data/hyperopts/sample_hyperopt_advanced.py</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="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>reduce the number of parallel processes (<code>-j <n></code>)</li>
|
|
<li>Increase the memory of your machine</li>
|
|
</ul>
|
|
<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 results (number of trades, their durations, profit, etc.) than during Hyperopt, please use 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 don't match, please double-check to make sure you transferred all conditions correctly.
|
|
Pay special care to the stoploss (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> or <code>trailing_stop</code>).</p>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
</article>
|
|
</div>
|
|
</div>
|
|
|
|
</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">
|
|
<div class="md-ellipsis">
|
|
<span class="md-footer__direction">
|
|
Previous
|
|
</span>
|
|
Backtesting
|
|
</div>
|
|
</div>
|
|
</a>
|
|
|
|
|
|
|
|
<a href="../utils/" class="md-footer__link md-footer__link--next" aria-label="Next: Utility Sub-commands" rel="next">
|
|
<div class="md-footer__title">
|
|
<div class="md-ellipsis">
|
|
<span class="md-footer__direction">
|
|
Next
|
|
</span>
|
|
Utility Sub-commands
|
|
</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-footer-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>
|
|
|
|
<!-- Load binance SDK -->
|
|
<script async defer src="https://public.bnbstatic.com/static/js/broker-sdk/broker-sdk@1.0.0.min.js"></script>
|
|
|
|
<script>
|
|
window.onload = function () {
|
|
var sidebar = document.getElementById('widget-wrapper')
|
|
var newDiv = document.createElement("div");
|
|
newDiv.id = "widget";
|
|
try {
|
|
sidebar.prepend(newDiv);
|
|
|
|
window.binanceBrokerPortalSdk.initBrokerSDK('#widget', {
|
|
apiHost: 'https://www.binance.com',
|
|
brokerId: 'R4BD3S82',
|
|
slideTime: 4e4,
|
|
});
|
|
} catch(err) {
|
|
console.log(err)
|
|
}
|
|
}
|
|
</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": [], "translations": {"clipboard.copy": "Copy to clipboard", "clipboard.copied": "Copied to clipboard", "search.config.lang": "en", "search.config.pipeline": "trimmer, stopWordFilter", "search.config.separator": "[\\s\\-]+", "search.placeholder": "Search", "search.result.placeholder": "Type to start searching", "search.result.none": "No matching documents", "search.result.one": "1 matching document", "search.result.other": "# matching documents", "search.result.more.one": "1 more on this page", "search.result.more.other": "# more on this page", "search.result.term.missing": "Missing", "select.version.title": "Select version"}, "search": "../assets/javascripts/workers/search.b0710199.min.js", "version": {"provider": "mike"}}</script>
|
|
|
|
|
|
<script src="../assets/javascripts/bundle.76f349be.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> |