Exemple #1
0
 def tearDown(self) -> None:
     return async_run(self.clean_test())
    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()


if __name__ == "__main__":
    async_run(run())
Exemple #3
0
 def setUp(self) -> None:
     return async_run(self.init_test())