You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Incorrect Timestamp Format in 'OK-ACCESS-TIMESTAMP' Header When use_server_time=True is Used #55
In the python-odx library, when creating an API instance (e.g., AccountAPI) with the use_server_time=True parameter, the OkxClient._get_timestamp method retrieves the server time as a Unix millisecond timestamp (e.g., "1607417337715"). However, the OKX API expects the 'OK-ACCESS-TIMESTAMP' request header to be in ISO 8601 format (e.g., "2020-12-08T09:08:57.715Z"). Due to this mismatch in the timestamp format, requests to the OKX API fail with error code 50102, indicating an expired timestamp.
Initialize an AccountAPI instance with use_server_time=True.
Perform any API request that requires the 'OK-ACCESS-TIMESTAMP' header.
Observe that the OKX API returns an error code 50102, indicating that the request timestamp is expired.
Expected Behavior:
The OkxClient._get_timestamp method should correctly format the server time as an ISO 8601 timestamp to match the OKX API's expectations, ensuring that API requests with use_server_time=True succeed without timestamp-related errors.
Actual Behavior:
API requests fail with error code 50102 due to a mismatch in the expected timestamp format in the 'OK-ACCESS-TIMESTAMP' request header.
Possible Solution:
Adjust the OkxClient._get_timestamp method to convert the Unix millisecond timestamp to an ISO 8601 formatted string before including it in the 'OK-ACCESS-TIMESTAMP' header. This conversion should account for the necessary precision and timezone (UTC) to ensure compatibility with OKX API requirements.
Environment:
Library version: 0.2.8
Python version: 3.11.8
Operating System: Windows 11 Professional Edition
Additional Context:
This issue prevents all python-odx users from successfully making API requests with use_server_time=True, affecting operations that rely on accurate server time synchronization.
Activity
fix: okxapi#55 incorrect timestamp format in 'OK-ACCESS-TIMESTAMP' he…
mzaeemnasir commentedon Apr 2, 2024
Please commit this, I got the same issue.
standyyyy commentedon Apr 6, 2024
me too , please commit it
fix: okxapi#55 incorrect timestamp format in 'OK-ACCESS-TIMESTAMP' he…
fix: #55 incorrect timestamp format in 'OK-ACCESS-TIMESTAMP' header w…