Skip to content

Commit 9fa1ac5

Browse files
luisleo526claude
andauthored
Fix fill recalculation, declared quantity steps, and intraday request grids (pineforge-4pass#727) [skip ci]
Fixes pineforge-4pass#723 Fixes pineforge-4pass#708 Fixes pineforge-4pass#722 Fixes pineforge-4pass#720 Part of pineforge-4pass#716: the engine now floors order quantities to a declared quantity step (qty_step, or mincontract when no qty_step is declared), which covers items 1 and 2 for runs that declare it; runs that declare neither key are unchanged, and the issue stays open until the callers supply the step. This change corrects entry handling during fill recalculation, uses an explicitly declared minimum contract as the quantity step, and aligns requested bars with the session grid. ### Entry replacement and the pyramiding cap With fill recalculation enabled and a flat book, a later same-id entry now replaces an earlier held priced entry. Previously the earlier held entry could be submitted afterwards and replace the later market entry. TradingView captures of the reproduction keep the later market entry with orders processed both at the next open and on close. The engine call logs for two seeded random scenarios show the same priced-entry then market-entry shape on the two divergence bars, with identical calls before and after the fix. The logged position is the script's view; which order wins is shown by the trade comparison. There is no TradingView tape of those random scenarios. Their eight pinned runs move; the other runs retain their recorded values. A settled opening also occupies its pyramiding slot while its applied notification is still queued. This prevents an explicit close followed by a reversing same-id entry from admitting a second lot past a cap of one. A 150-resting-limit test covers the large-book case. Its helper matches sell limits at the adapter's half-tick matching threshold; the order's own price is unchanged. A real-bars TradingView script of the same order shape refuses the repeated short lot. That capture is not a tape of the seeded transcript and is not a class-wide claim. The reported behavior is present in the released 1.9.1 engine. ### Declared quantity step When a symbol declares a minimum contract and no separate quantity step, the declared minimum contract supplies the step. The default path with neither declaration remains unchanged. The public test names the floor's one-millionth-of-a-step epsilon limit. Stop-limit chronology is outside this quantity-step change. This reaches library callers that set mincontract alone and preserves explicit qty_step precedence. Nothing is inferred from the symbol name. The default-metadata path and the other order-quantity cases in pineforge-4pass#716 remain open. ### Requested-bar session grid TradingView-checked: BINANCE:BTCUSDT 24x7 at 75m over 2025-04-01..04 (a bar opens at 00:00 UTC each day; the last bar of a day is 23:45-00:00). Session symbols, late-open anchoring, other time zones / DST and widths of a day or more are engine expectations, not TradingView-measured. The reviewed source candidate matched twelve BTC TradingView rows at 205 joined and equal trades each, and both explicit-session equity rows at 40 joined and equal trades each. These are member evidence for those cases; the combined candidate also passed full verification. The capped final time_close and DST characterization are engine expectations without a TradingView tape. An empty after-close bucket completes immediately and has no feed-level completion row. The default-session case remains open in the caller-metadata work. The open-label-only mutation survives by construction; the prefix-key mutation produces two completions and fails the existing one-completion assertion. The two default-session rows are deferred intact, with no skip or xfail introduced. ### Native-live report compatibility Native-live modules built with an earlier version are still accepted and use the standard report path (no live accumulator) until they are rebuilt. ### Documentation sentences removed by this change Stale references to `intraday_grid_clock_ms` are replaced with `intraday_bucket`, the requested-bar grid implementation. Source references are refreshed throughout, including the native example batch test registration. ### Validation All eight verification steps passed on Linux x86-64: preflight, Release, Debug, sanitizers, kernel, documentation, corpus parity and subset. The ABI layout probe passed in Release, Debug and sanitizers. On aarch64, the quantity-step tape/API tests passed three of three and the layout/report integration tests passed three of three, with zero skips. The full-population parity sweep completed; the required parity carry verdict follows publication. Commits: - 92db48b Add test: a later same-id entry replaces the earlier priced entry hel… - d6b0404 Drop the held priced entry when a later same-id opening is accepted - 4c8e027 Test: label the controls and the sequence guard, assert the resting l… - 16b9e22 Limit the held-entry cleanup to an accepted strategy.entry - 727c1d5 Test: do not check the pending count of the rows with the old id stil… - a3108c1 Re-pin the two quiet-bar random runs that held the lost-market-entry … - f5a64cc tests: red-first rows for the quantity step declared as mincontract - eae7b09 Use a declared mincontract as the quantity step when no qty_step is d… - 031e2a2 tests: the quantity step on handles that declare mincontract - fec17b6 docs: say where the API defines the quantity step, and name the floor… - 27583ab Add test: a settled entry occupies its pyramiding slot before its fil… - 7bfa51a Count a settled opening against the pyramiding cap during fill recalc… - 0b00663 Move the reused-id rows out of the pyramiding-slot test - 0fde717 Add a large-book row for the pyramiding-slot count - 7e35203 Re-pin the reversals seed-1780393 transcript digest after the pyramid… - 069b2d3 Fix the large-book test's count of resting limits - db2fa70 Match the large-book test's resting limits at the adapter's own trigg… - 5fdafcd tests: red-first rows for the requested-bar grid on non-dividing time… - dec9009 Anchor intraday request buckets to session days - 040d51d Keep intraday bucket ends at or after their opens - 9ae8af5 Move default-context equity controls out of the grid target - 04c4997 Glue: regenerate shared pins and re-anchor the final combined tree - b406ed5 Glue: name the superseded fixed-runner documentation - aeb7280 Update three scoped site identities of the source-bound inventory aft… - 5161e54 Glue: version the live engine layout and cover old-stamp report fallback - f88d96c Docs: refresh the native example test registration anchor - 179f76a Tests: refresh the host adapter offset after timeframe state growth Merged by spark L6 (11-03 23:43): pineforge/verify (8/8 steps on tree 61fada6, verdict 10ba8bcf) and pineforge/parity (carry of sweep train1100-f88d96ca 134/134, no-improve-no-regression, verdict 96253a9f) posted from recorded evidence; all 14 check runs green on the head; main e11b261 unchanged since the gate; REV GO 23:20. [skip ci]: the same tree's full proof already passed (owner 11-03 22:05: one proof per gate). Co-Authored-By: Claude Opus 5.5 <[email protected]>
1 parent e11b261 commit 9fa1ac5

41 files changed

Lines changed: 7290 additions & 242 deletions

Some content is hidden

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

‎ci/cr150-source-sites.json‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26939,7 +26939,7 @@
2693926939
"scope": [
2694026940
"namespace pineforge #1",
2694126941
"namespace #2",
26942-
"static int64_t compute_tf_close_ms ( int64_t open_ms , const std :: string & tf , const std :: string & tz ) #1",
26942+
"static int64_t compute_tf_close_ms ( int64_t bar_ms , const std :: string & tf , const std :: string & tz , const std :: string & sym_tz , const std :: string & sym_session ) #1",
2694326943
"if ( cp ! = CalendarPeriod :: NONE && utc_zone ( tz ) && in_civil_span ( static_cast < int64_t > ( osec ) ) ) #1"
2694426944
],
2694526945
"cls": "assign",
@@ -31839,7 +31839,7 @@
3183931839
"scope": [
3184031840
":: pineforge :: source :: detail :: PositionTailDiagnostics :: pineforge :: source :: detail :: PositionTailNoDiagnostics namespace pineforge :: source #1",
3184131841
"void PineExecutionAdapter :: place_entry ( const SourceId & id , bool is_long , double limit_price , double stop_price , double qty , const std :: string & comment , const std :: string & oca_name , int oca_type , int qty_type ) #1",
31842-
"if ( ! same_bar_market_candidate && config_ . pyramiding > 0 && current ! = 0 . 0 && ( ( current > 0 . 0 ) = = is_long ) && ! ( priced && config_ . process_orders_on_close ) ) #1",
31842+
"if ( ! same_bar_market_candidate && config_ . pyramiding > 0 && current ! = 0 . 0 && ( ( current > 0 . 0 ) = = is_long ) && ! ( priced && config_ . process_orders_on_close && ! coof_recalc_active_ ) ) #1",
3184331843
"PF_RARE ( records . has_value ( ) ) ) #1"
3184431844
],
3184531845
"cls": "assign",
@@ -31852,7 +31852,7 @@
3185231852
"scope": [
3185331853
":: pineforge :: source :: detail :: PositionTailDiagnostics :: pineforge :: source :: detail :: PositionTailNoDiagnostics namespace pineforge :: source #1",
3185431854
"void PineExecutionAdapter :: place_entry ( const SourceId & id , bool is_long , double limit_price , double stop_price , double qty , const std :: string & comment , const std :: string & oca_name , int oca_type , int qty_type ) #1",
31855-
"if ( ! same_bar_market_candidate && config_ . pyramiding > 0 && current ! = 0 . 0 && ( ( current > 0 . 0 ) = = is_long ) && ! ( priced && config_ . process_orders_on_close ) ) #1",
31855+
"if ( ! same_bar_market_candidate && config_ . pyramiding > 0 && current ! = 0 . 0 && ( ( current > 0 . 0 ) = = is_long ) && ! ( priced && config_ . process_orders_on_close && ! coof_recalc_active_ ) ) #1",
3185631856
"if ( ! ( config_ . process_orders_on_close && close_precedes_entry ) && accepted_in_cycle > = static_cast < std :: size_t > ( config_ . pyramiding ) && ! short_seed_final_candidate && ! paired_all_in_reentry && ! default_gross_over_cap_candidate && ! ( config_ . process_orders_on_close && opposite_opening_pending && ( opposite_opening_in_close_pass || detail :: run_position ( require_host ( ) ) . lot_count < static_cast < std :: size_t > ( config_ . pyramiding ) ) ) ) #1",
3185731857
"if ( priced ) #1",
3185831858
"if ( prior ! = live_by_source_key_ . end ( ) ) #1"

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

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

‎docs/design/arena-bound.md‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -341,14 +341,14 @@ indexPeak(k) = 24 * slots(k) # k > 32
341341
| Equity writer / selected hold-back / SpillCurve | 24*E | `pf_equity_point_t` size assertion `include/pineforge/metrics_stream.hpp:16`; `src/report_scratch.cpp:238` |
342342
| Position tail | (30+L)*T | `src/source/pine_position_tail.hpp:20`; footer packing at `src/source/pine_position_tail.cpp:94` |
343343
| Cohort AVL and five-word summary | (96+L)*D + 1[D>0] | `Links` at `include/pineforge/detail/disk_id_table.hpp:165-182`, `end_` at `:348`; `CohortFacts::Record` at `include/pineforge/source/pine_adapter.hpp:2059-2062` |
344-
| Entry-rank AVL | (60+L)*J + 1[J>0] | `exit_rank_keys_` at `src/source/pine_adapter.cpp:6773-6774`; `Links` at `include/pineforge/detail/disk_id_table.hpp:165-182`, `end_` at `:348` |
344+
| Entry-rank AVL | (60+L)*J + 1[J>0] | `exit_rank_keys_` at `src/source/pine_adapter.cpp:6800-6801`; `Links` at `include/pineforge/detail/disk_id_table.hpp:165-182`, `end_` at `:348` |
345345
| Erased minima data | (40+L)*D + (40+2*L)*Q | `erased_minima_` at `include/pineforge/source/pine_adapter.hpp:960`; 40-byte header at `include/pineforge/detail/id_pair_store.hpp:69` |
346346
| Erased minima index | indexPeak(D+Q) | 16-byte slot at `include/pineforge/detail/id_pair_store.hpp:69`; replacement at `:642` |
347347
| Consumed partial-cycle data | (41+2*L)*Q | `include/pineforge/source/pine_adapter.hpp:2834`; joined key at `src/source/pine_adapter.cpp:25493` |
348348
| Consumed partial-cycle index | indexPeak(Q) | `include/pineforge/detail/id_pair_store.hpp:642` |
349349
| Ordered consumed-cycle fold | 136*leaves + 2088*branches + 2096*savedPath | `include/pineforge/detail/id_pair_ordered_fold.hpp:161`, `:165`, `:172`, size assertion for `Leaf`, `Branch` and `Snapshot` at `:183` |
350350
| Successor-root rows | 16*R | `src/native_order.cpp:8220`, row assertion for `Row` at `:8148`, 64-row tail bound `kTailRows` at `:8153` |
351-
| Frozen external openings | **0 in this certified profile** | Stock source builds owned `BindOpenings` vectors at `src/source/pine_adapter.cpp:7058`, `:7051`, `:9745-9761`; generic external owners are excluded below |
351+
| Frozen external openings | **0 in this certified profile** | Stock source builds owned `BindOpenings` vectors at `src/source/pine_adapter.cpp:7085`, `:7078`, `:9794-9810`; generic external owners are excluded below |
352352

353353
The AVL node is seven uint64 words = 56 bytes, then its value and exact key
354354
bytes. CohortFacts::Record is handle, cycle, origin_count, origin_digest and
@@ -381,7 +381,7 @@ root only when a newly issued definition has one. The 64-row RAM tail makes
381381
charging every issued row conservative. Partial closes create one trade
382382
row per affected lot: `src/engine_execution.cpp:1241`. Bracket definitions
383383
have limit, stop and trailing families; per-entry expansion is visible at
384-
`src/source/pine_adapter.cpp:23456`. A closed-trade count cannot bound
384+
`src/source/pine_adapter.cpp:14809`. A closed-trade count cannot bound
385385
unfilled placement history or the replacement-root history.
386386

387387
The ordered fold retains distinct-ever keys, including erased keys.

0 commit comments

Comments
 (0)