Author

Topic: Python API "UNICORN Binance WebSocket API" (Read 192 times)

sr. member
Activity: 318
Merit: 250
sr. member
Activity: 318
Merit: 250
sr. member
Activity: 318
Merit: 250
We added support for Binance Jersey!

Code:
ubwa = unicorn_binance_websocket_api.BinanceWebSocketApiManager(exchange="binance.je")
sr. member
Activity: 318
Merit: 250
Hello!

I would like to introduce a python API to manage websockets to binance!

Project: https://github.com/LUCIT-Systems-and-Development/unicorn-binance-websocket-api

Code:
import unicorn_binance_websocket_api

ubwa = unicorn_binance_websocket_api.BinanceWebSocketApiManager(exchange="binance.com")
ubwa.create_stream(['trade', 'kline_1m'], ['btcusdt', 'bnbbtc', 'ethbtc'])

while True:
    oldest_data_from_stream_buffer = ubwa.pop_stream_data_from_stream_buffer()
    if oldest_data_from_stream_buffer:
        print(oldest_data_from_stream_buffer)

# What are the benefits of the UNICORN Binance WebSocket API?

  • Fully managed websockets and 100% auto-reconnect! Also handles maintenance windows!
  •     Streams are processing asynchronous/concurrent (Python asyncio) and each stream is started in a separate thread, so you dont need to deal with asyncio in your code!
  •     No use of the twisted module, so you can use this lib in a daemonized application (compatible with python-daemon).
  •     Supports subscribe/unsubscribe on all exchanges! (Take a look to the max supported subscriptions per stream in the endpoint configuration overview!)
  •     UNICORN Binance WebSocket API respects Binance's API guidelines and protects you from avoidable reconnects and bans.
  •     Support for multiple private !userData streams with different api_key and api_secret. (example_multiple_userdata_streams.py)
  •     Pick up the received data from the stream_buffer - if you can not store your data in cause of a temporary technical issue, you can kick back the data to the stream_buffer which stores the receives in the RAM till you are able to process the data in the normal way again. Learn more!
  •     Use separate stream_buffers for specific streams or users!
  •     Watch the stream_signal_buffer to receive CONNECT, DISCONNECT and FIRST_RECEIVED_DATA signals about the streams! Learn more!
  •     Get the received data unchanged as received, as Python dictionary or converted with UnicornFy into well-formed Python dictionaries. Use the output parameter of create_stream() to control the output format.
  •     Helpful management features like get_binance_api_status(), get_current_receiving_speed(), get_errors_from_endpoints(), get_limit_of_subscriptions_per_stream(), get_request_id(), get_result_by_request_id(), get_results_from_endpoints(), get_stream_buffer_length(), get_stream_info(), get_stream_list(), get_stream_id_by_label(), get_stream_statistic(), get_stream_subscriptions(), get_version(), is_update_availabe(), pop_stream_data_from_stream_buffer(), print_summary(), replace_stream(), set_stream_label(), set_ringbuffer_error_max_size(), subscribe_to_stream(), stop_stream(), stop_manager_with_all_streams(), unsubscribe_from_stream(), wait_till_stream_has_started() and many more! Explore them here.
  •     Monitor the status of the created BinanceWebSocketApiManager() instance within your code with get_monitoring_status_plain() and specific streams with get_stream_info().
  •     Nice to use with iPython: "IPython (Interactive Python) is a command shell for interactive computing that offers introspection, rich media, shell syntax, tab completion, and history." (example_interactive_mode.py) iPython
  •     Also nice to use with the Jupyter Notebook Smiley
  •     Monitoring API service and a check_command for ICINGA/Nagios icinga2-demo
  •     Excessively tested on Linux, Mac and Windows

Best regards,
Oliver
Jump to: