Exemplo n.º 1
0
def test_coverage_of_kraken_balances(kraken):
    # Since 05/08/2019 Kraken removed all delisted assets from their public API
    # query except for BSV. No idea why or why this incosistency.
    got_assets = set(kraken.api_query('Assets').keys())
    expected_assets = (set(KRAKEN_TO_WORLD.keys()) - set(KRAKEN_DELISTED)).union({'BSV'})
    # Ignore the staking assets from the got assets
    got_assets.remove('XTZ.S')
    got_assets.remove('EUR.M')
    got_assets.remove('USD.M')
    got_assets.remove('XBT.M')

    diff = expected_assets.symmetric_difference(got_assets)
    if len(diff) != 0:
        test_warnings.warn(UserWarning(
            f"Our known assets don't match kraken's assets. Difference: {diff}",
        ))
    else:
        # Make sure all assets are covered by our from and to functions
        for kraken_asset in got_assets:
            asset = asset_from_kraken(kraken_asset)
            assert asset.to_kraken() == kraken_asset

    # also check that staked assets are properly processed
    assert asset_from_kraken('XTZ.S') == Asset('XTZ')
    assert asset_from_kraken('EUR.M') == Asset('EUR')
Exemplo n.º 2
0
def test_coverage_of_kraken_balances(kraken):
    got_assets = set(kraken.api_query('Assets').keys())
    expected_assets = (set(KRAKEN_TO_WORLD.keys()) - set(KRAKEN_DELISTED))
    # Ignore the staking assets from the got assets
    got_assets.remove('XTZ.S')
    got_assets.remove('DOT.S')
    got_assets.remove('ATOM.S')
    got_assets.remove('EUR.M')
    got_assets.remove('USD.M')
    got_assets.remove('XBT.M')
    got_assets.remove('KSM.S')
    got_assets.remove('ETH2.S')
    got_assets.remove('EUR.HOLD')
    got_assets.remove('FLOW.S')
    got_assets.remove('FLOWH.S')
    # Ignore the following assets as well
    got_assets.remove('FLOW')
    got_assets.remove('FLOWH')

    diff = expected_assets.symmetric_difference(got_assets)
    if len(diff) != 0:
        test_warnings.warn(UserWarning(
            f"Our known assets don't match kraken's assets. Difference: {diff}",
        ))
    else:
        # Make sure all assets are covered by our from and to functions
        for kraken_asset in got_assets:
            asset = asset_from_kraken(kraken_asset)
            assert asset.to_kraken() == kraken_asset

    # also check that staked assets are properly processed
    assert asset_from_kraken('XTZ.S') == Asset('XTZ')
    assert asset_from_kraken('EUR.M') == Asset('EUR')
Exemplo n.º 3
0
def generate_random_kraken_balance_response():
    kraken_assets = set(KRAKEN_TO_WORLD.keys()) - set(KRAKEN_DELISTED)
    number_of_assets = random.randrange(0, len(kraken_assets))
    chosen_assets = random.sample(kraken_assets, number_of_assets)

    balances = {}
    for asset in chosen_assets:
        balances[asset] = make_random_positive_fval()

    return balances
Exemplo n.º 4
0
def get_random_kraken_asset() -> Asset:
    kraken_assets = set(KRAKEN_TO_WORLD.keys()) - set(KRAKEN_DELISTED)
    return random.choice(list(kraken_assets))