Updated conftest funding_rate and mark_price

This commit is contained in:
Sam Germain 2021-11-01 02:51:59 -06:00
parent 33b0778c0a
commit 765ee5af50
2 changed files with 203 additions and 41 deletions

View File

@ -2371,37 +2371,115 @@ def limit_order_open(limit_buy_order_usdt_open, limit_sell_order_usdt_open):
def mark_ohlcv():
return [
[
1635674520000,
1.954,
1.95435369,
1.9524,
1.95255532,
1630454400000,
2.770211435326142,
2.7760202570103396,
2.7347342529855143,
2.7357522788430635,
0
],
[
1635674580000,
1.95255532,
1.95356934,
1.9507,
1.9507,
1630458000000,
2.735269545167237,
2.7651119207106896,
2.7248808874275636,
2.7492972616764053,
0
],
[
1635674640000,
1.9505,
1.95240962,
1.9502,
1.9506914,
1630461600000,
2.7491481048915243,
2.7671609375432853,
2.745229551784277,
2.760245773504276,
0
],
[
1635674700000,
1.95067489,
1.95124984,
1.94852208,
1.9486,
1630465200000,
2.760401812866193,
2.761749613398891,
2.742224897842422,
2.761749613398891,
0
]
],
[
1630468800000,
2.7620775456230717,
2.775325047797592,
2.755971115233453,
2.77160966718816,
0
],
[
1630472400000,
2.7728718875620535,
2.7955600146848196,
2.7592691116925816,
2.787961168625268
],
[
1630476000000,
2.788924005374514,
2.80182349539391,
2.774329229105576,
2.7775662803443466,
0
],
[
1630479600000,
2.7813766192350453,
2.798346488192056,
2.77645121073195,
2.7799615628667596,
0
],
[
1630483200000,
2.779641041095253,
2.7925407904097304,
2.7759817614742652,
2.780262741297638,
0
],
[
1630486800000,
2.77978981220767,
2.8464871136756833,
2.7757262968052983,
2.846220775920381,
0
],
[
1630490400000,
2.846414592861413,
2.8518148465268256,
2.8155014025617695,
2.817651577376391
],
[
1630494000000,
2.8180253150511034,
2.8343230172207017,
2.8101780247041037,
2.817772761324752,
0
],
[
1630497600000,
2.8179208712533828,
2.849455604187112,
2.8133565804933927,
2.8276620505921377,
0
],
[
1630501200000,
2.829210740051151,
2.833768886983365,
2.811042782941919,
2.81926481267932,
0
],
]
@ -2410,22 +2488,86 @@ def funding_rate_history():
return [
{
"symbol": "ADA/USDT",
"fundingRate": 0.00042396,
"timestamp": 1635580800001
"fundingRate": -0.000008,
"timestamp": 1630454400000,
"datetime": "2021-09-01T00:00:00.000Z"
},
{
"symbol": "ADA/USDT",
"fundingRate": 0.00036859,
"timestamp": 1635609600013
"fundingRate": -0.000004,
"timestamp": 1630458000000,
"datetime": "2021-09-01T01:00:00.000Z"
},
{
"symbol": "ADA/USDT",
"fundingRate": 0.0005205,
"timestamp": 1635638400008
"fundingRate": 0.000012,
"timestamp": 1630461600000,
"datetime": "2021-09-01T02:00:00.000Z"
},
{
"symbol": "ADA/USDT",
"fundingRate": 0.00068396,
"timestamp": 1635667200010
}
"fundingRate": -0.000003,
"timestamp": 1630465200000,
"datetime": "2021-09-01T03:00:00.000Z"
},
{
"symbol": "ADA/USDT",
"fundingRate": -0.000007,
"timestamp": 1630468800000,
"datetime": "2021-09-01T04:00:00.000Z"
},
{
"symbol": "ADA/USDT",
"fundingRate": 0.000003,
"timestamp": 1630472400000,
"datetime": "2021-09-01T05:00:00.000Z"
},
{
"symbol": "ADA/USDT",
"fundingRate": 0.000019,
"timestamp": 1630476000000,
"datetime": "2021-09-01T06:00:00.000Z"
},
{
"symbol": "ADA/USDT",
"fundingRate": 0.000003,
"timestamp": 1630479600000,
"datetime": "2021-09-01T07:00:00.000Z"
},
{
"symbol": "ADA/USDT",
"fundingRate": 0,
"timestamp": 1630483200000,
"datetime": "2021-09-01T08:00:00.000Z"
},
{
"symbol": "ADA/USDT",
"fundingRate": -0.000003,
"timestamp": 1630486800000,
"datetime": "2021-09-01T09:00:00.000Z"
},
{
"symbol": "ADA/USDT",
"fundingRate": 0.000013,
"timestamp": 1630490400000,
"datetime": "2021-09-01T10:00:00.000Z"
},
{
"symbol": "ADA/USDT",
"fundingRate": 0.000077,
"timestamp": 1630494000000,
"datetime": "2021-09-01T11:00:00.000Z"
},
{
"symbol": "ADA/USDT",
"fundingRate": 0.000072,
"timestamp": 1630497600000,
"datetime": "2021-09-01T12:00:00.000Z"
},
{
"symbol": "ADA/USDT",
"fundingRate": 0.000097,
"timestamp": 1630501200000,
"datetime": "2021-09-01T13:00:00.000Z"
},
]

View File

@ -3425,12 +3425,22 @@ def test__get_mark_price_history(mocker, default_conf, mark_ohlcv):
# mocker.patch('freqtrade.exchange.Exchange.get_funding_fees', lambda pair, since: y)
exchange = get_patched_exchange(mocker, default_conf, api_mock)
mark_prices = exchange._get_mark_price_history("ADA/USDT", 1635674520000)
mark_prices = exchange._get_mark_price_history("ADA/USDT", 1630454400000)
assert mark_prices == {
1635674520000: 1.954,
1635674580000: 1.95255532,
1635674640000: 1.9505,
1635674700000: 1.95067489,
1630454400000: 2.770211435326142,
1630458000000: 2.735269545167237,
1630461600000: 2.7491481048915243,
1630465200000: 2.760401812866193,
1630468800000: 2.7620775456230717,
1630472400000: 2.7728718875620535,
1630476000000: 2.788924005374514,
1630479600000: 2.7813766192350453,
1630483200000: 2.779641041095253,
1630486800000: 2.77978981220767,
1630490400000: 2.846414592861413,
1630494000000: 2.8180253150511034,
1630497600000: 2.8179208712533828,
1630501200000: 2.829210740051151,
}
ccxt_exceptionhandlers(
@ -3441,7 +3451,7 @@ def test__get_mark_price_history(mocker, default_conf, mark_ohlcv):
"_get_mark_price_history",
"fetch_ohlcv",
pair="ADA/USDT",
since=1635674520000
since=1635580800001
)
@ -3455,10 +3465,20 @@ def test_get_funding_rate_history(mocker, default_conf, funding_rate_history):
funding_rates = exchange.get_funding_rate_history('ADA/USDT', 1635580800001)
assert funding_rates == {
1635580800001: 0.00042396,
1635609600013: 0.00036859,
1635638400008: 0.0005205,
1635667200010: 0.00068396,
1630454400000: -0.000008,
1630458000000: -0.000004,
1630461600000: 0.000012,
1630465200000: -0.000003,
1630468800000: -0.000007,
1630472400000: 0.000003,
1630476000000: 0.000019,
1630479600000: 0.000003,
1630483200000: 0,
1630486800000: -0.000003,
1630490400000: 0.000013,
1630494000000: 0.000077,
1630497600000: 0.000072,
1630501200000: 0.000097,
}
ccxt_exceptionhandlers(
@ -3469,7 +3489,7 @@ def test_get_funding_rate_history(mocker, default_conf, funding_rate_history):
"get_funding_rate_history",
"fetch_funding_rate_history",
pair="ADA/USDT",
since=1635580800001
since=1630454400000
)