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

Function run_all_exchanges

examples/py/async-basic-callchain.py:13–43  ·  view source on GitHub ↗
(exchange_ids)

Source from the content-addressed store, hash-verified

11
12
13async def run_all_exchanges(exchange_ids):
14 results = {}
15
16 for exchange_id in exchange_ids:
17
18 exchange = getattr(ccxt, exchange_id)({
19 'options': {
20 'useWebapiForFetchingFees': False,
21 }
22 })
23
24 symbol = 'ETH/BTC'
25 print('Exchange:', exchange_id)
26
27 print(exchange_id, 'symbols:')
28 markets = await load_markets(exchange, symbol) # ←----------- STEP 1
29 print(list(markets.keys()))
30
31 print(symbol, 'ticker:')
32 ticker = await fetch_ticker(exchange, symbol) # ←------------ STEP 2
33 print(ticker)
34
35 print(symbol, 'orderbook:')
36 orderbook = await fetch_orderbook(exchange, symbol) # ←------ STEP 3
37 print(orderbook)
38
39 await exchange.close() # ←----------- LAST STEP GOES AFTER ALL CALLS
40
41 results[exchange_id] = ticker
42
43 return results
44
45
46async def load_markets(exchange, symbol):

Callers 1

Calls 4

fetch_orderbookFunction · 0.85
load_marketsFunction · 0.70
fetch_tickerFunction · 0.70
closeMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…