enarjord / passivbot

Trading bot running on Bybit, Bitget, OKX, GateIO, Binance and Hyperliquid
https://www.passivbot.com
Other
1.13k stars 419 forks source link

Bybit API returns "Invalid request, please check your server timestamp or recv_window param" #424

Open zlly20 opened 1 year ago

zlly20 commented 1 year ago

the bot is running on a VPS hosted by DigitalOcean. it was fine, but all of a sudden, I got this error. it seems happening to most of coin pairs but not all of them. and it seems on and off.

bybit api returns {"retCode":10002,"retMsg":"invalid request, please check your server timestamp or recv_window param. req_timestamp[1699248598448],server_timestamp[1699248604342],recv_window[5000]","result":{},"retExtInfo":{},"time":1699248604342}

I have checked the server time also the bybit time via its public endpoint, it shows the time (in seconds) is exactly the same to the VPS server time. I also checked the CPU usage on the server, it is pretty low, and so is the memory usage. Why do I get this error then? any thoughts on the cause of this would be good. thanks.

Current Local Time (Unix Timestamp): 1699252559 Bybit server Time: {"retCode":0,"retMsg":"OK","result":{"timeSecond":"1699252559","timeNano":"1699252559570293266"},"retExtInfo":{},"time":1699252559570}

`The above exception was the direct cause of the following exception:

Traceback (most recent call last): File "/home/gary/passivbot-live/tradingbot-passivbot/exchanges/bybit.py", line 137, in fetch_position positions, balance = await asyncio.gather( File "/opt/pyenv-shared/pyenv/versions/3.9.6/lib/python3.9/site-packages/ccxt/async_support/bybit.py", line 5486, in fetch_positions response = await self.privateGetV5PositionList(self.extend(request, params)) File "/opt/pyenv-shared/pyenv/versions/3.9.6/lib/python3.9/site-packages/ccxt/async_support/base/exchange.py", line 1889, in request return await self.fetch2(path, api, method, params, headers, body, config) File "/opt/pyenv-shared/pyenv/versions/3.9.6/lib/python3.9/site-packages/ccxt/async_support/base/exchange.py", line 1886, in fetch2 return await self.fetch(request['url'], request['method'], request['headers'], request['body']) File "/opt/pyenv-shared/pyenv/versions/3.9.6/lib/python3.9/site-packages/ccxt/async_support/base/exchange.py", line 211, in fetch raise RequestTimeout(details) from e ccxt.base.errors.RequestTimeout: bybit GET https://api.bybit.com/v5/position/list?symbol=BCHUSDT&category=linear 2023-11-06T05:29:10 ERROR error with update position 'NoneType' object is not subscriptable Traceback (most recent call last): File "/home/gary/passivbot-live/tradingbot-passivbot/passivbot.py", line 428, in update_position position["wallet_balance"] = self.adjust_wallet_balance(position["wallet_balance"]) TypeError: 'NoneType' object is not subscriptable 2023-11-06T05:29:10 ERROR error with 2023-11-06T05:30:04 ERROR error fetching latest fills bybit {"retCode":10002,"retMsg":"invalid request, please check your server timestamp or recv_window param. req_timestamp[1699248598448],server_timestamp[1699248604342],recv_window[5000]","result":{},"retExtInfo":{},"time":1699248604342} Traceback (most recent call last): File "/home/gary/passivbot-live/tradingbot-passivbot/exchanges/bybit.py", line 421, in fetch_latest_fills fetched = await self.cc.fetch_my_trades(symbol=self.symbol) File "/opt/pyenv-shared/pyenv/versions/3.9.6/lib/python3.9/site-packages/ccxt/async_support/bybit.py", line 4609, in fetch_my_trades response = await self.privateGetV5ExecutionList(self.extend(request, params)) File "/opt/pyenv-shared/pyenv/versions/3.9.6/lib/python3.9/site-packages/ccxt/async_support/base/exchange.py", line 1889, in request return await self.fetch2(path, api, method, params, headers, body, config) File "/opt/pyenv-shared/pyenv/versions/3.9.6/lib/python3.9/site-packages/ccxt/async_support/base/exchange.py", line 1886, in fetch2 return await self.fetch(request['url'], request['method'], request['headers'], request['body']) File "/opt/pyenv-shared/pyenv/versions/3.9.6/lib/python3.9/site-packages/ccxt/async_support/base/exchange.py", line 221, in fetch self.handle_errors(http_status_code, http_status_text, url, method, headers, http_response, json_response, request_headers, request_body) File "/opt/pyenv-shared/pyenv/versions/3.9.6/lib/python3.9/site-packages/ccxt/async_support/bybit.py", line 7046, in handle_errors self.throw_exactly_matched_exception(self.exceptions['exact'], errorCode, feedback) File "/opt/pyenv-shared/pyenv/versions/3.9.6/lib/python3.9/site-packages/ccxt/async_support/base/exchange.py", line 2252, in throw_exactly_matched_exception raise exactstring ccxt.base.errors.InvalidNonce: bybit {"retCode":10002,"retMsg":"invalid request, please check your server timestamp or recv_window param. req_timestamp[1699248598448],server_timestamp[1699248604342],recv_window[5000]","result":{},"retExtInfo":{},"time":1699248604342} `