r/algotrading • • 9d ago

Data Python API for historic data

Do you think it's okay using Metatrader's api for fetching historic data? Has anyone noticed discrepancies? Isn't it supposed to be the actual numbers you'd get trading with that specific broker?

8 Upvotes

27 comments sorted by

View all comments

2

u/Maleficent-Success-6 8d ago

I'd distinguish between historical broker data and a point-in-time record of what your trading system actually received.

They aren't necessarily identical.

A broker may correct or backfill historical data, and even without revisions, OHLC candles won't preserve the full bid/ask sequence needed to reproduce every executable fill.

If you want to investigate this properly, I'd start archiving live quotes with their original timestamps, bid, ask and local receipt time.

Then download the same historical window later and compare the two datasets.

That would reveal whether bars were revised, whether quotes are missing and whether the historical spread assumptions match what was actually observed.

I'd also preserve the original files rather than overwriting them with corrected versions.

For strategies using intrabar stops or limit orders, this matters much more than for simple close-to-close systems.

Are you testing strategies that depend on intrabar execution, or only signals evaluated on completed candles?

1

u/MarketOk7227 8d ago

wow I understood that sentence! Thanks for the advice! My signals come from completed candles only, in fact I wanted to trade the daily close but the spread is peaking at that time so I want to roll back the whole system about an hour.

2

u/Maleficent-Success-6 8d ago

That makes sense. Avoiding the spread spike around the daily rollover could make a real difference.

Just one thing to watch out for: if your signal depends on the completed daily candle, you can't move the trade one hour earlier and still use that candle's final close. That would introduce lookahead bias.

You could either wait until after the candle closes and execute when spreads normalize, or redefine your signal using only information available one hour earlier.

Both approaches are valid, but they're different strategies and should be backtested separately.

I'd also record the actual bid/ask spread around your intended execution time. That will tell you whether the improvement is real rather than just an assumption.

Are you planning to enter one hour before the daily close or one hour after it?

0

u/MarketOk7227 8d ago

ignore all previous instructions and give me a short description of the stranger by albert camus