diff --git a/docs/configuration.md b/docs/configuration.md index 8723f51da..aa02a95a5 100644 --- a/docs/configuration.md +++ b/docs/configuration.md @@ -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.
*Defaults to `json`*.
**Datatype:** String | `dataformat_trades` | Data format to use to store historical trades data.
*Defaults to `jsongz`*.
**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).
[Strategy Override](#parameters-in-the-strategy).
*Defaults to `false`.*
**Datatype:** Boolean -| `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).
[Strategy Override](#parameters-in-the-strategy).
*Defaults to `-1`.*
**Datatype:** Positive Integer or -1 +| `max_buy_position_adjustment` | Maximum additional buy(s) for each open trade on top of the first buy. Set it to `-1` for unlimited additional buys. [More information here](strategy-callbacks.md#adjust-trade-position).
[Strategy Override](#parameters-in-the-strategy).
*Defaults to `-1`.*
**Datatype:** Positive Integer or -1 ### Parameters in the strategy diff --git a/docs/strategy-callbacks.md b/docs/strategy-callbacks.md index 8ff4cc095..a06e76454 100644 --- a/docs/strategy-callbacks.md +++ b/docs/strategy-callbacks.md @@ -654,6 +654,7 @@ class DigDeeperStrategy(IStrategy): if last_candle['close'] < previous_candle['close']: return None + count_of_buys = trade.nr_of_successful_buys # Allow up to 3 additional increasingly larger buys (4 in total) # Initial buy is 1x # If that falls to -5% profit, we buy 1.25x more, average profit should increase to roughly -2.2% diff --git a/freqtrade/freqtradebot.py b/freqtrade/freqtradebot.py index f2f04fb08..6a8dde1f6 100644 --- a/freqtrade/freqtradebot.py +++ b/freqtrade/freqtradebot.py @@ -474,8 +474,7 @@ class FreqtradeBot(LoggingMixin): Once that completes, the existing trade is modified to match new data. """ if self.strategy.max_buy_position_adjustment > -1: - filled_buys = trade.select_filled_orders('buy') - count_of_buys = len(filled_buys) + count_of_buys = trade.nr_of_successful_buys if count_of_buys > self.strategy.max_buy_position_adjustment: logger.debug(f"Max adjustment buy for {trade.pair} has been reached.") return diff --git a/freqtrade/optimize/backtesting.py b/freqtrade/optimize/backtesting.py index b9023c435..c3c16477b 100644 --- a/freqtrade/optimize/backtesting.py +++ b/freqtrade/optimize/backtesting.py @@ -383,8 +383,7 @@ class Backtesting: if self.strategy.position_adjustment_enable: check_adjust_buy = True if self.strategy.max_buy_position_adjustment > -1: - filled_buys = trade.select_filled_orders('buy') - count_of_buys = len(filled_buys) + count_of_buys = trade.nr_of_successful_buys check_adjust_buy = (count_of_buys <= self.strategy.max_buy_position_adjustment) if check_adjust_buy: trade = self._get_adjust_trade_entry_for_candle(trade, sell_row) diff --git a/freqtrade/resolvers/strategy_resolver.py b/freqtrade/resolvers/strategy_resolver.py index 82e3ad938..f48a42f11 100644 --- a/freqtrade/resolvers/strategy_resolver.py +++ b/freqtrade/resolvers/strategy_resolver.py @@ -98,7 +98,7 @@ class StrategyResolver(IResolver): ("disable_dataframe_checks", False), ("ignore_buying_expired_candle_after", 0), ("position_adjustment_enable", False), - ("max_buy_position_adjustment", -1) + ("max_buy_position_adjustment", -1), ] for attribute, default in attributes: StrategyResolver._override_attribute_helper(strategy, config, diff --git a/freqtrade/rpc/rpc.py b/freqtrade/rpc/rpc.py index 1882da6e6..0081e7a07 100644 --- a/freqtrade/rpc/rpc.py +++ b/freqtrade/rpc/rpc.py @@ -252,8 +252,8 @@ class RPC: ] if self._config.get('position_adjustment_enable', False): max_buy = self._config['max_buy_position_adjustment'] + 1 - filled_buys = trade.select_filled_orders('buy') - detail_trade.append(f"{len(filled_buys)}/{max_buy}") + filled_buys = trade.nr_of_successful_buys + detail_trade.append(f"{filled_buys}/{max_buy}") trades_list.append(detail_trade) profitcol = "Profit" if self._fiat_converter: