freqtrade_origin/en/2019.8-1/edge/index.html

1623 lines
47 KiB
HTML
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<!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="../hyperopt/">
<link rel="next" href="../plotting/">
<link rel="icon" href="../assets/images/favicon.png">
<meta name="generator" content="mkdocs-1.6.0, mkdocs-material-9.5.30">
<title>Edge positioning - 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="#edge-positioning" 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">
Edge positioning
</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 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">
Edge positioning
</span>
<span class="md-nav__icon md-icon"></span>
</label>
<a href="./" class="md-nav__link md-nav__link--active">
<span class="md-ellipsis">
Edge positioning
</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="#introduction" class="md-nav__link">
<span class="md-ellipsis">
Introduction
</span>
</a>
<nav class="md-nav" aria-label="Introduction">
<ul class="md-nav__list">
<li class="md-nav__item">
<a href="#win-rate" class="md-nav__link">
<span class="md-ellipsis">
Win Rate
</span>
</a>
</li>
<li class="md-nav__item">
<a href="#risk-reward-ratio" class="md-nav__link">
<span class="md-ellipsis">
Risk Reward Ratio
</span>
</a>
</li>
<li class="md-nav__item">
<a href="#expectancy" class="md-nav__link">
<span class="md-ellipsis">
Expectancy
</span>
</a>
</li>
</ul>
</nav>
</li>
<li class="md-nav__item">
<a href="#how-does-it-work" class="md-nav__link">
<span class="md-ellipsis">
How does it work?
</span>
</a>
<nav class="md-nav" aria-label="How does it work?">
<ul class="md-nav__list">
<li class="md-nav__item">
<a href="#position-size" class="md-nav__link">
<span class="md-ellipsis">
Position size
</span>
</a>
</li>
</ul>
</nav>
</li>
<li class="md-nav__item">
<a href="#configurations" class="md-nav__link">
<span class="md-ellipsis">
Configurations
</span>
</a>
<nav class="md-nav" aria-label="Configurations">
<ul class="md-nav__list">
<li class="md-nav__item">
<a href="#enabled" class="md-nav__link">
<span class="md-ellipsis">
enabled
</span>
</a>
</li>
<li class="md-nav__item">
<a href="#process_throttle_secs" class="md-nav__link">
<span class="md-ellipsis">
process_throttle_secs
</span>
</a>
</li>
<li class="md-nav__item">
<a href="#calculate_since_number_of_days" class="md-nav__link">
<span class="md-ellipsis">
calculate_since_number_of_days
</span>
</a>
</li>
<li class="md-nav__item">
<a href="#capital_available_percentage" class="md-nav__link">
<span class="md-ellipsis">
capital_available_percentage
</span>
</a>
</li>
<li class="md-nav__item">
<a href="#allowed_risk" class="md-nav__link">
<span class="md-ellipsis">
allowed_risk
</span>
</a>
</li>
<li class="md-nav__item">
<a href="#stoploss_range_min" class="md-nav__link">
<span class="md-ellipsis">
stoploss_range_min
</span>
</a>
</li>
<li class="md-nav__item">
<a href="#stoploss_range_max" class="md-nav__link">
<span class="md-ellipsis">
stoploss_range_max
</span>
</a>
</li>
<li class="md-nav__item">
<a href="#stoploss_range_step" class="md-nav__link">
<span class="md-ellipsis">
stoploss_range_step
</span>
</a>
</li>
<li class="md-nav__item">
<a href="#minimum_winrate" class="md-nav__link">
<span class="md-ellipsis">
minimum_winrate
</span>
</a>
</li>
<li class="md-nav__item">
<a href="#minimum_expectancy" class="md-nav__link">
<span class="md-ellipsis">
minimum_expectancy
</span>
</a>
</li>
<li class="md-nav__item">
<a href="#min_trade_number" class="md-nav__link">
<span class="md-ellipsis">
min_trade_number
</span>
</a>
</li>
<li class="md-nav__item">
<a href="#max_trade_duration_minute" class="md-nav__link">
<span class="md-ellipsis">
max_trade_duration_minute
</span>
</a>
</li>
<li class="md-nav__item">
<a href="#remove_pumps" class="md-nav__link">
<span class="md-ellipsis">
remove_pumps
</span>
</a>
</li>
</ul>
</nav>
</li>
<li class="md-nav__item">
<a href="#running-edge-independently" class="md-nav__link">
<span class="md-ellipsis">
Running Edge independently
</span>
</a>
<nav class="md-nav" aria-label="Running Edge independently">
<ul class="md-nav__list">
<li class="md-nav__item">
<a href="#update-cached-pairs-with-the-latest-data" class="md-nav__link">
<span class="md-ellipsis">
Update cached pairs with the latest data
</span>
</a>
</li>
<li class="md-nav__item">
<a href="#precising-stoploss-range" class="md-nav__link">
<span class="md-ellipsis">
Precising stoploss range
</span>
</a>
</li>
<li class="md-nav__item">
<a href="#advanced-use-of-timerange" class="md-nav__link">
<span class="md-ellipsis">
Advanced use of timerange
</span>
</a>
</li>
</ul>
</nav>
</li>
</ul>
</nav>
</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">
<a href="../developer/" class="md-nav__link">
<span class="md-ellipsis">
Contributors guide
</span>
</a>
</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="#introduction" class="md-nav__link">
<span class="md-ellipsis">
Introduction
</span>
</a>
<nav class="md-nav" aria-label="Introduction">
<ul class="md-nav__list">
<li class="md-nav__item">
<a href="#win-rate" class="md-nav__link">
<span class="md-ellipsis">
Win Rate
</span>
</a>
</li>
<li class="md-nav__item">
<a href="#risk-reward-ratio" class="md-nav__link">
<span class="md-ellipsis">
Risk Reward Ratio
</span>
</a>
</li>
<li class="md-nav__item">
<a href="#expectancy" class="md-nav__link">
<span class="md-ellipsis">
Expectancy
</span>
</a>
</li>
</ul>
</nav>
</li>
<li class="md-nav__item">
<a href="#how-does-it-work" class="md-nav__link">
<span class="md-ellipsis">
How does it work?
</span>
</a>
<nav class="md-nav" aria-label="How does it work?">
<ul class="md-nav__list">
<li class="md-nav__item">
<a href="#position-size" class="md-nav__link">
<span class="md-ellipsis">
Position size
</span>
</a>
</li>
</ul>
</nav>
</li>
<li class="md-nav__item">
<a href="#configurations" class="md-nav__link">
<span class="md-ellipsis">
Configurations
</span>
</a>
<nav class="md-nav" aria-label="Configurations">
<ul class="md-nav__list">
<li class="md-nav__item">
<a href="#enabled" class="md-nav__link">
<span class="md-ellipsis">
enabled
</span>
</a>
</li>
<li class="md-nav__item">
<a href="#process_throttle_secs" class="md-nav__link">
<span class="md-ellipsis">
process_throttle_secs
</span>
</a>
</li>
<li class="md-nav__item">
<a href="#calculate_since_number_of_days" class="md-nav__link">
<span class="md-ellipsis">
calculate_since_number_of_days
</span>
</a>
</li>
<li class="md-nav__item">
<a href="#capital_available_percentage" class="md-nav__link">
<span class="md-ellipsis">
capital_available_percentage
</span>
</a>
</li>
<li class="md-nav__item">
<a href="#allowed_risk" class="md-nav__link">
<span class="md-ellipsis">
allowed_risk
</span>
</a>
</li>
<li class="md-nav__item">
<a href="#stoploss_range_min" class="md-nav__link">
<span class="md-ellipsis">
stoploss_range_min
</span>
</a>
</li>
<li class="md-nav__item">
<a href="#stoploss_range_max" class="md-nav__link">
<span class="md-ellipsis">
stoploss_range_max
</span>
</a>
</li>
<li class="md-nav__item">
<a href="#stoploss_range_step" class="md-nav__link">
<span class="md-ellipsis">
stoploss_range_step
</span>
</a>
</li>
<li class="md-nav__item">
<a href="#minimum_winrate" class="md-nav__link">
<span class="md-ellipsis">
minimum_winrate
</span>
</a>
</li>
<li class="md-nav__item">
<a href="#minimum_expectancy" class="md-nav__link">
<span class="md-ellipsis">
minimum_expectancy
</span>
</a>
</li>
<li class="md-nav__item">
<a href="#min_trade_number" class="md-nav__link">
<span class="md-ellipsis">
min_trade_number
</span>
</a>
</li>
<li class="md-nav__item">
<a href="#max_trade_duration_minute" class="md-nav__link">
<span class="md-ellipsis">
max_trade_duration_minute
</span>
</a>
</li>
<li class="md-nav__item">
<a href="#remove_pumps" class="md-nav__link">
<span class="md-ellipsis">
remove_pumps
</span>
</a>
</li>
</ul>
</nav>
</li>
<li class="md-nav__item">
<a href="#running-edge-independently" class="md-nav__link">
<span class="md-ellipsis">
Running Edge independently
</span>
</a>
<nav class="md-nav" aria-label="Running Edge independently">
<ul class="md-nav__list">
<li class="md-nav__item">
<a href="#update-cached-pairs-with-the-latest-data" class="md-nav__link">
<span class="md-ellipsis">
Update cached pairs with the latest data
</span>
</a>
</li>
<li class="md-nav__item">
<a href="#precising-stoploss-range" class="md-nav__link">
<span class="md-ellipsis">
Precising stoploss range
</span>
</a>
</li>
<li class="md-nav__item">
<a href="#advanced-use-of-timerange" class="md-nav__link">
<span class="md-ellipsis">
Advanced use of timerange
</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="edge-positioning">Edge positioning<a class="headerlink" href="#edge-positioning" title="Permanent link">&para;</a></h1>
<p>This page explains how to use Edge Positioning module in your bot in order to enter into a trade only if the trade has a reasonable win rate and risk reward ratio, and consequently adjust your position size and stoploss.</p>
<div class="admonition warning">
<p class="admonition-title">Warning</p>
<p>Edge positioning is not compatible with dynamic (volume-based) whitelist.</p>
</div>
<div class="admonition note">
<p class="admonition-title">Note</p>
<p>Edge does not consider anything else than buy/sell/stoploss signals. So trailing stoploss, ROI, and everything else are ignored in its calculation.</p>
</div>
<h2 id="introduction">Introduction<a class="headerlink" href="#introduction" title="Permanent link">&para;</a></h2>
<p>Trading is all about probability. No one can claim that he has a strategy working all the time. You have to assume that sometimes you lose.</p>
<p>But it doesn't mean there is no rule, it only means rules should work "most of the time". Let's play a game: we toss a coin, heads: I give you 10<span class="arithmatex"><span class="MathJax_Preview">, tails: you give me 10</span><script type="math/tex">, tails: you give me 10</script></span>. Is it an interesting game? No, it's quite boring, isn't it?</p>
<p>But let's say the probability that we have heads is 80% (because our coin has the displaced distribution of mass or other defect), and the probability that we have tails is 20%. Now it is becoming interesting...</p>
<p>That means 10$ X 80% versus 10$ X 20%. 8$ versus 2<span class="arithmatex"><span class="MathJax_Preview">. That means over time you will win 8</span><script type="math/tex">. That means over time you will win 8</script></span> risking only 2$ on each toss of coin.</p>
<p>Let's complicate it more: you win 80% of the time but only 2<span class="arithmatex"><span class="MathJax_Preview">, I win 20% of the time but 8</span><script type="math/tex">, I win 20% of the time but 8</script></span>. The calculation is: 80% X 2$ versus 20% X 8<span class="arithmatex"><span class="MathJax_Preview">. It is becoming boring again because overtime you win <span class="arithmatex"><span class="MathJax_Preview">1.6</span><script type="math/tex">1.6</script></span> (80% X 2 (80% X 2</span><script type="math/tex">. It is becoming boring again because overtime you win <span class="arithmatex"><span class="MathJax_Preview">1.6</span><script type="math/tex">1.6</script></span> (80% X 2 (80% X 2</script></span>) and me <span class="arithmatex"><span class="MathJax_Preview">1.6 (20% X 8</span><script type="math/tex">1.6 (20% X 8</script></span>) too.</p>
<p>The question is: How do you calculate that? How do you know if you wanna play?</p>
<p>The answer comes to two factors:
- Win Rate
- Risk Reward Ratio</p>
<h3 id="win-rate">Win Rate<a class="headerlink" href="#win-rate" title="Permanent link">&para;</a></h3>
<p>Win Rate (<em>W</em>) is is the mean over some amount of trades (<em>N</em>) what is the percentage of winning trades to total number of trades (note that we don't consider how much you gained but only if you won or not).</p>
<div class="codehilite"><pre><span></span><code>W = (Number of winning trades) / (Total number of trades) = (Number of winning trades) / N
</code></pre></div>
<p>Complementary Loss Rate (<em>L</em>) is defined as</p>
<div class="codehilite"><pre><span></span><code>L = (Number of losing trades) / (Total number of trades) = (Number of losing trades) / N
</code></pre></div>
<p>or, which is the same, as</p>
<div class="codehilite"><pre><span></span><code>L = 1 W
</code></pre></div>
<h3 id="risk-reward-ratio">Risk Reward Ratio<a class="headerlink" href="#risk-reward-ratio" title="Permanent link">&para;</a></h3>
<p>Risk Reward Ratio (<em>R</em>) is a formula used to measure the expected gains of a given investment against the risk of loss. It is basically what you potentially win divided by what you potentially lose:</p>
<div class="codehilite"><pre><span></span><code>R = Profit / Loss
</code></pre></div>
<p>Over time, on many trades, you can calculate your risk reward by dividing your average profit on winning trades by your average loss on losing trades:</p>
<div class="codehilite"><pre><span></span><code>Average profit = (Sum of profits) / (Number of winning trades)
Average loss = (Sum of losses) / (Number of losing trades)
R = (Average profit) / (Average loss)
</code></pre></div>
<h3 id="expectancy">Expectancy<a class="headerlink" href="#expectancy" title="Permanent link">&para;</a></h3>
<p>At this point we can combine <em>W</em> and <em>R</em> to create an expectancy ratio. This is a simple process of multiplying the risk reward ratio by the percentage of winning trades and subtracting the percentage of losing trades, which is calculated as follows:</p>
<div class="codehilite"><pre><span></span><code>Expectancy Ratio = (Risk Reward Ratio X Win Rate) Loss Rate = (R X W) L
</code></pre></div>
<p>So lets say your Win rate is 28% and your Risk Reward Ratio is 5:</p>
<div class="codehilite"><pre><span></span><code>Expectancy = (5 X 0.28) 0.72 = 0.68
</code></pre></div>
<p>Superficially, this means that on average you expect this strategys trades to return .68 times the size of your loses. This is important for two reasons: First, it may seem obvious, but you know right away that you have a positive return. Second, you now have a number you can compare to other candidate systems to make decisions about which ones you employ.</p>
<p>It is important to remember that any system with an expectancy greater than 0 is profitable using past data. The key is finding one that will be profitable in the future.</p>
<p>You can also use this value to evaluate the effectiveness of modifications to this system.</p>
<p><strong>NOTICE:</strong> It's important to keep in mind that Edge is testing your expectancy using historical data, there's no guarantee that you will have a similar edge in the future. It's still vital to do this testing in order to build confidence in your methodology, but be wary of "curve-fitting" your approach to the historical data as things are unlikely to play out the exact same way for future trades.</p>
<h2 id="how-does-it-work">How does it work?<a class="headerlink" href="#how-does-it-work" title="Permanent link">&para;</a></h2>
<p>If enabled in config, Edge will go through historical data with a range of stoplosses in order to find buy and sell/stoploss signals. It then calculates win rate and expectancy over <em>N</em> trades for each stoploss. Here is an example:</p>
<table>
<thead>
<tr>
<th>Pair</th>
<th style="text-align: center;">Stoploss</th>
<th style="text-align: right;">Win Rate</th>
<th style="text-align: right;">Risk Reward Ratio</th>
<th style="text-align: right;">Expectancy</th>
</tr>
</thead>
<tbody>
<tr>
<td>XZC/ETH</td>
<td style="text-align: center;">-0.01</td>
<td style="text-align: right;">0.50</td>
<td style="text-align: right;">1.176384</td>
<td style="text-align: right;">0.088</td>
</tr>
<tr>
<td>XZC/ETH</td>
<td style="text-align: center;">-0.02</td>
<td style="text-align: right;">0.51</td>
<td style="text-align: right;">1.115941</td>
<td style="text-align: right;">0.079</td>
</tr>
<tr>
<td>XZC/ETH</td>
<td style="text-align: center;">-0.03</td>
<td style="text-align: right;">0.52</td>
<td style="text-align: right;">1.359670</td>
<td style="text-align: right;">0.228</td>
</tr>
<tr>
<td>XZC/ETH</td>
<td style="text-align: center;">-0.04</td>
<td style="text-align: right;">0.51</td>
<td style="text-align: right;">1.234539</td>
<td style="text-align: right;">0.117</td>
</tr>
</tbody>
</table>
<p>The goal here is to find the best stoploss for the strategy in order to have the maximum expectancy. In the above example stoploss at 3% leads to the maximum expectancy according to historical data.</p>
<p>Edge module then forces stoploss value it evaluated to your strategy dynamically.</p>
<h3 id="position-size">Position size<a class="headerlink" href="#position-size" title="Permanent link">&para;</a></h3>
<p>Edge also dictates the stake amount for each trade to the bot according to the following factors:</p>
<ul>
<li>Allowed capital at risk</li>
<li>Stoploss</li>
</ul>
<p>Allowed capital at risk is calculated as follows:</p>
<div class="codehilite"><pre><span></span><code>Allowed capital at risk = (Capital available_percentage) X (Allowed risk per trade)
</code></pre></div>
<p>Stoploss is calculated as described above against historical data.</p>
<p>Your position size then will be:</p>
<div class="codehilite"><pre><span></span><code>Position size = (Allowed capital at risk) / Stoploss
</code></pre></div>
<p>Example:</p>
<p>Let's say the stake currency is ETH and you have 10 ETH on the exchange, your capital available percentage is 50% and you would allow 1% of risk for each trade. thus your available capital for trading is <strong>10 x 0.5 = 5 ETH</strong> and allowed capital at risk would be <strong>5 x 0.01 = 0.05 ETH</strong>.</p>
<p>Let's assume Edge has calculated that for <strong>XLM/ETH</strong> market your stoploss should be at 2%. So your position size will be <strong>0.05 / 0.02 = 2.5 ETH</strong>.</p>
<p>Bot takes a position of 2.5 ETH on XLM/ETH (call it trade 1). Up next, you receive another buy signal while trade 1 is still open. This time on <strong>BTC/ETH</strong> market. Edge calculated stoploss for this market at 4%. So your position size would be 0.05 / 0.04 = 1.25 ETH (call it trade 2).</p>
<p>Note that available capital for trading didnt change for trade 2 even if you had already trade 1. The available capital doesnt mean the free amount on your wallet.</p>
<p>Now you have two trades open. The bot receives yet another buy signal for another market: <strong>ADA/ETH</strong>. This time the stoploss is calculated at 1%. So your position size is <strong>0.05 / 0.01 = 5 ETH</strong>. But there are already 3.75 ETH blocked in two previous trades. So the position size for this third trade would be <strong>5 3.75 = 1.25 ETH</strong>.</p>
<p>Available capital doesnt change before a position is sold. Lets assume that trade 1 receives a sell signal and it is sold with a profit of 1 ETH. Your total capital on exchange would be 11 ETH and the available capital for trading becomes 5.5 ETH.</p>
<p>So the Bot receives another buy signal for trade 4 with a stoploss at 2% then your position size would be <strong>0.055 / 0.02 = 2.75 ETH</strong>.</p>
<h2 id="configurations">Configurations<a class="headerlink" href="#configurations" title="Permanent link">&para;</a></h2>
<p>Edge module has following configuration options:</p>
<h4 id="enabled">enabled<a class="headerlink" href="#enabled" title="Permanent link">&para;</a></h4>
<p>If true, then Edge will run periodically.</p>
<p>(defaults to false)</p>
<h4 id="process_throttle_secs">process_throttle_secs<a class="headerlink" href="#process_throttle_secs" title="Permanent link">&para;</a></h4>
<p>How often should Edge run in seconds?</p>
<p>(defaults to 3600 so one hour)</p>
<h4 id="calculate_since_number_of_days">calculate_since_number_of_days<a class="headerlink" href="#calculate_since_number_of_days" title="Permanent link">&para;</a></h4>
<p>Number of days of data against which Edge calculates Win Rate, Risk Reward and Expectancy
Note that it downloads historical data so increasing this number would lead to slowing down the bot.</p>
<p>(defaults to 7)</p>
<h4 id="capital_available_percentage">capital_available_percentage<a class="headerlink" href="#capital_available_percentage" title="Permanent link">&para;</a></h4>
<p>This is the percentage of the total capital on exchange in stake currency.</p>
<p>As an example if you have 10 ETH available in your wallet on the exchange and this value is 0.5 (which is 50%), then the bot will use a maximum amount of 5 ETH for trading and considers it as available capital.</p>
<p>(defaults to 0.5)</p>
<h4 id="allowed_risk">allowed_risk<a class="headerlink" href="#allowed_risk" title="Permanent link">&para;</a></h4>
<p>Percentage of allowed risk per trade.</p>
<p>(defaults to 0.01 so 1%)</p>
<h4 id="stoploss_range_min">stoploss_range_min<a class="headerlink" href="#stoploss_range_min" title="Permanent link">&para;</a></h4>
<p>Minimum stoploss.</p>
<p>(defaults to -0.01)</p>
<h4 id="stoploss_range_max">stoploss_range_max<a class="headerlink" href="#stoploss_range_max" title="Permanent link">&para;</a></h4>
<p>Maximum stoploss.</p>
<p>(defaults to -0.10)</p>
<h4 id="stoploss_range_step">stoploss_range_step<a class="headerlink" href="#stoploss_range_step" title="Permanent link">&para;</a></h4>
<p>As an example if this is set to -0.01 then Edge will test the strategy for [-0.01, -0,02, -0,03 ..., -0.09, -0.10] ranges.
Note than having a smaller step means having a bigger range which could lead to slow calculation.</p>
<p>If you set this parameter to -0.001, you then slow down the Edge calculation by a factor of 10.</p>
<p>(defaults to -0.01)</p>
<h4 id="minimum_winrate">minimum_winrate<a class="headerlink" href="#minimum_winrate" title="Permanent link">&para;</a></h4>
<p>It filters out pairs which don't have at least minimum_winrate.</p>
<p>This comes handy if you want to be conservative and don't comprise win rate in favour of risk reward ratio.</p>
<p>(defaults to 0.60)</p>
<h4 id="minimum_expectancy">minimum_expectancy<a class="headerlink" href="#minimum_expectancy" title="Permanent link">&para;</a></h4>
<p>It filters out pairs which have the expectancy lower than this number.</p>
<p>Having an expectancy of 0.20 means if you put 10$ on a trade you expect a 12$ return.</p>
<p>(defaults to 0.20)</p>
<h4 id="min_trade_number">min_trade_number<a class="headerlink" href="#min_trade_number" title="Permanent link">&para;</a></h4>
<p>When calculating <em>W</em>, <em>R</em> and <em>E</em> (expectancy) against historical data, you always want to have a minimum number of trades. The more this number is the more Edge is reliable.</p>
<p>Having a win rate of 100% on a single trade doesn't mean anything at all. But having a win rate of 70% over past 100 trades means clearly something.</p>
<p>(defaults to 10, it is highly recommended not to decrease this number)</p>
<h4 id="max_trade_duration_minute">max_trade_duration_minute<a class="headerlink" href="#max_trade_duration_minute" title="Permanent link">&para;</a></h4>
<p>Edge will filter out trades with long duration. If a trade is profitable after 1 month, it is hard to evaluate the strategy based on it. But if most of trades are profitable and they have maximum duration of 30 minutes, then it is clearly a good sign.</p>
<p><strong>NOTICE:</strong> While configuring this value, you should take into consideration your ticker interval. As an example filtering out trades having duration less than one day for a strategy which has 4h interval does not make sense. Default value is set assuming your strategy interval is relatively small (1m or 5m, etc.).</p>
<p>(defaults to 1 day, i.e. to 60 * 24 = 1440 minutes)</p>
<h4 id="remove_pumps">remove_pumps<a class="headerlink" href="#remove_pumps" title="Permanent link">&para;</a></h4>
<p>Edge will remove sudden pumps in a given market while going through historical data. However, given that pumps happen very often in crypto markets, we recommend you keep this off.</p>
<p>(defaults to false)</p>
<h2 id="running-edge-independently">Running Edge independently<a class="headerlink" href="#running-edge-independently" title="Permanent link">&para;</a></h2>
<p>You can run Edge independently in order to see in details the result. Here is an example:</p>
<div class="highlight"><pre><span></span><code>freqtrade<span class="w"> </span>edge
</code></pre></div>
<p>An example of its output:</p>
<table>
<thead>
<tr>
<th style="text-align: left;">pair</th>
<th style="text-align: right;">stoploss</th>
<th style="text-align: right;">win rate</th>
<th style="text-align: right;">risk reward ratio</th>
<th style="text-align: right;">required risk reward</th>
<th style="text-align: right;">expectancy</th>
<th style="text-align: right;">total number of trades</th>
<th style="text-align: right;">average duration (min)</th>
</tr>
</thead>
<tbody>
<tr>
<td style="text-align: left;">AGI/BTC</td>
<td style="text-align: right;">-0.02</td>
<td style="text-align: right;">0.64</td>
<td style="text-align: right;">5.86</td>
<td style="text-align: right;">0.56</td>
<td style="text-align: right;">3.41</td>
<td style="text-align: right;">14</td>
<td style="text-align: right;">54</td>
</tr>
<tr>
<td style="text-align: left;">NXS/BTC</td>
<td style="text-align: right;">-0.03</td>
<td style="text-align: right;">0.64</td>
<td style="text-align: right;">2.99</td>
<td style="text-align: right;">0.57</td>
<td style="text-align: right;">1.54</td>
<td style="text-align: right;">11</td>
<td style="text-align: right;">26</td>
</tr>
<tr>
<td style="text-align: left;">LEND/BTC</td>
<td style="text-align: right;">-0.02</td>
<td style="text-align: right;">0.82</td>
<td style="text-align: right;">2.05</td>
<td style="text-align: right;">0.22</td>
<td style="text-align: right;">1.50</td>
<td style="text-align: right;">11</td>
<td style="text-align: right;">36</td>
</tr>
<tr>
<td style="text-align: left;">VIA/BTC</td>
<td style="text-align: right;">-0.01</td>
<td style="text-align: right;">0.55</td>
<td style="text-align: right;">3.01</td>
<td style="text-align: right;">0.83</td>
<td style="text-align: right;">1.19</td>
<td style="text-align: right;">11</td>
<td style="text-align: right;">48</td>
</tr>
<tr>
<td style="text-align: left;">MTH/BTC</td>
<td style="text-align: right;">-0.09</td>
<td style="text-align: right;">0.56</td>
<td style="text-align: right;">2.82</td>
<td style="text-align: right;">0.80</td>
<td style="text-align: right;">1.12</td>
<td style="text-align: right;">18</td>
<td style="text-align: right;">52</td>
</tr>
<tr>
<td style="text-align: left;">ARDR/BTC</td>
<td style="text-align: right;">-0.04</td>
<td style="text-align: right;">0.42</td>
<td style="text-align: right;">3.14</td>
<td style="text-align: right;">1.40</td>
<td style="text-align: right;">0.73</td>
<td style="text-align: right;">12</td>
<td style="text-align: right;">42</td>
</tr>
<tr>
<td style="text-align: left;">BCPT/BTC</td>
<td style="text-align: right;">-0.01</td>
<td style="text-align: right;">0.71</td>
<td style="text-align: right;">1.34</td>
<td style="text-align: right;">0.40</td>
<td style="text-align: right;">0.67</td>
<td style="text-align: right;">14</td>
<td style="text-align: right;">30</td>
</tr>
<tr>
<td style="text-align: left;">WINGS/BTC</td>
<td style="text-align: right;">-0.02</td>
<td style="text-align: right;">0.56</td>
<td style="text-align: right;">1.97</td>
<td style="text-align: right;">0.80</td>
<td style="text-align: right;">0.65</td>
<td style="text-align: right;">27</td>
<td style="text-align: right;">42</td>
</tr>
<tr>
<td style="text-align: left;">VIBE/BTC</td>
<td style="text-align: right;">-0.02</td>
<td style="text-align: right;">0.83</td>
<td style="text-align: right;">0.91</td>
<td style="text-align: right;">0.20</td>
<td style="text-align: right;">0.59</td>
<td style="text-align: right;">12</td>
<td style="text-align: right;">35</td>
</tr>
<tr>
<td style="text-align: left;">MCO/BTC</td>
<td style="text-align: right;">-0.02</td>
<td style="text-align: right;">0.79</td>
<td style="text-align: right;">0.97</td>
<td style="text-align: right;">0.27</td>
<td style="text-align: right;">0.55</td>
<td style="text-align: right;">14</td>
<td style="text-align: right;">31</td>
</tr>
<tr>
<td style="text-align: left;">GNT/BTC</td>
<td style="text-align: right;">-0.02</td>
<td style="text-align: right;">0.50</td>
<td style="text-align: right;">2.06</td>
<td style="text-align: right;">1.00</td>
<td style="text-align: right;">0.53</td>
<td style="text-align: right;">18</td>
<td style="text-align: right;">24</td>
</tr>
<tr>
<td style="text-align: left;">HOT/BTC</td>
<td style="text-align: right;">-0.01</td>
<td style="text-align: right;">0.17</td>
<td style="text-align: right;">7.72</td>
<td style="text-align: right;">4.81</td>
<td style="text-align: right;">0.50</td>
<td style="text-align: right;">209</td>
<td style="text-align: right;">7</td>
</tr>
<tr>
<td style="text-align: left;">SNM/BTC</td>
<td style="text-align: right;">-0.03</td>
<td style="text-align: right;">0.71</td>
<td style="text-align: right;">1.06</td>
<td style="text-align: right;">0.42</td>
<td style="text-align: right;">0.45</td>
<td style="text-align: right;">17</td>
<td style="text-align: right;">38</td>
</tr>
<tr>
<td style="text-align: left;">APPC/BTC</td>
<td style="text-align: right;">-0.02</td>
<td style="text-align: right;">0.44</td>
<td style="text-align: right;">2.28</td>
<td style="text-align: right;">1.27</td>
<td style="text-align: right;">0.44</td>
<td style="text-align: right;">25</td>
<td style="text-align: right;">43</td>
</tr>
<tr>
<td style="text-align: left;">NEBL/BTC</td>
<td style="text-align: right;">-0.03</td>
<td style="text-align: right;">0.63</td>
<td style="text-align: right;">1.29</td>
<td style="text-align: right;">0.58</td>
<td style="text-align: right;">0.44</td>
<td style="text-align: right;">19</td>
<td style="text-align: right;">59</td>
</tr>
</tbody>
</table>
<h3 id="update-cached-pairs-with-the-latest-data">Update cached pairs with the latest data<a class="headerlink" href="#update-cached-pairs-with-the-latest-data" title="Permanent link">&para;</a></h3>
<p>Edge requires historic data the same way as backtesting does.
Please refer to the <a href="../backtesting/#Getting-data-for-backtesting-and-hyperopt">download section</a> of the documentation for details.</p>
<h3 id="precising-stoploss-range">Precising stoploss range<a class="headerlink" href="#precising-stoploss-range" title="Permanent link">&para;</a></h3>
<div class="highlight"><pre><span></span><code>freqtrade<span class="w"> </span>edge<span class="w"> </span>--stoplosses<span class="o">=</span>-0.01,-0.1,-0.001<span class="w"> </span><span class="c1">#min,max,step</span>
</code></pre></div>
<h3 id="advanced-use-of-timerange">Advanced use of timerange<a class="headerlink" href="#advanced-use-of-timerange" title="Permanent link">&para;</a></h3>
<div class="highlight"><pre><span></span><code>freqtrade<span class="w"> </span>edge<span class="w"> </span>--timerange<span class="o">=</span><span class="m">20181110</span>-20181113
</code></pre></div>
<p>Doing <code>--timerange=-200</code> will get the last 200 timeframes from your inputdata. You can also specify specific dates, or a range span indexed by start and stop.</p>
<p>The full timerange specification:</p>
<ul>
<li>Use last 123 tickframes of data: <code>--timerange=-123</code></li>
<li>Use first 123 tickframes of data: <code>--timerange=123-</code></li>
<li>Use tickframes from line 123 through 456: <code>--timerange=123-456</code></li>
<li>Use tickframes till 2018/01/31: <code>--timerange=-20180131</code></li>
<li>Use tickframes since 2018/01/31: <code>--timerange=20180131-</code></li>
<li>Use tickframes since 2018/01/31 till 2018/03/01 : <code>--timerange=20180131-20180301</code></li>
<li>Use tickframes between POSIX timestamps 1527595200 1527618600: <code>--timerange=1527595200-1527618600</code></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>