sammchardy / python-binance

Binance Exchange API python implementation for automated trading
https://python-binance.readthedocs.io/en/latest/
MIT License
6.09k stars 2.21k forks source link

stream klines #484

Closed lcdunne closed 4 years ago

lcdunne commented 4 years ago

I just followed the example in the documentation for streaming klines, and specified a 1m interval. Despite that, the stream gives an output every 2 s which is in line with the frequency rate stated in the documentation. The price is changing each time as well, which means it's streaming the live price every 2 seconds. But if that's the case, what is the difference between kline streams and the standard tradesocket?

Is there a way to stream the kline data and have it return a value on the minute every minute (or whatever the interval is) rather than every 2 s?

oliver-zehentleitner commented 4 years ago

Hello! You get updates of the klines ... its starting with 0 vol and get updated after a change. So you are interested in getting the last kline. You can do this with in an if statement: if 'event_time' >= 'kline_close_time':

The difference between trade and kline stream is, that the trade stream sends you info about every trade that happens. kline stream streams the klines of a timeframe. Starting with 0, changing on updates and then sending you the last one of the timeframe and starts with the next interval.

Best regards!

lcdunne commented 4 years ago

I see, thanks for clearing that up!