updated requested changes in PR #6545

This commit is contained in:
மனோஜ்குமார் பழனிச்சாமி
2022-03-26 10:44:59 +05:30
parent b640905647
commit ab7cdca68e
2 changed files with 22 additions and 14 deletions

View File

@@ -454,20 +454,27 @@ class FreqtradeBot(LoggingMixin):
Once that completes, the existing trade is modified to match new data.
"""
current_entry_rate, current_exit_rate = self.exchange.get_rates(trade.pair, True)
current_rate = current_entry_rate # backward compatibilty
current_profit = trade.calc_profit_ratio(current_rate)
min_stake_amount = self.exchange.get_min_pair_stake_amount(trade.pair,
current_rate,
self.strategy.stoploss)
max_stake_amount = self.wallets.get_available_stake_amount()
current_entry_profit = trade.calc_profit_ratio(current_entry_rate)
current_exit_profit = trade.calc_profit_ratio(current_exit_rate)
min_entry_stake = self.exchange.get_min_pair_stake_amount(trade.pair,
current_entry_rate,
self.strategy.stoploss)
min_exit_stake = self.exchange.get_min_pair_stake_amount(trade.pair,
current_exit_rate,
self.strategy.stoploss)
max_stake = self.wallets.get_available_stake_amount()
logger.debug(f"Calling adjust_trade_position for pair {trade.pair}")
stake_amount = strategy_safe_wrapper(self.strategy.adjust_trade_position,
default_retval=None)(
trade=trade, current_time=datetime.now(timezone.utc), current_rate=current_rate,
current_profit=current_profit, min_stake=min_stake_amount,
max_stake=max_stake_amount, current_entry_rate=current_entry_rate,
current_exit_rate=current_exit_rate)
trade=trade, current_time=datetime.now(timezone.utc), current_rate=current_entry_rate,
current_profit=current_entry_profit, min_stake=min_entry_stake,
max_stake=max_stake,
current_entry_rate=current_entry_rate, current_exit_rate=current_exit_rate,
current_entry_profit=current_entry_profit, current_exit_profit=current_exit_profit,
min_entry_stake=min_entry_stake, min_exit_stake=min_exit_stake
)
if stake_amount is not None and stake_amount > 0.0:
# We should increase our position
@@ -484,7 +491,7 @@ class FreqtradeBot(LoggingMixin):
# We should decrease our position
# Strategy should return value as Decimal for accuracy.
amount = abs(float(Decimal(stake_amount) / Decimal(current_exit_rate)))
if trade.amount - amount < min_stake_amount:
if trade.amount - amount < min_exit_stake_amount:
logger.info('Remaining amount would be too small')
return
if amount > trade.amount: