mirror of
https://github.com/freqtrade/freqtrade.git
synced 2026-01-20 14:00:38 +00:00
properly account for fee when assigning order.cost in backtesting
(although it's not relevant for operations, it shouldn't be obivously wrong). closes #11003
This commit is contained in:
@@ -1139,7 +1139,7 @@ class Backtesting:
|
||||
amount=amount,
|
||||
filled=0,
|
||||
remaining=amount,
|
||||
cost=amount * propose_rate + trade.fee_open,
|
||||
cost=amount * propose_rate * (1 + self.fee),
|
||||
ft_order_tag=entry_tag,
|
||||
)
|
||||
order._trade_bt = trade
|
||||
|
||||
@@ -632,7 +632,7 @@ def test_backtest__enter_trade_futures(default_conf_usdt, fee, mocker) -> None:
|
||||
trade = backtesting._enter_trade(pair, row=row, direction="short")
|
||||
assert pytest.approx(trade.liquidation_price) == 0.11787191
|
||||
assert pytest.approx(trade.orders[0].cost) == (
|
||||
trade.stake_amount * trade.leverage + trade.fee_open
|
||||
trade.stake_amount * trade.leverage * (1 + fee.return_value)
|
||||
)
|
||||
assert pytest.approx(trade.orders[-1].stake_amount) == trade.stake_amount
|
||||
|
||||
|
||||
Reference in New Issue
Block a user