coin_key=bsm.start_symbol_ticker_socket(coin,ticker_socket)
AttributeError: 'BinanceSocketManager' object has no attribute 'start_symbol_ticker_socket'
my code :
from itertools import count
REPEAT_EVERY = 60
import os, time
if msg['e']!= 'error':
global CURRENT_PRICE
CURRENT_PRICE['{0}'.format(msg['s'])]=msg['c']
else:
print('error')
bsm=BinanceSocketManager(client)
for coin in keywords:
coin_key=bsm.start_symbol_ticker_socket(coin,ticker_socket)
bsm.start()
if name == 'main':
print('Press Ctrl-Q to stop the script')
for i in count():
ticker_socket()
print(f'Iteration {i}')
time.sleep(60*REPEAT_EVERY)
Expected behavior :
I am working on my first bot : I want here the endprices of the tickers (in the array 'keywords'), but it seems i have a
problem which i cannot handle ...
Environment (please complete the following information):
Python version: 3.8.10
Virtual Env: 20.7.2 ?? (not sure about this one,can't find how to get the version)
OS: Ubuntu20.04
python-binance version: 1.2.1
Logs or Additional context
Many thanks if you could help me out with this ...)
You need to change your websocket code, start_symbol_ticker_socket function it's at ThreadedWebsocketManager class and not at BinanceSocketManager, check here.
Describe the bug
coin_key=bsm.start_symbol_ticker_socket(coin,ticker_socket) AttributeError: 'BinanceSocketManager' object has no attribute 'start_symbol_ticker_socket'
my code :
from itertools import count REPEAT_EVERY = 60 import os, time
import numpy as np
from binance.client import Client from binance.enums import * from binance.streams import BinanceSocketManager api_key = os.getenv('XXXXXXXXXXXXXXXXXXXXXXXXXXXXXX') api_secret = os.getenv('XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX') client = Client(api_key,api_secret) client.API_URL = 'https://testnet.binance.vision/api' keywords =[ 'XRPUSDT', 'BTCUSDT', 'XLMUSDT', 'BCHUSDT', 'ETHUSDT', 'BNBUSDT', 'LTCUSDT' ]
CURRENT_PRICE={} def ticker_socket(msg):
bsm=BinanceSocketManager(client) for coin in keywords: coin_key=bsm.start_symbol_ticker_socket(coin,ticker_socket) bsm.start()
if name == 'main': print('Press Ctrl-Q to stop the script') for i in count(): ticker_socket() print(f'Iteration {i}') time.sleep(60*REPEAT_EVERY)
Expected behavior :
I am working on my first bot : I want here the endprices of the tickers (in the array 'keywords'), but it seems i have a problem which i cannot handle ...
Environment (please complete the following information):
Logs or Additional context Many thanks if you could help me out with this ...)