tiagosiebler / bybit-api

Node.js SDK for the Bybit APIs and WebSockets, with TypeScript & browser support.
https://www.npmjs.com/package/bybit-api
MIT License
244 stars 80 forks source link

getPastOrders always throws recvWindow #167

Closed pranaypratyush closed 1 year ago

pranaypratyush commented 1 year ago

Getting the Timestamp for this request is outside of the recvWindow. error on getPastOrders regardless of anything. Other functions work.

tiagosiebler commented 1 year ago

Strange, which version are you using? Is this with the spot client?

pranaypratyush commented 1 year ago

yes, with spotclient on master. I fail to understand how this is even possible.

tiagosiebler commented 1 year ago

Definitely strange, given how the abstraction layers work...and given there are integration tests on all endpoints.

Can you try the latest beta release? It corresponds to the code currently in the open PR #166

npm install bybit-api@2.4.0-beta.1

You have two choices here as well, there's the SpotClient (which uses the original v1 spot apis from the docs) and there's SpotClientV3 (the successor, which uses the newer v3 spot apis from the docs).

I've tried to keep method naming consistent to reduce any transition pains as much as possible (from the v1 to v3 spot clients), but I would suggest to try both as there were under-the-hood refinements to how requests are built and authentication is handled. If there's a problem with auth in the current public release, it might be fixed in the beta release v1 client.

tiagosiebler commented 1 year ago

Closing this for now - the latest version (3.0.1 at time of writing) has tons of integration tests making real API calls, including this function, which is currently passing: https://github.com/tiagosiebler/bybit-api/blob/master/test/spot/private.v3.read.test.ts#L38-L40

If the issue does somehow come back in the latest version, feel free to reopen. Thanks

emorling commented 1 year ago

I am using v3, and still get:

ret_code: 10002,
ret_msg: 'invalid request, please check your timestamp and recv_window param. 
req_timestamp: 1663797780831
server_timestamp: 1663797785964
recv_window: 5000',

I noticed these settings. Should I increase recv_window? and enable enable_time_sync? What do you recommend for sync_interval_ms?

/** Override the max size of the request window (in ms) */
    recv_window?: number;
    /** Disabled by default. This can help on machines with consistent latency problems. */
    enable_time_sync?: boolean;
    /** How often to sync time drift with bybit servers */
    sync_interval_ms?: number | string;
tiagosiebler commented 1 year ago

Timestamp errors are different, I wrote an explanation of this and why your system time & network is important: https://github.com/tiagosiebler/awesome-crypto-examples/wiki/Timestamp-for-this-request-is-outside-of-the-recvWindow.

I'd suggest to try these, with each further step only a last resort if the previous step doesn't fix it: