Skip to content

Commit 0631e04

Browse files
luisleo526claude
andcommitted
INT27 merge: a magnified recalculation's market order after the matcher's fill at an intrabar's second extreme fills there
R5 lane MAG-INTRABAR's base (PAR-MARGIN-2's tip) did not carry INT26's PAR-ORDERS-2 picks or H-MEASURE's test_magnified_aggregated_tape, so the two lanes' rules met first on this tree. - PAR-ORDERS-2 (H-MEASURE Finding 6d): the matcher's fill of a resting request at its own level AT a bar's second extreme ends the leg there, and the recalculation's market order fills at that extreme; a fill the adapter forced there advances. It is written for the chart path (PineExecutionAdapter::coof_fill_at_second_extreme); on a lower path the magnified run met it only by accident: the old next_input_waypoint took an off-grid extreme's booked tick for a fill short of it and returned the extreme. - MAG-INTRABAR: a magnified run walks TradingView's 2-minute intrabars, and after an intrabar's second extreme the next fill point is the next intrabar's open (mi-coof-refill*, 72 of 72 cascades, every one a market order's -- forced -- fill), with the same-point rule that no longer mistakes a booked tick for a fill short of its print. Together, on hm-mag-diff-v2 and -v3 bar 19 (NYSE:F, 14:15 ET) PX's limit fills at its own level on the high of the 14:26 intrabar (11.715, booked 11.72), its second extreme, and the ML entry its recalculation places went to the 14:28 intrabar's open, 11.71; TradingView books 11.72 on both tapes. PineScheduler::next_input_waypoint now returns the second extreme itself for the matcher's own (unforced) fill there, so the market order fills at it, and keeps the next intrabar's open for a forced fill: row 5 of both magnified replays is TradingView's again, and every cascade, bracket and margin tape of MAG-INTRABAR still passes (test_adapter_magnifier_intrabar_ tapes, test_adapter_coof_relower, test_native_calc_timing_twin, and the 95 magnifier / intrabar / lower-path / margin / calc_on_order_fills / POOC / extreme-order rows all pass). No hash witness moves (the eleven witness rows pass unchanged). The same test's v3 row 2 (magnified), a recorded divergence (11.58 where TradingView books 11.54), flipped to TradingView's with MAG-INTRABAR's kernel commit alone: PX's limit fills on the leg to the high of a sub-bar that opens at its own low (bar 6, the 11:01 ET minute), and the kernel now walks such a bar through its four turning points instead of the sampler's uniform fill, so the entry books that high, 11.54. It stays exact on the 2-minute intrabars. The row is no longer recorded, and the file's header says why. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
1 parent 5a6c3ba commit 0631e04

2 files changed

Lines changed: 25 additions & 5 deletions

File tree

‎src/source/pine_scheduler_native.cpp‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -245,6 +245,16 @@ std::optional<PineScheduler::InputWaypoint> PineScheduler::next_input_waypoint(
245245
// waypoint, not short of it.
246246
if (index > 0 && index < 3 && !host.adapter_.coof_fill_at_path_point(price[index]))
247247
return InputWaypoint{price[index], false};
248+
// The matcher's fill of a resting request at its own level AT the
249+
// intrabar's second extreme ends the leg there, and the
250+
// recalculation's market order fills at that extreme, as on a chart
251+
// bar (PineExecutionAdapter::coof_fill_at_second_extreme, H-MEASURE
252+
// Finding 6d): TradingView's hm-mag-diff-v2 / -v3 bar 19 book ML at
253+
// 11.72, where PX's limit filled on the 2-minute intrabar's high. A
254+
// fill the adapter forced there -- a cascade's market order -- still
255+
// takes the next intrabar's open (R5 lane INT27).
256+
if (index == 2 && !host.adapter_.coof_fill_forced_)
257+
return InputWaypoint{price[index], false};
248258
if (index < 2) return InputWaypoint{price[index + 1], false};
249259
return next_open;
250260
}

‎tests/test_magnified_aggregated_tape.cpp‎

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -46,15 +46,25 @@
4646
* fill is the matcher's, PX's limit at its own level on the leg to the bar's
4747
* second extreme, and a market order its recalculation places fills at that
4848
* extreme. It used to book the close (11.71 / 11.73) under
49-
* process_orders_on_close and the next open without it.
49+
* process_orders_on_close and the next open without it. The magnified v2 and
50+
* v3 book it there too: since R5 lane MAG-INTRABAR the fill lands on the high
51+
* of TradingView's 2-minute intrabar, that intrabar's second extreme, and a
52+
* market order the matcher's own fill there re-issues fills at it, not at the
53+
* next intrabar's open, where a forced fill's order goes (INT27,
54+
* PineScheduler::next_input_waypoint).
5055
*
5156
* The other rows below are RECORDED divergences, each asserted to differ, so a
5257
* fix flips them deliberately:
5358
* - v7 rows 8 and 9 (chart, aggregated): after bar 33's close_all and
5459
* same-bar add TradingView keeps the add (ML 11.86) and fills bar 38's
55-
* stop entry at 11.83, the engine drops the add and books 11.82;
56-
* - v3 row 2 (magnified): a fill recalculation's market entry books 11.58
57-
* where TradingView books 11.54.
60+
* stop entry at 11.83, the engine drops the add and books 11.82.
61+
* v3 row 2 (magnified) was recorded too: its fill recalculation's market entry
62+
* booked 11.58 where TradingView books 11.54. PX's limit fills on the leg to
63+
* the high of a sub-bar that opens at its own low (bar 6, 11:01 ET); since
64+
* R5 lane MAG-INTRABAR the kernel walks such a bar through its own four
65+
* turning points instead of the sampler's uniform fill, so the entry books
66+
* that high, 11.54, as TradingView does -- on the 1-minute path and on
67+
* TradingView's 2-minute intrabars alike (INT27).
5868
* v7's magnified run is not replayed: TradingView books two more ML rows at
5969
* bar 59 there (16 against 14).
6070
*
@@ -390,7 +400,7 @@ int main() {
390400
replay("hm-mag-diff-v2", v2, Path::Magnified);
391401
replay("hm-mag-diff-v4", v4, Path::Magnified);
392402
replay("hm-mag-diff-v5", v5, Path::Magnified);
393-
replay("hm-mag-diff-v3", v3, Path::Magnified, rows({2}));
403+
replay("hm-mag-diff-v3", v3, Path::Magnified);
394404
// 2. controls: the chart and plain-aggregated paths against the magnifier-off tapes
395405
for (const Path path : {Path::Chart, Path::Aggregated}) {
396406
replay("hm-chart-diff-v0", v0, path);

0 commit comments

Comments
 (0)