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

Add '!userData@arr' + 'MARGIN/SPOT/FUTURES' to 'stream_type' #16

Closed CryptoFuturesAU closed 3 years ago

CryptoFuturesAU commented 3 years ago

In the Binance websocket stream, 'outboundAccountInfo' websocket data is depreciated and will soon be removed. In the Binance websocket stream, 'account_permissions': ['SPOT'] within 'outboundAccountInfo' is the only indicator of which account the user stream belongs. In the unicorn-fy dictionary, user data streams are listed identically as: 'stream_type': '!userData@arr' whether the user streams are SPOT, MARGIN, ISOLATED or FUTURES

Can 'stream_type': '!userData@arr' be modified to include whether the stream is SPOT, MARGIN, ISOLATED or FUTURES? for example: 'stream_type': '!userData@arrSpot', '!userData@arrMargin', '!userData@arrIsolated', '!userData@arrFutures

If there is a better way of labeling different types of user data streams please let me know!

oliver-zehentleitner commented 3 years ago

Hello!

The returned dict should include stream_data['unicorn_fied'] which should include the exchange info which also includes isolated_margin and futures.

A second good way to identify the source stream of your data is to use the stream_buffer in create_stream():

stream_buffer_name (bool or str) – If False the data is going to get written to the default stream_buffer, set to True to read the data via pop_stream_data_from_stream_buffer(stream_id) or provide a string to create and use a shared stream_buffer and read it via pop_stream_data_from_stream_buffer(‘string’).

That way you can create userData streams of spot, margin, isolated_margin for User A and bind them to stream_buffer_name="UserA", the same for UserB and so on. Then you would have two separate stream_buffers for 2 different users including their 3 userData streams of spot, margin and isolated_margin.

If you set stream_buffer_name=True you can access the stream_buffer of this specific stream via its stream_id: pop_stream_data_from_stream_buffer(stream_id_isolated_margin)

Does this help you out?

Best regards, Oliver

oliver-zehentleitner commented 3 years ago

:) I wrote wrong infos! you cant mix different userdata types within one instance! Once instance for one exchange ....

oliver-zehentleitner commented 3 years ago

In the Binance websocket stream, 'outboundAccountInfo' websocket data is depreciated and will soon be removed.

Do you have a link to that info?

CryptoFuturesAU commented 3 years ago

https://binance-docs.github.io/apidocs/spot/en/#payload-account-update

"outboundAccountInfo has been deprecated and will be removed in the future. It is recommended to use outboundAccountPosition instead. "