Repository navigation
Engine train: margin state of a full-margin long, and negative-limit exit reservation - #859
Conversation
…anchors re-pointed Members, merged in order on main a9c58cf: - #812: the long-tick margin state of a full-margin long, with the measured x86_64 layout pins (heads 102ffb6, bca5a47) - #826: a strategy.exit whose limit price is negative reserves its quantity (heads 8b77a164, 4808823d, take-main bbc529d7) The two new test registration files sit in tests/lanes.d. Documentation line anchors that the two code changes moved are re-pointed by line number only; no sentence changes. Introducing commits of the re-pointed citations: 8b77a164, 4808823d, bca5a47, 102ffb6. Fixes #812 Fixes #826 Co-Authored-By: Claude Opus 5.5 <[email protected]>
There was a problem hiding this comment.
Graphify reviewed this change.
No issues found by static checks — no coupling regressions or blocking issues in the code graph. That is not the same as safe to merge: see what was not checked.
Not checked: tests were not run; no formal proof of the changed code.
Graphify review — findings
Adds chart-tick margin calls for qualifying full-margin long positions (unleveraged, one long lot opened at a bar's open, no slippage, bracket or limit orders). They re-check once after a call and carry any further sale to the next waypoint unless that waypoint makes its own call. Every margin requirement and deficit, long or short, is now rounded to ten significant digits but never more coarsely than one currency unit, and other positions keep their old behaviour apart from that rounding above 10^10. Fixes strategy.exit on a short position whose limit computes negative so the order keeps resting and reserves its qty_percent share, and a later partial exit sizes from what is left. The resting order has a zero trigger, so a feed with prices at or below zero would fill it at 0 where TradingView would not. Refreshes the ADR line references and the native-parity design and migration docs for the new margin-call scope, and makes the pre-open margin scheduling branch in on_applied an else if of the opening-check chain.
Review partial — this diff was larger than one review pass covers, so later files were not reviewed; some findings may be missing.
Analysis details — impact, health, verification
Impact & health
Graphify review
Impact — 2269 functions depend on the 2139 functions this change touches.
Health — this change adds coupling hotspots:
- worse:
find()— 10 callers, 4 callees - worse:
observe()— 4 callers, 5 callees
Verification — 2269 functions in the blast radius were not formally verified this run (proofs are advisory here).
Gate & verification
graphify gate
PASS — objectively clean (no health regressions, tests not run — proofs not run this pass (advisory)). Grounded, not self-assessed.
Advisory (not blocking):
- verification_scope: 2220 function(s) in the blast radius were not formally verified this run
Test selection
Test selection
1434 of 1434 test file(s) selected (100%) via static blast radius.
Escalated to a full run for safety (
noncode-change,uncovered-code) — the selection is not trustworthy on its own (see below). CI should run the whole suite.
benchmarks/tests/test_aggregate.py— full-run-safetybenchmarks/tests/test_check_provenance.py— full-run-safetybenchmarks/tests/test_compare.py— full-run-safetybenchmarks/tests/test_public_names.py— full-run-safetybenchmarks/tests/test_run_all.py— full-run-safetybenchmarks/tests/test_run_strategy_feeds.py— full-run-safetydocker/pineforge_sink_finalize_test.py— full-run-safetydocker/pineforge_sink_replay_rq_test.py— full-run-safetydocker/pineforge_sink_replay_test.py— full-run-safetydocker/pineforge_sink_to_json_test.py— full-run-safetydocker/quota_columns_test.py— full-run-safetydocker/quota_convert_test.py— full-run-safetydocker/quota_finalize_test.py— full-run-safetydocker/replay_rq_engine_test.py— full-run-safetydocker/run_json_artifact_window_test.py— full-run-safetydocker/run_json_bin_test.py— full-run-safetydocker/run_json_bounded_transport_test.py— full-run-safetydocker/run_json_bulk_equity_fuzz_test.py— full-run-safetydocker/run_json_bulk_equity_test.py— full-run-safetydocker/run_json_codes_test.py— full-run-safetydocker/run_json_converter_metadata_test.py— full-run-safetydocker/run_json_converter_session_test.py— full-run-safetydocker/run_json_diagnostics_test.py— full-run-safetydocker/run_json_equity_scan_test.py— full-run-safetydocker/run_json_fused_test.py— full-run-safetydocker/run_json_harnesses_test.py— full-run-safetydocker/run_json_metrics_only_test.py— full-run-safetydocker/run_json_misc2_test.py— full-run-safetydocker/run_json_misc_test.py— full-run-safetydocker/run_json_pfbar_test.py— full-run-safetydocker/run_json_provenance_test.py— full-run-safetydocker/run_json_quota_supervisor_test.py— full-run-safetydocker/run_json_replay_test.py— full-run-safetydocker/run_json_selected_sink_test.py— full-run-safetydocker/run_json_sink_lexical_test.py— full-run-safetydocker/run_json_sink_summary_test.py— full-run-safetydocker/run_json_sink_test.py— full-run-safetydocker/run_json_sink_vectors_test.py— full-run-safetydocker/run_json_spool_work_test.py— full-run-safetydocker/run_json_stringio_test.py— full-run-safetydocker/run_json_symbol_feeds_test.py— full-run-safetydocker/run_json_syminfo_test.py— full-run-safetydocker/run_json_trade_scan_test.py— full-run-safetydocker/run_json_window_budget_test.py— full-run-safetydocker/run_json_wrapper_work_test.py— full-run-safetyinclude/pineforge/native_run_spec.hpp— full-run-safetyscripts/derive_corpus_feeds_self_test.py— full-run-safetyscripts/fingerprint_self_test.py— full-run-safetyscripts/run_corpus_self_test.py— full-run-safetyscripts/test_abi_receipt_skips.py— full-run-safety- … and 1384 more
non-code file(s) changed (
CHANGELOG.md,ci/cr150-source-sites.json,docs/adr/0001-kernel-adapter-boundary.md,docs/design/arena-bound.md,docs/design/cr150-contracts.md…) → running the full suite for safety (a code graph can't see config/fixture/data deps)
changed code file(s) with no mapped test (
CHANGELOG.md,docs/adr/0001-kernel-adapter-boundary.md,docs/design/arena-bound.md,docs/design/cr150-contracts.md,docs/design/native-feature-parity.md…) — a coverage gap or a missing link — running the full suite rather than only the selected tests
Selection is safe under the controlled-regression assumption; always-run tests + a periodic full run are the backstops. Advisory — it never changes the check verdict.
· 2 more finding(s) on lines outside this diff (see the check run).
The #812 margin-state re-pin moves observe_long_tick_margin_bar into the pinned source window; keep the gate assertion exact on the train head.
One commit on
main(a9c58cf) carrying two reviewed members, merged in order:margin_long = 100: PineForge produces 18 of TradingView's 65 margin calls, and fills entries TradingView skips #812: the long-tick margin state of a full-margin long, with the measured x86_64 layout pinsstrategy.exitwhose limit price is negative reserves no quantity, so a later partial exit for the same entry closes more than TradingView #826: astrategy.exitwhose limit price is negative reserves its quantityThe two new test registration files sit in
tests/lanes.d. Documentation line anchors that the two code changes moved are re-pointed by line number only; no sentence text changes, and the anchor checker resolves every citation.Fixes #812
Fixes #826
🤖 Generated with Claude Code