Simplify calculation by reusing what's already there
This commit is contained in:
parent
e07696ee06
commit
2abea58750
@ -857,15 +857,12 @@ class LocalTrade():
|
|||||||
# Process partial exits
|
# Process partial exits
|
||||||
exit_rate = o.safe_price
|
exit_rate = o.safe_price
|
||||||
exit_amount = o.safe_amount_after_fee
|
exit_amount = o.safe_amount_after_fee
|
||||||
exit_stake_amount = exit_rate * exit_amount * (1 - self.fee_close)
|
|
||||||
profit = self.calc_profit(rate=exit_rate, amount=exit_amount, open_rate=avg_price)
|
profit = self.calc_profit(rate=exit_rate, amount=exit_amount, open_rate=avg_price)
|
||||||
if total_amount > 0:
|
if total_amount > 0:
|
||||||
# Exclude final (closing) trade
|
# Exclude final (closing) trade
|
||||||
close_profit_abs += profit
|
close_profit_abs += profit
|
||||||
if self.is_short:
|
close_profit += self.calc_profit_ratio(exit_rate, amount=exit_amount,
|
||||||
close_profit += (exit_stake_amount - profit) / exit_stake_amount - 1
|
open_rate=avg_price)
|
||||||
else:
|
|
||||||
close_profit += exit_stake_amount / (exit_stake_amount - profit) - 1
|
|
||||||
|
|
||||||
if close_profit:
|
if close_profit:
|
||||||
self.close_profit = close_profit
|
self.close_profit = close_profit
|
||||||
|
Loading…
Reference in New Issue
Block a user