From 26956b9b5eff392298a84107678a897661463259 Mon Sep 17 00:00:00 2001 From: grzhan Date: Sun, 17 Mar 2024 22:43:57 +0800 Subject: [PATCH] fix: #55 incorrect timestamp format in 'OK-ACCESS-TIMESTAMP' header when use_server_time=True is used --- okx/okxclient.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/okx/okxclient.py b/okx/okxclient.py index ae8d6d9..f799b22 100644 --- a/okx/okxclient.py +++ b/okx/okxclient.py @@ -1,4 +1,5 @@ import json +from datetime import datetime, timezone import httpx from httpx import Client @@ -50,6 +51,7 @@ class OkxClient(Client): request_path = c.API_URL + c.SERVER_TIMESTAMP_URL response = self.get(request_path) if response.status_code == 200: - return response.json()['data'][0]['ts'] + ts = datetime.fromtimestamp(int(response.json()['data'][0]['ts']) / 1000.0, tz=timezone.utc) + return ts.isoformat(timespec='milliseconds').replace('+00:00', 'Z') else: return ""