fix: oddly wrong fee_cost calculation

This commit is contained in:
Matthias
2024-08-12 16:45:51 +02:00
parent 6cf92c2a90
commit 7972a023ed
2 changed files with 4 additions and 4 deletions

View File

@@ -1236,7 +1236,7 @@ class LocalTrade:
self.open_rate = float(current_stake / current_amount)
self.amount = current_amount_tr
self.stake_amount = float(current_stake) / (self.leverage or 1.0)
self.fee_open_cost = self.fee_open * float(current_stake)
self.fee_open_cost = self.fee_open * float(self.max_stake_amount)
self.recalc_open_trade_value()
if self.stop_loss_pct is not None and self.open_rate is not None:
self.adjust_stop_loss(self.open_rate, self.stop_loss_pct)

View File

@@ -2571,7 +2571,7 @@ def test_recalc_trade_from_orders_ignores_bad_orders(fee, is_short):
assert trade.amount == 2 * o1_amount
assert trade.stake_amount == 2 * o1_amount
assert trade.open_rate == o1_rate
assert trade.fee_open_cost == 2 * o1_fee_cost
assert trade.fee_open_cost == trade.nr_of_successful_entries * o1_fee_cost
assert trade.open_trade_value == 2 * o1_trade_val
assert trade.nr_of_successful_entries == 2
@@ -2598,7 +2598,7 @@ def test_recalc_trade_from_orders_ignores_bad_orders(fee, is_short):
assert trade.amount == o1_amount
assert trade.stake_amount == o1_amount
assert trade.open_rate == o1_rate
assert trade.fee_open_cost == o1_fee_cost
assert trade.fee_open_cost == trade.nr_of_successful_entries * o1_fee_cost
assert trade.open_trade_value == o1_trade_val
assert trade.nr_of_successful_entries == 2
@@ -2626,7 +2626,7 @@ def test_recalc_trade_from_orders_ignores_bad_orders(fee, is_short):
assert trade.amount == 2 * o1_amount
assert trade.stake_amount == 2 * o1_amount
assert trade.open_rate == o1_rate
assert trade.fee_open_cost == 2 * o1_fee_cost
assert trade.fee_open_cost == trade.nr_of_successful_entries * o1_fee_cost
assert trade.open_trade_value == 2 * o1_trade_val
assert trade.nr_of_successful_entries == 3