Exemplo n.º 1
0
def test_get_ohlc_data_since():

    since_ts = 1610640300
    asset_pair = 'SCXBT'

    sess = KrakenSession()
    ohlc_data_since = sess.get_ohlc_data(asset_pair, since=since_ts)
    ts_list = ohlc_data_since[asset_pair]
    for timestamp_data in ts_list:
        assert timestamp_data[0] > since_ts
    with pytest.raises(InvalidTimestampException):
        sess.get_ohlc_data(asset_pair, since="badinput")
Exemplo n.º 2
0
def test_get_ohlc_data_interval():

    interval_mins = 60
    asset_pair = 'SCXBT'

    sess = KrakenSession()
    ohlc_data_interval = sess.get_ohlc_data(asset_pair, interval=interval_mins)
    ts_list = ohlc_data_interval[asset_pair]
    for i, timestamp_data in enumerate(ts_list):
        if i > 0:
            assert timestamp_data[0] - (interval_mins * 60) == ts_list[i -
                                                                       1][0]
    with pytest.raises(InvalidRequestParameterOptionsException):
        sess.get_ohlc_data(asset_pair, interval=49)
Exemplo n.º 3
0
def test_get_ohlc_data_base():

    sess = KrakenSession()

    with pytest.raises(MissingRequiredParameterException):
        sess.get_ohlc_data(None)

    asset_pair = 'SCXBT'
    ohlc_data = sess.get_ohlc_data(asset_pair)
    assert lists_match(ohlc_data.keys(), [asset_pair, 'last'])

    ohlc_pair_data = ohlc_data[asset_pair]
    for time_data in ohlc_pair_data:
        assert len(time_data) == OHLC_DATA_LENGTH

    with pytest.raises(InvalidRequestParameterOptionsException):
        sess.get_ohlc_data("BADPAIR")