r/CryptoTradingBot • u/Constant_Guidance_47 • 19h ago
My Python trading bot times out on the OKX API. How can I tell where the delay happens?
I’m running a Python bot on Windows that watches LINK and XRP on OKX. It usually gets candle data successfully, but sometimes a request times out.
In one case, a LINK 5-minute candle request timed out. The bot then checked my account settings and positions successfully. When it tried to fetch open orders (GET /api/v5/trade/orders-pending), it had only about 1.3 seconds left to wait for a response. That request timed out too, so the bot paused trading. Windows didn’t record a disconnect during either request.
For anyone who’s debugged something similar: what timings would you log to tell how much time the bot spends preparing a request versus waiting for OKX to respond? I’d like to understand where the time goes before increasing the timeout again.