freqtrade_origin/en/2019.7/developer/index.html

1255 lines
36 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="prev" href="../sandbox-testing/">
<link rel="icon" href="../assets/images/favicon.png">
<meta name="generator" content="mkdocs-1.6.0, mkdocs-material-9.5.30">
<title>Contributors guide - Freqtrade</title>
<link rel="stylesheet" href="../assets/stylesheets/main.3cba04c6.min.css">
<link rel="stylesheet" href="../assets/stylesheets/palette.06af60db.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>
<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">
<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="#development-help" 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">
Contributors guide
</span>
</div>
</div>
</div>
<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">
<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" tabindex="0" 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>
</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">
<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>
<ul class="md-nav__list" data-md-scrollfix>
<li class="md-nav__item">
<a href=".." class="md-nav__link">
<span class="md-ellipsis">
About
</span>
</a>
</li>
<li class="md-nav__item">
<a href="../installation/" class="md-nav__link">
<span class="md-ellipsis">
Installation
</span>
</a>
</li>
<li class="md-nav__item">
<a href="../docker/" class="md-nav__link">
<span class="md-ellipsis">
Installation Docker
</span>
</a>
</li>
<li class="md-nav__item">
<a href="../configuration/" class="md-nav__link">
<span class="md-ellipsis">
Configuration
</span>
</a>
</li>
<li class="md-nav__item">
<a href="../strategy-customization/" class="md-nav__link">
<span class="md-ellipsis">
Strategy Customization
</span>
</a>
</li>
<li class="md-nav__item">
<a href="../stoploss/" class="md-nav__link">
<span class="md-ellipsis">
Stoploss
</span>
</a>
</li>
<li class="md-nav__item">
<a href="../bot-usage/" class="md-nav__link">
<span class="md-ellipsis">
Start the bot
</span>
</a>
</li>
<li class="md-nav__item md-nav__item--nested">
<input class="md-nav__toggle md-toggle " type="checkbox" id="__nav_8" >
<label class="md-nav__link" for="__nav_8" id="__nav_8_label" tabindex="0">
<span class="md-ellipsis">
Control the bot
</span>
<span class="md-nav__icon md-icon"></span>
</label>
<nav class="md-nav" data-md-level="1" aria-labelledby="__nav_8_label" aria-expanded="false">
<label class="md-nav__title" for="__nav_8">
<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">
<span class="md-ellipsis">
Telegram
</span>
</a>
</li>
<li class="md-nav__item">
<a href="../webhook-config/" class="md-nav__link">
<span class="md-ellipsis">
Web Hook
</span>
</a>
</li>
<li class="md-nav__item">
<a href="../rest-api/" class="md-nav__link">
<span class="md-ellipsis">
REST API
</span>
</a>
</li>
</ul>
</nav>
</li>
<li class="md-nav__item">
<a href="../backtesting/" class="md-nav__link">
<span class="md-ellipsis">
Backtesting
</span>
</a>
</li>
<li class="md-nav__item">
<a href="../hyperopt/" class="md-nav__link">
<span class="md-ellipsis">
Hyperopt
</span>
</a>
</li>
<li class="md-nav__item">
<a href="../edge/" class="md-nav__link">
<span class="md-ellipsis">
Edge positioning
</span>
</a>
</li>
<li class="md-nav__item">
<a href="../plotting/" class="md-nav__link">
<span class="md-ellipsis">
Plotting
</span>
</a>
</li>
<li class="md-nav__item">
<a href="../deprecated/" class="md-nav__link">
<span class="md-ellipsis">
Deprecated features
</span>
</a>
</li>
<li class="md-nav__item">
<a href="../faq/" class="md-nav__link">
<span class="md-ellipsis">
FAQ
</span>
</a>
</li>
<li class="md-nav__item">
<a href="../data-analysis/" class="md-nav__link">
<span class="md-ellipsis">
Data Analysis
</span>
</a>
</li>
<li class="md-nav__item">
<a href="../sql_cheatsheet/" class="md-nav__link">
<span class="md-ellipsis">
SQL Cheatsheet
</span>
</a>
</li>
<li class="md-nav__item">
<a href="../sandbox-testing/" class="md-nav__link">
<span class="md-ellipsis">
Sandbox testing
</span>
</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">
<span class="md-ellipsis">
Contributors guide
</span>
<span class="md-nav__icon md-icon"></span>
</label>
<a href="./" class="md-nav__link md-nav__link--active">
<span class="md-ellipsis">
Contributors guide
</span>
</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="#documentation" class="md-nav__link">
<span class="md-ellipsis">
Documentation
</span>
</a>
</li>
<li class="md-nav__item">
<a href="#developer-setup" class="md-nav__link">
<span class="md-ellipsis">
Developer setup
</span>
</a>
</li>
<li class="md-nav__item">
<a href="#modules" class="md-nav__link">
<span class="md-ellipsis">
Modules
</span>
</a>
<nav class="md-nav" aria-label="Modules">
<ul class="md-nav__list">
<li class="md-nav__item">
<a href="#dynamic-pairlist" class="md-nav__link">
<span class="md-ellipsis">
Dynamic Pairlist
</span>
</a>
<nav class="md-nav" aria-label="Dynamic Pairlist">
<ul class="md-nav__list">
<li class="md-nav__item">
<a href="#configuration" class="md-nav__link">
<span class="md-ellipsis">
configuration
</span>
</a>
</li>
<li class="md-nav__item">
<a href="#short_desc" class="md-nav__link">
<span class="md-ellipsis">
short_desc
</span>
</a>
</li>
<li class="md-nav__item">
<a href="#refresh_pairlist" class="md-nav__link">
<span class="md-ellipsis">
refresh_pairlist
</span>
</a>
<nav class="md-nav" aria-label="refresh_pairlist">
<ul class="md-nav__list">
<li class="md-nav__item">
<a href="#sample" class="md-nav__link">
<span class="md-ellipsis">
sample
</span>
</a>
</li>
</ul>
</nav>
</li>
<li class="md-nav__item">
<a href="#_gen_pair_whitelist" class="md-nav__link">
<span class="md-ellipsis">
_gen_pair_whitelist
</span>
</a>
</li>
</ul>
</nav>
</li>
</ul>
</nav>
</li>
<li class="md-nav__item">
<a href="#implement-a-new-exchange-wip" class="md-nav__link">
<span class="md-ellipsis">
Implement a new Exchange (WIP)
</span>
</a>
<nav class="md-nav" aria-label="Implement a new Exchange (WIP)">
<ul class="md-nav__list">
<li class="md-nav__item">
<a href="#stoploss-on-exchange" class="md-nav__link">
<span class="md-ellipsis">
Stoploss On Exchange
</span>
</a>
</li>
<li class="md-nav__item">
<a href="#incomplete-candles" class="md-nav__link">
<span class="md-ellipsis">
Incomplete candles
</span>
</a>
</li>
</ul>
</nav>
</li>
<li class="md-nav__item">
<a href="#creating-a-release" class="md-nav__link">
<span class="md-ellipsis">
Creating a release
</span>
</a>
<nav class="md-nav" aria-label="Creating a release">
<ul class="md-nav__list">
<li class="md-nav__item">
<a href="#create-release-branch" class="md-nav__link">
<span class="md-ellipsis">
Create release branch
</span>
</a>
</li>
<li class="md-nav__item">
<a href="#create-changelog-from-git-commits" class="md-nav__link">
<span class="md-ellipsis">
Create changelog from git commits
</span>
</a>
</li>
<li class="md-nav__item">
<a href="#create-github-release-tag" class="md-nav__link">
<span class="md-ellipsis">
Create github release / tag
</span>
</a>
</li>
<li class="md-nav__item">
<a href="#after-release" class="md-nav__link">
<span class="md-ellipsis">
After-release
</span>
</a>
</li>
</ul>
</nav>
</li>
</ul>
</nav>
</li>
</ul>
</nav>
</div>
</div>
</div>
<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="#documentation" class="md-nav__link">
<span class="md-ellipsis">
Documentation
</span>
</a>
</li>
<li class="md-nav__item">
<a href="#developer-setup" class="md-nav__link">
<span class="md-ellipsis">
Developer setup
</span>
</a>
</li>
<li class="md-nav__item">
<a href="#modules" class="md-nav__link">
<span class="md-ellipsis">
Modules
</span>
</a>
<nav class="md-nav" aria-label="Modules">
<ul class="md-nav__list">
<li class="md-nav__item">
<a href="#dynamic-pairlist" class="md-nav__link">
<span class="md-ellipsis">
Dynamic Pairlist
</span>
</a>
<nav class="md-nav" aria-label="Dynamic Pairlist">
<ul class="md-nav__list">
<li class="md-nav__item">
<a href="#configuration" class="md-nav__link">
<span class="md-ellipsis">
configuration
</span>
</a>
</li>
<li class="md-nav__item">
<a href="#short_desc" class="md-nav__link">
<span class="md-ellipsis">
short_desc
</span>
</a>
</li>
<li class="md-nav__item">
<a href="#refresh_pairlist" class="md-nav__link">
<span class="md-ellipsis">
refresh_pairlist
</span>
</a>
<nav class="md-nav" aria-label="refresh_pairlist">
<ul class="md-nav__list">
<li class="md-nav__item">
<a href="#sample" class="md-nav__link">
<span class="md-ellipsis">
sample
</span>
</a>
</li>
</ul>
</nav>
</li>
<li class="md-nav__item">
<a href="#_gen_pair_whitelist" class="md-nav__link">
<span class="md-ellipsis">
_gen_pair_whitelist
</span>
</a>
</li>
</ul>
</nav>
</li>
</ul>
</nav>
</li>
<li class="md-nav__item">
<a href="#implement-a-new-exchange-wip" class="md-nav__link">
<span class="md-ellipsis">
Implement a new Exchange (WIP)
</span>
</a>
<nav class="md-nav" aria-label="Implement a new Exchange (WIP)">
<ul class="md-nav__list">
<li class="md-nav__item">
<a href="#stoploss-on-exchange" class="md-nav__link">
<span class="md-ellipsis">
Stoploss On Exchange
</span>
</a>
</li>
<li class="md-nav__item">
<a href="#incomplete-candles" class="md-nav__link">
<span class="md-ellipsis">
Incomplete candles
</span>
</a>
</li>
</ul>
</nav>
</li>
<li class="md-nav__item">
<a href="#creating-a-release" class="md-nav__link">
<span class="md-ellipsis">
Creating a release
</span>
</a>
<nav class="md-nav" aria-label="Creating a release">
<ul class="md-nav__list">
<li class="md-nav__item">
<a href="#create-release-branch" class="md-nav__link">
<span class="md-ellipsis">
Create release branch
</span>
</a>
</li>
<li class="md-nav__item">
<a href="#create-changelog-from-git-commits" class="md-nav__link">
<span class="md-ellipsis">
Create changelog from git commits
</span>
</a>
</li>
<li class="md-nav__item">
<a href="#create-github-release-tag" class="md-nav__link">
<span class="md-ellipsis">
Create github release / tag
</span>
</a>
</li>
<li class="md-nav__item">
<a href="#after-release" class="md-nav__link">
<span class="md-ellipsis">
After-release
</span>
</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">
<h1 id="development-help">Development Help<a class="headerlink" href="#development-help" title="Permanent link">&para;</a></h1>
<p>This page is intended for developers of FreqTrade, people who want to contribute to the FreqTrade codebase or documentation, or people who want to understand the source code of the application they're running.</p>
<p>All contributions, bug reports, bug fixes, documentation improvements, enhancements and ideas are welcome. We <a href="https://github.com/freqtrade/freqtrade/issues">track issues</a> on <a href="https://github.com">GitHub</a> and also have a dev channel in <a href="https://join.slack.com/t/highfrequencybot/shared_invite/enQtNjU5ODcwNjI1MDU3LWEyODBiNzkzNzcyNzU0MWYyYzE5NjIyOTQxMzBmMGUxOTIzM2YyN2Y4NWY1YTEwZDgwYTRmMzE2NmM5ZmY2MTg">slack</a> where you can ask questions.</p>
<h2 id="documentation">Documentation<a class="headerlink" href="#documentation" title="Permanent link">&para;</a></h2>
<p>Documentation is available at <a href="https://www.freqtrade.io/">https://freqtrade.io</a> and needs to be provided with every new feature PR.</p>
<p>Special fields for the documentation (like Note boxes, ...) can be found <a href="https://squidfunk.github.io/mkdocs-material/extensions/admonition/">here</a>.</p>
<h2 id="developer-setup">Developer setup<a class="headerlink" href="#developer-setup" title="Permanent link">&para;</a></h2>
<p>To configure a development environment, use best use the <code>setup.sh</code> script and answer "y" when asked "Do you want to install dependencies for dev [y/N]? ".
Alternatively (if your system is not supported by the setup.sh script), follow the manual installation process and run <code>pip3 install -r requirements-dev.txt</code>.</p>
<p>This will install all required tools for development, including <code>pytest</code>, <code>flake8</code>, <code>mypy</code>, and <code>coveralls</code>.</p>
<h2 id="modules">Modules<a class="headerlink" href="#modules" title="Permanent link">&para;</a></h2>
<h3 id="dynamic-pairlist">Dynamic Pairlist<a class="headerlink" href="#dynamic-pairlist" title="Permanent link">&para;</a></h3>
<p>You have a great idea for a new pair selection algorithm you would like to try out? Great.
Hopefully you also want to contribute this back upstream.</p>
<p>Whatever your motivations are - This should get you off the ground in trying to develop a new Pairlist provider.</p>
<p>First of all, have a look at the <a href="https://github.com/freqtrade/freqtrade/blob/develop/freqtrade/pairlist/VolumePairList.py">VolumePairList</a> provider, and best copy this file with a name of your new Pairlist Provider.</p>
<p>This is a simple provider, which however serves as a good example on how to start developing.</p>
<p>Next, modify the classname of the provider (ideally align this with the Filename).</p>
<p>The base-class provides the an instance of the bot (<code>self._freqtrade</code>), as well as the configuration (<code>self._config</code>), and initiates both <code>_blacklist</code> and <code>_whitelist</code>.</p>
<div class="highlight"><pre><span></span><code> <span class="bp">self</span><span class="o">.</span><span class="n">_freqtrade</span> <span class="o">=</span> <span class="n">freqtrade</span>
<span class="bp">self</span><span class="o">.</span><span class="n">_config</span> <span class="o">=</span> <span class="n">config</span>
<span class="bp">self</span><span class="o">.</span><span class="n">_whitelist</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_config</span><span class="p">[</span><span class="s1">&#39;exchange&#39;</span><span class="p">][</span><span class="s1">&#39;pair_whitelist&#39;</span><span class="p">]</span>
<span class="bp">self</span><span class="o">.</span><span class="n">_blacklist</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_config</span><span class="p">[</span><span class="s1">&#39;exchange&#39;</span><span class="p">]</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">&#39;pair_blacklist&#39;</span><span class="p">,</span> <span class="p">[])</span>
</code></pre></div>
<p>Now, let's step through the methods which require actions:</p>
<h4 id="configuration">configuration<a class="headerlink" href="#configuration" title="Permanent link">&para;</a></h4>
<p>Configuration for PairListProvider is done in the bot configuration file in the element <code>"pairlist"</code>.
This Pairlist-object may contain a <code>"config"</code> dict with additional configurations for the configured pairlist.
By convention, <code>"number_assets"</code> is used to specify the maximum number of pairs to keep in the whitelist. Please follow this to ensure a consistent user experience.</p>
<p>Additional elements can be configured as needed. <code>VolumePairList</code> uses <code>"sort_key"</code> to specify the sorting value - however feel free to specify whatever is necessary for your great algorithm to be successfull and dynamic.</p>
<h4 id="short_desc">short_desc<a class="headerlink" href="#short_desc" title="Permanent link">&para;</a></h4>
<p>Returns a description used for Telegram messages.
This should contain the name of the Provider, as well as a short description containing the number of assets. Please follow the format <code>"PairlistName - top/bottom X pairs"</code>.</p>
<h4 id="refresh_pairlist">refresh_pairlist<a class="headerlink" href="#refresh_pairlist" title="Permanent link">&para;</a></h4>
<p>Override this method and run all calculations needed in this method.
This is called with each iteration of the bot - so consider implementing caching for compute/network heavy calculations.</p>
<p>Assign the resulting whiteslist to <code>self._whitelist</code> and <code>self._blacklist</code> respectively. These will then be used to run the bot in this iteration. Pairs with open trades will be added to the whitelist to have the sell-methods run correctly.</p>
<p>Please also run <code>self._validate_whitelist(pairs)</code> and to check and remove pairs with inactive markets. This function is available in the Parent class (<code>StaticPairList</code>) and should ideally not be overwritten.</p>
<h5 id="sample">sample<a class="headerlink" href="#sample" title="Permanent link">&para;</a></h5>
<div class="highlight"><pre><span></span><code> <span class="k">def</span> <span class="nf">refresh_pairlist</span><span class="p">(</span><span class="bp">self</span><span class="p">)</span> <span class="o">-&gt;</span> <span class="kc">None</span><span class="p">:</span>
<span class="c1"># Generate dynamic whitelist</span>
<span class="n">pairs</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_gen_pair_whitelist</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_config</span><span class="p">[</span><span class="s1">&#39;stake_currency&#39;</span><span class="p">],</span> <span class="bp">self</span><span class="o">.</span><span class="n">_sort_key</span><span class="p">)</span>
<span class="c1"># Validate whitelist to only have active market pairs</span>
<span class="bp">self</span><span class="o">.</span><span class="n">_whitelist</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_validate_whitelist</span><span class="p">(</span><span class="n">pairs</span><span class="p">)[:</span><span class="bp">self</span><span class="o">.</span><span class="n">_number_pairs</span><span class="p">]</span>
</code></pre></div>
<h4 id="_gen_pair_whitelist">_gen_pair_whitelist<a class="headerlink" href="#_gen_pair_whitelist" title="Permanent link">&para;</a></h4>
<p>This is a simple method used by <code>VolumePairList</code> - however serves as a good example.
It implements caching (<code>@cached(TTLCache(maxsize=1, ttl=1800))</code>) as well as a configuration option to allow different (but similar) strategies to work with the same PairListProvider.</p>
<h2 id="implement-a-new-exchange-wip">Implement a new Exchange (WIP)<a class="headerlink" href="#implement-a-new-exchange-wip" title="Permanent link">&para;</a></h2>
<div class="admonition note">
<p class="admonition-title">Note</p>
<p>This section is a Work in Progress and is not a complete guide on how to test a new exchange with FreqTrade.</p>
</div>
<p>Most exchanges supported by CCXT should work out of the box.</p>
<h3 id="stoploss-on-exchange">Stoploss On Exchange<a class="headerlink" href="#stoploss-on-exchange" title="Permanent link">&para;</a></h3>
<p>Check if the new exchange supports Stoploss on Exchange orders through their API.</p>
<p>Since CCXT does not provide unification for Stoploss On Exchange yet, we'll need to implement the exchange-specific parameters ourselfs. Best look at <code>binance.py</code> for an example implementation of this. You'll need to dig through the documentation of the Exchange's API on how exactly this can be done. <a href="https://github.com/ccxt/ccxt/issues">CCXT Issues</a> may also provide great help, since others may have implemented something similar for their projects.</p>
<h3 id="incomplete-candles">Incomplete candles<a class="headerlink" href="#incomplete-candles" title="Permanent link">&para;</a></h3>
<p>While fetching OHLCV data, we're may end up getting incomplete candles (Depending on the exchange).
To demonstrate this, we'll use daily candles (<code>"1d"</code>) to keep things simple.
We query the api (<code>ct.fetch_ohlcv()</code>) for the timeframe and look at the date of the last entry. If this entry changes or shows the date of a "incomplete" candle, then we should drop this since having incomplete candles is problematic because indicators assume that only complete candles are passed to them, and will generate a lot of false buy signals. By default, we're therefore removing the last candle assuming it's incomplete.</p>
<p>To check how the new exchange behaves, you can use the following snippet:</p>
<div class="highlight"><pre><span></span><code><span class="kn">import</span> <span class="nn">ccxt</span>
<span class="kn">from</span> <span class="nn">datetime</span> <span class="kn">import</span> <span class="n">datetime</span>
<span class="kn">from</span> <span class="nn">freqtrade.data.converter</span> <span class="kn">import</span> <span class="n">parse_ticker_dataframe</span>
<span class="n">ct</span> <span class="o">=</span> <span class="n">ccxt</span><span class="o">.</span><span class="n">binance</span><span class="p">()</span>
<span class="n">timeframe</span> <span class="o">=</span> <span class="s2">&quot;1d&quot;</span>
<span class="n">pair</span> <span class="o">=</span> <span class="s2">&quot;XLM/BTC&quot;</span> <span class="c1"># Make sure to use a pair that exists on that exchange!</span>
<span class="n">raw</span> <span class="o">=</span> <span class="n">ct</span><span class="o">.</span><span class="n">fetch_ohlcv</span><span class="p">(</span><span class="n">pair</span><span class="p">,</span> <span class="n">timeframe</span><span class="o">=</span><span class="n">timeframe</span><span class="p">)</span>
<span class="c1"># convert to dataframe</span>
<span class="n">df1</span> <span class="o">=</span> <span class="n">parse_ticker_dataframe</span><span class="p">(</span><span class="n">raw</span><span class="p">,</span> <span class="n">timeframe</span><span class="p">,</span> <span class="n">pair</span><span class="o">=</span><span class="n">pair</span><span class="p">,</span> <span class="n">drop_incomplete</span><span class="o">=</span><span class="kc">False</span><span class="p">)</span>
<span class="nb">print</span><span class="p">(</span><span class="n">df1</span><span class="p">[</span><span class="s2">&quot;date&quot;</span><span class="p">]</span><span class="o">.</span><span class="n">tail</span><span class="p">(</span><span class="mi">1</span><span class="p">))</span>
<span class="nb">print</span><span class="p">(</span><span class="n">datetime</span><span class="o">.</span><span class="n">utcnow</span><span class="p">())</span>
</code></pre></div>
<div class="highlight"><pre><span></span><code><span class="go">19 2019-06-08 00:00:00+00:00</span>
<span class="go">2019-06-09 12:30:27.873327</span>
</code></pre></div>
<p>The output will show the last entry from the Exchange as well as the current UTC date.
If the day shows the same day, then the last candle can be assumed as incomplete and should be dropped (leave the setting <code>"ohlcv_partial_candle"</code> from the exchange-class untouched / True). Otherwise, set <code>"ohlcv_partial_candle"</code> to <code>False</code> to not drop Candles (shown in the example above).</p>
<h2 id="creating-a-release">Creating a release<a class="headerlink" href="#creating-a-release" title="Permanent link">&para;</a></h2>
<p>This part of the documentation is aimed at maintainers, and shows how to create a release.</p>
<h3 id="create-release-branch">Create release branch<a class="headerlink" href="#create-release-branch" title="Permanent link">&para;</a></h3>
<div class="highlight"><pre><span></span><code><span class="c1"># make sure you&#39;re in develop branch</span>
git<span class="w"> </span>checkout<span class="w"> </span>develop
<span class="c1"># create new branch</span>
git<span class="w"> </span>checkout<span class="w"> </span>-b<span class="w"> </span>new_release
</code></pre></div>
<ul>
<li>Edit <code>freqtrade/__init__.py</code> and add the version matching the current date (for example <code>2019.7</code> for July 2019). Minor versions can be <code>2019.7-1</code> should we need to do a second release that month.</li>
<li>Commit this part</li>
<li>push that branch to the remote and create a PR against the master branch</li>
</ul>
<h3 id="create-changelog-from-git-commits">Create changelog from git commits<a class="headerlink" href="#create-changelog-from-git-commits" title="Permanent link">&para;</a></h3>
<div class="admonition note">
<p class="admonition-title">Note</p>
<p>Make sure that both master and develop are up-todate!.</p>
</div>
<div class="highlight"><pre><span></span><code><span class="c1"># Needs to be done before merging / pulling that branch.</span>
git<span class="w"> </span>log<span class="w"> </span>--oneline<span class="w"> </span>--no-decorate<span class="w"> </span>--no-merges<span class="w"> </span>master..develop
</code></pre></div>
<h3 id="create-github-release-tag">Create github release / tag<a class="headerlink" href="#create-github-release-tag" title="Permanent link">&para;</a></h3>
<ul>
<li>Use the button "Draft a new release" in the Github UI (subsection releases)</li>
<li>Use the version-number specified as tag. </li>
<li>Use "master" as reference (this step comes after the above PR is merged).</li>
<li>Use the above changelog as release comment (as codeblock)</li>
</ul>
<h3 id="after-release">After-release<a class="headerlink" href="#after-release" title="Permanent link">&para;</a></h3>
<ul>
<li>Update version in develop by postfixing that with <code>-dev</code> (<code>2019.6 -&gt; 2019.6-dev</code>).</li>
<li>Create a PR against develop to update that branch.</li>
</ul>
</article>
</div>
<script>var target=document.getElementById(location.hash.slice(1));target&&target.name&&(target.checked=target.name.startsWith("__tabbed_"))</script>
</div>
</main>
<footer class="md-footer">
<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>
</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": [], "search": "../assets/javascripts/workers/search.b8dbb3d2.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.fe8b6f2b.min.js"></script>
</body>
</html>