Update setting to max_entry_position_adjustment

This commit is contained in:
Matthias
2022-01-27 16:57:50 +01:00
parent 0fa7986369
commit 002226f5fd
11 changed files with 23 additions and 22 deletions

View File

@@ -373,7 +373,7 @@ CONF_SCHEMA = {
'default': 'jsongz'
},
'position_adjustment_enable': {'type': 'boolean', 'default': False},
'max_buy_position_adjustment': {'type': ['integer', 'number'], 'minimum': -1},
'max_entry_position_adjustment': {'type': ['integer', 'number'], 'minimum': -1},
},
'definitions': {
'exchange': {

View File

@@ -471,13 +471,13 @@ 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:
if self.strategy.max_entry_position_adjustment > -1:
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.")
if count_of_buys > self.strategy.max_entry_position_adjustment:
logger.debug(f"Max adjustment entries for {trade.pair} has been reached.")
return
else:
logger.debug("Max adjustment buy is set to unlimited.")
logger.debug("Max adjustment entries 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

@@ -382,9 +382,9 @@ class Backtesting:
# Check if we need to adjust our current positions
if self.strategy.position_adjustment_enable:
check_adjust_buy = True
if self.strategy.max_buy_position_adjustment > -1:
if self.strategy.max_entry_position_adjustment > -1:
count_of_buys = trade.nr_of_successful_buys
check_adjust_buy = (count_of_buys <= self.strategy.max_buy_position_adjustment)
check_adjust_buy = (count_of_buys <= self.strategy.max_entry_position_adjustment)
if check_adjust_buy:
trade = self._get_adjust_trade_entry_for_candle(trade, sell_row)

View File

@@ -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_entry_position_adjustment", -1),
]
for attribute, default in attributes:
StrategyResolver._override_attribute_helper(strategy, config,

View File

@@ -174,7 +174,7 @@ class ShowConfig(BaseModel):
state: str
runmode: str
position_adjustment_enable: bool
max_buy_position_adjustment: int
max_entry_position_adjustment: int
class TradeSchema(BaseModel):

View File

@@ -138,9 +138,10 @@ class RPC:
'state': str(botstate),
'runmode': config['runmode'].value,
'position_adjustment_enable': config.get('position_adjustment_enable', False),
'max_buy_position_adjustment': (config['max_buy_position_adjustment']
if config['max_buy_position_adjustment'] != float('inf')
else -1)
'max_entry_position_adjustment': (
config['max_entry_position_adjustment']
if config['max_entry_position_adjustment'] != float('inf')
else -1)
}
return val
@@ -251,7 +252,7 @@ class RPC:
profit_str
]
if self._config.get('position_adjustment_enable', False):
max_buy = self._config['max_buy_position_adjustment'] + 1
max_buy = self._config['max_entry_position_adjustment'] + 1
filled_buys = trade.nr_of_successful_buys
detail_trade.append(f"{filled_buys}/{max_buy}")
trades_list.append(detail_trade)

View File

@@ -1350,7 +1350,7 @@ class Telegram(RPCHandler):
if val['position_adjustment_enable']:
pa_info = (
f"*Position adjustment:* On\n"
f"*Max buy position adjustment:* `{val['max_buy_position_adjustment']}`\n"
f"*Max enter position adjustment:* `{val['max_entry_position_adjustment']}`\n"
)
else:
pa_info = "*Position adjustment:* Off\n"

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_entry_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