forked from ccxt/ccxt
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest_async.py
699 lines (550 loc) · 24.4 KB
/
test_async.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
# -*- coding: utf-8 -*-
import argparse
import asyncio
import json
# import logging
import os
import sys
import time # noqa: F401
from traceback import format_tb
# ------------------------------------------------------------------------------
# logging.basicConfig(level=logging.INFO)
# ------------------------------------------------------------------------------
root = os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
sys.path.append(root)
# ------------------------------------------------------------------------------
import ccxt.async_support as ccxt # noqa: E402
from test_trade import test_trade # noqa: E402
from test_order import test_order # noqa: E402
from test_ohlcv import test_ohlcv # noqa: E402
from test_position import test_position # noqa: E402
from test_transaction import test_transaction # noqa: E402
# ------------------------------------------------------------------------------
class Argv(object):
token_bucket = False
sandbox = False
privateOnly = False
private = False
verbose = False
nonce = None
exchange = None
symbol = None
pass
argv = Argv()
parser = argparse.ArgumentParser()
parser.add_argument('--token_bucket', action='store_true', help='enable token bucket experimental test')
parser.add_argument('--sandbox', action='store_true', help='enable sandbox mode')
parser.add_argument('--privateOnly', action='store_true', help='run private tests only')
parser.add_argument('--private', action='store_true', help='run private tests')
parser.add_argument('--verbose', action='store_true', help='enable verbose output')
parser.add_argument('--nonce', type=int, help='integer')
parser.add_argument('exchange', type=str, help='exchange id in lowercase', nargs='?')
parser.add_argument('symbol', type=str, help='symbol in uppercase', nargs='?')
parser.parse_args(namespace=argv)
exchanges = {}
# ------------------------------------------------------------------------------
path = os.path.dirname(ccxt.__file__)
print(os.getcwd(), path)
print(sys.argv)
if 'site-packages' in os.path.dirname(ccxt.__file__):
raise Exception("You are running test_async.py/test.py against a globally-installed version of the library! It was previously installed into your site-packages folder by pip or pip3. To ensure testing against the local folder uninstall it first with pip uninstall ccxt or pip3 uninstall ccxt")
# ------------------------------------------------------------------------------
# string coloring functions
def style(s, style):
return str(s) # style + str (s) + '\033[0m'
def green(s):
return style(s, '\033[92m')
def blue(s):
return style(s, '\033[94m')
def yellow(s):
return style(s, '\033[93m')
def red(s):
return style(s, '\033[91m')
def pink(s):
return style(s, '\033[95m')
def bold(s):
return style(s, '\033[1m')
def underline(s):
return style(s, '\033[4m')
# print a colored string
def dump(*args):
print(' '.join([str(arg) for arg in args]))
# print an error string
def dump_error(*args):
string = ' '.join([str(arg) for arg in args])
print(string)
sys.stderr.write(string + "\n")
sys.stderr.flush()
# ------------------------------------------------------------------------------
def handle_all_unhandled_exceptions(type, value, traceback):
dump_error(yellow(type), yellow(value), '\n\n' + yellow('\n'.join(format_tb(traceback))))
exit(1) # unrecoverable crash
sys.excepthook = handle_all_unhandled_exceptions
# ------------------------------------------------------------------------------
async def test_order_book(exchange, symbol):
method = 'fetchOrderBook'
if exchange.has[method]:
delay = int(exchange.rateLimit / 1000)
await asyncio.sleep(delay)
# dump(green(exchange.id), green(symbol), 'fetching order book...')
orderbook = await getattr(exchange, method)(symbol)
dump(
green(exchange.id),
green(symbol),
'order book',
orderbook['datetime'],
'bid: ' + str(orderbook['bids'][0][0] if len(orderbook['bids']) else 'N/A'),
'bidVolume: ' + str(orderbook['bids'][0][1] if len(orderbook['bids']) else 'N/A'),
'ask: ' + str(orderbook['asks'][0][0] if len(orderbook['asks']) else 'N/A'),
'askVolume: ' + str(orderbook['asks'][0][1] if len(orderbook['asks']) else 'N/A'))
else:
dump(yellow(exchange.id), method + '() is not supported')
# ------------------------------------------------------------------------------
async def test_ohlcvs(exchange, symbol):
method = 'fetchOHLCV'
ignored_exchanges = [
'cex', # CEX can return historical candles for a certain date only
'okex', # okex fetchOHLCV counts "limit" candles from current time backwards
'okcoinusd', # okex base class
]
if exchange.id in ignored_exchanges:
return
if exchange.has[method]:
delay = int(exchange.rateLimit / 1000)
await asyncio.sleep(delay)
timeframes = exchange.timeframes if exchange.timeframes else {'1d': '1d'}
exchange_has_one_minute_timeframe = '1m' in timeframes
timeframe = '1m' if exchange_has_one_minute_timeframe else list(timeframes.keys())[0]
limit = 10
duration = exchange.parse_timeframe(timeframe)
since = exchange.milliseconds() - duration * limit * 1000 - 1000
ohlcvs = await getattr(exchange, method)(symbol, timeframe, since, limit)
for ohlcv in ohlcvs:
test_ohlcv(exchange, ohlcv, symbol, int(time.time() * 1000))
dump(green(exchange.id), 'fetched', green(len(ohlcvs)), 'OHLCVs')
else:
dump(yellow(exchange.id), method + '() is not supported')
# ------------------------------------------------------------------------------
async def test_tickers(exchange, symbol):
method = 'fetchTickers'
ignored_exchanges = [
'digifinex', # requires apiKey to call v2 tickers
]
if exchange.id in ignored_exchanges:
return
if exchange.has[method]:
delay = int(exchange.rateLimit / 1000)
await asyncio.sleep(delay)
tickers = None
try:
# dump(green(exchange.id), 'fetching all tickers at once...')
tickers = await getattr(exchange, method)()
dump(green(exchange.id), 'fetched all', green(len(list(tickers.keys()))), 'tickers')
except Exception as e:
dump(green(exchange.id), 'failed to fetch all tickers, fetching multiple tickers at once...')
tickers = await exchange.fetch_tickers([symbol])
dump(green(exchange.id), 'fetched', green(len(list(tickers.keys()))), 'tickers')
elif argv.token_bucket:
await test_tickers_async(exchange)
if argv.token_bucket:
await test_l2_order_books_async(exchange)
# ------------------------------------------------------------------------------
def get_active_symbols(exchange):
return [symbol for symbol in exchange.symbols if is_active_symbol(exchange, symbol)]
def is_active_symbol(exchange, symbol):
return ('.' not in symbol) and (('active' not in exchange.markets[symbol]) or (exchange.markets[symbol]['active']))
async def test_tickers_async(exchange):
print('Activated here')
dump(green(exchange.id), 'fetching all tickers by simultaneous multiple concurrent requests')
symbols_to_load = get_active_symbols(exchange)
input_coroutines = [exchange.fetch_ticker(symbol) for symbol in symbols_to_load]
tickers = await asyncio.gather(*input_coroutines, return_exceptions=True)
for ticker, symbol in zip(tickers, symbols_to_load):
if not isinstance(ticker, dict):
dump_error(red('[Error with symbol loading ticker]'),
' Symbol failed to load: {0}, ERROR: {1}'.format(symbol, ticker))
dump(green(exchange.id), 'fetched', green(len(list(tickers))), 'tickers')
async def test_l2_order_books_async(exchange):
dump(green(exchange.id), 'fetching all order books by simultaneous multiple concurrent requests')
symbols_to_load = get_active_symbols(exchange)
input_coroutines = [exchange.fetch_l2_order_book(symbol) for symbol in symbols_to_load]
orderbooks = await asyncio.gather(*input_coroutines, return_exceptions=True)
for orderbook, symbol in zip(orderbooks, symbols_to_load):
if not isinstance(orderbook, dict):
dump_error(red('[Error with symbol loading l2 order book]'),
' Symbol failed to load: {0}, ERROR: {1}'.format(symbol, orderbook))
dump(green(exchange.id), 'fetched', green(len(list(orderbooks))), 'order books')
# ------------------------------------------------------------------------------
async def test_ticker(exchange, symbol):
method = 'fetchTicker'
ignored_exchanges = [
'digifinex', # requires apiKey to call v2 tickers
]
if exchange.id in ignored_exchanges:
return
if exchange.has[method]:
delay = int(exchange.rateLimit / 1000)
await asyncio.sleep(delay)
ticker = await getattr(exchange, method)(symbol)
dump(
green(exchange.id),
green(symbol),
'ticker',
ticker['datetime'],
'high: ' + str(ticker['high']),
'low: ' + str(ticker['low']),
'bid: ' + str(ticker['bid']),
'ask: ' + str(ticker['ask']),
'volume: ' + str(ticker['quoteVolume']))
else:
dump(green(exchange.id), green(symbol), method + '() is not supported')
# ------------------------------------------------------------------------------
async def test_trades(exchange, symbol):
method = 'fetchTrades'
if exchange.has[method]:
delay = int(exchange.rateLimit / 1000)
await asyncio.sleep(delay)
# dump(green(exchange.id), green(symbol), 'fetching trades...')
trades = await getattr(exchange, method)(symbol)
if trades:
test_trade(exchange, trades[0], symbol, int(time.time() * 1000))
dump(green(exchange.id), green(symbol), 'fetched', green(len(trades)), 'trades')
else:
dump(green(exchange.id), green(symbol), method + '() is not supported')
# ------------------------------------------------------------------------------
async def test_orders(exchange, symbol):
method = 'fetchOrders'
if exchange.has[method]:
delay = int(exchange.rateLimit / 1000)
await asyncio.sleep(delay)
# dump(green(exchange.id), green(symbol), 'fetching orders...')
try:
orders = await exchange.fetch_orders(symbol)
for order in orders:
test_order(exchange, order, symbol, int(time.time() * 1000))
dump(green(exchange.id), green(symbol), 'fetched', green(len(orders)), 'orders')
except Exception as e:
dump_error(green(exchange.id), green(symbol), method + '() failed with:', str(e))
else:
dump(green(exchange.id), green(symbol), method + '() is not supported')
# ------------------------------------------------------------------------------
async def test_positions(exchange, symbol):
method = 'fetchPositions'
if exchange.has[method]:
skipped_exchanges = [
]
if exchange.id in skipped_exchanges:
dump(green(exchange.id), green(symbol), method + '() skipped')
return
delay = int(exchange.rateLimit / 1000)
await asyncio.sleep(delay)
# without symbol
dump(green(exchange.id), 'fetching positions...')
positions = await getattr(exchange, method)()
for position in positions:
test_position(exchange, position, None, int(time.time() * 1000))
dump(green(exchange.id), 'fetched', green(len(positions)), 'positions')
# with symbol
dump(green(exchange.id), green(symbol), 'fetching positions...')
positions = await getattr(exchange, method)([symbol])
for position in positions:
test_position(exchange, position, symbol, int(time.time() * 1000))
dump(green(exchange.id), green(symbol), 'fetched', green(len(positions)), 'positions')
else:
dump(green(exchange.id), green(symbol), method + '() is not supported')
# ------------------------------------------------------------------------------
async def test_closed_orders(exchange, symbol):
method = 'fetchClosedOrders'
if exchange.has[method]:
delay = int(exchange.rateLimit / 1000)
await asyncio.sleep(delay)
# dump(green(exchange.id), green(symbol), 'fetching orders...')
orders = await getattr(exchange, method)(symbol)
for order in orders:
test_order(exchange, order, symbol, int(time.time() * 1000))
assert order['status'] == 'closed' or order['status'] == 'canceled'
dump(green(exchange.id), green(symbol), 'fetched', green(len(orders)), 'closed orders')
else:
dump(green(exchange.id), green(symbol), method + '() is not supported')
# ------------------------------------------------------------------------------
async def test_open_orders(exchange, symbol):
method = 'fetchOpenOrders'
if exchange.has[method]:
delay = int(exchange.rateLimit / 1000)
await asyncio.sleep(delay)
# dump(green(exchange.id), green(symbol), 'fetching orders...')
orders = await getattr(exchange, method)(symbol)
for order in orders:
test_order(exchange, order, symbol, int(time.time() * 1000))
assert order['status'] == 'open'
dump(green(exchange.id), green(symbol), 'fetched', green(len(orders)), 'open orders')
else:
dump(green(exchange.id), green(symbol), method + '() is not supported')
# ------------------------------------------------------------------------------
async def test_transactions(exchange, code):
method = 'fetchTransactions'
if exchange.has[method]:
delay = int(exchange.rateLimit / 1000)
await asyncio.sleep(delay)
transactions = await getattr(exchange, method)(code)
for transaction in transactions:
test_transaction(exchange, transaction, code, int(time.time() * 1000))
dump(green(exchange.id), green(code), 'fetched', green(len(transactions)), 'transactions')
else:
dump(green(exchange.id), green(code), method + '() is not supported')
# ------------------------------------------------------------------------------
async def test_balance(exchange):
method = 'fetchBalance'
if exchange.has[method]:
delay = int(exchange.rateLimit / 1000)
await asyncio.sleep(delay)
await getattr(exchange, method)()
dump(green(exchange.id), 'fetched balance')
else:
dump(green(exchange.id), method + '() is not supported')
# ------------------------------------------------------------------------------
async def test_symbol(exchange, symbol, code):
if not argv.privateOnly:
await run_public_tests(exchange, symbol, code)
if argv.privateOnly or argv.private:
if (not hasattr(exchange, 'apiKey') or (len(exchange.apiKey) < 1)):
dump(yellow(exchange.id), 'keys not found, skipping private API tests')
return
await run_private_tests(exchange, symbol, code)
# ------------------------------------------------------------------------------
async def run_public_tests(exchange, symbol, code):
dump(green('SYMBOL: ' + symbol))
dump(green('CODE: ' + code))
dump('Testing fetch_ticker:' + symbol)
await test_ticker(exchange, symbol)
dump('Testing fetch_tickers:' + symbol)
await test_tickers(exchange, symbol)
dump('Testing fetch_ohlcv:' + symbol)
await test_ohlcvs(exchange, symbol)
dump('Testing fetch_order_book:' + symbol)
await test_order_book(exchange, symbol)
dump('Testing fetch_trades:' + symbol)
await test_trades(exchange, symbol)
# ------------------------------------------------------------------------------
async def run_private_tests(exchange, symbol, code):
method = 'signIn'
if exchange.has[method]:
dump('Testing ' + method + '()')
await getattr(exchange, method)()
dump('Testing fetch_orders:' + symbol)
await test_orders(exchange, symbol)
dump('Testing fetch_open_orders:' + symbol)
await test_open_orders(exchange, symbol)
dump('Testing fetch_closed_orders:' + symbol)
await test_closed_orders(exchange, symbol)
dump('Testing fetch_transactions:' + code)
await test_transactions(exchange, code)
dump('Testing fetch_balance')
await test_balance(exchange)
dump('Testing fetch_positions:' + symbol)
await test_positions(exchange, symbol)
# ------------------------------------------------------------------------------
async def load_exchange(exchange):
await exchange.load_markets()
def get_test_symbol(exchange, symbols):
symbol = None
for s in symbols:
market = exchange.safe_value(exchange.markets, s)
if market is not None:
active = exchange.safe_value(market, 'active')
if active or (active is None):
symbol = s
break
return symbol
def get_exchange_code(exchange, codes=None):
if codes is None:
codes = ['BTC', 'ETH', 'XRP', 'LTC', 'BCH', 'EOS', 'BNB', 'BSV', 'USDT']
code = codes[0]
for i in range(0, len(codes)):
if codes[i] in exchange.currencies:
code = codes[i]
return code
async def test_exchange(exchange, symbol=None):
dump(green('EXCHANGE: ' + exchange.id))
# delay = 2
# ..........................................................................
# public API
codes = [
'BTC',
'ETH',
'XRP',
'LTC',
'BCH',
'EOS',
'BNB',
'BSV',
'USDT',
'ATOM',
'BAT',
'BTG',
'DASH',
'DOGE',
'ETC',
'IOTA',
'LSK',
'MKR',
'NEO',
'PAX',
'QTUM',
'TRX',
'TUSD',
'USD',
'USDC',
'WAVES',
'XEM',
'XMR',
'ZEC',
'ZRX',
]
code = get_exchange_code(exchange, codes)
if not symbol:
symbol = get_test_symbol(exchange, [
'BTC/USD',
'BTC/USDT',
'BTC/CNY',
'BTC/EUR',
'BTC/ETH',
'ETH/BTC',
'ETH/USDT',
'BTC/JPY',
'LTC/BTC',
'USD/SLL',
'EUR/USD',
])
if symbol is None:
for code in codes:
markets = list(exchange.markets.values())
activeMarkets = [market for market in markets if market['base'] == code]
if len(activeMarkets):
activeSymbols = [market['symbol'] for market in activeMarkets]
symbol = get_test_symbol(exchange, activeSymbols)
break
if symbol is None:
markets = list(exchange.markets.values())
activeMarkets = [market for market in markets if market['base'] in codes]
activeSymbols = [market['symbol'] for market in activeMarkets]
symbol = get_test_symbol(exchange, activeSymbols)
if symbol is None:
markets = list(exchange.markets.values())
activeMarkets = [market for market in markets if not exchange.safe_value(market, 'active', False)]
activeSymbols = [market['symbol'] for market in activeMarkets]
symbol = get_test_symbol(exchange, activeSymbols)
if symbol is None:
symbol = get_test_symbol(exchange, exchange.symbols)
if symbol is None:
symbol = exchange.symbols[0]
if symbol.find('.d') < 0:
await test_symbol(exchange, symbol, code)
# ..........................................................................
# private API
# move to testnet/sandbox if possible before accessing the balance if possible
# if 'test' in exchange.urls:
# exchange.urls['api'] = exchange.urls['test']
# await asyncio.sleep(exchange.rateLimit / 1000)
# time.sleep(delay)
# amount = 1
# price = 0.0161
# marketBuy = exchange.create_market_buy_order(symbol, amount)
# print(marketBuy)
# time.sleep(delay)
# marketSell = exchange.create_market_sell_order(symbol, amount)
# print(marketSell)
# time.sleep(delay)
# limitBuy = exchange.create_limit_buy_order(symbol, amount, price)
# print(limitBuy)
# time.sleep(delay)
# limitSell = exchange.create_limit_sell_order(symbol, amount, price)
# print(limitSell)
# time.sleep(delay)
# ------------------------------------------------------------------------------
async def try_all_proxies(exchange, proxies=['']):
current_proxy = 0
max_retries = len(proxies)
if exchange.proxy in proxies:
current_proxy = proxies.index(exchange.proxy)
for num_retries in range(0, max_retries):
try:
# do not use cors proxy when using a http proxy
if not hasattr(exchange, "httpProxy"):
exchange.proxy = proxies[current_proxy]
dump(green(exchange.id), 'using proxy', '`' + exchange.proxy + '`')
current_proxy = (current_proxy + 1) % len(proxies)
await load_exchange(exchange)
await test_exchange(exchange)
except (ccxt.RequestTimeout, ccxt.AuthenticationError, ccxt.NotSupported, ccxt.DDoSProtection, ccxt.ExchangeNotAvailable, ccxt.ExchangeError) as e:
print({'type': type(e).__name__, 'num_retries': num_retries, 'max_retries': max_retries}, str(e)[0:200])
if (num_retries + 1) == max_retries:
dump_error(yellow('[' + type(e).__name__ + ']'), str(e)[0:200])
else:
# no exception
return True
# exception
return False
# ------------------------------------------------------------------------------
def read_credentials_from_env(exchange):
requiredCredentials = exchange.requiredCredentials
for credential, isRequired in requiredCredentials.items():
if isRequired and credential and not getattr(exchange, credential, None):
credentialEnvName = (exchange.id + '_' + credential).upper() # example: KRAKEN_APIKEY
if credentialEnvName in os.environ:
credentialValue = os.environ[credentialEnvName]
setattr(exchange, credential, credentialValue)
# ------------------------------------------------------------------------------
proxies = [
'',
'https://cors-anywhere.herokuapp.com/',
]
# prefer local testing keys to global keys
keys_folder = os.path.dirname(root)
keys_global = os.path.join(keys_folder, 'keys.json')
keys_local = os.path.join(keys_folder, 'keys.local.json')
keys_file = keys_local if os.path.exists(keys_local) else keys_global
# load the api keys from config
with open(keys_file, encoding='utf8') as file:
config = json.load(file)
# instantiate all exchanges
for id in ccxt.exchanges:
exchange = getattr(ccxt, id)
exchange_config = {'verbose': argv.verbose}
if sys.version_info[0] < 3:
exchange_config.update()
if id in config:
exchange_config = ccxt.Exchange.deep_extend(exchange_config, config[id])
exchanges[id] = exchange(exchange_config)
# check auth keys in env var
read_credentials_from_env(exchanges[id])
# ------------------------------------------------------------------------------
async def main():
if argv.exchange:
exchange = exchanges[argv.exchange]
symbol = argv.symbol
if hasattr(exchange, 'skip') and exchange.skip:
dump(green(exchange.id), 'skipped')
elif hasattr(exchange, 'alias') and exchange.alias:
dump(green(exchange.id), 'Skipped alias')
else:
# add http proxy if any
if hasattr(exchange, 'httpProxy'):
exchange.aiohttp_proxy = exchange.httpProxy
if argv.sandbox or getattr(exchange, 'sandbox', None):
exchange.set_sandbox_mode(True)
if symbol:
code = get_exchange_code(exchange)
await load_exchange(exchange)
await test_symbol(exchange, symbol, code)
else:
await try_all_proxies(exchange, proxies)
else:
for exchange in sorted(exchanges.values(), key=lambda x: x.id):
if hasattr(exchange, 'skip') and exchange.skip:
dump(green(exchange.id), 'skipped')
else:
await try_all_proxies(exchange, proxies)
# ------------------------------------------------------------------------------
if __name__ == '__main__':
asyncio.run(main())