async def run():
    api_key = os.environ['ETERBASEAPIKEY']
    sec_key = os.environ['ETERBASESECKEY']
    acct_key = os.environ['ETERBASEACCTKEY']

    client = CryptoXLib.create_eterbase_client(acct_key, api_key, sec_key)

    markets = await client.get_markets()
    ethusdt_id = get_market_id(markets, 'ETHUSDT')
    xbaseebase_id = get_market_id(markets, 'XBASEEBASE')

    # Bundle several subscriptions into a single websocket
    client.compose_subscriptions([
        OrderbookSubscription([ethusdt_id, xbaseebase_id],
                              callbacks=[order_book_update]),
        TradesSubscription([ethusdt_id, xbaseebase_id],
                           callbacks=[trades_update]),
        OHLCVSubscription([ethusdt_id, xbaseebase_id],
                          callbacks=[ohlcv_update]),
    ])

    # Bundle another subscriptions into a separate websocket
    client.compose_subscriptions([
        AccountSubscription([ethusdt_id, xbaseebase_id],
                            callbacks=[account_update]),
    ])

    # Execute all websockets asynchronously
    await client.start_websockets()
async def run():
    api_key = os.environ['ETERBASEAPIKEY']
    sec_key = os.environ['ETERBASESECKEY']
    acct_key = os.environ['ETERBASEACCTKEY']

    client = CryptoXLib.create_eterbase_client(acct_key, api_key, sec_key)

    print("Time:")
    response = await client.get_ping()
    print(f"Headers: {response['headers']}")

    print("Currencies:")
    await client.get_currencies()

    print("Markets:")
    markets = await client.get_markets()

    print("Balances:")
    try:
        await client.get_balances()
    except EterbaseException as e:
        print(e)

    print("Create market order:")
    try:
        await client.create_order(
            pair_id=get_market_id(markets, 'ETHUSDT'),
            side=enums.OrderSide.BUY,
            type=enums.OrderType.LIMIT,
            amount="100000",
            price="1",
            time_in_force=enums.TimeInForce.GOOD_TILL_CANCELLED)
    except EterbaseException as e:
        print(e)

    print("Cancel order:")
    try:
        await client.cancel_order(order_id=str(uuid.uuid4()))
    except EterbaseException as e:
        print(e)

    await client.close()
示例#3
0
 async def init_test(self):
     self.client = CryptoXLib.create_eterbase_client(
         acct_key, api_key, sec_key)