Combine stake_amount recalculation

This commit is contained in:
Matthias
2022-03-20 20:00:30 +01:00
parent f01c9cd28c
commit 4fd0681265
4 changed files with 21 additions and 13 deletions

View File

@@ -663,13 +663,11 @@ class FreqtradeBot(LoggingMixin):
)
amount = safe_value_fallback(order, 'filled', 'amount')
enter_limit_filled_price = safe_value_fallback(order, 'average', 'price')
stake_amount = amount * enter_limit_filled_price / leverage
# in case of FOK the order may be filled immediately and fully
elif order_status == 'closed':
amount = safe_value_fallback(order, 'filled', 'amount')
enter_limit_filled_price = safe_value_fallback(order, 'average', 'price')
stake_amount = amount * enter_limit_filled_price / leverage
# TODO: this might be unnecessary, as we're calling it in update_trade_state.
isolated_liq = self.exchange.get_liquidation_price(

View File

@@ -847,7 +847,10 @@ class LocalTrade():
def recalc_trade_from_orders(self):
# We need at least 2 entry orders for averaging amounts and rates.
# TODO: this condition could probably be removed
if len(self.select_filled_orders(self.enter_side)) < 2:
self.stake_amount = self.amount * self.open_rate / self.leverage
# Just in case, still recalc open trade value
self.recalc_open_trade_value()
return