LUCIT-Systems-and-Development / unicorn-fy

A Python SDK by LUCIT to convert received raw data from crypto exchange API endpoints into well-formed python dictionaries.
https://unicorn-fy.docs.lucit.tech
MIT License
54 stars 20 forks source link

!userData Channel ? #6

Closed DennyZen closed 3 years ago

DennyZen commented 4 years ago

Hi i've added userData stream. binance_com_user_data_stream_id = binance_com_websocket_api_manager.create_stream('arr', '!userData') Can UnicornFy work with this kind of stream? userData stream don't have data in response and i got this:

Traceback (most recent call last):
  File "userdata_stream.py", line 34, in print_stream_data_from_stream_buffer
    unicorn = UnicornFy.binance_com_websocket(oldest_stream_data_from_stream_buffer)
  File "/home/dennis/py-projects/binance_ws/venv/lib/python3.7/site-packages/unicorn_fy/unicorn_fy.py", line 125, in binance_com_websocket
    return UnicornFy.binance_websocket(stream_data_json, exchange="binance.com", show_deprecated_warning=False)
  File "/home/dennis/py-projects/binance_ws/venv/lib/python3.7/site-packages/unicorn_fy/unicorn_fy.py", line 246, in binance_websocket
    if stream_data['data']['e'] == 'aggTrade':
KeyError: 'data'

info from response :

{"e":"ORDER_TRADE_UPDATE","T":1593708087377,"E":1593708087381,"o":{"s":"BTCUSDT","c":"u7AlA2t0ltH7fmyNOXon0j","S":"BUY","o":"MARKET","f":"GTC","q":"0.128","
p":"0","ap":"8958.98000","sp":"0","x":"TRADE","X":"FILLED","i":5520695062,"l":"0.016","z":"0.128","L":"8958.98","n":"0.05733747","N":"USDT","T":1593708087377
,"t":157239716,"b":"0","a":"0","m":false,"R":false,"wt":"CONTRACT_PRICE","ot":"MARKET","ps":"BOTH","cp":false,"rp":"0"}}
oliver-zehentleitner commented 4 years ago

Hi Denny! There was a time when UserData worked... The lib needs a revision

  1. write tests for all results
  2. make it stable again

But i dont have the time atm....

oliver-zehentleitner commented 3 years ago

Fix: https://github.com/oliver-zehentleitner/unicorn_fy/issues/11

giahung24 commented 3 years ago

Hello, Sorry for reopening the issue. I have the same error today when listening on UserData Stream. I have verified the version of unicorn-fy, it's 0.6.0.

  File "/usr/lib/python3.7/threading.py", line 926, in _bootstrap_inner
    self.run()
  File "/usr/lib/python3.7/threading.py", line 870, in run
    self._target(*self._args, **self._kwargs)
  File "/home/jean/myriad/projects/pyenv/crypto/lib/python3.7/site-packages/unicorn_binance_websocket_api/unicorn_binance_websocket_api_manager.py", line 415, in _create_stream_thread
    loop.run_until_complete(socket.start_socket())
  File "/usr/lib/python3.7/asyncio/base_events.py", line 579, in run_until_complete
    return future.result()
  File "/home/jean/myriad/projects/pyenv/crypto/lib/python3.7/site-packages/unicorn_binance_websocket_api/unicorn_binance_websocket_api_socket.py", line 114, in start_socket
    received_stream_data = self.unicorn_fy.binance_com_websocket(received_stream_data_json)
  File "/home/jean/myriad/projects/pyenv/crypto/lib/python3.7/site-packages/unicorn_fy/unicorn_fy.py", line 85, in binance_com_websocket
    return UnicornFy.binance_websocket(stream_data_json, exchange="binance.com", show_deprecated_warning=False)
  File "/home/jean/myriad/projects/pyenv/crypto/lib/python3.7/site-packages/unicorn_fy/unicorn_fy.py", line 249, in binance_websocket
    if stream_data['data']['e'] == 'aggTrade':
KeyError: 'data'

[Update] I have identified the response that causes the error.

{
    "e": "listStatus",
    "E": 1606754342870,
    "s": "BTCUSDT",
    "g": 10610159,
    "c": "OCO",
    "l": "EXEC_STARTED",
    "L": "EXECUTING",
    "r": "NONE",
    "C": "VR0br4b4QJEFkbMqCsDUBJ",
    "T": 1606754342869,
    "O": [{
        "s": "BTCUSDT",
        "i": xxx,
        "c": "xxx"
    }, {
        "s": "BTCUSDT",
        "i": xxx,
        "c": "xxx"
    }]
}

Can you add support for this ? Thanks in advance for your help!

oliver-zehentleitner commented 3 years ago

@giahung24 Hello! I moved your post into a new issue! thanks for reporting it! Yes i will add it asap! Best regards!