add max_buy_position_adjustment as attribute

This commit is contained in:
Stefano Ariestasia 2022-01-19 16:50:13 +09:00
parent 301b2e8a0f
commit 5525fdae1a
4 changed files with 7 additions and 3 deletions

View File

@ -173,6 +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
### Parameters in the strategy
@ -198,6 +199,7 @@ Values set in the configuration file always overwrite values set in the strategy
* `ignore_roi_if_buy_signal`
* `ignore_buying_expired_candle_after`
* `position_adjustment_enable`
* `max_buy_position_adjustment`
### Configuring amount per trade

View File

@ -611,7 +611,7 @@ class DigDeeperStrategy(IStrategy):
# ... populate_* methods
# Example specific variables
max_dca_orders = 3
max_buy_position_adjustment = 3
# This number is explained a bit further down
max_dca_multiplier = 5.5
@ -663,7 +663,7 @@ class DigDeeperStrategy(IStrategy):
# Total stake for this trade would be 1 + 1.25 + 1.5 + 1.75 = 5.5x of the initial allowed stake.
# That is why max_dca_multiplier is 5.5
# Hope you have a deep wallet!
if 0 < count_of_buys <= self.max_dca_orders:
if 0 < count_of_buys <= self.max_buy_position_adjustment:
try:
# This returns first order stake size
stake_amount = filled_buys[0].cost

View File

@ -97,7 +97,8 @@ class StrategyResolver(IResolver):
("sell_profit_offset", 0.0),
("disable_dataframe_checks", False),
("ignore_buying_expired_candle_after", 0),
("position_adjustment_enable", False)
("position_adjustment_enable", False),
("max_buy_position_adjustment", 1)
]
for attribute, default in attributes:
StrategyResolver._override_attribute_helper(strategy, config,

View File

@ -108,6 +108,7 @@ class IStrategy(ABC, HyperStrategyMixin):
# Position adjustment is disabled by default
position_adjustment_enable: bool = False
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