from noobit_markets.exchanges.binance.rest.private.exposure import get_exposure_binance
from noobit_markets.exchanges.binance.rest.private.ws_auth import get_wstoken_binance



# ============================================================
# SYMBOLS
# ============================================================

# return value is wrapped in a Result object, and accessible with the .value() method
# we can inspec wether the call was successful by calling .is_err() or .is_ok()
# here we wrap it directly into a custom class object
sym = asyncio.run(
    get_symbols_binance(
        client=httpx.AsyncClient(),
    )
)

# wrapping the result inside custom class to get access to more user friendly representations
symbols = NSymbol(sym)

# we can inspect if the call was a success with .is_ok() and .is_err() methods
if symbols.is_err():
    # this is equivalent to calling result.value (returns value held inside the wrapper object) 
    print(symbols.result)
else:
    # will print a nicely formatted tabulate table
    # print(symbols.table)
    print("Symbols ok")
Exemple #2
0
import asyncio

import pytest
import httpx
import aiohttp

from noobit_markets.exchanges.binance.rest.public.ohlc import get_ohlc_binance
from noobit_markets.exchanges.binance.rest.public.symbols import get_symbols_binance

from noobit_markets.base.models.result import Ok
from noobit_markets.base.models.rest.response import NoobitResponseOhlc

symbols = asyncio.run(get_symbols_binance(client=httpx.AsyncClient(), ))


async def fetch(client, symbols_resp):

    ohlc = await get_ohlc_binance(
        # loop=None,
        client=client,
        symbol="XBT-USDT",
        symbols_resp=symbols_resp.value,
        timeframe="1H",
        since=None)

    assert isinstance(ohlc, Ok)
    assert isinstance(ohlc.value, NoobitResponseOhlc)


@pytest.mark.asyncio
@pytest.mark.vcr()