❗️Issue: Time mismatch between local system and platform server causes missed candle timings
Describe the issue
Hey bro, my script logic is like this: I fetch the most recent candle, then calculate how long to wait until the next candle starts, so I can place trades exactly at the candle open.
The logic works well in theory, but in practice there's a time mismatch between my local system clock (from time.time()) and the actual platform/server time. Sometimes it's off by 1–2 minutes. This causes my script to either miss the start of a new candle or think a candle has started when it hasn’t yet.
As a result, I sometimes miss important trade setups because I'm either too early or too late based on incorrect timing.
My approach so far:
# I currently use this to calculate time until the next candle
current_time = time.time()
next_interval = (current_time // period) * period + period
time_to_wait = next_interval - current_time
await asyncio.sleep(time_to_wait)
But this logic depends on my local system time — which doesn't always match the broker/exchange candle timing.
💡 Suggestion / Request
Would it be possible to add a function in the library like:
await client.get_server_time()
...so we can fetch the real-time from the platform (UNIX timestamp), and sync candle logic accurately?
Or is there a recommended way to get platform-aligned time using the current API?
Why this matters:
Precise timing is critical in trading strategies. A 1–2 minute mismatch in candle start time can completely break signal logic or cause missed entries.
🙏 Asking for Help / Guidance Is there any way to fetch the server time from the platform using this library? Or is there another recommended method to sync the timing exactly with the platform’s candle generation?
Any help, guidance, or suggestions would mean a lot — just want to make sure I’m acting at the exact candle open to avoid losing trades.
Thanks!
Hey big bro, any suggestion for me?
Is there another way to align timing accurately with the server using the current API?
I just wanna make sure my trades hit exactly at candle open — any tip or workaround would help a lot 🙏
Thanks!
💡 Suggestion / Request
Would it be possible to add a function in the library like:
await client.get_server_time() ...so we can fetch the real-time from the platform (UNIX timestamp), and sync candle logic accurately?
This function does not exist in the public version, but you can obtain the server date and time based on your timezone which is defined in the platform's initial settings, here for me it is UTC-3 :
Through the Quotex API itself, the basic version that we access through the browser is translated as shown in the image below :
from datetime import datetime, timedelta
def get_server_time_from_offset(local_time: datetime = None, time_offset: int = 0) -> datetime:
"""
Calculates the server time (UTC) based on the local time and a given time offset in seconds.
Args:
local_time (datetime, optional): The local time to use as a reference. Defaults to current time.
time_offset (int): The time offset in seconds (e.g., -10800 for UTC-3).
Returns:
datetime: The calculated server (UTC) time.
"""
if local_time is None:
local_time = datetime.now()
return local_time - timedelta(seconds=time_offset)
# Example usage
if __name__ == "__main__":
offset = -10800 # UTC-3
server_time = get_server_time_from_offset(time_offset=offset)
print("Local time:", datetime.now().strftime("%H:%M:%S"))
print("Server time (UTC):", server_time.strftime("%H:%M:%S"))
This would give you the server time. Also, there is already an implementation to capture this offset using the current get_profile method. All you need to do is use client.get_profile() to get the profile object with the required attributes, including the offset, and thus automate this process in your workflow. Do this, don't wait for someone to do it for you. Read the documentation, read the methods, use the library and try something, implement something and contribute to this library. Although opening issues can be a way to contribute, as you can see, I am the only one responding here and just asking questions is not a real help. Contribute to implementing this feature in the public version, open a PR and help others with the same problem. Thanks in advance and if this solves your problem or questions, I ask you to close the issue or keep it open until someone solves it or until you decide to take action and send us a solution to the problem.
Hey bro, 🕒 In this screenshot I marked the exact time on the platform: 00:27 – this is the kind of exact timing I want to align with.
Bro, I tried your suggestion with some changes — it works and gives the server time. Thanks for that!
But there’s still a lot of work to be done. The candle time doesn’t match exactly with the platform. I don’t want calculated time — I need the actual candle open and close time from the server.
If you have any suggestions, please let me know.
Thanks!
Hey bro, 🕒 In this screenshot I marked the exact time on the platform: 00:27 – this is the kind of exact timing I want to align with.
Bro, I tried your suggestion with some changes — it works and gives the server time. Thanks for that!
But there’s still a lot of work to be done. The candle time doesn’t match exactly with the platform. I don’t want calculated time — I need the actual candle open and close time from the server.
If you have any suggestions, please let me know.
Thanks!
So my friend, the platform does not make this information available via websocket, so I would like to ask you to look for other ways to get it, and I have no suggestions or information about that. Good luck with that, I can't help you anymore, as my efforts are limited to what I can get from the platform. If this answer was satisfactory, I ask you to close this topic. If you want to keep it open, that's your decision, maybe others can help you. See you later.