Closed DrPaprikaa closed 3 years ago
Hi! I guess you are working with milliseconds but expect to be working with seconds. Just do /1000 and try again. Best regards, Oliver
Hi!
I already tried :
print(datetime.datetime.utcfromtimestamp(2046077850))
gives 2034-11-02 10:57:30
print(datetime.datetime.utcfromtimestamp(2046077850/1000))
gives 1970-01-24 16:21:17.850000
I'm a bit lost...
oh, you are using the ID not the timestamp: oldest_stream_data_from_stream_buffer['last_update_id']
Ok thanks my bad, last_update_id
is not a timestamp :) I am using the Partial Book Depth Stream which doesn't return any timestamp. But then, how can I know the timestamp of the data I'm receiving ? Trading is about timing, I need to know if the data I'm receiving is delayed !
btw, oldest_stream_data_from_stream_buffer
is confusing (from my perspective), since the 'oldest' in the name suggests that we retreive the oldest data and not the newest
i dont work with depth... isnt there an event_time?
To know if the data you receive is delayed you can do 2 different things.
actually its a FIFO stack and we do a pop(0) which should return the oldest entry from the stack....
There is an event_time
for the Diff. Depth Stream, but it's not what I need and is different than the Partial Book Depth Stream, which only has an lastUpdateId
.
Would you mind explaining how the size of the stream_buffer allows to know if the data is delayed ? By how much milliseconds ? I'm plotting the bids & asks in real time and I need to have the correct time labels.
actually its a FIFO stack and we do a pop(0) which should return the oldest entry from the stack
If it's a FIFO, wouldn't a pop(0)
get us the newest entry ?
for that the stream_buffer doesnt help but if its not empty or not almost empty you know there is a delay...
I think a pop() delivers the latest entry, a pop(0) delivers the oldest entrie... anyway. It seems there are faster and better ways to do so. https://docs.python.org/2/tutorial/datastructures.html#using-lists-as-queues
Hi, Thank you for your amazing library !
I have a hard time converting timestamps to valid datetimes and wouldn't mind a bit of help. Here is what I'm doing :
create_stream()
withdepth20@100ms
oldest_stream_data_from_stream_buffer = binance_websocket_api_manager.pop_stream_data_from_stream_buffer()
oldest_stream_data_from_stream_buffer['last_update_id']
This gives me a timestamp like
2046077850
. Fair enough, let's convert it to a datetime object :print(datetime.datetime.utcfromtimestamp(2046077850))
results in2034-11-02 10:57:30
, which is nowhere near the current time.How can I have the correct datetime, with milliseconds ?
Sorry if this not fully related to this library, I can delete my issue as soon as it's resolved if you want.
DrPaprikaa