我正在嘗試獲取加密貨幣交易所的訂單簿如何支持特定對(例如 ETH/BTC)。因為我的函數需要每分鐘運行一次,所以每次檢查都非常耗時。我正在使用 ccxt 來獲取交易所的訂單簿。用這行代碼,我檢查每一次交換。import ccxtbinance = ccxt.binance()livecoin = ccxt.livecoin()kucoin = ccxt.kucoin()hitbtc = ccxt.hitbtc()kraken = ccxt.kraken()crex24 = ccxt.crex24()okex = ccxt.okex()headerList = ["time","type","pair"]try: orderbookBinance = binance.fetch_order_book(self.pair,5) headerList.append("binance") headerList.append("binanceAmount")except: print("Pair isn't available in binance")try: orderbookLivecoin = livecoin.fetch_order_book(self.pair,5) headerList.append("livecoin") headerList.append("livecoinAmount")except: print("Pair isn't available in livecoin")try: orderbookKucoin = kucoin.fetch_order_book(self.pair,5) headerList.append("kucoin") headerList.append("kucoinAmount")except: print("Pair isn't available in kucoin")try: orderbookHitbtc = hitbtc.fetch_order_book(self.pair,5) headerList.append("hitbtc") headerList.append("hitbtcAmount")except: print("Pair isn't available in hitbtc")try: orderbookKraken = kraken.fetch_order_book(self.pair,5) headerList.append("kraken") headerList.append("krakenAmount")except: print("Pair isn't available in kraken")try: orderbookCrex24 = crex24.fetch_order_book(self.pair,5) headerList.append("crex24") headerList.append("crex24Amount")except: print("Pair isn't available in crex24")try: orderbookOkex = okex.fetch_order_book(self.pair,5) headerList.append("okex") headerList.append("okexAmount")except: print("Pair isn't available in okex")現在我需要添加所有 try-blocks 的第一行,如果它們可以輸出的話。這在python中可能嗎?
添加回答
舉報
0/150
提交
取消