updated requested changes in PR #6545
This commit is contained in:
parent
b640905647
commit
ab7cdca68e
@ -1139,7 +1139,7 @@ class Exchange:
|
||||
|
||||
conf_strategy = self._config.get(strat_name, {})
|
||||
|
||||
if conf_strategy.get('use_order_book', False) and ('use_order_book' in conf_strategy):
|
||||
if conf_strategy.get('use_order_book', False):
|
||||
|
||||
order_book_top = conf_strategy.get('order_book_top', 1)
|
||||
if order_book is None:
|
||||
@ -1178,14 +1178,15 @@ class Exchange:
|
||||
return rate
|
||||
|
||||
def get_rates(self, pair: str, refresh: bool) -> Tuple[float, float]:
|
||||
buy_rate = sell_rate = None
|
||||
buy_rate = None
|
||||
sell_rate = None
|
||||
if not refresh:
|
||||
buy_rate, sell_rate = self._buy_rate_cache.get(pair), self._sell_rate_cache.get(pair)
|
||||
|
||||
bid_strategy = self._config.get('bid_strategy', {})
|
||||
ask_strategy = self._config.get('ask_strategy', {})
|
||||
order_book = ticker = None
|
||||
if bid_strategy.get('use_order_book', False) and ('use_order_book' in bid_strategy):
|
||||
if bid_strategy.get('use_order_book', False):
|
||||
order_book_top = max(bid_strategy.get('order_book_top', 1),
|
||||
ask_strategy.get('order_book_top', 1))
|
||||
order_book = self.fetch_l2_order_book(pair, order_book_top)
|
||||
|
@ -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,
|
||||
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)
|
||||
max_stake_amount = self.wallets.get_available_stake_amount()
|
||||
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:
|
||||
|
Loading…
Reference in New Issue
Block a user