From 20eff6509b49f72c16ee099b4121b923cafdc7c7 Mon Sep 17 00:00:00 2001 From: Pepijn Boers Date: Sun, 31 Oct 2021 11:23:13 +0100 Subject: [PATCH] Add websocket code snippet to useful examples --- docs/source/index.rst | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/docs/source/index.rst b/docs/source/index.rst index c5e8792..2a15048 100644 --- a/docs/source/index.rst +++ b/docs/source/index.rst @@ -97,6 +97,26 @@ or by providing attributes to :code:`Account(api_key='***', api_secret='***')` ... +- Get orderbook via websocket + +.. testcode:: + + import asyncio + import cryptocom.exchange as cro + + async def main(): + exchange = cro.Exchange() + cro_usdt = cro.Pair(exchange_name="CRO_USDT", price_precision=4, quantity_precision=6) + async for orderbook in exchange.listen_orderbook(cro_usdt): + print(f"First buy in orderbook: {orderbook.buys[0]}") + + + asyncio.run(main()) + +.. testoutput:: + :hide: + + ... Indices and tables ==================