MCPcopy Create free account
hub / github.com/ccxt/ccxt / main

Function main

examples/py/async-multiple-parallel-calls.py:26–49  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

24
25
26async def main():
27 exchange = ccxt.okx({
28 'apiKey': 'YOUR_API_KEY',
29 'secret': 'YOUR_SECRET',
30 'enableRateLimit': False, # not recommended
31 })
32 markets = await exchange.load_markets()
33 # exchange.verbose = True # uncomment for debugging purposes
34 symbol = 'BTC/USDT'
35 loops = [
36 exchange.fetch_balance(),
37 exchange.fetch_order_book(symbol),
38 exchange.fetch_open_orders()
39 ]
40 results = await gather(*loops)
41 print('Balance:')
42 print(results[0])
43 print('------------------------------------------------------------------')
44 print(symbol, 'orderbook:')
45 print(results[1])
46 print('------------------------------------------------------------------')
47 print('Open orders:')
48 print(results[2])
49 await exchange.close()
50
51
52run(main())

Calls 5

load_marketsMethod · 0.45
fetch_balanceMethod · 0.45
fetch_order_bookMethod · 0.45
fetch_open_ordersMethod · 0.45
closeMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…