Improve leggibility of test

This commit is contained in:
Matthias 2021-11-14 19:53:08 +01:00
parent da3ceb0904
commit e7499b7c44
2 changed files with 23 additions and 20 deletions

View File

@ -2896,6 +2896,8 @@ def test_timeframe_to_prev_date():
# Does not round # Does not round
time = datetime(2019, 8, 12, 13, 20, 0, tzinfo=timezone.utc) time = datetime(2019, 8, 12, 13, 20, 0, tzinfo=timezone.utc)
assert timeframe_to_prev_date('5m', time) == time assert timeframe_to_prev_date('5m', time) == time
time = datetime(2019, 8, 12, 13, 0, 0, tzinfo=timezone.utc)
assert timeframe_to_prev_date('1h', time) == time
def test_timeframe_to_next_date(): def test_timeframe_to_next_date():

View File

@ -4760,46 +4760,47 @@ def test_update_funding_fees(
default_conf['trading_mode'] = 'futures' default_conf['trading_mode'] = 'futures'
default_conf['collateral'] = 'isolated' default_conf['collateral'] = 'isolated'
default_conf['dry_run'] = True default_conf['dry_run'] = True
timestamp_midnight = 1630454400000
timestamp_eight = 1630483200000
funding_rates_midnight = { funding_rates_midnight = {
"LTC/BTC": { "LTC/BTC": {
1630454400000: 0.00032583, timestamp_midnight: 0.00032583,
}, },
"ETH/BTC": { "ETH/BTC": {
1630454400000: 0.0001, timestamp_midnight: 0.0001,
}, },
"XRP/BTC": { "XRP/BTC": {
1630454400000: 0.00049426, timestamp_midnight: 0.00049426,
} }
} }
funding_rates_eight = { funding_rates_eight = {
"LTC/BTC": { "LTC/BTC": {
1630454400000: 0.00032583, timestamp_midnight: 0.00032583,
1630483200000: 0.00024472, timestamp_eight: 0.00024472,
}, },
"ETH/BTC": { "ETH/BTC": {
1630454400000: 0.0001, timestamp_midnight: 0.0001,
1630483200000: 0.0001, timestamp_eight: 0.0001,
}, },
"XRP/BTC": { "XRP/BTC": {
1630454400000: 0.00049426, timestamp_midnight: 0.00049426,
1630483200000: 0.00032715, timestamp_eight: 0.00032715,
} }
} }
mark_prices = { mark_prices = {
"LTC/BTC": { "LTC/BTC": {
1630454400000: 3.3, timestamp_midnight: 3.3,
1630483200000: 3.2, timestamp_eight: 3.2,
}, },
"ETH/BTC": { "ETH/BTC": {
1630454400000: 2.4, timestamp_midnight: 2.4,
1630483200000: 2.5, timestamp_eight: 2.5,
}, },
"XRP/BTC": { "XRP/BTC": {
1630454400000: 1.2, timestamp_midnight: 1.2,
1630483200000: 1.2, timestamp_eight: 1.2,
} }
} }
@ -4838,8 +4839,8 @@ def test_update_funding_fees(
for trade in trades: for trade in trades:
assert trade.funding_fees == ( assert trade.funding_fees == (
trade.amount * trade.amount *
mark_prices[trade.pair][1630454400000] * mark_prices[trade.pair][timestamp_midnight] *
funding_rates_midnight[trade.pair][1630454400000] funding_rates_midnight[trade.pair][timestamp_midnight]
) )
mocker.patch('freqtrade.exchange.Exchange.create_order', return_value=open_exit_order) mocker.patch('freqtrade.exchange.Exchange.create_order', return_value=open_exit_order)
# create_mock_trades(fee, False) # create_mock_trades(fee, False)
@ -4852,8 +4853,8 @@ def test_update_funding_fees(
for trade in trades: for trade in trades:
assert trade.funding_fees == ( assert trade.funding_fees == (
trade.amount * trade.amount *
mark_prices[trade.pair][1630454400000] * mark_prices[trade.pair][timestamp_midnight] *
funding_rates_eight[trade.pair][1630454400000] funding_rates_eight[trade.pair][timestamp_midnight]
) )
freqtrade.execute_trade_exit( freqtrade.execute_trade_exit(
trade=trade, trade=trade,