question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

don't know howto heandle the receive data from binance

See original GitHub issue

hi, guy I came from python-biannce client user, i like current unicorn-binance socket client. but i found there is missing some sample case to examine the usage case.

such as: I want to handle KDJ kline. i can reference this repo’s sample code:

oldest_stream_data_from_stream_buffer = UnicornFy.binance_com_websocket(oldest_stream_data_from_stream_buffer)

but the oldest_stream_data_from_stream_buffer is not easy to use to feed pandas framedata.

below is my python-binance code

    candles = client.get_klines(symbol=symbol, interval=Client.KLINE_INTERVAL_5MINUTE)
    df = pd.DataFrame(candles)
    df.columns=['timestart','open','high','low','close','?','timeend','?','?','?','?','?']
    df.timestart = [datetime.fromtimestamp(i/1000) for i in df.timestart.values]
    df.timeend = [datetime.fromtimestamp(i/1000) for i in df.timeend.values]

in unicorn-binance. howto do that. please give some example. thanks.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:6 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
xiaodscommented, May 25, 2020

@oliver-zehentleitner thanks for your patient reply. I got it. Thanks a lot

0reactions
oliver-zehentleitnercommented, May 25, 2020

I have very less time this days so I cant prepare an example file atm.

The first request from python binance is a REST API request for ONE symbol!

The websocket is able to deliver klines for any symbol via one single connection. So they add some more infos to enable you to recognize what you got.

the output you get is:

{
  "stream": "btcusdt@kline_5m",
  "data": {
    "e": "kline",
    "E": 1590406118165,
    "s": "BTCUSDT",
    "k": {
      "t": 1590405900000,
      "T": 1590406199999,
      "s": "BTCUSDT",
      "i": "5m",
      "f": 327937931,
      "L": 327939777,
      "o": "8721.72000000",
      "c": "8737.20000000",
      "h": "8740.73000000",
      "l": "8721.61000000",
      "v": "160.07843500",
      "n": 1847,
      "x": false,
      "q": "1398014.06181080",
      "V": "77.99050700",
      "Q": "681137.56961985",
      "B": "0"
    }
  }
}

This is a string variable with json content, now convert the json to a python dict with: your_dict = json.loads(stream_data_json)

https://github.com/binance-exchange/binance-official-api-docs/blob/master/web-socket-streams.md#klinecandlestick-streams

What you need is o c h l (open, close, highest and lowest price).

I hope this helps you!

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to get live crypto data from Binance | by Gabriele Deri
Just call the ws_trade() function like a normal function and wsapp.run_forever() will handle all the incoming messages from Binance and it will display...
Read more >
Exploratory Data Analysis with the Binance API using Python ...
Want to start your own crypto analysis?Keen to apply a little Python or Data Science to your finances?Well this series is for you!...
Read more >
15 Tips to Enhance Security of Your Binance Account
1. Always use · 2. Check the list of devices · 3. Use a strong password for your Binance account and change it...
Read more >
Binance Python API – A Step-by-Step Guide - Algo Trading 101
Using the Binance WebSocket for the latest Bitcoin price. The Binance WebSocket requires us to only send a command once to open up...
Read more >
Do you want consistent data from binance? *** #254 - GitHub
Yes I do think that should be the process of recovering lost data. As for the way to receive the signal, I don't...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found