<metaname="description"content="Freqtrade is a free and open source crypto trading bot written in Python, designed to support all major exchanges and be controlled via Telegram or builtin Web UI">
<inputclass="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_0">
<labelclass="md-header__button md-icon"title="Switch to dark mode"for="__palette_1"hidden>
<inputclass="md-option"data-md-color-media=""data-md-color-scheme="slate"data-md-color-primary="blue-grey"data-md-color-accent="tear"aria-label="Switch to light mode"type="radio"name="__palette"id="__palette_1">
<labelclass="md-header__button md-icon"title="Switch to light mode"for="__palette_0"hidden>
<h2id="prices-used-for-orders">Prices used for orders<aclass="headerlink"href="#prices-used-for-orders"title="Permanent link">¶</a></h2>
<p>Prices for regular orders can be controlled via the parameter structures <code>entry_pricing</code> for trade entries and <code>exit_pricing</code> for trade exits.
Prices are always retrieved right before an order is placed, either by querying the exchange tickers or by using the orderbook data.</p>
<divclass="admonition note">
<pclass="admonition-title">Note</p>
<p>Orderbook data used by Freqtrade are the data retrieved from exchange by the ccxt's function <code>fetch_order_book()</code>, i.e. are usually data from the L2-aggregated orderbook, while the ticker data are the structures returned by the ccxt's <code>fetch_ticker()</code>/<code>fetch_tickers()</code> functions. Refer to the ccxt library <ahref="https://github.com/ccxt/ccxt/wiki/Manual#market-data">documentation</a> for more details.</p>
<p>The configuration setting <code>entry_pricing.price_side</code> defines the side of the orderbook the bot looks for when buying.</p>
<p>The following displays an orderbook.</p>
<divclass="highlight"><pre><span></span><code>...
103
102
101 # ask
-------------Current spread
99 # bid
98
97
...
</code></pre></div>
<p>If <code>entry_pricing.price_side</code> is set to <code>"bid"</code>, then the bot will use 99 as entry price.<br/>
In line with that, if <code>entry_pricing.price_side</code> is set to <code>"ask"</code>, then the bot will use 101 as entry price.</p>
<p>Depending on the order direction (<em>long</em>/<em>short</em>), this will lead to different results. Therefore we recommend to use <code>"same"</code> or <code>"other"</code> for this configuration instead.
This would result in the following pricing matrix:</p>
<table>
<thead>
<tr>
<th>direction</th>
<th>Order</th>
<th>setting</th>
<th>price</th>
<th>crosses spread</th>
</tr>
</thead>
<tbody>
<tr>
<td>long</td>
<td>buy</td>
<td>ask</td>
<td>101</td>
<td>yes</td>
</tr>
<tr>
<td>long</td>
<td>buy</td>
<td>bid</td>
<td>99</td>
<td>no</td>
</tr>
<tr>
<td>long</td>
<td>buy</td>
<td>same</td>
<td>99</td>
<td>no</td>
</tr>
<tr>
<td>long</td>
<td>buy</td>
<td>other</td>
<td>101</td>
<td>yes</td>
</tr>
<tr>
<td>short</td>
<td>sell</td>
<td>ask</td>
<td>101</td>
<td>no</td>
</tr>
<tr>
<td>short</td>
<td>sell</td>
<td>bid</td>
<td>99</td>
<td>yes</td>
</tr>
<tr>
<td>short</td>
<td>sell</td>
<td>same</td>
<td>101</td>
<td>no</td>
</tr>
<tr>
<td>short</td>
<td>sell</td>
<td>other</td>
<td>99</td>
<td>yes</td>
</tr>
</tbody>
</table>
<p>Using the other side of the orderbook often guarantees quicker filled orders, but the bot can also end up paying more than what would have been necessary.
Taker fees instead of maker fees will most likely apply even when using limit buy orders.
Also, prices at the "other" side of the spread are higher than prices at the "bid" side in the orderbook, so the order behaves similar to a market order (however with a maximum price).</p>
<h4id="entry-price-with-orderbook-enabled">Entry price with Orderbook enabled<aclass="headerlink"href="#entry-price-with-orderbook-enabled"title="Permanent link">¶</a></h4>
<p>When entering a trade with the orderbook enabled (<code>entry_pricing.use_order_book=True</code>), Freqtrade fetches the <code>entry_pricing.order_book_top</code> entries from the orderbook and uses the entry specified as <code>entry_pricing.order_book_top</code> on the configured side (<code>entry_pricing.price_side</code>) of the orderbook. 1 specifies the topmost entry in the orderbook, while 2 would use the 2<sup>nd</sup> entry in the orderbook, and so on.</p>
<h4id="entry-price-without-orderbook-enabled">Entry price without Orderbook enabled<aclass="headerlink"href="#entry-price-without-orderbook-enabled"title="Permanent link">¶</a></h4>
<p>The following section uses <code>side</code> as the configured <code>entry_pricing.price_side</code> (defaults to <code>"same"</code>).</p>
<p>When not using orderbook (<code>entry_pricing.use_order_book=False</code>), Freqtrade uses the best <code>side</code> price from the ticker if it's below the <code>last</code> traded price from the ticker. Otherwise (when the <code>side</code> price is above the <code>last</code> price), it calculates a rate between <code>side</code> and <code>last</code> price based on <code>entry_pricing.price_last_balance</code>.</p>
<p>The <code>entry_pricing.price_last_balance</code> configuration parameter controls this. A value of <code>0.0</code> will use <code>side</code> price, while <code>1.0</code> will use the <code>last</code> price and values between those interpolate between ask and last price.</p>
<h4id="check-depth-of-market">Check depth of market<aclass="headerlink"href="#check-depth-of-market"title="Permanent link">¶</a></h4>
<p>When check depth of market is enabled (<code>entry_pricing.check_depth_of_market.enabled=True</code>), the entry signals are filtered based on the orderbook depth (sum of all amounts) for each orderbook side.</p>
<p>Orderbook <code>bid</code> (buy) side depth is then divided by the orderbook <code>ask</code> (sell) side depth and the resulting delta is compared to the value of the <code>entry_pricing.check_depth_of_market.bids_to_ask_delta</code> parameter. The entry order is only executed if the orderbook delta is greater than or equal to the configured delta value.</p>
<divclass="admonition note">
<pclass="admonition-title">Note</p>
<p>A delta value below 1 means that <code>ask</code> (sell) orderbook side depth is greater than the depth of the <code>bid</code> (buy) orderbook side, while a value greater than 1 means opposite (depth of the buy side is higher than the depth of the sell side).</p>
<p>The configuration setting <code>exit_pricing.price_side</code> defines the side of the spread the bot looks for when exiting a trade.</p>
<p>The following displays an orderbook:</p>
<divclass="highlight"><pre><span></span><code>...
103
102
101 # ask
-------------Current spread
99 # bid
98
97
...
</code></pre></div>
<p>If <code>exit_pricing.price_side</code> is set to <code>"ask"</code>, then the bot will use 101 as exiting price.<br/>
In line with that, if <code>exit_pricing.price_side</code> is set to <code>"bid"</code>, then the bot will use 99 as exiting price.</p>
<p>Depending on the order direction (<em>long</em>/<em>short</em>), this will lead to different results. Therefore we recommend to use <code>"same"</code> or <code>"other"</code> for this configuration instead.
This would result in the following pricing matrix:</p>
<table>
<thead>
<tr>
<th>Direction</th>
<th>Order</th>
<th>setting</th>
<th>price</th>
<th>crosses spread</th>
</tr>
</thead>
<tbody>
<tr>
<td>long</td>
<td>sell</td>
<td>ask</td>
<td>101</td>
<td>no</td>
</tr>
<tr>
<td>long</td>
<td>sell</td>
<td>bid</td>
<td>99</td>
<td>yes</td>
</tr>
<tr>
<td>long</td>
<td>sell</td>
<td>same</td>
<td>101</td>
<td>no</td>
</tr>
<tr>
<td>long</td>
<td>sell</td>
<td>other</td>
<td>99</td>
<td>yes</td>
</tr>
<tr>
<td>short</td>
<td>buy</td>
<td>ask</td>
<td>101</td>
<td>yes</td>
</tr>
<tr>
<td>short</td>
<td>buy</td>
<td>bid</td>
<td>99</td>
<td>no</td>
</tr>
<tr>
<td>short</td>
<td>buy</td>
<td>same</td>
<td>99</td>
<td>no</td>
</tr>
<tr>
<td>short</td>
<td>buy</td>
<td>other</td>
<td>101</td>
<td>yes</td>
</tr>
</tbody>
</table>
<h4id="exit-price-with-orderbook-enabled">Exit price with Orderbook enabled<aclass="headerlink"href="#exit-price-with-orderbook-enabled"title="Permanent link">¶</a></h4>
<p>When exiting with the orderbook enabled (<code>exit_pricing.use_order_book=True</code>), Freqtrade fetches the <code>exit_pricing.order_book_top</code> entries in the orderbook and uses the entry specified as <code>exit_pricing.order_book_top</code> from the configured side (<code>exit_pricing.price_side</code>) as trade exit price.</p>
<p>1 specifies the topmost entry in the orderbook, while 2 would use the 2<sup>nd</sup> entry in the orderbook, and so on.</p>
<h4id="exit-price-without-orderbook-enabled">Exit price without Orderbook enabled<aclass="headerlink"href="#exit-price-without-orderbook-enabled"title="Permanent link">¶</a></h4>
<p>The following section uses <code>side</code> as the configured <code>exit_pricing.price_side</code> (defaults to <code>"ask"</code>).</p>
<p>When not using orderbook (<code>exit_pricing.use_order_book=False</code>), Freqtrade uses the best <code>side</code> price from the ticker if it's above the <code>last</code> traded price from the ticker. Otherwise (when the <code>side</code> price is below the <code>last</code> price), it calculates a rate between <code>side</code> and <code>last</code> price based on <code>exit_pricing.price_last_balance</code>.</p>
<p>The <code>exit_pricing.price_last_balance</code> configuration parameter controls this. A value of <code>0.0</code> will use <code>side</code> price, while <code>1.0</code> will use the last price and values between those interpolate between <code>side</code> and last price.</p>
<h3id="market-order-pricing">Market order pricing<aclass="headerlink"href="#market-order-pricing"title="Permanent link">¶</a></h3>
<p>When using market orders, prices should be configured to use the "correct" side of the orderbook to allow realistic pricing detection.
Assuming both entry and exits are using market orders, a configuration similar to the following must be used</p>
<scriptid="__config"type="application/json">{"base":"../..","features":["content.code.annotate","search.share","content.code.copy","navigation.top","navigation.footer"],"search":"../../assets/javascripts/workers/search.07f07601.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":{"alias":true,"provider":"mike"}}</script>