This commit is contained in:
Stefano Ariestasia 2022-01-19 21:58:24 +09:00
parent 5525fdae1a
commit ac93eea585
3 changed files with 12 additions and 2 deletions

View File

@ -173,7 +173,7 @@ Mandatory parameters are marked as **Required**, which means that they are requi
| `dataformat_ohlcv` | Data format to use to store historical candle (OHLCV) data. <br> *Defaults to `json`*. <br> **Datatype:** String
| `dataformat_trades` | Data format to use to store historical trades data. <br> *Defaults to `jsongz`*. <br> **Datatype:** String
| `position_adjustment_enable` | Enables the strategy to use position adjustments (additional buys or sells). [More information here](strategy-callbacks.md#adjust-trade-position). <br> [Strategy Override](#parameters-in-the-strategy). <br>*Defaults to `false`.*<br> **Datatype:** Boolean
| `max_buy_position_adjustment` | Maximum additional buy(s) for each open trades on top of the first buy. [More information here](strategy-callbacks.md#adjust-trade-position). <br> [Strategy Override](#parameters-in-the-strategy). <br>*Defaults to `1`.*<br> **Datatype:** Positive Integer
| `max_buy_position_adjustment` | Maximum additional buy(s) for each open trades on top of the first buy. Set it to `-1` for unlimited additional buys. [More information here](strategy-callbacks.md#adjust-trade-position). <br> [Strategy Override](#parameters-in-the-strategy). <br>*Defaults to `-1`.*<br> **Datatype:** Positive Integer or -1
### Parameters in the strategy

View File

@ -473,6 +473,16 @@ class FreqtradeBot(LoggingMixin):
If the strategy triggers the adjustment, a new order gets issued.
Once that completes, the existing trade is modified to match new data.
"""
if self.strategy.max_buy_position_adjustment > -1:
logger.info(f"Max adjustment buy is set to {self.strategy.max_buy_position_adsjutment}.")
filled_buys = trade.select_filled_orders('buy')
count_of_buys = len(filled_buys)
if count_of_buys > self.strategy.max_buy_position_adjustment:
logger.info(f"Max adjustment buy for {trade.pair} has been reached.")
return
else:
logger.info(f"Max adjustment buy is set to unlimited.")
current_rate = self.exchange.get_rate(trade.pair, refresh=True, side="buy")
current_profit = trade.calc_profit_ratio(current_rate)

View File

@ -108,7 +108,7 @@ class IStrategy(ABC, HyperStrategyMixin):
# Position adjustment is disabled by default
position_adjustment_enable: bool = False
max_buy_position_adjustment: int = 1
max_buy_position_adjustment: int = -1
# Number of seconds after which the candle will no longer result in a buy on expired candles
ignore_buying_expired_candle_after: int = 0