Fix tests

This commit is contained in:
Matthias 2022-03-22 19:28:13 +01:00
parent 2c89da6bf7
commit 247635db79
2 changed files with 10 additions and 14 deletions

View File

@ -276,7 +276,7 @@ class FreqtradeBot(LoggingMixin):
pair=trade.pair, pair=trade.pair,
amount=trade.amount, amount=trade.amount,
is_short=trade.is_short, is_short=trade.is_short,
open_date=trade.open_date open_date=trade.open_date_utc
) )
trade.funding_fees = funding_fees trade.funding_fees = funding_fees
else: else:
@ -1358,7 +1358,7 @@ class FreqtradeBot(LoggingMixin):
pair=trade.pair, pair=trade.pair,
amount=trade.amount, amount=trade.amount,
is_short=trade.is_short, is_short=trade.is_short,
open_date=trade.open_date, open_date=trade.open_date_utc,
) )
exit_type = 'exit' exit_type = 'exit'
if sell_reason.sell_type in (SellType.STOP_LOSS, SellType.TRAILING_STOP_LOSS): if sell_reason.sell_type in (SellType.STOP_LOSS, SellType.TRAILING_STOP_LOSS):

View File

@ -5034,9 +5034,9 @@ def test_update_funding_fees(
default_conf['trading_mode'] = 'futures' default_conf['trading_mode'] = 'futures'
default_conf['margin_mode'] = 'isolated' default_conf['margin_mode'] = 'isolated'
date_midnight = arrow.get('2021-09-01 00:00:00') date_midnight = arrow.get('2021-09-01 00:00:00').datetime
date_eight = arrow.get('2021-09-01 08:00:00') date_eight = arrow.get('2021-09-01 08:00:00').datetime
date_sixteen = arrow.get('2021-09-01 16:00:00') date_sixteen = arrow.get('2021-09-01 16:00:00').datetime
columns = ['date', 'open', 'high', 'low', 'close', 'volume'] columns = ['date', 'open', 'high', 'low', 'close', 'volume']
# 16:00 entry is actually never used # 16:00 entry is actually never used
# But should be kept in the test to ensure we're filtering correctly. # But should be kept in the test to ensure we're filtering correctly.
@ -5119,11 +5119,7 @@ def test_update_funding_fees(
trades = Trade.get_open_trades() trades = Trade.get_open_trades()
assert len(trades) == 3 assert len(trades) == 3
for trade in trades: for trade in trades:
assert pytest.approx(trade.funding_fees) == ( assert pytest.approx(trade.funding_fees) == 0
trade.amount *
mark_prices[trade.pair].iloc[0]['open'] *
funding_rates[trade.pair].iloc[0]['open'] * multipl
)
mocker.patch('freqtrade.exchange.Exchange.create_order', return_value=open_exit_order) mocker.patch('freqtrade.exchange.Exchange.create_order', return_value=open_exit_order)
time_machine.move_to("2021-09-01 08:00:00 +00:00") time_machine.move_to("2021-09-01 08:00:00 +00:00")
if schedule_off: if schedule_off:
@ -5136,8 +5132,8 @@ def test_update_funding_fees(
) )
assert trade.funding_fees == pytest.approx(sum( assert trade.funding_fees == pytest.approx(sum(
trade.amount * trade.amount *
mark_prices[trade.pair].iloc[0:2]['open'] * mark_prices[trade.pair].iloc[1:2]['open'] *
funding_rates[trade.pair].iloc[0:2]['open'] * multipl funding_rates[trade.pair].iloc[1:2]['open'] * multipl
)) ))
else: else:
@ -5147,8 +5143,8 @@ def test_update_funding_fees(
for trade in trades: for trade in trades:
assert trade.funding_fees == pytest.approx(sum( assert trade.funding_fees == pytest.approx(sum(
trade.amount * trade.amount *
mark_prices[trade.pair].iloc[0:2]['open'] * mark_prices[trade.pair].iloc[1:2]['open'] *
funding_rates[trade.pair].iloc[0:2]['open'] * funding_rates[trade.pair].iloc[1:2]['open'] *
multipl multipl
)) ))