from binance.client import Client
from binance.streams import BinanceSocketManager
import json
# API Setup
with open('/Users/anon/Desktop/LOB-bot/LOB/api.json', 'r') as file:
api_data = json.load(file)
api_key = api_data['API_KEY']
api_secret = api_data['API_SECRET']
client = Client(api_key, api_secret, testnet=True)
bsm = BinanceSocketManager(client)
symbol = 'WIFUSDT'
async with bsm.futures_multiplex_socket(streams=[f"{symbol.lower()}@depth20@100ms", f"{symbol.lower()}@kline_4h"]) as stream:
while True:
res = await stream.recv()
print(res)
Hi, I’ve been running this code as part of my live trading strategy on a server. I’ve integrated both error and rate limit handling. It worked fine before, but now as I’ve simultaneously ran it while testing it locally, it suddenly stopped working.
I thought it could be due to my api being banned, i used a coworkers test api keys, with no luck.
My question is, why has it stopped returning any data whatsover. Shouldn’t it display an error message or something? This is the data I was expecting, and is being returned on the server:
Received data for WIFUSDT: [('buffer', [[Timestamp('2024-04-25 14:17:42.967000'), '3.0361000', '33.3', '3.0362000', '25.0'], [Timestamp('2024-04-25 14:17:43.075000'), '3.0355000', '4.6', '3.0356000', '170.1'], [Timestamp('2024-04-25 14:17:43.190000'), '3.0357000', '9.9', '3.0358000', '139.4'], [Timestamp('2024-04-25 14:17:43.299000'), '3.0356000', '59.3', '3.0358000', '9.4'], [Timestamp('2024-04-25 14:17:43.407000'), '3.0357000', '286.4', '3.0358000', '16.6'], [Timestamp('2024-04-25 14:17:43.515000'), '3.0362000', '164.9', '3.0363000', '299.8'], [Timestamp('2024-04-25 14:17:43.618000'), '3.0362000', '10.6', '3.0363000', '299.8'], [Timestamp('2024-04-25 14:17:43.726000'), '3.0354000', '3168.9', '3.0357000', '334.5'], [Timestamp('2024-04-25 14:17:43.828000'), '3.0355000', '300.0', '3.0356000', '112.6'], [Timestamp('2024-04-25 14:17:43.936000'), '3.0360000', '9.9', '3.0362000', '466.3'], [Timestamp('2024-04-25 14:17:44.038000'), '3.0360000', '9.9', '3.0361000', '44.5'], [Timestamp('2024-04-25 14:17:44.140000'), '3.0353000', '42.0', '3.0354000', '65.8'], [Timestamp('2024-04-25 14:17:44.245000'), '3.0361000', '551.9', '3.0364000', '3.8'], [Timestamp('2024-04-25 14:17:44.347000'), '3.0360000', '133.3', '3.0363000', '103.0'], [Timestamp('2024-04-25 14:17:44.450000'), '3.0363000', '52.0', '3.0365000', '337.8'], [Timestamp('2024-04-25 14:17:44.558000'), '3.0371000', '123.4', '3.0374000', '225.8'], [Timestamp('2024-04-25 14:17:44.674000'), '3.0370000', '300.0', '3.0374000', '296.6'], [Timestamp('2024-04-25 14:17:44.777000'), '3.0375000', '126.5', '3.0376000', '48.1'], [Timestamp('2024-04-25 14:17:44.879000'), '3.0372000', '300.0', '3.0374000', '59.8'], [Timestamp('2024-04-25 14:17:44.981000'), '3.0363000', '47.4', '3.0365000', '82.3']])]
and this is what it’s returning locally:
Received data for BTCUSDT: [('buffer', [])]
Received data for WIFUSDT: [('buffer', [])]
Received data for ONDOUSDT: [('buffer', [])]
Received data for MYROUSDT: [('buffer', [])]
Received data for FETUSDT: [('buffer', [])]