Deployed 8dfbf34 to develop in en with MkDocs 1.6.1 and mike 2.1.3

This commit is contained in:
github-actions[bot]
2024-12-14 13:13:37 +00:00
parent 8083ccff12
commit cd3e1ef6c7
2 changed files with 17 additions and 12 deletions

File diff suppressed because one or more lines are too long

View File

@@ -2927,11 +2927,27 @@ For performance reasons, it's disabled by default and freqtrade will show a warn
<p>Position adjustments will always be applied in the direction of the trade, so a positive value will always increase your position (negative values will decrease your position), no matter if it's a long or short trade.
Adjustment orders can be assigned with a tag by returning a 2 element Tuple, with the first element being the adjustment amount, and the 2<sup>nd</sup> element the tag (e.g. <code>return 250, "increase_favorable_conditions"</code>).</p>
<p>Modifications to leverage are not possible, and the stake-amount returned is assumed to be before applying leverage.</p>
<div class="admonition danger">
<p class="admonition-title">Loose Logic</p>
<p>On dry and live run, this function will be called every <code>throttle_process_secs</code> (default to 5s). If you have a loose logic, for example your logic for extra entry is only to check RSI of last candle is below 30, then when such condition fulfilled, your bot will do extra re-entry every 5 secs until either it run out of money, it hit the <code>max_position_adjustment</code> limit, or a new candle with RSI more than 30 arrived.</p>
<p>Same thing also can happen with partial exit. So be sure to have a strict logic and/or check for the last filled order.</p>
</div>
<div class="admonition warning">
<p class="admonition-title">Backtesting</p>
<p>During backtesting this callback is called for each candle in <code>timeframe</code> or <code>timeframe_detail</code>, so run-time performance will be affected.
This can also cause deviating results between live and backtesting, since backtesting can adjust the trade only once per candle, whereas live could adjust the trade multiple times per candle.</p>
</div>
<h3 id="increase-position">Increase position<a class="headerlink" href="#increase-position" title="Permanent link">&para;</a></h3>
<p>The strategy is expected to return a positive <strong>stake_amount</strong> (in stake currency) between <code>min_stake</code> and <code>max_stake</code> if and when an additional entry order should be made (position is increased -&gt; buy order for long trades, sell order for short trades).</p>
<p>If there are not enough funds in the wallet (the return value is above <code>max_stake</code>) then the signal will be ignored.
<code>max_entry_position_adjustment</code> property is used to limit the number of additional entries per trade (on top of the first entry order) that the bot can execute. By default, the value is -1 which means the bot have no limit on number of adjustment entries.</p>
<p>Additional entries are ignored once you have reached the maximum amount of extra entries that you have set on <code>max_entry_position_adjustment</code>, but the callback is called anyway looking for partial exits.</p>
<div class="admonition note">
<p class="admonition-title">About stake size</p>
<p>Using fixed stake size means it will be the amount used for the first order, just like without position adjustment.
If you wish to buy additional orders with DCA, then make sure to leave enough funds in the wallet for that.
Using <code>"unlimited"</code> stake amount with DCA orders requires you to also implement the <code>custom_stake_amount()</code> callback to avoid allocating all funds to the initial order.</p>
</div>
<h3 id="decrease-position">Decrease position<a class="headerlink" href="#decrease-position" title="Permanent link">&para;</a></h3>
<p>The strategy is expected to return a negative stake_amount (in stake currency) for a partial exit.
Returning the full owned stake at that point (<code>-trade.stake_amount</code>) results in a full exit.<br />
@@ -2939,12 +2955,6 @@ Returning a value more than the above (so remaining stake_amount would become ne
<p>For a partial exit, it's important to know that the formula used to calculate the amount of the coin for the partial exit order is <code>amount to be exited partially = negative_stake_amount * trade.amount / trade.stake_amount</code>, where <code>negative_stake_amount</code> is the value returned from the <code>adjust_trade_position</code> function. As seen in the formula, the formula don't care about current profit/loss of the position. It only care about <code>trade.amount</code> and <code>trade.stake_amount</code> which aren't affected by the price movement at all.</p>
<p>For example, let's say you buy 2 SHITCOIN/USDT at open rate of 50, which means the trade's stake amount is 100 USDT. Now the price has rose to 200 and you want to sell half of it. In that case, you have to return -50% of trade.stake_amount (0.5 * 100 USDT) which equals to -50. The bot will calculate the amount it needed to sell, which is <code>50 * 2 / 100</code> which equals 1 SHITCOIN/USDT. If you return -200 (50% of 2 * 200), the bot will ignore it since trade.stake_amount is only 100 USDT but you asked it to sell 200 USDT which means you are asking it to sell 4 SHITCOIN/USDT.</p>
<p>Back to the example above, since current rate is 200, the current USDT value of your trade is now 400 USDT. Let's say you want to partially sell 100 USDT to take out the initial investment and leave the profit in the trade in hope of the price keep rising. In that case, you have to do different approach. First, you need to calculate the exact amount you needed to sell. In this case, since you want to sell 100 USDT worth based of current rate, the exact amount you need to partially sell is <code>100 * 2 / 400</code> which equals 0.5 SHITCOIN/USDT. Since we know now the exact amount we want to sell (0.5), the value you need to return in the <code>adjust_trade_position</code> function is <code>-amount to be exited partially * trade.stake_amount / trade.amount</code>, which equals -25. The bot will sell 0.5 SHITCOIN/USDT, keeping 1.5 in trade. You will receive 100 USDT from the partial exit.</p>
<div class="admonition note">
<p class="admonition-title">About stake size</p>
<p>Using fixed stake size means it will be the amount used for the first order, just like without position adjustment.
If you wish to buy additional orders with DCA, then make sure to leave enough funds in the wallet for that.
Using <code>"unlimited"</code> stake amount with DCA orders requires you to also implement the <code>custom_stake_amount()</code> callback to avoid allocating all funds to the initial order.</p>
</div>
<div class="admonition warning">
<p class="admonition-title">Stoploss calculation</p>
<p>Stoploss is still calculated from the initial opening price, not averaged price.
@@ -2952,11 +2962,6 @@ Regular stoploss rules still apply (cannot move down).</p>
<p>While <code>/stopentry</code> command stops the bot from entering new trades, the position adjustment feature will continue buying new orders on existing trades.</p>
</div>
<div class="admonition warning">
<p class="admonition-title">Backtesting</p>
<p>During backtesting this callback is called for each candle in <code>timeframe</code> or <code>timeframe_detail</code>, so run-time performance will be affected.
This can also cause deviating results between live and backtesting, since backtesting can adjust the trade only once per candle, whereas live could adjust the trade multiple times per candle.</p>
</div>
<div class="admonition warning">
<p class="admonition-title">Performance with many position adjustments</p>
<p>Position adjustments can be a good approach to increase a strategy's output - but it can also have drawbacks if using this feature extensively.<br />
Each of the orders will be attached to the trade object for the duration of the trade - hence increasing memory usage.