OKEx exchange transaction date and time of turn-millisecond timestamp

This article describes how to record the date and time records OKEx exchanges data transfer millisecond timestamp.

Author: bit quantization

 

1. OKEx transaction format

[
    {
        "time":"2019-09-14T10:29:20.142Z",
        "timestamp":"2019-09-14T10:29:20.142Z",
        "trade_id":"1650300056",
        "price":"68.43",
        "size":"0.00166",
        "side":"sell"
    }
]

timstamp time and to the same value, a bit irregular

 

2. Switch to the millisecond timestamp

dt = '2019-09-14T10:29:20.142Z' #来源 比特量化
utc8 = datetime.datetime.strptime(dt, "%Y-%m-%dT%H:%M:%S.%fZ") + datetime.timedelta(hours=8)
utc8_ms = int(time.mktime(utc8.timetuple()) * 1000 + utc8.microsecond / 1000)
print(utc8_ms) 

return

1568456960142

 

Guess you like

Origin www.cnblogs.com/fangbei/p/okex-datetime_to_timestamp.html