Tests for _get_funding_fee_dates

This commit is contained in:
Sam Germain 2021-11-01 01:09:57 -06:00
parent edfc3377c5
commit 8b9dfafdf4

View File

@ -3307,34 +3307,115 @@ def test__get_funding_fee(
assert exchange._get_funding_fee(contract_size, funding_rate, mark_price) == funding_fee
@pytest.mark.parametrize('exchange,d1,d2', [
('binance', "2021-09-01 00:00:00", "2021-09-01 08:00:00"),
('binance', "2021-09-01 00:00:15", "2021-09-01 08:00:00"),
('binance', "2021-09-01 00:00:16", "2021-09-01 08:00:00"),
('binance', "2021-09-01 00:00:00", "2021-09-01 07:59:45"),
('binance', "2021-09-01 00:00:00", "2021-09-01 07:59:44"),
('binance', "2021-09-01 00:00:00", "2021-09-01 12:00:00"),
('kraken', "2021-09-01 00:00:00", "2021-09-01 08:00:00"),
('kraken', "2021-09-01 00:00:15", "2021-09-01 08:00:00"),
('kraken', "2021-09-01 00:00:16", "2021-09-01 08:00:00"),
('kraken', "2021-09-01 00:00:00", "2021-09-01 07:59:45"),
('kraken', "2021-09-01 00:00:00", "2021-09-01 07:59:44"),
('kraken', "2021-09-01 00:00:00", "2021-09-01 12:00:00"),
('ftx', "2021-09-01 00:00:00", "2021-09-01 08:00:00"),
('ftx', "2021-09-01 00:00:15", "2021-09-01 08:00:00"),
('ftx', "2021-09-01 00:00:16", "2021-09-01 08:00:00"),
('ftx', "2021-09-01 00:00:00", "2021-09-01 07:59:45"),
('ftx', "2021-09-01 00:00:00", "2021-09-01 07:59:44"),
('ftx', "2021-09-01 00:00:00", "2021-09-01 12:00:00"),
('gateio', "2021-09-01 00:00:00", "2021-09-01 08:00:00"),
('gateio', "2021-09-01 00:00:15", "2021-09-01 08:00:00"),
('gateio', "2021-09-01 00:00:16", "2021-09-01 08:00:00"),
('gateio', "2021-09-01 00:00:00", "2021-09-01 07:59:45"),
('gateio', "2021-09-01 00:00:00", "2021-09-01 07:59:44"),
('gateio', "2021-09-01 00:00:00", "2021-09-01 12:00:00"),
@pytest.mark.parametrize('exchange,d1,d2,funding_times', [
(
'binance',
"2021-09-01 00:00:00",
"2021-09-01 08:00:00",
["2021-09-01 00", "2021-09-01 08"]
),
('binance', "2021-09-01 00:00:15", "2021-09-01 08:00:00", ["2021-09-01 00", "2021-09-01 08"]),
('binance', "2021-09-01 00:00:16", "2021-09-01 08:00:00", ["2021-09-01 08"]),
('binance', "2021-09-01 00:00:00", "2021-09-01 07:59:59", ["2021-09-01 00"]),
('binance', "2021-09-01 00:00:00", "2021-09-01 12:00:00", ["2021-09-01 00", "2021-09-01 08"]),
(
'binance',
"2021-09-01 00:00:01",
"2021-09-01 08:00:00",
["2021-09-01 00", "2021-09-01 08"]
),
(
'kraken',
"2021-09-01 00:00:00",
"2021-09-01 08:00:00",
["2021-09-01 00", "2021-09-01 04", "2021-09-01 08"]
),
(
'kraken',
"2021-09-01 00:00:15",
"2021-09-01 08:00:00",
["2021-09-01 04", "2021-09-01 08"]
),
(
'kraken',
"2021-09-01 00:00:00",
"2021-09-01 07:59:59",
["2021-09-01 00", "2021-09-01 04"]
),
(
'kraken',
"2021-09-01 00:00:00",
"2021-09-01 12:00:00",
["2021-09-01 00", "2021-09-01 04", "2021-09-01 08", "2021-09-01 12"]
),
(
'kraken',
"2021-09-01 00:00:01",
"2021-09-01 08:00:00",
["2021-09-01 04", "2021-09-01 08"]
),
(
'ftx',
"2021-09-01 00:00:00",
"2021-09-01 08:00:00",
[
"2021-09-01 00",
"2021-09-01 01",
"2021-09-01 02",
"2021-09-01 03",
"2021-09-01 04",
"2021-09-01 05",
"2021-09-01 06",
"2021-09-01 07",
"2021-09-01 08"
]
),
(
'ftx',
"2021-09-01 00:00:00",
"2021-09-01 12:00:00",
[
"2021-09-01 00",
"2021-09-01 01",
"2021-09-01 02",
"2021-09-01 03",
"2021-09-01 04",
"2021-09-01 05",
"2021-09-01 06",
"2021-09-01 07",
"2021-09-01 08",
"2021-09-01 09",
"2021-09-01 10",
"2021-09-01 11",
"2021-09-01 12"
]
),
(
'ftx',
"2021-09-01 00:00:01",
"2021-09-01 08:00:00",
[
"2021-09-01 01",
"2021-09-01 02",
"2021-09-01 03",
"2021-09-01 04",
"2021-09-01 05",
"2021-09-01 06",
"2021-09-01 07",
"2021-09-01 08"
]
),
('gateio', "2021-09-01 00:00:00", "2021-09-01 08:00:00", ["2021-09-01 00", "2021-09-01 08"]),
('gateio', "2021-09-01 00:00:00", "2021-09-01 12:00:00", ["2021-09-01 00", "2021-09-01 08"]),
('gateio', "2021-09-01 00:00:01", "2021-09-01 08:00:00", ["2021-09-01 08"]),
])
def test__get_funding_fee_dates(exchange, d1, d2):
return
def test__get_funding_fee_dates(mocker, default_conf, exchange, d1, d2, funding_times):
expected_result = [datetime.strptime(d, '%Y-%m-%d %H') for d in funding_times]
d1 = datetime.strptime(d1, '%Y-%m-%d %H:%M:%S')
d2 = datetime.strptime(d2, '%Y-%m-%d %H:%M:%S')
exchange = get_patched_exchange(mocker, default_conf, id=exchange)
result = exchange._get_funding_fee_dates(d1, d2)
assert result == expected_result
def test__get_mark_price_history(mocker, default_conf, mark_ohlcv):