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 }}
This repository was archived by the owner on Jun 1, 2025. It is now read-only.
Hi, I’m experiencing an issue where the get_candles method occasionally hangs. Most of the time it works correctly, but sometimes the script just freezes after printing:
Fetching most recent candle for time: <timestamp>
No error is thrown and no further output is logged. Below is my script and sample output. I’ve removed unrelated lines for clarity.
💻 Script (Relevant Part)
# Fetch the most recent candleend_from_time=time.time() # Directly use the current timeprint(f"Fetching most recent candle for time: {end_from_time}")
# Fetch the candles data (only the most recent one)candles=awaitclient.get_candles(asset, end_from_time, offset, period)
candles_data=candlesiflen(candles_data) >0:
ifnotcandles_data[0].get("open"):
candles=process_candles(candles_data, period)
candles_data=candles# Update the candles data with processed data# In the place where you're getting the datarecent_candle=candles_data[-1]
ifnothas_printed:
print(f"Most recent candle for {asset}: {recent_candle}")
has_printed=Trueiffirst_fetch:
# Calculate the next 5-minute interval to align with the next candlecurrent_time=time.time()
next_interval_start_time= (current_time//period) *period+period# Calculate time to wait until the next 5-minute intervaltime_to_next_candle=next_interval_start_time-current_timetime_to_next_candle+=10# Adding 10 extra seconds for the waitiftime_to_next_candle>0:
print(f"Waiting for {time_to_next_candle:.2f} seconds until the new candle starts.")
awaitasyncio.sleep(time_to_next_candle)
first_fetch=False# After the initial wait, fetch the next candles without delay calculationscandles=awaitclient.get_candles(asset, time.time(), offset, period)
candles_data=candlesiflen(candles_data) >0:
recent_candle=candles_data[-1]
print(f"Most recent candle for {asset}: {recent_candle}")
color=get_color(recent_candle)
candles_color.append(color)
print(f"Color of the most recent candle: {color}")
🧪 Sample Output
Fetching most recent candle for time: 1745601008.5277383
Most recent candle for USDINR_otc: {'time': 1745600700, 'open': 90.7622, 'close': 90.7474, 'high': 90.7622, 'low': 90.7387, 'ticks': 688}
Waiting for 290.19 seconds until the new candle starts.
Most recent candle for USDINR_otc: {'time': 1745600700, 'open': 90.7622, 'close': 90.7474, 'high': 90.7622, 'low': 90.7387, 'ticks': 387}
Color of the most recent candle: red
Fetching most recent candle for time: 1745601601.1610038
Most recent candle for USDINR_otc: {'time': 1745601300, 'open': 90.7629, 'close': 90.7722, 'high': 90.7752, 'low': 90.7568, 'ticks': 713}
Color of the most recent candle: green
Fetching most recent candle for time: 1745601904.2905717
Most recent candle for USDINR_otc: {'time': 1745601600, 'open': 90.7722, 'close': 90.7546, 'high': 90.7729, 'low': 90.7536, 'ticks': 705}
Color of the most recent candle: red
Fetching most recent candle for time: 1745602206.4088607
Most recent candle for USDINR_otc: {'time': 1745601900, 'open': 90.7544, 'close': 90.7673, 'high': 90.7689, 'low': 90.7509, 'ticks': 703}
Color of the most recent candle: green
Fetching most recent candle for time: 1745602508.3360462 <-- Script freezes here
🔎 Summary
The script consistently prints the Fetching most recent candle for time: log, then hangs.
It doesn't print the actual candle data afterward.
There’s no exception or traceback — it just stops.
This seems to happen randomly after several successful fetches.
Is this a known issue, or could this be due to an unstable API response, rate limiting, or something else?
Would you recommend using a timeout or some advise for get_candles and fix this problem?
Thanks for your support!
The text was updated successfully, but these errors were encountered:
Sign up for freeto subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Hi, I’m experiencing an issue where the
get_candles
method occasionally hangs. Most of the time it works correctly, but sometimes the script just freezes after printing:No error is thrown and no further output is logged. Below is my script and sample output. I’ve removed unrelated lines for clarity.
💻 Script (Relevant Part)
🧪 Sample Output
🔎 Summary
Fetching most recent candle for time:
log, then hangs.Is this a known issue, or could this be due to an unstable API response, rate limiting, or something else?
Would you recommend using a timeout or some advise for
get_candles
and fix this problem?Thanks for your support!
The text was updated successfully, but these errors were encountered: