I am trying to use CCXT to get the BTC bid and ask price across different exchanges, but running the code sequencially cannot get the price of a given moment correctly. Is there any way to execute them at the same time and return the correct price?
import ccxt
binance = ccxt.binance()
coinbase = ccxt.coinbase()
ftx = ccxt.ftx()
kraken = ccxt.kraken()
kucoin = ccxt.kucoin()
stat_list = binance.fetchTicker('BTC/USDT')
print('Binance', stat_list['bid'], stat_list['ask'])
stat_list = coinbase.fetchTicker('BTC-USD')
print('Coinbase', stat_list['bid'], stat_list['ask'])
stat_list = ftx.fetchTicker('BTC/USDT')
print('FTX', stat_list['bid'], stat_list['ask'])
stat_list = kraken.fetchTicker('BTC/USDT')
print('Kraken', stat_list['bid'], stat_list['ask'])
stat_list = kucoin.fetchTicker('BTC/USDT')
print('Kucoin', stat_list['bid'], stat_list['ask'])
Output:
Binance 20451.04 20451.33
Coinbase 20343.33 20552.61
FTX 20451.0 20452.0
Kraken 20454.5 20454.6
Kucoin 20450.9 20451.0