LUCIT-Systems-and-Development / unicorn-binance-websocket-api

A Python SDK by LUCIT to use the Binance Websocket API`s (com+testnet, com-margin+testnet, com-isolated_margin+testnet, com-futures+testnet, com-coin_futures, us, tr, dex/chain+testnet) in a simple, fast, flexible, robust and fully-featured way.
https://unicorn-binance-websocket-api.docs.lucit.tech/
Other
683 stars 164 forks source link

TypeError: process_stream_data() got an unexpected keyword argument 'stream_buffer_name' #88

Closed mbellmbell closed 4 years ago

mbellmbell commented 4 years ago

Check this or we will delete your issue. (fill in the checkbox with an X like so: [x])

Select one:

Environment

Operating System? (include version)

Python Version Requirement

Exact Python Version?

Include here the response of 'python --version' or 'python3 --version'
Python 3.6.9

Pip Version?

Include here the response of 'pip --version' or 'pip3 --version'
pip 20.1.1 from /home/ubuntu/.local/lib/python3.6/site-packages/pip (python 3.6)

Dependencies

Run pip list > pip_list.txt and upload the file. pip_list.txt I have also upgraded to aiohttp 3.6.2 and same problem.

UNICORN Binance WebSocket API Version?

Did you upgrade to the latest release version with `pip install unicorn-binance-websocket-api --upgrade`?
YES
Please control what version you are using with this script and post the output: https://github.com/oliver-zehentleitner/unicorn-binance-websocket-api/blob/master/tools/get_used_module_version.py
1.16.3

Description of your issue

Things work fine on MacOS, but when install on Ubuntu 18.0, I get this error when starting up:

Exception in thread Thread-7:
Traceback (most recent call last):
  File "/usr/lib/python3.6/threading.py", line 916, in _bootstrap_inner
    self.run()
  File "/usr/lib/python3.6/threading.py", line 864, in run
    self._target(*self._args, **self._kwargs)
  File "/home/ubuntu/.local/lib/python3.6/site-packages/unicorn_binance_websocket_api/unicorn_binance_websocket_api_manager.py", line 312, in _create_stream_thread
    loop.run_until_complete(binance_websocket_api_socket.start_socket())
  File "/usr/lib/python3.6/asyncio/base_events.py", line 484, in run_until_complete
    return future.result()
  File "/home/ubuntu/.local/lib/python3.6/site-packages/unicorn_binance_websocket_api/unicorn_binance_websocket_api_socket.py", line 90, in start_socket
    stream_buffer_name=self.handler_binance_websocket_api_manager.stream_list[self.stream_id]['stream_buffer_name'])
TypeError: process_stream_data() got an unexpected keyword argument 'stream_buffer_name'

I was able to run simple example you have (3 + 4 lines of code) successfully. Not sure where to look for source of problem.

Include the contents of the log here (if applicable). < REPLACE THIS TEXT
oliver-zehentleitner commented 4 years ago

Hi! I know you told it, but i really guess you are not up to date with the lib! What is your example code? BR, Oliver

mbellmbell commented 4 years ago

Thx. Here is example code:

from unicorn_binance_websocket_api.unicorn_binance_websocket_api_manager import BinanceWebSocketApiManager

class BinanceWebSocketApiProcessStreams:
    @staticmethod
    def process_stream_data(received_stream_data_json):
        print(received_stream_data_json)

def start():
    binance_websocket_api_manager = BinanceWebSocketApiManager(BinanceWebSocketApiProcessStreams.process_stream_data)
    binance_websocket_api_manager.create_stream({'aggTrade'}, {'BTCUSDT'})

if __name__ == '__main__':
    start()

I have attached latest pip list file.

pip_list.txt

mbellmbell commented 4 years ago

OK, it looks like def_process_stream_data() now requires stream_buffer_name param:

def process_stream_data(received_stream_data_json, stream_buffer_name=False):

The reason is work on my local machine is that I'm running an old version of Unicorn library that doesn't require param. I'm guessing if I upgrade local Unicorn version it will break as well.

Back in business. Thanks again.

oliver-zehentleitner commented 4 years ago

Great! :+1:

oliver-zehentleitner commented 4 years ago

just 4 info: process_stream_data() is overloading add_to_stream_buffer() and needs to get the same args: https://oliver-zehentleitner.github.io/unicorn-binance-websocket-api/unicorn_binance_websocket_api.html#unicorn_binance_websocket_api.unicorn_binance_websocket_api_manager.BinanceWebSocketApiManager.add_to_stream_buffer

The way you use with the call back function was the first implementation, then I implemented the stream_buffer and i think its better to work with the stream_buffer! https://github.com/oliver-zehentleitner/unicorn-binance-websocket-api/blob/master/example_stream_buffer.py https://github.com/oliver-zehentleitner/unicorn-binance-websocket-api/blob/master/example_stream_buffer_extended.py

mbellmbell commented 4 years ago

OK, thanks. Got it.

BTW, where is the fastest place to run to minimize network overhead to binance API? I'm noticing it takes about 250ms to place a trade (running on AWS East). I'm sure most of this is Binance processing, but trying to understand where I should be running to shave a few ms off of things as that has an impact on what I'm doing.

kimchirichie commented 3 years ago

the examples seem to be outdated. processing class example fails

oliver-zehentleitner commented 3 years ago

Which one? What error?