sammchardy / python-binance

Binance Exchange API python implementation for automated trading
https://python-binance.readthedocs.io/en/latest/
MIT License
5.91k stars 2.19k forks source link

AttributeError: 'BinanceSocketManager' object has no attribute 'start_symbol_ticker_socket' #1020

Open driesdep opened 2 years ago

driesdep commented 2 years ago

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):

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):

Logs or Additional context Many thanks if you could help me out with this ...)

alexjorgef commented 2 years ago

You need to change your websocket code, start_symbol_ticker_socket function it's at ThreadedWebsocketManager class and not at BinanceSocketManager, check here.