Hi all,
I just created account today. I really like interface and when i think about possibilities to test and create new strategies - I am excited. However, what i found really weird are following things:
For the same execution (not a single line of the code was changed) I get different results. I even simplified the code to the level that it should only print to debug if the 4hour candle is bullish or bearish. I'm only using EURUSD Oanda and starting at the same date. It gives… different results. In addition when I also add time of the candle to debug to find it on the chart (using TradingView for that) i can't match it with the chart from that period of time (beginning of 2025).
Is it because data is randomized cause of free tier? I need to understand why it works like this before i buy… anyone?
Robert Lemois
yes, this came about 2-3 months ago. It drove me crazy, I typically run 5 test and see where they cluster.
Reason: Lean is a non-deterministic replay engine, not a deterministic simulation engine.
1. Warmup data variability. Lean pulls historical data from disk cache, in-memory cache, and remote QC servers. The order and completeness of those packets varies run-to-run.
2. Non-deterministic iteration order. Python's hash seed randomizes per container launch, so dict.items() and set iteration order varies.
3. Minute→daily bar merging is runtime, not stored. Lean constructs daily bars by merging minute bars on the fly during warmup. This merge is multi-threaded and cached non-deterministically, so the exact daily OHLCV values can differ subtly between runs.
Accept the platform constraint for backtesting purposes and rely on live production as the deterministic truth source — real market data doesn't have this problem because there's exactly one price stream.
Mikolaj
The material on this website is provided for informational purposes only and does not constitute an offer to sell, a solicitation to buy, or a recommendation or endorsement for any security or strategy, nor does it constitute an offer to provide investment advisory services by QuantConnect. In addition, the material offers no opinion with respect to the suitability of any security or specific investment. QuantConnect makes no guarantees as to the accuracy or completeness of the views expressed in the website. The views are subject to change, and may have become unreliable for various reasons, including changes in market conditions or economic circumstances. All investments involve risk, including loss of principal. You should consult with an investment professional before making any investment decisions.
To unlock posting to the community forums please complete at least 30% of Boot Camp.
You can continue your Boot Camp training progress from the terminal. We hope to see you in the community soon!