You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 2922ade
Browse filesBrowse the repository at this point in the historyBrowse files
Adapter: a process_orders_on_close add stays under the pyramiding cap when the pending opposite entry is not in the close pass (R5 lane PAR-ORDERS, H-MEASURE Finding 6c)
Under the magnifier with process_orders_on_close and calc_on_order_fills,
H-MEASURE's differential script (variant v3, pyramiding=1) opened 86 lots
on one bar: every fill's recalculation re-issued strategy.entry("ML") as a
same-side market add and each one filled. TradingView's tape of that run
(hm-mag-diff-v3) books 12 rows and ends flat.
Root cause. entry()'s pyramiding check (pine_adapter.cpp, the
accepted_in_cycle block) is skipped under process_orders_on_close whenever
any opposite opening is pending (opposite_opening_pending): the cap is
deferred to the close pass, where ab9714b judged a market add at its fill
(add_to_pyramid_market: position_entry_count_ >= pyramiding) and
TradingView against the trades then open. That pass fills an opposite
opening first only if it processes it; here the pending opposite entry
was a PS limit short resting from the previous bar, so nothing moved the
book, and no fill-time check exists for a fixed-size add
(validate_precommit's lot test covers the variable default sizes only).
Each exempted add filled, the fill recalculated, and the next add came.
Fix, adapter only (ADR-0001 rule 2: Pine's pyramiding is adapter command
policy; no kernel line changes). The exemption still applies when the
opposite opening is in the close pass -- a market entry, or one this
script bar's own calculation placed -- where the add may be a reversal by
the time it fills. With only a priced opposite entry resting from an
earlier bar, the add is held to the lots open now: the count ab9714b and
TradingView apply at the fill.
The row: test_magnified_aggregated_tape gains "the pyramiding cap": no
path of any of the eight variants holds more lots than its pyramiding at
any script call, and the v3 magnified run books TradingView's 12 rows and
ends flat (tape hm-mag-diff-v3 committed from H-MEASURE's evidence, README
row added). Against the base library the row fails: "v3 ..., magnifier: 86
lots open at once, pyramiding 1", 8500 units open at the end. After: 176
checks, 0 failures.
Every command the change drops, traced on the tapes and the regression
batteries, is a same-side add with the lots then open already at the cap
(v3 magnified: ML at bars 33 and 59, 1 lot at pyramiding 1; quiet-bar
Random10 bar 42: 3 lots at pyramiding 2; Random14 bar 41: 2 at 2; Random21
bar 9: 1 at 1). Those three random runs are the only quiet-bar runs whose
trades move; test_publication_witness (4 runs) and
test_adapter_live_state_equivalence (9 digests) move with them. All are
re-pinned in the lane's named hash commit.
Docs: the design's magnified-residual paragraph records the bypass as
closed; digits re-anchored.
Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
(cherry picked from commit 8d312d81fed3802d98f495f93791a3663285f21e)
INT26 pick note: the adapter, test and fixture hunks applied without
conflict; the ADR and design pages merged on citation digits only.
@@ -282,7 +282,7 @@ kernel and own these quirks, each at its site:
282
282
projects `NativeCalculationTrigger::BarCloseAndFills` with TradingView's guard literal as
283
283
`max_recalculations_per_point`. What stays are the specifics COOF adds on top —
284
284
the language-state snapshot/restore around a recalculation, the waypoint-only refill deferral
285
-
(`next_source_path_waypoint``pine_adapter.cpp:8282`), the first-open execution chain and its
285
+
(`next_source_path_waypoint``pine_adapter.cpp:8312`), the first-open execution chain and its
286
286
own loop guard (`kFirstOpenLoopGuard``pine_scheduler_native.cpp:680`), and the two fills Pine refuses to
287
287
recalculate on (`suppress_grouped_stop_recalc``pine_adapter.cpp:5641`).
288
288
-**Pine language state and harness flags.** Series, the tick-level barstate flags and
@@ -643,8 +643,8 @@ Every line number in this section names its symbol on this tree, which
643
643
|`NativeRunSpec` field | ruling | what the adapter runs instead | measurement and ruling of record | executed native consumers |
644
644
|---|---|---|---|---|
645
645
| `price_grid`, `grid_rounding` | **native-only** | TradingView's per-order-kind tick rules on top of `None`: `source_trigger_threshold` (`pine_adapter.cpp:342`), `source_level_on_price_grid` (`:328`), `nearest_tick` (`:266`) / `source_bar_fill_tick` (`:287`) / `directional_tick` (`:311`), behind the terms seam | R5-3 and design risk E7 ruled `None` for the adapter before the lane ran; lanes R7 and N13 measured the alternative anyway (raw levels submitted, `QuantizeFillsAndTriggers` with `HalfUp` declared). L8b closed the first blocker (no run aborts). The second has no remedy on either side: TradingView quantizes per order kind (stop and limit legs and a trail's activation on the quantized bar; the trail stop, the running best, stop-limit entries and the `calc_on_order_fills` cursors raw), the grid is one rule for the run, and the old N13 trial moved 30 pinned checks in 4 units; this is historical evidence, not a current-head result; a per-kind mask would spell that inconsistency into the kernel. The corpus cannot arbitrate (every probe runs a 0.01 tick on an on-grid feed; 5 of 312 differ in an engine-only column). Permanent witness: `tests/test_adapter_grid_relower.cpp`, whose section 5 pins the trail stop the grid fires a bar early. Design row PG and §3.6 | `examples/native/native_price_grid_strategy.cpp`, `examples/native/native_price_grid_c.c`, `tests/test_native_price_grid.cpp` |
646
-
| `risk` | **native-only** | all of `strategy.risk.*` but the direction: `update_risk_state` (`pine_adapter.cpp:13879`), `SourceDayLedger`, `submit_intraday_loss_close` (`pine_adapter.cpp:14934`), `chart_day_key` (`pine_adapter.cpp:13776`), `compat::pine::IntradayCap` with `IntradayOrderBudget` (337 lines) | Structural first: Pine's risk calls are per-bar statements, so a limit reaches the adapter on script bar 0, after `project()` (`pine_strategy_host.cpp:324`) and `configure_native` (`pine_strategy_host.cpp:325`) have fixed and digested the spec. In substance (lane N12, `tests/test_adapter_risk_relower.cpp`, 62 checks over nine paired scenarios): the drawdown latch samples at the close only and still admits a reversal; the loss-day streak counts trades, not days; the intraday loss closes at the path's adverse extreme, refuses every placement and withdraws the book; the fill cap charges slots, transfers quota and closes at the bar's better extreme on the chart timezone's day. With the kernel seeded on the corpus, 3 of 4 cap probes diverge (3840 of 3916, 312 of 604, 2370 of 2384 rows; re-derived by `scripts/check_seeded_risk_experiment.sh` since R5 lane H-MEASURE). `strategy.risk.allow_entry_in` is the one rule that is the kernel's already (`allowed_open_directions`). Design §3.6 | `examples/native/native_risk_limits_strategy.cpp`, `examples/native/native_trail_risk_strategy.cpp`, `tests/test_native_risk_limits.cpp`, `tests/test_native_c_api.c` |
647
-
|`max_abs_units`|**adapter-policy**|`strategy.risk.max_position_size` as a gate on the LIVE book before the fill (`max_position_size``pine_adapter.cpp:13238-13239`): an entry is refused once the book already holds the limit | design row MG2 (R5-1): the resulting-book cap is the generic one. Measured by N12's scenario `PS` in `tests/test_adapter_risk_relower.cpp`: two-unit entries against a limit of 3 leave the adapter at 4 and the kernel cap at 2 |`tests/test_native_resting_matching_contract.cpp`, `tests/test_native_run_spec.cpp`|
646
+
| `risk` | **native-only** | all of `strategy.risk.*` but the direction: `update_risk_state` (`pine_adapter.cpp:13909`), `SourceDayLedger`, `submit_intraday_loss_close` (`pine_adapter.cpp:14964`), `chart_day_key` (`pine_adapter.cpp:13806`), `compat::pine::IntradayCap` with `IntradayOrderBudget` (337 lines) | Structural first: Pine's risk calls are per-bar statements, so a limit reaches the adapter on script bar 0, after `project()` (`pine_strategy_host.cpp:324`) and `configure_native` (`pine_strategy_host.cpp:325`) have fixed and digested the spec. In substance (lane N12, `tests/test_adapter_risk_relower.cpp`, 62 checks over nine paired scenarios): the drawdown latch samples at the close only and still admits a reversal; the loss-day streak counts trades, not days; the intraday loss closes at the path's adverse extreme, refuses every placement and withdraws the book; the fill cap charges slots, transfers quota and closes at the bar's better extreme on the chart timezone's day. With the kernel seeded on the corpus, 3 of 4 cap probes diverge (3840 of 3916, 312 of 604, 2370 of 2384 rows; re-derived by `scripts/check_seeded_risk_experiment.sh` since R5 lane H-MEASURE). `strategy.risk.allow_entry_in` is the one rule that is the kernel's already (`allowed_open_directions`). Design §3.6 | `examples/native/native_risk_limits_strategy.cpp`, `examples/native/native_trail_risk_strategy.cpp`, `tests/test_native_risk_limits.cpp`, `tests/test_native_c_api.c` |
647
+
|`max_abs_units`|**adapter-policy**|`strategy.risk.max_position_size` as a gate on the LIVE book before the fill (`max_position_size``pine_adapter.cpp:13268-13269`): an entry is refused once the book already holds the limit | design row MG2 (R5-1): the resulting-book cap is the generic one. Measured by N12's scenario `PS` in `tests/test_adapter_risk_relower.cpp`: two-unit entries against a limit of 3 leave the adapter at 4 and the kernel cap at 2 |`tests/test_native_resting_matching_contract.cpp`, `tests/test_native_run_spec.cpp`|
648
648
|`max_open_lots`|**adapter-policy**| Pine pyramiding is a per-cycle entry count in the adapter's command policy; a resting source entry must not consume a physical-lot cap before it fills, so `project()` leaves the cap unset (`max_open_lots``pine_adapter.cpp:2360-2362`) | design row MG3 (R5-1); the contract comment in `project()`. Measured against TradingView by R5 lane H-MEASURE (`tests/test_pyramiding_count_differential.cpp`, 15 scenarios on three `lab tv` tapes): TradingView checks an entry once, at its first eligible point, against the trades then open, and does not check a resting entry again at its fill; the kernel's cap books 14 of the 15 as TradingView does, the adapter's per-cycle count 8 (it counts a resting entry, admits three market entries on a flat bar and keeps a slot another entry's exit drained). A recorded divergence: the retention stands pending a re-lowering ruling |`tests/test_native_resting_matching_contract.cpp`, `tests/test_native_margin_model.cpp`|
649
649
|`initial_margin_fraction`|**adapter-policy**| TradingView's ten-significant-digit money admission against the signal-time tuple, answered as `AdmitWithHostMargin`; the `margin` model the adapter does declare is maintenance-only (`NativeMarginModel``pine_adapter.cpp:2387-2395`, `margin.maintenance_long``pine_adapter.cpp:2402`) | design row MG4 and the wave-4 ruling recorded in `project()`: a positive initial requirement would decline openings TradingView takes. Measured both ways by R5 lane H-MEASURE (`tests/test_adapter_margin_schedule_differential.cpp`, M11): the kernel's gate declines a 1x long whose entry fee the adapter admits (`InitialMargin`), and admits a gap-up add the adapter refuses against its signal-time equity; `ab9714be` books the adapter's answer both times |`tests/test_native_precommit_view.cpp`, `tests/test_native_margin_model.cpp`|
650
650
|`report_open_position_at_end`|**adapter-policy**| TradingView's range-end report re-marks the curve's last point and re-folds every extreme from it (`scheduler_record_range_end` pine_strategy_host.cpp:1713): report shape, not a mark-to-market row (`KernelRecordedAtHostMarks` pine_adapter.cpp:2298) | design row RP5; the kernel reads the field under `KernelRecorded` only, which `scripts/check_adapter_spec_shadowing.py` gates |`examples/native/native_sized_report_strategy.cpp`, `tests/test_native_report_truth.cpp`|
0 commit comments