Repository navigation
fix(candles): unify completed reads across live and backtest - #660
Open
Jeremy891102 wants to merge 4 commits into
Open
Jeremy891102 wants to merge 4 commits into
Jeremy891102 wants to merge 4 commits into
Conversation
|
As far as I understood your proposed fix, its not fixing what I mentioned. |
Author
|
yea your right, I'll revisit the existing get_candles() paths and establish a shared behavior contract, with cross-mode regression tests, before proposing further changes. |
Jeremy891102
marked this pull request as draft
November 25, 2026 14:47
Jeremy891102
marked this pull request as ready for review
November 25, 2026 15:10
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
A 30m strategy reading a 4h data route previously went through different
get_candles()branches in live and backtest modes. Backtest reads could synthesize and store a forming anchor, and a delayed live execution only filtered by open time, leaving an unclosed higher-timeframe bar visible.Use one completed-candle contract for the existing
get_candles()service,Strategy.get_candles()andStrategy.candles: include a stored row only whenopen + timeframe <= boundary. Prefer the strategy's thread-local execution cutoff; otherwise use the simulation/live clock. An exact close is included. Reads no longer generate bars or modify storage. No additional public getter is introduced.For example, at 12:30 UTC a 30m strategy excludes the 12:00–16:00 anchor; at 16:00 it includes it. A delayed execution for 12:30 continues to exclude it even after wall time reaches 16:00.
get_current_candle()retains access to forming bars, including causal higher-timeframe reads during delayed execution. Live aggregation, backtest aggregation/warmup, and intrabar order simulation consume raw observed source rows so the completed-only strategy filter does not remove their forming inputs.Related to #656. Compatibility: this changes existing getter semantics for strategies that relied on a forming last row, including 1m live reads. Forming-bar consumers should use the existing current-candle service (
Strategy.current_candlefor the trading route). Completion means elapsed timeframe, not confirmation that a venue's final update has arrived. This intentional change to the default contract needs maintainer review.Validation:
open + timeframe <= boundary) on the unchanged scenarios, seeds and strategies. Both captures pass, and exact metrics plus complete trade hashes remain asserted. The actual getter reproduces both fingerprints; step/fast equivalence also passes.git diff --checkpasses. Synced with upstream master at5b97b13a.Environment: macOS arm64, isolated Python 3.12.4, NumPy 2.5.5, pytest 6.2.5. Native extension built from unchanged jesse-rust in release mode. Synthetic/stored-data tests exercise live storage and clocks; no live exchange, external PostgreSQL integration, or private jesse-live installation was exercised. No new runtime dependencies.
Assisted-by: OpenAI Codex (GPT-6). AI implemented and tested this proposal. No human code review before submission is claimed.