Skip to content

Commit 962960b

Browse files
luisleo526claude
andauthored
Session flags match TradingView on multi-window and extended-hours charts (K-SESSION-WINDOWS) (#293)
* Session: pre- and post-market read every session window, and an overnight session has neither TradingView flags no bar of TSE:7203 (0900-1130,1230-1530 Asia/Tokyo), HKEX:700 (0930-1200,1300-1600 Asia/Hong_Kong) or CBOT:ZC1! (1900-0745, 0830-1320 America/Chicago) pre- or post-market, at 15, 60 and 240 minutes: 1,570 bars across nine `lab tv` every-flag tapes, the 60-minute bars that open inside a break (TSE 12:00, ZC 08:00) included. Nor any bar of the overnight and 24-hour charts CME_MINI:ES1! (1700-1600), OANDA:XAUUSD (1800-1700), OANDA:EURUSD (1700-1700) and BINANCE:ETHUSDT.P (24x7). On NASDAQ:AAPL, the one-window control, the extended-hours tapes flag the bars opening 04:00 to before 09:30 ET pre-market and 16:00 to before 20:00 post-market, and the regular-hours tapes none. pineforge::session_in_premarket / session_in_postmarket (session_time.cpp), which generated code reaches through PineStrategyHost's class-scope wrappers -- gated by the calendar's in-market answer on the chart, and alone inside a request.security payload -- took the pre-market end and the post-market start from the FIRST "HHMM-HHMM" window, with fixed 04:00 / 20:00 bounds (lane CG-SESSION-2 finding F6). So HKEX:700's and TSE:7203's afternoons read post-market, the same windows written the other way round made the morning pre-market, and an overnight first window made one instant both (ZC 60: 60 bars both). The rule is now: pre-market runs from 04:00 to the session day's first open and post-market from its last close to 20:00, over every window in any order (extended_hours_bounds); a break between windows is neither; a session with a window that wraps midnight -- its day opens on the previous date -- or one that spans 24 hours has neither. A single same-day window reads exactly as before, the 24-hour spellings too. tests/test_session_prepost_windows_tape.cpp (kernel-only, new) replays the seventeen tapes of tests/fixtures/session_windows (README.md there: every tape's provenance; the CG-SESSION-2 and CG-ISMARKET tapes are copied unchanged from pineforge-codegen) through the chart-bar forms, and pins a synthetic day's off-market bars: the HKEX lunch is neither in either order, corn has neither. At 1e360bd it fails 31 of 114 checks (log in the lane scratch, tdd-f6-red.log): pre / post misses HKEX 15 0/120, reversed 100/0, TSE 15 0/130, ZC 15 350/240 (both-order 150/40), HKEX 60 0/30, TSE 60 0/40, ZC 60 100/70 with 60 both, ES1! 108/30, XAUUSD 117/20; the AAPL, EURUSD and ETH tapes 0 before and after. The replay reads TSE:7203 at 1545, where TradingView holds the 15:30 closing bar (CG-SESSION-2's open finding). Session policy, in the language calendar functions ADR-0001 rules for generated code (session_time.cpp); the kernel is untouched. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]> * Kernel: a script bar's session-day facts read the bar at its own label, not at an earlier instant of its interval TradingView flags NASDAQ:AAPL 60 with extended hours (bars on the hour, 04:00-19:00 ET, `cgim-flags-aapl-60-ext`) out of market on the 16:00 bar, and ends the regular day on the 15:00 bar (islastbar_regular); its first regular bar is 10:00. TSE:7203's 60-minute bar that opens at 12:00, inside the 11:30-12:30 break, and CBOT:ZC1!'s that opens at 08:00, inside 07:45-08:30, are in market (`ksw-flags-tse7203-60`, `ksw-flags-zc1-60`, and the 240-minute tapes; `lab tv --no-note`). present_session_day (native_execution_consumer.cpp) read every bar -- and every held neighbour, through eligible_session_point -- at the first eligible instant of the script interval holding its label. On the extended chart the regular session's 09:30-anchored grid files the 16:00 bar under the 15:30 interval, so it read in session and closed the day in place of 15:00 (lane CG-ISMARKET finding F1): in_session missed 10 bars of the tape and closes_session_day 20. A bar is now read at its label, or at its interval's first eligible instant when that is LATER: the break-open bars keep reading in session at their reopen, and an instant before a bar's own open is never the bar's. The certified-cycle fast path already answered that way (an in-span label is at or after its interval's first eligible instant), so it is unchanged. ADR-0001 ruling (row `present_session_day`, amended here): generic kernel. Reading a bar at its own label is a property of the facts, not a platform rule -- an instant before a bar opened is not in that bar, whatever grid the calendar keys the bar's interval to -- and nothing branches on a venue: the session, the zone and the labels are the run's data. The facts stay presentation and fold into no digest, so no hash, epoch or layout moves. Pine's pre/post-market and the extended-hours day stay in the adapter and session_time.cpp. tests/test_native_session_day_bar_open.cpp (kernel-only, new): a bare FeedTolerant host replays AAPL 60 / 15 with and without extended hours, and TSE:7203 / CBOT:ZC1! 60 and 240 aggregated from TradingView's own 15-minute bars; every script label, in_session, opens_session_day and closes_session_day is TradingView's session.ismarket / isfirstbar_regular / islastbar_regular on every bar. At 1e360bd the extended AAPL 60 tape fails 2 of 64 checks (in_session 10 bars, closes_session_day 20; lane scratch tdd-f1-red.log); every other case passes before and after, the break-open bars included. The 102 session, calendar, stream and C-API ctest rows pass unchanged. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]> * Adapter: session.isfirstbar / islastbar mark the chart's session day, and the _regular pair the regular one TradingView's extended-hours tapes of NASDAQ:AAPL (`cgim-flags-aapl-60-ext`, `cgs2-hist-aapl-15-ext`) part the two pairs: at 60 minutes isfirstbar is the 04:00 ET bar and islastbar the 19:00 one, isfirstbar_regular 10:00 and islastbar_regular 15:00; at 15 minutes 04:00, 19:45, 09:30 and 15:45. On every chart without extended hours (AAPL regular, TSE:7203, HKEX:700, CBOT:ZC1!, CME_MINI:ES1!, OANDA:XAUUSD / EURUSD, BINANCE:ETHUSDT.P) each pair is one flag. The Pine host held one pair, the kernel's regular session-day facts, which generated code read for both spellings (lane CG-ISMARKET finding F2): with F1 in place the extended tapes still missed isfirstbar and islastbar on 20 bars each (lane scratch tdd-f2-red-behaviour.log). PineStrategyHost now holds session_isfirstbar_regular_ / session_islastbar_regular_, the kernel's facts as they are, and widens the plain pair to the chart's session day (update_extended_session_day): the regular day plus the pre- and post-market bars of its date the chart holds, pre- and post-market being session_time's windows (F6), which exist only on a session day that opens and closes on one date. The bar before is the script bar published last; the bar after is the first retained input past the script bar's interval (PineScheduler::retained_input_from), so the chart, magnified and aggregated paths read one answer for the same bars, as lane E25 requires; a batch's final bar closes its day by the kernel's convention. A stream's realtime bar has nothing held after it: a pre- or post-market bar then reads the chart timeframe's next slot and a regular bar keeps the kernel's close. A chart holding no pre- or post-market bar reads exactly the kernel's facts, as before. Pine policy, in the adapter; the kernel is untouched and the new members fold into no hash (waivers beside the other session flags). tests/test_session_extended_day_tape.cpp (release, new) replays eleven tapes of tests/fixtures/session_windows through the host: every flag of all four is TradingView's, and a stream of the extended AAPL 60 tape keeps the plain pair exact. It pins one kernel residual there: on a realtime day the kernel's scheduled close steps the regular session's 09:30-anchored grid and expects a 15:30 bar after the off-grid 15:00 one, so islastbar_regular never fires (8 days). Fail-before at its parent 3d218d7 (F1): the unit does not compile (`session_isfirstbar_regular_` undeclared, tdd-f2-red-compile.log). Two existing rows fed synthetic post- and pre-market bars and pinned the regular day on the plain flags. Their strings move to the _regular members unchanged, and the plain flags now read the chart's day as TradingView's extended tapes do: test_session_islastbar_aggregation (one session close: islastbar 16:10, the last post-market bar; two sessions: islastbar Tuesday 16:10, isfirstbar Wednesday 09:15, the first pre-market bar; every path still agrees bar for bar) and test_aggregated_path_regressions (the calc_on_order_fills post-market case: 15:45 keeps islastbar_regular, and one answer per bar still holds). None of the 312 corpus probes reads a session flag. Three documentation sentences are rewritten because the host now widens the plain pair: the design record's OT7 row (lane F5, f064b1c: the adapter selecting the kernel's facts into the three flags) and the Pine v6 coverage detail's session.isfirstbar_regular / islastbar_regular rows (e244d65: 'Aliased to session.isfirstbar'), and ADR-0001's line that the host computes no session-day rule of its own. Generated code still lowers session.isfirstbar_regular / islastbar_regular to the plain members (codegen visit_expr.py): routing them to the new members is the transpiler's follow-up, until which a generated _regular read on an extended-hours chart follows the chart's day. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]> * Pin TradingView's aggregated bars that open inside a session break: in market, as the kernel reads them Lane CG-ISMARKET's finding F7 (an aggregated split-session bar whose nominal open falls in a break reads out of market) had no tape. This lane's `lab tv --no-note` exports give one (tests/fixtures/session_windows): TSE:7203 60 opens a bar at 12:00, inside the 11:30-12:30 lunch break, and CBOT:ZC1! 60 one at 08:00, inside 07:45-08:30; TradingView flags both in market, neither pre- nor post-market nor a day's first or last bar. Its 60- and 240-minute bars open at the same instants as the engine's aggregation of TradingView's own 15-minute bars of the window. TradingView agrees with the engine where it answers per bar, so nothing changes: the kernel reads such a bar at its interval's first eligible instant, the reopen (kept by F1), and session_ismarket_, the session-day flags and the gated pre- / post-market predicates are TradingView's on every bar. What disagrees is a reading at the bar's open instant -- the time-of-day predicate pine_session_ismarket, and the session calendar asked at the open, which is how the transpiler lowers a chart's session.ismarket (codegen session_market.py) -- 10 bars on each 60-minute tape, none at 240. tests/test_session_break_open_bar_tape.cpp (release, new) replays TSE:7203 and CBOT:ZC1! 60 and 240, aggregated from their 15-minute tapes, through the Pine host: labels and every flag are TradingView's, and the at-open readings' misses are pinned (RESIDUAL) for the transpiler, whose change is to lower session.ismarket to session_ismarket_. The rows it checks agree at 1e360bd as well (the kernel fact already read the bucket's first eligible instant); the unit compiles from df4510e (F2) on, which adds the _regular members it reads. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]> * Docs: how a generated session.ismarket is read -- the transpiler's calendar at the bar's open, the predicate only inside request.security Lane CG-ISMARKET's finding F5: the comment above PineStrategyHost's session flags said a generated session.ismarket calls pine_session_ismarket. Since pineforge-codegen a425965 a chart's session.ismarket asks the session calendar at the bar's open through the transpiler's own helper (_pf_session_market_, native_calendar::session_day_at; e.g. the corpus's validation/symbol-specified/AAPL/session-ismarket-nyse-rth-01/generated.cpp), and only a read inside a request.security payload still calls the class-scope pine_session_ismarket. The comment now says so, and says which member each flag spelling reads today (the transpiler lowers the _regular spellings to the plain pair). The same stale sentence stood in ADR-0001 (the adapter's Pine language state), docs/pages/pine-to-native.md (the session.ismarket row, whose in_session sentence now also states F1's reading), the Pine v6 coverage detail and the design record's row 36, and in the H-MEASURE tape row's header; each now names the calendar reading on the chart, the predicate in a request.security payload, and the break-open bar only the kernel's fact holds in market (tests/test_session_break_open_bar_tape.cpp). The design record's row 36 sentence (INT26, d093560: the generated predicate is codegen's to route) is rewritten to what the transpiler does now. Two ADR and design citations of the host header re-anchored. Comments and pages only. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]> * CI floors: the lane's four ctest rows on top of XSYM-D's -- kernel 291 -> 293, release 720 -> 724, PR registration 705/705/714 Lane K-SESSION-WINDOWS adds four CTest rows. Two are source-free and register in the kernel profile and in release (F6 test_session_prepost_windows_tape, F1 test_native_session_day_bar_open); two reach the source layer and register in release only (F2 test_session_extended_day_tape, F7 test_session_break_open_bar_tape). All four register in the Debug, sanitizers and native profiles as well. Counted with ctest -N after configuring each profile exactly as ci_verify does (configure only), on main 7f807b9 and on this rebased tree: profile main 7f807b9 rebased delta release 720 724 +4 debug 701 705 +4 sanitizers 701 705 +4 native 710 714 +4 kernel 292 registered 294 +2 (F6, F1) The row diff between the two trees is exactly the lane's four rows (two in the kernel profile), none of them XSYM-D's. So KERNEL_MIN_TESTS 291 -> 293 (294 registered, the WebSocket row still skips on a system libcurl), RELEASE_MIN_TESTS 720 -> 724 and EXCLUDED_REGISTERED_MIN 701/701/710 -> 705/705/714, each keeping XSYM-D's accounting above the lane's, with the self-test's literal and docs/ci.md's sentence naming both lanes. The two constants moved lines, so their citations in CONTRIBUTING.md and docs/pages/contributing-llm.md are carried by hand (ci_verify.py:284 -> :293, :447 -> :463); check_doc_anchors resolves every anchor. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]> --------- Co-authored-by: Claude Opus 5.5 (1M context) <[email protected]>
1 parent 7f807b9 commit 962960b

94 files changed

Lines changed: 9498 additions & 163 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎CONTRIBUTING.md‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -152,8 +152,8 @@ What each gate refuses:
152152
### The floors
153153

154154
`ci_verify.py` counts the CTest rows that actually **ran** and fails below a
155-
floor — `KERNEL_MIN_TESTS` ci_verify.py:284 and `RELEASE_MIN_TESTS`
156-
ci_verify.py:447.
155+
floor — `KERNEL_MIN_TESTS` ci_verify.py:293 and `RELEASE_MIN_TESTS`
156+
ci_verify.py:463.
157157
A deleted or silently skipped row is a failure, not a quieter run. If your
158158
change adds rows, raise the floor in the same commit and say by how much; if it
159159
legitimately removes one, lower it deliberately and say why. `--min-tests`

‎docs/adr/0001-kernel-adapter-boundary.md‎

Lines changed: 31 additions & 25 deletions
Large diffs are not rendered by default.

‎docs/ci.md‎

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -102,11 +102,12 @@ requires the rows that actually ran to equal the second count, and records
102102
`registered`, `labelled = registered - selected`, and `ran` in
103103
`ctest-exclusion.log` and `ci-summary.json`. A skip, missing executable, lost
104104
registration below the PR registration floor, unreadable enumeration, or
105-
missing label fails. The PR registration floors after lane XSYM-D are 701 for
106-
Debug and sanitizers and 710 for native (653 and 662 at the INT24 base, plus
107-
wave G's six rows, wave H's twenty-four, INT26's own tape row, INT27's thirteen
108-
and XSYM-D's four). The full-run release and kernel floors are 720 and 291 rows
109-
that ran; full runs do not exclude a label.
105+
missing label fails. The PR registration floors after lanes XSYM-D and
106+
K-SESSION-WINDOWS are 705 for Debug and sanitizers and 714 for native (653 and
107+
662 at the INT24 base, plus wave G's six rows, wave H's twenty-four, INT26's own
108+
tape row, INT27's thirteen, XSYM-D's four and K-SESSION-WINDOWS' four). The
109+
full-run release and kernel floors are 724 and 293 rows that ran; full runs do
110+
not exclude a label.
110111

111112
Preflight also runs the detached-comment census of the kernel compile closure
112113
(`detached-comments`: `scripts/measure_detached_comments.py --check-ceiling`)

‎docs/design/native-feature-parity.md‎

Lines changed: 11 additions & 11 deletions
Large diffs are not rendered by default.

‎docs/pages/contributing-llm.md‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -117,8 +117,8 @@ finding to report, not a step to take.
117117
`scripts/check_doc_reverts.py`.
118118

119119
10. **A test row never silently disappears.** Each profile counts the rows that
120-
*ran* against a floor: `KERNEL_MIN_TESTS` ci_verify.py:284 and
121-
`RELEASE_MIN_TESTS` ci_verify.py:447. Adding rows means raising the floor
120+
*ran* against a floor: `KERNEL_MIN_TESTS` ci_verify.py:293 and
121+
`RELEASE_MIN_TESTS` ci_verify.py:463. Adding rows means raising the floor
122122
in the same commit.
123123

124124
## The recipe for a lane
@@ -264,7 +264,7 @@ measurement that produced it, so a later change to it is visible as a change to
264264
the record, not as an edit to a literal.
265265

266266
**floor** — the minimum number of CTest rows a profile must actually run
267-
(`KERNEL_MIN_TESTS` ci_verify.py:284, `RELEASE_MIN_TESTS` ci_verify.py:447). It
267+
(`KERNEL_MIN_TESTS` ci_verify.py:293, `RELEASE_MIN_TESTS` ci_verify.py:463). It
268268
counts rows that ran, so a skipped row does not pad it.
269269

270270
**receipt** — the recorded evidence an ABI-comparison row needs (a prepared

‎docs/pages/native-engine.md‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1976,7 +1976,9 @@ session-day facts (R5 lane F5): `in_session` (`market_driver.hpp:161`),
19761976
`closes_session_day_open_ended`. They read the run's own calendar and
19771977
session day — the cycle that rolls at the session's first window start,
19781978
keyed to its trading date, so an overnight session is one day across local
1979-
midnight — and the bar before or after the script bar: the one the run
1979+
midnight — each bar at its own label, or at its interval's first eligible
1980+
instant when that is later (a bar opening inside a declared break), and the
1981+
bar before or after the script bar: the one the run
19801982
holds (its batch input or stream warmup), otherwise the calendar's previous
19811983
or next eligible input slot, across declared breaks. A run's first bar opens
19821984
its session day and a batch's

‎docs/pages/pine-to-native.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -467,7 +467,7 @@ part both ways (`tests/test_adapter_margin_schedule_differential.cpp`, M11).
467467
| raw input before aggregation | `on_native_input` native_host.hpp:875 | `on_input` native_c_api.h:2499 | `native_auxiliary_feed_strategy.cpp` | Every accepted confirmed input bar, before aggregation or matching. |
468468
| a lower-timeframe sub-bar | `on_native_sub_bar` native_host.hpp:928 | `on_sub_bar` native_c_api.h:2540 | `tests/test_native_calc_timing.cpp` | `NativeCalculationReason::SubBar` is reserved and never delivered to the recalculate hook — a sub-bar has its own callback. |
469469
| `time`, `bar_index`, the bar's calendar interval, session facts | `NativeDecisionContext` market_driver.hpp:120 with `NativeCoordinate` market_driver.hpp:72 | `pf_native_decision_v1` native_c_api.h:1484 | `hello_kernel.cpp` | `NativeCoordinate::interval_index` is the sequential SCRIPT-bar index on every run, including aggregation; `input_interval_index` names the input slot for a host that needs input cadence. Both are copied onto the callback stack, and mutating them changes nothing. In C++ `script_interval` market_driver.hpp:124 and `input_interval` market_driver.hpp:123 add the calendar facts (eligible open, last traded close, next period and next input opens); the C decision carries the script interval's five instants and the session days of its open and of the next input in its tail, presented to a callback table at `PF_NATIVE_CALLBACKS_V1_POLICY_SIZE` or later, and no input interval. The C `on_input` callback receives the input index separately. The session-day facts are the three rows below. |
470-
| `session.ismarket` | `in_session` market_driver.hpp:161 | `in_session` native_c_api.h:1502 | `tests/test_native_session_day_facts.cpp` | The script bar's label is in session on the run's own calendar (`NativeRunSpec::session` / `timezone`); a D/W/M bar holds whole session days, so it is always true there. The calendar applies a session's day mask to the session day's trading date: Sunday 17:00 CT of a CME-style `1700-1600:23456` is Monday's session, in session. Pine's own `session.ismarket` is still generated as the time-of-day predicate `pine_session_ismarket` session_time.hpp:247, whose mask reads each instant's weekday, so on such a masked overnight session the two differ: on six `lab tv` tapes TradingView flags every bar in market, the calendar's fact matches it on every bar, and the predicate misses every Sunday open under a weekday mask (`1700-1600:23456`) and every bar of `0000-2400`, which it cannot parse as a whole day (`tests/test_session_ismarket_tape.cpp`). Unmasked sessions (`1700-1600`, `1700-1700`, `24x7`, `0930-1600`) agree on all three. In C, read the three session bytes only when `session_facts` native_c_api.h:1501 is 1. |
470+
| `session.ismarket` | `in_session` market_driver.hpp:161 | `in_session` native_c_api.h:1502 | `tests/test_native_session_day_facts.cpp` | The script bar is in session on the run's own calendar (`NativeRunSpec::session` / `timezone`), read at its label, or at its interval's first eligible instant when that is later (a bar opening inside a break); a D/W/M bar holds whole session days, so it is always true there. The calendar applies a session's day mask to the session day's trading date: Sunday 17:00 CT of a CME-style `1700-1600:23456` is Monday's session, in session. Pine's own chart `session.ismarket` is generated as the session calendar asked at the bar's open (the transpiler's helper), which holds those Sunday opens and a `0000-2400` day in market, as TradingView does. Inside a `request.security` payload it is still the time-of-day predicate `pine_session_ismarket` session_time.hpp:247, whose mask reads each instant's weekday: on six `lab tv` tapes it misses every Sunday open under a weekday mask (`1700-1600:23456`) and every bar of `0000-2400`, which it cannot parse as a whole day (`tests/test_session_ismarket_tape.cpp`); unmasked sessions (`1700-1600`, `1700-1700`, `24x7`, `0930-1600`) agree. Any reading at the bar's open puts a bar that opens inside a break out of market, which TradingView and this fact hold in market (`tests/test_session_break_open_bar_tape.cpp`). In C, read the three session bytes only when `session_facts` native_c_api.h:1501 is 1. |
471471
| `session.isfirstbar` | `opens_session_day` market_driver.hpp:162 | `opens_session_day` native_c_api.h:1503 | `tests/test_native_session_day_facts.cpp` | In session, and the bar before it is not, or is on another session day. The session day rolls at the session's first window start and is keyed to its trading date, so an overnight session is one day across local midnight (Tokyo `2230-0500`: its days open at 22:30). "The bar before" is the one the run holds — the batch input, the stream warmup — else the calendar's previous eligible input slot across declared breaks; a run's first bar opens its day. |
472472
| `session.islastbar` | `closes_session_day` market_driver.hpp:163, `closes_session_day_open_ended` market_driver.hpp:164 | `closes_session_day` native_c_api.h:1504 | `tests/test_native_session_day_facts.cpp` | In session, and the bar after it is not, or is on another session day, "the bar after" read the same way. A batch's final bar closes its day (a batch is complete input); `closes_session_day_open_ended` reads the calendar there instead, for a host recomputing a batch whose last input is still forming (C++ only: a C host's live edge is a stream). A stream's bars read the calendar, so a stream cannot see an early close its session string does not declare: the NYSE half day's 12:45 closes the day in a batch (the next bar held is the next day's) but not in a stream (ADR-0001, ruling "Session-day facts at a bar with nothing held after it"). |
473473
| the price at the current point | `current_execution_point` native_host.hpp:1087 | `price` native_c_api.h:1563 | `native_selected_strategy.cpp` | The readiness preview `inspect_current_execution` native_host.hpp:1099 is an observation, never an apply token; `execute_current` native_host.hpp:1104 is the apply. |

‎docs/pine_v6_coverage_detail.md‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -160,11 +160,11 @@
160160

161161
| Identifier | Kind | Status | Backing | Notes |
162162
|---|---|---|---|---|
163-
| `session.isfirstbar` | var | ✅ Runtime | `session_isfirstbar_` on the Pine host, selected by `scheduler_update_session_state` (`src/source/pine_strategy_host.cpp`) from the kernel's `NativeDecisionContext::opens_session_day` (R5 lane F5); the first bar of a session DAY — its predecessor was out of session or belonged to another session day; on a 1D+ chart every bar (the bar is its whole session) | Sprint A |
164-
| `session.isfirstbar_regular` | var | ✅ Runtime | Aliased to `session.isfirstbar` — engine has single session string, cannot distinguish RTH vs ETH (documented limitation) | Sprint A |
165-
| `session.islastbar` | var | ✅ Runtime | `session_islastbar_` on the Pine host, same selection, from `NativeDecisionContext::closes_session_day` (`closes_session_day_open_ended` on a live probe's forming bar); the last bar of a session DAY — a one-bar lookahead whose successor is out of session or belongs to another session day, as TradingView's tapes flag it (`tests/fixtures/session_islastbar`); on a 1D+ chart every bar (the bar is its whole session) | Sprint A |
166-
| `session.islastbar_regular` | var | ✅ Runtime | Aliased to `session.islastbar` | Sprint A |
167-
| `session.ismarket` | var | ✅ Runtime | `pine_session_ismarket(session, tz, bar_ms, chart_tf)` in `session_time.hpp` (via `source::PineStrategyHost::pine_session_ismarket`); always true on a 1D+ chart, as TradingView documents. Measured against TradingView (`tests/test_session_ismarket_tape.cpp`): it misses every Sunday open of a weekday-masked overnight session (`1700-1600:23456`) and every bar of `0000-2400`, where the kernel's `in_session` matches the tapes | Sprint A |
163+
| `session.isfirstbar` | var | ✅ Runtime | `session_isfirstbar_` on the Pine host, selected by `scheduler_update_session_state` (`src/source/pine_strategy_host.cpp`) from the kernel's `NativeDecisionContext::opens_session_day` (R5 lane F5), widened on an extended-hours chart to the first pre-market bar of the day (`update_extended_session_day`, `tests/test_session_extended_day_tape.cpp`); the first bar of a session DAY — its predecessor was out of session or belonged to another session day; on a 1D+ chart every bar (the bar is its whole session) | Sprint A |
164+
| `session.isfirstbar_regular` | var | ✅ Runtime | The regular session day's first bar, `PineStrategyHost::session_isfirstbar_regular_` (the kernel's `opens_session_day`); on an extended-hours chart `session.isfirstbar` is the pre-market's first bar instead. The transpiler still lowers it to `session.isfirstbar`'s member, so generated code reads the chart's day there until it routes the `_regular` spelling | Sprint A |
165+
| `session.islastbar` | var | ✅ Runtime | `session_islastbar_` on the Pine host, same selection, from `NativeDecisionContext::closes_session_day` (`closes_session_day_open_ended` on a live probe's forming bar), widened on an extended-hours chart to the last post-market bar of the day; the last bar of a session DAY — a one-bar lookahead whose successor is out of session or belongs to another session day, as TradingView's tapes flag it (`tests/fixtures/session_islastbar`); on a 1D+ chart every bar (the bar is its whole session) | Sprint A |
166+
| `session.islastbar_regular` | var | ✅ Runtime | The regular session day's last bar, `PineStrategyHost::session_islastbar_regular_`; on an extended-hours chart `session.islastbar` is the post-market's last bar instead. Lowered to `session.islastbar`'s member by the transpiler, as above | Sprint A |
167+
| `session.ismarket` | var | ✅ Runtime | On the chart, the session calendar asked at the bar's open (the transpiler's own helper over `native_calendar::session_day_at`), which reads a masked overnight session's Sunday open and a `0000-2400` day as TradingView's tapes do; always true on a 1D+ chart, as TradingView documents. Inside a `request.security` payload it is `pine_session_ismarket(session, tz, bar_ms, chart_tf)` in `session_time.hpp` (via `source::PineStrategyHost::pine_session_ismarket`), which misses every Sunday open of a weekday-masked overnight session (`1700-1600:23456`) and every bar of `0000-2400` (`tests/test_session_ismarket_tape.cpp`). A reading at the bar's open puts a bar that opens inside a break out of market, where TradingView and the kernel's `in_session` hold it in market (`tests/test_session_break_open_bar_tape.cpp`) | Sprint A |
168168
| `session.ispostmarket` | var | ✅ Runtime | `pine_session_ispostmarket(...)` — standard ETH window `RTH_close-2000` local; always false on a 1D+ chart | Sprint A |
169169
| `session.ispremarket` | var | ✅ Runtime | `pine_session_ispremarket(...)` — standard ETH window `0400-RTH_open` local; always false on a 1D+ chart | Sprint A |
170170

‎include/pineforge/market_driver.hpp‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -135,17 +135,17 @@ struct NativeDecisionContext {
135135
// day across local midnight). Every callback of the bar carries the same
136136
// four: its open, its sub-bars and ticks, its calculation, and every fill
137137
// and recalculation on it.
138-
// in_session the script bar has an eligible instant in session.
138+
// in_session in session at the bar's label, or at its interval's
139+
// first eligible instant when later (a break's reopen).
139140
// opens_session_day in session, and the bar before it is not, or is on
140141
// another session day.
141142
// closes_session_day in session, and the bar after it is not, or is on
142143
// another session day.
143144
// "The bar before / after" is the one the run holds — the batch input or
144145
// stream warmup being consumed — and otherwise the calendar's previous
145146
// or next eligible input slot, across declared breaks. At the run's own
146-
// edges nothing is held: its first bar
147-
// opens its session day, and a batch's final bar closes it, because a
148-
// batch is complete input; a stream reads on, because it continues.
147+
// edges nothing is held: its first bar opens its session day, and a
148+
// batch's final bar closes it (complete input); a stream reads on.
149149
// closes_session_day_open_ended
150150
// closes_session_day for a run whose input goes on
151151
// past it: a batch's final bar, which nothing held

‎include/pineforge/session_time.hpp‎

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -144,18 +144,18 @@ int64_t session_trading_day_open_ms(int64_t bar_ms,
144144
// ---------------------------------------------------------------------------
145145
// Session predicates backing session.is* Pine v6 variables.
146146
//
147-
// LIMITATION: The engine has a single syminfo.session string and cannot
148-
// distinguish RTH from ETH. Therefore:
149-
// session.isfirstbar_regular == session.isfirstbar
150-
// session.islastbar_regular == session.islastbar
151-
// in the current architecture. Future work: add SymInfo.regular_session
152-
// field for strict RTH separation (deferred — separate sprint).
147+
// syminfo.session is the regular session: session.isfirstbar_regular /
148+
// islastbar_regular mark its day, and session.isfirstbar / islastbar the
149+
// chart's, which on an extended-hours chart takes in the pre- and post-market
150+
// bars the chart holds (PineStrategyHost's session flags, tests/
151+
// test_session_extended_day_tape.cpp). A chart without extended hours holds
152+
// none, so there each pair is one bar.
153153
//
154-
// Pre/post-market predicates assume standard US ETH windows:
155-
// premarket : 04:00 – RTH_open (RTH_open parsed from session string)
156-
// postmarket: RTH_close – 20:00
157-
// For exchanges with non-standard ETH (e.g. LSE auctions), accuracy may
158-
// degrade. This is documented behaviour, not a bug.
154+
// Pre/post-market predicates assume standard US ETH windows around the day:
155+
// premarket : 04:00 – its first open, postmarket: its last close – 20:00,
156+
// over every window in any order; a break between windows is neither, and an
157+
// overnight or 24-hour session has neither (TradingView's TSE, HKEX, CBOT, CME
158+
// and OANDA tapes, tests/test_session_prepost_windows_tape.cpp).
159159
// ---------------------------------------------------------------------------
160160

161161
bool session_in_market(const std::string& session,

0 commit comments

Comments
 (0)