-1

I need help with the code to stary binance futures userdata stream as the package is not working.

I tried following changes in the code but it failed stating that APIERROR(code=0) Invalid Jason error message from Binance. The tweaks I made to subscribe futures userdatastream are as follows:

In my script:

bm = BinanceSocketManager(client)
def processmessage(msg):
    print(msg)
    conn_keys = bm.start_user_socket(processmsg)
    bm.start()

In websockets.py in def start_socket: I replaced stream_url with fstream_url

In client.py in def create_api_uri: I replaced api_url with futures_url

I am in need of binance futures’s userdata stream websockets.

Mike Malyi
  • 983
  • 8
  • 18
  • 2
    "help with the code". What code? You need to show us your code if you want help with it. How are we supposed to know why what you're doing isn't working when you haven't showed us what that is? – CryptoFool Feb 12 '21 at 07:19
  • I tried following changes in the code but it failed stating that APIERROR(code=0) Invalid Jason error message from Binance. the tweaks I made to subscribe futures userdatastream are as follows: 1-In my script bm = BinanceSocketManager(client) def processmessage(msg): print(msg) conn_keys = bm.start_user_socket(processmsg) bm.start() 2 In websockets.py in def start_socket: I replaced stream_url with fstream_url 3 in client.py in def create_api_uri: I replaced api_url with futures_url I am in need of binance futures’s userdata stream websockets.... Please help Thanks.... – mahesh solanki Feb 12 '21 at 14:11
  • I guessed that anyone who uses python-binance module knows that it doesn't have future's userdatasream websockets...and therefore I asked without code... – mahesh solanki Feb 12 '21 at 14:12
  • I moved your comments into the question itself, where those additions belong. – CryptoFool Feb 12 '21 at 18:43
  • Where is the rest of your solution? What code `websockets.py` and `client.py` are you talking about? Are you expecting that we know about some example that you are starting with and modifying? We can't know what that example is because you haven't told us. Also, you shouldn't just refer to an example. You should include all of the code that is involved directly in your question. Please try to provide a [Minimal, Complete, and Verifiable Example](https://stackoverflow.com/help/mcve). – CryptoFool Feb 12 '21 at 18:47

3 Answers3

0

I am also using the package as you.

What you need is to re-write the process_data logic to get the data, and then us the code as following:

bm.start_futures_socket(process_data)

bm.start()

0

I was also trying to do the same. I couldn't get python-binance to work, so I switched to the unicorn_binance_websocket_api.

Quick example:

from unicorn_binance_websocket_api.unicorn_binance_websocket_api_manager import BinanceWebSocketApiManager

binance_websocket_api_manager = BinanceWebSocketApiManager(exchange="binance.com-futures")
binance_websocket_api_manager.create_stream('arr', '!userData', api_key=<Your API key>, api_secret=<Your secret API key>, output="UnicornFy")
while True:
    data = binance_websocket_api_manager.pop_stream_data_from_stream_buffer()
    if data:
        #do something with that data
        pass

Maybe that helps.

ALZERCODE
  • 47
  • 6
0

this is my code:

binance = await AsyncClient.create(config.API_KEY, config.API_SECRET)
bsm = BinanceSocketManager(binance)
async with bsm.futures_multiplex_socket(streams) as ms:
    while True:
        msg = await ms.recv()
        ...
Mariusz
  • 2,617
  • 1
  • 23
  • 26