mirror of
https://github.com/freqtrade/freqtrade.git
synced 2026-02-10 00:01:40 +00:00
Deployed 38f1981 to develop in en with MkDocs 1.6.1 and mike 2.1.3
This commit is contained in:
@@ -1790,7 +1790,11 @@ This will also run the <code>bot_start()</code> callback.</p>
|
||||
<li>Check timeouts for open orders.<ul>
|
||||
<li>Calls <code>check_entry_timeout()</code> strategy callback for open entry orders.</li>
|
||||
<li>Calls <code>check_exit_timeout()</code> strategy callback for open exit orders.</li>
|
||||
<li>Calls <code>adjust_entry_price()</code> strategy callback for open entry orders.</li>
|
||||
<li>Calls <code>adjust_order_price()</code> strategy callback for open orders.<ul>
|
||||
<li>Calls <code>adjust_entry_price()</code> strategy callback for open entry orders. <em>only called when <code>adjust_order_price()</code> is not implemented</em></li>
|
||||
<li>Calls <code>adjust_exit_price()</code> strategy callback for open exit orders. <em>only called when <code>adjust_order_price()</code> is not implemented</em></li>
|
||||
</ul>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
</ul>
|
||||
@@ -1798,7 +1802,7 @@ This will also run the <code>bot_start()</code> callback.</p>
|
||||
<li>Verifies existing positions and eventually places exit orders.<ul>
|
||||
<li>Considers stoploss, ROI and exit-signal, <code>custom_exit()</code> and <code>custom_stoploss()</code>.</li>
|
||||
<li>Determine exit-price based on <code>exit_pricing</code> configuration setting or by using the <code>custom_exit_price()</code> callback.</li>
|
||||
<li>Before a exit order is placed, <code>confirm_trade_exit()</code> strategy callback is called.</li>
|
||||
<li>Before an exit order is placed, <code>confirm_trade_exit()</code> strategy callback is called.</li>
|
||||
</ul>
|
||||
</li>
|
||||
<li>Check position adjustments for open trades if enabled by calling <code>adjust_trade_position()</code> and place additional order if required.</li>
|
||||
@@ -1822,7 +1826,11 @@ This will also run the <code>bot_start()</code> callback.</p>
|
||||
<li>Loops per candle simulating entry and exit points.<ul>
|
||||
<li>Calls <code>bot_loop_start()</code> strategy callback.</li>
|
||||
<li>Check for Order timeouts, either via the <code>unfilledtimeout</code> configuration, or via <code>check_entry_timeout()</code> / <code>check_exit_timeout()</code> strategy callbacks.</li>
|
||||
<li>Calls <code>adjust_entry_price()</code> strategy callback for open entry orders.</li>
|
||||
<li>Calls <code>adjust_order_price()</code> strategy callback for open orders.<ul>
|
||||
<li>Calls <code>adjust_entry_price()</code> strategy callback for open entry orders. <em>only called when <code>adjust_order_price()</code> is not implemented!</em></li>
|
||||
<li>Calls <code>adjust_exit_price()</code> strategy callback for open exit orders. <em>only called when <code>adjust_order_price()</code> is not implemented!</em></li>
|
||||
</ul>
|
||||
</li>
|
||||
<li>Check for trade entry signals (<code>enter_long</code> / <code>enter_short</code> columns).</li>
|
||||
<li>Confirm trade entry / exits (calls <code>confirm_trade_entry()</code> and <code>confirm_trade_exit()</code> if implemented in the strategy).</li>
|
||||
<li>Call <code>custom_entry_price()</code> (if implemented in the strategy) to determine entry price (Prices are moved to be within the opening candle).</li>
|
||||
|
||||
File diff suppressed because one or more lines are too long
@@ -849,12 +849,36 @@
|
||||
</li>
|
||||
|
||||
<li class="md-nav__item">
|
||||
<a href="#adjust-order-price" class="md-nav__link">
|
||||
<span class="md-ellipsis">
|
||||
Adjust order Price
|
||||
</span>
|
||||
</a>
|
||||
|
||||
<nav class="md-nav" aria-label="Adjust order Price">
|
||||
<ul class="md-nav__list">
|
||||
|
||||
<li class="md-nav__item">
|
||||
<a href="#adjust-entry-price" class="md-nav__link">
|
||||
<span class="md-ellipsis">
|
||||
Adjust Entry Price
|
||||
</span>
|
||||
</a>
|
||||
|
||||
</li>
|
||||
|
||||
<li class="md-nav__item">
|
||||
<a href="#adjust-exit-price" class="md-nav__link">
|
||||
<span class="md-ellipsis">
|
||||
Adjust Exit Price
|
||||
</span>
|
||||
</a>
|
||||
|
||||
</li>
|
||||
|
||||
</ul>
|
||||
</nav>
|
||||
|
||||
</li>
|
||||
|
||||
<li class="md-nav__item">
|
||||
@@ -2239,12 +2263,36 @@
|
||||
</li>
|
||||
|
||||
<li class="md-nav__item">
|
||||
<a href="#adjust-order-price" class="md-nav__link">
|
||||
<span class="md-ellipsis">
|
||||
Adjust order Price
|
||||
</span>
|
||||
</a>
|
||||
|
||||
<nav class="md-nav" aria-label="Adjust order Price">
|
||||
<ul class="md-nav__list">
|
||||
|
||||
<li class="md-nav__item">
|
||||
<a href="#adjust-entry-price" class="md-nav__link">
|
||||
<span class="md-ellipsis">
|
||||
Adjust Entry Price
|
||||
</span>
|
||||
</a>
|
||||
|
||||
</li>
|
||||
|
||||
<li class="md-nav__item">
|
||||
<a href="#adjust-exit-price" class="md-nav__link">
|
||||
<span class="md-ellipsis">
|
||||
Adjust Exit Price
|
||||
</span>
|
||||
</a>
|
||||
|
||||
</li>
|
||||
|
||||
</ul>
|
||||
</nav>
|
||||
|
||||
</li>
|
||||
|
||||
<li class="md-nav__item">
|
||||
@@ -3140,22 +3188,20 @@ Regular stoploss rules still apply (cannot move down).</p>
|
||||
</ul>
|
||||
<p>The total profit for this trade was 950$ on a 3350$ investment (<code>100@8$ + 100@9$ + 150@11$</code>). As such - the final relative profit is 28.35% (<code>950 / 3350</code>).</p>
|
||||
</details>
|
||||
<h2 id="adjust-entry-price">Adjust Entry Price<a class="headerlink" href="#adjust-entry-price" title="Permanent link">¶</a></h2>
|
||||
<p>The <code>adjust_entry_price()</code> callback may be used by strategy developer to refresh/replace limit orders upon arrival of new candles.<br />
|
||||
<h2 id="adjust-order-price">Adjust order Price<a class="headerlink" href="#adjust-order-price" title="Permanent link">¶</a></h2>
|
||||
<p>The <code>adjust_order_price()</code> callback may be used by strategy developer to refresh/replace limit orders upon arrival of new candles.<br />
|
||||
This callback is called once every iteration unless the order has been (re)placed within the current candle - limiting the maximum (re)placement of each order to once per candle.
|
||||
This also means that the first call will be at the start of the next candle after the initial order was placed.</p>
|
||||
<p>Be aware that <code>custom_entry_price()</code> is still the one dictating initial entry limit order price target at the time of entry trigger.</p>
|
||||
<p>Be aware that <code>custom_entry_price()</code>/<code>custom_exit_price()</code> is still the one dictating initial limit order price target at the time of the signal.</p>
|
||||
<p>Orders can be cancelled out of this callback by returning <code>None</code>.</p>
|
||||
<p>Returning <code>current_order_rate</code> will keep the order on the exchange "as is".
|
||||
Returning any other price will cancel the existing order, and replace it with a new order.</p>
|
||||
<p>The trade open-date (<code>trade.open_date_utc</code>) will remain at the time of the very first order placed.
|
||||
Please make sure to be aware of this - and eventually adjust your logic in other callbacks to account for this, and use the date of the first filled order instead.</p>
|
||||
<p>If the cancellation of the original order fails, then the order will not be replaced - though the order will most likely have been canceled on exchange. Having this happen on initial entries will result in the deletion of the order, while on position adjustment orders, it'll result in the trade size remaining as is.<br />
|
||||
If the order has been partially filled, the order will not be replaced. You can however use <a href="#adjust-trade-position"><code>adjust_trade_position()</code></a> to adjust the trade size to the full, expected position size, should this be necessary / desired.</p>
|
||||
If the order has been partially filled, the order will not be replaced. You can however use <a href="#adjust-trade-position"><code>adjust_trade_position()</code></a> to adjust the trade size to the expected position size, should this be necessary / desired.</p>
|
||||
<div class="admonition warning">
|
||||
<p class="admonition-title">Regular timeout</p>
|
||||
<p>Entry <code>unfilledtimeout</code> mechanism (as well as <code>check_entry_timeout()</code>) takes precedence over this.
|
||||
Entry Orders that are cancelled via the above methods will not have this callback called. Be sure to update timeout values to match your expectations.</p>
|
||||
<p>Entry <code>unfilledtimeout</code> mechanism (as well as <code>check_entry_timeout()</code>/<code>check_exit_timeout()</code>) takes precedence over this callback.
|
||||
Orders that are cancelled via the above methods will not have this callback called. Be sure to update timeout values to match your expectations.</p>
|
||||
</div>
|
||||
<div class="highlight"><pre><span></span><code><span class="c1"># Default imports</span>
|
||||
|
||||
@@ -3163,14 +3209,26 @@ Entry Orders that are cancelled via the above methods will not have this callbac
|
||||
|
||||
<span class="c1"># ... populate_* methods</span>
|
||||
|
||||
<span class="k">def</span><span class="w"> </span><span class="nf">adjust_entry_price</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">trade</span><span class="p">:</span> <span class="n">Trade</span><span class="p">,</span> <span class="n">order</span><span class="p">:</span> <span class="n">Order</span> <span class="o">|</span> <span class="kc">None</span><span class="p">,</span> <span class="n">pair</span><span class="p">:</span> <span class="nb">str</span><span class="p">,</span>
|
||||
<span class="n">current_time</span><span class="p">:</span> <span class="n">datetime</span><span class="p">,</span> <span class="n">proposed_rate</span><span class="p">:</span> <span class="nb">float</span><span class="p">,</span> <span class="n">current_order_rate</span><span class="p">:</span> <span class="nb">float</span><span class="p">,</span>
|
||||
<span class="n">entry_tag</span><span class="p">:</span> <span class="nb">str</span> <span class="o">|</span> <span class="kc">None</span><span class="p">,</span> <span class="n">side</span><span class="p">:</span> <span class="nb">str</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">)</span> <span class="o">-></span> <span class="nb">float</span><span class="p">:</span>
|
||||
<span class="k">def</span><span class="w"> </span><span class="nf">adjust_order_price</span><span class="p">(</span>
|
||||
<span class="bp">self</span><span class="p">,</span>
|
||||
<span class="n">trade</span><span class="p">:</span> <span class="n">Trade</span><span class="p">,</span>
|
||||
<span class="n">order</span><span class="p">:</span> <span class="n">Order</span> <span class="o">|</span> <span class="kc">None</span><span class="p">,</span>
|
||||
<span class="n">pair</span><span class="p">:</span> <span class="nb">str</span><span class="p">,</span>
|
||||
<span class="n">current_time</span><span class="p">:</span> <span class="n">datetime</span><span class="p">,</span>
|
||||
<span class="n">proposed_rate</span><span class="p">:</span> <span class="nb">float</span><span class="p">,</span>
|
||||
<span class="n">current_order_rate</span><span class="p">:</span> <span class="nb">float</span><span class="p">,</span>
|
||||
<span class="n">entry_tag</span><span class="p">:</span> <span class="nb">str</span> <span class="o">|</span> <span class="kc">None</span><span class="p">,</span>
|
||||
<span class="n">side</span><span class="p">:</span> <span class="nb">str</span><span class="p">,</span>
|
||||
<span class="n">is_entry</span><span class="p">:</span> <span class="nb">bool</span><span class="p">,</span>
|
||||
<span class="o">**</span><span class="n">kwargs</span><span class="p">,</span>
|
||||
<span class="p">)</span> <span class="o">-></span> <span class="nb">float</span><span class="p">:</span>
|
||||
<span class="w"> </span><span class="sd">"""</span>
|
||||
<span class="sd"> Entry price re-adjustment logic, returning the user desired limit price.</span>
|
||||
<span class="sd"> Exit and entry order price re-adjustment logic, returning the user desired limit price.</span>
|
||||
<span class="sd"> This only executes when a order was already placed, still open (unfilled fully or partially)</span>
|
||||
<span class="sd"> and not timed out on subsequent candles after entry trigger.</span>
|
||||
|
||||
<span class="sd"> For full documentation please go to https://www.freqtrade.io/en/latest/strategy-callbacks/</span>
|
||||
|
||||
<span class="sd"> When not implemented by a strategy, returns current_order_rate as default.</span>
|
||||
<span class="sd"> If current_order_rate is returned then the existing order is maintained.</span>
|
||||
<span class="sd"> If None is returned then order gets canceled but not replaced by a new one.</span>
|
||||
@@ -3182,14 +3240,16 @@ Entry Orders that are cancelled via the above methods will not have this callbac
|
||||
<span class="sd"> :param proposed_rate: Rate, calculated based on pricing settings in entry_pricing.</span>
|
||||
<span class="sd"> :param current_order_rate: Rate of the existing order in place.</span>
|
||||
<span class="sd"> :param entry_tag: Optional entry_tag (buy_tag) if provided with the buy signal.</span>
|
||||
<span class="sd"> :param side: "long" or "short" - indicating the direction of the proposed trade</span>
|
||||
<span class="sd"> :param side: 'long' or 'short' - indicating the direction of the proposed trade</span>
|
||||
<span class="sd"> :param is_entry: True if the order is an entry order, False if it's an exit order.</span>
|
||||
<span class="sd"> :param **kwargs: Ensure to keep this here so updates to this won't break your strategy.</span>
|
||||
<span class="sd"> :return float: New entry price value if provided</span>
|
||||
|
||||
<span class="sd"> """</span>
|
||||
<span class="c1"># Limit orders to use and follow SMA200 as price target for the first 10 minutes since entry trigger for BTC/USDT pair.</span>
|
||||
|
||||
<span class="c1"># Limit entry orders to use and follow SMA200 as price target for the first 10 minutes since entry trigger for BTC/USDT pair.</span>
|
||||
<span class="k">if</span> <span class="p">(</span>
|
||||
<span class="n">pair</span> <span class="o">==</span> <span class="s2">"BTC/USDT"</span>
|
||||
<span class="n">is_entry</span>
|
||||
<span class="ow">and</span> <span class="n">pair</span> <span class="o">==</span> <span class="s2">"BTC/USDT"</span>
|
||||
<span class="ow">and</span> <span class="n">entry_tag</span> <span class="o">==</span> <span class="s2">"long_sma200"</span>
|
||||
<span class="ow">and</span> <span class="n">side</span> <span class="o">==</span> <span class="s2">"long"</span>
|
||||
<span class="ow">and</span> <span class="p">(</span><span class="n">current_time</span> <span class="o">-</span> <span class="n">timedelta</span><span class="p">(</span><span class="n">minutes</span><span class="o">=</span><span class="mi">10</span><span class="p">))</span> <span class="o"><=</span> <span class="n">trade</span><span class="o">.</span><span class="n">open_date_utc</span>
|
||||
@@ -3205,6 +3265,22 @@ Entry Orders that are cancelled via the above methods will not have this callbac
|
||||
<span class="c1"># default: maintain existing order</span>
|
||||
<span class="k">return</span> <span class="n">current_order_rate</span>
|
||||
</code></pre></div>
|
||||
<div class="admonition danger">
|
||||
<p class="admonition-title">Incompatibility with <code>adjust_*_price()</code></p>
|
||||
<p>If you have both <code>adjust_order_price()</code> and <code>adjust_entry_price()</code>/<code>adjust_exit_price()</code> implemented, only <code>adjust_order_price()</code> will be used.
|
||||
If you need to adjust entry/exit prices, you can either implement the logic in <code>adjust_order_price()</code>, or use the split <code>adjust_entry_price()</code> / <code>adjust_exit_price()</code> callbacks, but not both.
|
||||
Mixing these is not supported and will raise an error during bot startup.</p>
|
||||
</div>
|
||||
<h3 id="adjust-entry-price">Adjust Entry Price<a class="headerlink" href="#adjust-entry-price" title="Permanent link">¶</a></h3>
|
||||
<p>The <code>adjust_entry_price()</code> callback may be used by strategy developer to refresh/replace entry limit orders upon arrival.
|
||||
It's a sub-set of <code>adjust_order_price()</code> and is called only for entry orders.
|
||||
All remaining behavior is identical to <code>adjust_order_price()</code>.</p>
|
||||
<p>The trade open-date (<code>trade.open_date_utc</code>) will remain at the time of the very first order placed.
|
||||
Please make sure to be aware of this - and eventually adjust your logic in other callbacks to account for this, and use the date of the first filled order instead.</p>
|
||||
<h3 id="adjust-exit-price">Adjust Exit Price<a class="headerlink" href="#adjust-exit-price" title="Permanent link">¶</a></h3>
|
||||
<p>The <code>adjust_exit_price()</code> callback may be used by strategy developer to refresh/replace exit limit orders upon arrival.
|
||||
It's a sub-set of <code>adjust_order_price()</code> and is called only for exit orders.
|
||||
All remaining behavior is identical to <code>adjust_order_price()</code>.</p>
|
||||
<h2 id="leverage-callback">Leverage Callback<a class="headerlink" href="#leverage-callback" title="Permanent link">¶</a></h2>
|
||||
<p>When trading in markets that allow leverage, this method must return the desired Leverage (Defaults to 1 -> No leverage).</p>
|
||||
<p>Assuming a capital of 500USDT, a trade with leverage=3 would result in a position with 500 x 3 = 1500 USDT.</p>
|
||||
|
||||
Reference in New Issue
Block a user