Small cleanups
This commit is contained in:
parent
05ca4fed06
commit
a8218feea8
@ -1540,6 +1540,7 @@ class FreqtradeBot(LoggingMixin):
|
|||||||
profit_rate = order.safe_price
|
profit_rate = order.safe_price
|
||||||
|
|
||||||
if not fill:
|
if not fill:
|
||||||
|
# TODO: this call is wrong here.
|
||||||
trade.process_exit_sub_trade(order, is_closed=False)
|
trade.process_exit_sub_trade(order, is_closed=False)
|
||||||
|
|
||||||
profit_ratio = trade.close_profit
|
profit_ratio = trade.close_profit
|
||||||
|
@ -632,6 +632,9 @@ class LocalTrade():
|
|||||||
Trade.commit()
|
Trade.commit()
|
||||||
|
|
||||||
def process_exit_sub_trade(self, order: Order, is_closed: bool = True) -> None:
|
def process_exit_sub_trade(self, order: Order, is_closed: bool = True) -> None:
|
||||||
|
"""
|
||||||
|
Recalculate trade amount and realized profit after partial exit
|
||||||
|
"""
|
||||||
exit_amount = order.safe_amount_after_fee
|
exit_amount = order.safe_amount_after_fee
|
||||||
exit_rate = order.safe_price
|
exit_rate = order.safe_price
|
||||||
exit_stake_amount = exit_rate * exit_amount * (1 - self.fee_close)
|
exit_stake_amount = exit_rate * exit_amount * (1 - self.fee_close)
|
||||||
@ -642,10 +645,7 @@ class LocalTrade():
|
|||||||
self.amount -= exit_amount
|
self.amount -= exit_amount
|
||||||
self.stake_amount = self.open_rate * self.amount
|
self.stake_amount = self.open_rate * self.amount
|
||||||
self.realized_profit += profit
|
self.realized_profit += profit
|
||||||
logger.info(
|
# logger.info(f"Processed exit sub trade for {self}")
|
||||||
'Processed exit sub trade for %s',
|
|
||||||
self
|
|
||||||
)
|
|
||||||
self.close_profit_abs = profit
|
self.close_profit_abs = profit
|
||||||
if self.is_short:
|
if self.is_short:
|
||||||
self.close_profit = (exit_stake_amount - profit) / exit_stake_amount - 1
|
self.close_profit = (exit_stake_amount - profit) / exit_stake_amount - 1
|
||||||
|
@ -243,7 +243,7 @@ def check_exit_timeout(self, pair: str, trade: 'Trade', order: 'Order',
|
|||||||
"""
|
"""
|
||||||
return False
|
return False
|
||||||
|
|
||||||
def adjust_trade_position(self, trade: Trade, current_time: datetime,
|
def adjust_trade_position(self, trade: 'Trade', current_time: datetime,
|
||||||
current_rate: float, current_profit: float,
|
current_rate: float, current_profit: float,
|
||||||
min_stake: Optional[float], max_stake: float,
|
min_stake: Optional[float], max_stake: float,
|
||||||
current_entry_rate: float, current_exit_rate: float,
|
current_entry_rate: float, current_exit_rate: float,
|
||||||
|
@ -5860,4 +5860,4 @@ def test_check_and_call_adjust_trade_position(mocker, default_conf_usdt, fee, ca
|
|||||||
|
|
||||||
freqtrade.strategy.adjust_trade_position = MagicMock(return_value=-10)
|
freqtrade.strategy.adjust_trade_position = MagicMock(return_value=-10)
|
||||||
freqtrade.process_open_trade_positions()
|
freqtrade.process_open_trade_positions()
|
||||||
assert log_has_re(r"Processed exit sub trade for .*", caplog)
|
# assert log_has_re(r"Processed exit sub trade for .*", caplog)
|
||||||
|
Loading…
Reference in New Issue
Block a user