From d528c44974a318d5b40176a45c0d54c7255587a7 Mon Sep 17 00:00:00 2001 From: Matthias Date: Mon, 15 Jun 2020 08:47:43 +0200 Subject: [PATCH] Add test for pair_history --- tests/rpc/test_rpc_apiserver.py | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/tests/rpc/test_rpc_apiserver.py b/tests/rpc/test_rpc_apiserver.py index fea7b1c73..bb13531b5 100644 --- a/tests/rpc/test_rpc_apiserver.py +++ b/tests/rpc/test_rpc_apiserver.py @@ -811,3 +811,27 @@ def test_api_forcesell(botclient, mocker, ticker, fee, markets): data='{"tradeid": "1"}') assert_response(rc) assert rc.json == {'result': 'Created sell order for trade 1.'} + + +def test_api_pair_history(botclient, ohlcv_history): + ftbot, client = botclient + timeframe = '5m' + amount = 2 + ohlcv_history['sma'] = ohlcv_history['close'].rolling(2).mean() + ftbot.dataprovider._set_cached_df("XRP/BTC", timeframe, ohlcv_history) + + rc = client_get(client, + f"{BASE_URI}/pair_history?limit={amount}&pair=XRP%2FBTC&timeframe={timeframe}") + assert_response(rc) + assert 'columns' in rc.json + assert isinstance(rc.json['columns'], list) + assert rc.json['columns'] == ['date', 'open', 'high', 'low', 'close', 'volume', 'sma'] + + assert 'data' in rc.json + assert len(rc.json['data']) == amount + + assert (rc.json['data'] == + [[1511686200000, 8.794e-05, 8.948e-05, 8.794e-05, 8.88e-05, 0.0877869, None], + [1511686500000, 8.88e-05, 8.942e-05, 8.88e-05, + 8.893e-05, 0.05874751, 8.886500000000001e-05] + ])