Skip to content

Is there any limitation of "get_candles" returning only latest 199 candles & not more #65

Description

@lokeshgmali3

Hii dear, im using your github repository to fetch historical candles data for one minute timeframe for BRLUSD_otc asset, using "get_candles" method i found out that its not fetching candles data more than 199, i wanted to fetch 1440 number of candles data, then i assumed that in each request irrespective of "offset" it always returns only 199 candles & then i wanted to page backward to get more candles data but i found out that its just returning the same time candles data & not going backward,

i request you to please analye the code & its output pasted here & explain me if its issue in my code or way of using your repository or its the limitation of your repo that it will return just latest 199 candles data & wont fetch more older data beyond this, below are steps i did:

thanks in advance...

############################################################

first i pulled your repo into my pc & then to pull your repo to my pc i did ran below commands in cmd window & it proceeded successfully:

cd C:\Users\hp\Desktop\Quo
git clone https://github.com/cleitonleonel/pyquotex.git
cd pyquotex
python -m pip install --upgrade pip setuptools wheel
python -m pip install -e .
cd C:\Users\hp\Desktop\Quo

means i had repo installed in "C:\Users\hp\Desktop\Quo\pyquotex" & then i created a python file to fetch historical candles data whose location is "C:\Users\hp\Desktop\Quo"

############################################################

python file code:

Fetches and prints just the first two pages of candles, raw

import asyncio, time
from pyquotex.stable_api import Quotex

EMAIL = "add_your_quotex_credentials"
PASSWORD = "add_your_quotex_credentials"
LANG = "en"

ASSET = "BRLUSD_otc"
PERIOD = 60 # timeframe of minute converted into seconds
PAGE_WINDOW = PERIOD * 300 # ask for a 300-bar window

async def main():
client = Quotex(email=EMAIL, password=PASSWORD, lang=LANG)
print("Connecting…")
await client.connect()
print("Login successful.\n")

# 1) Batch 1: latest candles
end_ts = time.time()
batch1 = await client.get_candles(
    asset=ASSET,
    end_from_time=end_ts,
    offset=PAGE_WINDOW,
    period=PERIOD
)
print(f"Batch 1: fetched {len(batch1)} raw bars")
for i, c in enumerate(batch1, start=1):
    print(f"  [{i}] {c}")

if not batch1:
    print("No data in batch1, exiting.")
    await client.close()
    return

# 2a) Prepare for Batch 2: page backward just before the oldest of batch1
oldest1 = batch1[0]["time"]
print(f"oldest1 (batch1[0]['time']): {oldest1}")        # ← Debug print
end_ts = oldest1 - 60
print(f"end_ts for batch2 fetch: {end_ts}\n")           # ← Debug print

# 2b) Debug: show what end_from_time, offset, and period we’re about to use
print("About to fetch batch2 with parameters:")
print(f"  end_from_time = {end_ts}")
print(f"  offset        = {PAGE_WINDOW}")
print(f"  period        = {PERIOD}\n")

# 2c) Batch 2: the next page
batch2 = await client.get_candles(
    asset=ASSET,
    end_from_time=end_ts,
    offset=PAGE_WINDOW,
    period=PERIOD
)
print(f"\nBatch 2: fetched {len(batch2)} raw bars")
for i, c in enumerate(batch2, start=1):
    print(f"  [{i}] {c}")

await client.close()
print("\nDone.")

if name == "main":
asyncio.run(main())

############################################################

output on cmd:

C:\Users\hp\Desktop\Quo>p.py
Connecting…
Login successful.

Batch 1: fetched 199 raw bars
[1] {'time': 1752575520, 'open': 0.18106, 'close': 0.18053, 'high': 0.18108, 'low': 0.18044, 'ticks': 68}
[2] {'time': 1752575580, 'open': 0.18053, 'close': 0.18029, 'high': 0.18053, 'low': 0.18017, 'ticks': 73}
[3] {'time': 1752575640, 'open': 0.18029, 'close': 0.1794, 'high': 0.18034, 'low': 0.17929, 'ticks': 87}
...
[197] {'time': 1752587280, 'open': 0.17904, 'close': 0.17883, 'high': 0.17928, 'low': 0.17878, 'ticks': 78}
[198] {'time': 1752587340, 'open': 0.17885, 'close': 0.17859, 'high': 0.17896, 'low': 0.17852, 'ticks': 88}
[199] {'time': 1752587400, 'open': 0.17859, 'close': 0.17879, 'high': 0.17882, 'low': 0.17844, 'ticks': 142}

oldest1 (batch1[0]['time']): 1752575520
end_ts for batch2 fetch: 1752575460

About to fetch batch2 with parameters:
end_from_time = 1752575460
offset = 18000
period = 60

{'BRLUSD_otc': ['BRLUSD_otc', 1752587507.299, 0.17923, 0]}

Batch 2: fetched 199 raw bars
[1] {'time': 1752575520, 'open': 0.18106, 'close': 0.18053, 'high': 0.18108, 'low': 0.18044, 'ticks': 68}
[2] {'time': 1752575580, 'open': 0.18053, 'close': 0.18029, 'high': 0.18053, 'low': 0.18017, 'ticks': 73}
[3] {'time': 1752575640, 'open': 0.18029, 'close': 0.1794, 'high': 0.18034, 'low': 0.17929, 'ticks': 87}
...
[197] {'time': 1752587280, 'open': 0.17904, 'close': 0.17883, 'high': 0.17928, 'low': 0.17878, 'ticks': 78}
[198] {'time': 1752587340, 'open': 0.17885, 'close': 0.17859, 'high': 0.17896, 'low': 0.17852, 'ticks': 88}
[199] {'time': 1752587400, 'open': 0.17859, 'close': 0.17879, 'high': 0.17882, 'low': 0.17844, 'ticks': 142}

Done.

C:\Users\hp\Desktop\Quo>

############################################################

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions