Exemplo n.º 1
0
def test_get_trade_balance_base():

    sess = KrakenSession()
    sess.load_keys_from_file('kraken.key')

    trade_balance = sess.get_trade_balance()
    assert lists_match(trade_balance.keys(), TRADE_BALANCE_RESULT_KEYS)
Exemplo n.º 2
0
def test_get_open_orders_base():

    sess = KrakenSession()
    sess.load_keys_from_file('kraken.key')

    open_orders = sess.get_open_orders()
    assert lists_match(open_orders.keys(), ['open'])
Exemplo n.º 3
0
def test_get_account_balance_base():

    sess = KrakenSession()
    sess.load_keys_from_file('kraken.key')

    account_balance = sess.get_account_balance()
    assert isinstance(account_balance, dict)
Exemplo n.º 4
0
def test_get_asset_info_aclass():

    sess = KrakenSession()
    asset_info_aclass_param = sess.get_asset_info(aclass='currency')
    for asset in asset_info_aclass_param.values():
        assert lists_match(asset.keys(), EXPECTED_ASSET_INFO_KEYS)
    with pytest.raises(InvalidRequestParameterOptionsException):
        sess.get_asset_info(aclass='unknown')
Exemplo n.º 5
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.º 6
0
def test_get_recent_spread_data_since():

    asset_pair = "ETH2.SETH"
    since = 1610650690.1234

    sess = KrakenSession()
    recent_spread_data = sess.get_recent_spread_data(asset_pair, since=since)

    for spread_data in recent_spread_data[asset_pair]:
        assert spread_data[0] >= since

    with pytest.raises(InvalidTimestampException):
        sess.get_recent_spread_data(asset_pair, since="bad")
Exemplo n.º 7
0
def test_get_recent_trades_since():

    asset_pair = "OXTETH"
    since = 1610660648.5366

    sess = KrakenSession()
    recent_trades = sess.get_recent_trades(asset_pair, since=since)

    for trade in recent_trades[asset_pair]:
        assert trade[2] >= since

    with pytest.raises(InvalidTimestampException):
        sess.get_recent_trades(asset_pair, since="11-12-20")
Exemplo n.º 8
0
def test_get_order_book_count():

    asset_pair = "XXRPZCAD"
    count = 3

    sess = KrakenSession()
    order_book = sess.get_order_book(asset_pair, count=count)

    asset_pair_order_book = order_book[asset_pair]
    for order_lists in asset_pair_order_book.values():
        assert len(order_lists) <= count

    with pytest.raises(InvalidRequestParameterException):
        sess.get_order_book(asset_pair, "four")
Exemplo n.º 9
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.º 10
0
def test_get_ticker_information():

    sess = KrakenSession()

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

    single_pair = 'XXDGXXBT'
    single_list = [single_pair]
    single_list_as_string = ','.join(single_list)
    asset_pairs_single = sess.get_ticker_information(
        pair=single_list_as_string)
    assert lists_match(asset_pairs_single.keys(), single_list)

    ticker_data_pair = asset_pairs_single[single_pair]
    assert lists_match(ticker_data_pair.keys(),
                       ['a', 'b', 'c', 'v', 'p', 't', 'l', 'h', 'o'])

    for key in ticker_data_pair.keys():
        # 'o' represents opening value, which is not a list
        if key != 'o':
            assert dict_value_length_check(key, ticker_data_pair,
                                           TICKER_RESULTS_EXPECTED_LENGTH)

    multi_list = ['XETHZUSD', 'USDTEUR', 'KAVAEUR']
    multi_list_as_string = ','.join(multi_list)
    asset_pairs_multi = sess.get_ticker_information(pair=multi_list_as_string)
    assert lists_match(asset_pairs_multi.keys(), multi_list)

    bad_list = ['PAXGXBT', 'XLTCZEUR', 'GNOXBT', 'BADPAIR']
    with pytest.raises(InvalidRequestParameterOptionsException):
        bad_list_as_string = ','.join(bad_list)
        sess.get_ticker_information(pair=bad_list_as_string)
Exemplo n.º 11
0
def test_get_trade_balance_asset():

    sess = KrakenSession()
    sess.load_keys_from_file('kraken.key')

    trade_balance = sess.get_trade_balance(asset='ZCAD')
    assert lists_match(trade_balance.keys(), TRADE_BALANCE_RESULT_KEYS)

    with pytest.raises(InvalidRequestParameterOptionsException):
        sess.get_trade_balance(asset='FNYMN')
Exemplo n.º 12
0
def tes_kraken_session_get_trade_balance_aclass():

    sess = KrakenSession()
    sess.load_keys_from_file('kraken.key')

    trade_balance = sess.get_trade_balance(aclass='currency')
    assert lists_match(trade_balance.keys(), TRADE_BALANCE_RESULT_KEYS)

    with pytest.raises(InvalidRequestParameterOptionsException):
        sess.get_trade_balance(aclass="otherstuff")
Exemplo n.º 13
0
def test_get_closed_orders_base():

    sess = KrakenSession()
    sess.load_keys_from_file('kraken.key')

    with pytest.raises(NotImplementedError):
        sess.get_closed_orders()
Exemplo n.º 14
0
def test_get_open_positions_base():

    sess = KrakenSession()
    sess.load_keys_from_file('kraken.key')

    with pytest.raises(NotImplementedError):
        sess.get_open_positions(1)
Exemplo n.º 15
0
def test_get_ledgers_info_base():

    sess = KrakenSession()
    sess.load_keys_from_file('kraken.key')

    with pytest.raises(NotImplementedError):
        sess.get_ledgers_info()
Exemplo n.º 16
0
def test_wallet_transfer_base():

    sess = KrakenSession()
    sess.load_keys_from_file('kraken.key')

    with pytest.raises(NotImplementedError):
        sess.wallet_transfer(1, 1, 1, 1)
Exemplo n.º 17
0
def test_get_web_socket_token_base():

    sess = KrakenSession()
    sess.load_keys_from_file('kraken.key')

    with pytest.raises(NotImplementedError):
        sess.get_web_socket_token()
Exemplo n.º 18
0
def test_get_status_of_recent_withdrawals():

    sess = KrakenSession()
    sess.load_keys_from_file('kraken.key')

    with pytest.raises(NotImplementedError):
        sess.get_status_of_recent_withdrawals(1, 1)
Exemplo n.º 19
0
def test_request_withdrawal_cancellation_base():

    sess = KrakenSession()
    sess.load_keys_from_file('kraken.key')

    with pytest.raises(NotImplementedError):
        sess.request_withdrawal_cancellation(1, 1)
Exemplo n.º 20
0
def test_get_withdrawal_information_base():

    sess = KrakenSession()
    sess.load_keys_from_file('kraken.key')

    with pytest.raises(NotImplementedError):
        sess.get_withdrawal_information(1, 1, 1)
Exemplo n.º 21
0
def test_withdraw_funds_base():

    sess = KrakenSession()
    sess.load_keys_from_file('kraken.key')

    with pytest.raises(NotImplementedError):
        sess.withdraw_funds(1, 1, 1)
Exemplo n.º 22
0
def test_cancel_all_orders_after_base():

    sess = KrakenSession()
    sess.load_keys_from_file('kraken.key')

    with pytest.raises(NotImplementedError):
        sess.cancel_all_orders_after(1)
Exemplo n.º 23
0
def test_get_deposit_status_base():

    sess = KrakenSession()
    sess.load_keys_from_file('kraken.key')

    with pytest.raises(NotImplementedError):
        sess.get_deposit_status(1, 1)
Exemplo n.º 24
0
def test_add_standard_order_base():

    sess = KrakenSession()
    sess.load_keys_from_file('kraken.key')

    with pytest.raises(NotImplementedError):
        sess.add_standard_order(1, 1, 1, 1)
Exemplo n.º 25
0
def test_remove_export_report_base():

    sess = KrakenSession()
    sess.load_keys_from_file('kraken.key')

    with pytest.raises(NotImplementedError):
        sess.remove_export_report(1, 1)
Exemplo n.º 26
0
def test_get_trade_volume_base():

    sess = KrakenSession()
    sess.load_keys_from_file('kraken.key')

    with pytest.raises(NotImplementedError):
        sess.get_trade_volume()
Exemplo n.º 27
0
def test_query_ledgers_base():

    sess = KrakenSession()
    sess.load_keys_from_file('kraken.key')

    with pytest.raises(NotImplementedError):
        sess.query_ledgers(1)
Exemplo n.º 28
0
def test_get_tradable_asset_pairs_info():

    sess = KrakenSession()
    asset_pairs_info = sess.get_tradable_asset_pairs(info='info')
    for asset in asset_pairs_info.values():
        assert list_in_list(asset.keys(), ALL_POSSIBLE_ASSET_PAIR_KEYS)
    asset_pairs_leverage = sess.get_tradable_asset_pairs(info='leverage')
    for asset in asset_pairs_leverage.values():
        assert list_in_list(asset.keys(), ALL_POSSIBLE_ASSET_PAIR_KEYS)
    asset_pairs_fees = sess.get_tradable_asset_pairs(info='fees')
    for asset in asset_pairs_fees.values():
        assert list_in_list(asset.keys(), ALL_POSSIBLE_ASSET_PAIR_KEYS)
    asset_pairs_margin = sess.get_tradable_asset_pairs(info='margin')
    for asset in asset_pairs_margin.values():
        assert list_in_list(asset.keys(), ALL_POSSIBLE_ASSET_PAIR_KEYS)
    with pytest.raises(InvalidRequestParameterOptionsException):
        sess.get_tradable_asset_pairs(info='bad')
Exemplo n.º 29
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")
Exemplo n.º 30
0
def test_get_recent_trades_base():

    asset_pair = "OXTETH"

    sess = KrakenSession()
    recent_trades = sess.get_recent_trades(asset_pair)

    assert lists_match(recent_trades.keys(), [asset_pair, 'last'])

    recent_trades_pair = recent_trades[asset_pair]
    for trade in recent_trades_pair:
        assert len(trade) == RECENT_TRADES_LENGTH

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

    with pytest.raises(InvalidRequestParameterOptionsException):
        sess.get_recent_trades("UNKCURR")