p0-ship-fx-stack-20260731: stack FX series loader + short 1× rollover - #142
Merged
Conversation
… rollover Ship lead-adjudicated ACCEPT_SHIP stack (update seq 392, sb:59078b18c459): - task-76: engine account-currency FX series JSON loader (run_strategy.py) - task-79 A1: short 1x FX rollover fix (engine fills/run + affordability tests) Gate: pr-gate PASS 14 UP > 6 DOWN (+briancurry missing as DOWN => 14>7) vs pre-FX-wire baseline; test_affordability_fx 128/0.
There was a problem hiding this comment.
Pull request overview
This PR stacks two FX-related patches: it broadens the broker-open “timestamped FX rollover” handling from carried 1× longs to also include carried 1× shorts (while keeping leveraged shapes fail-closed), and adds a Python harness loader for bar-grain FX series JSON so runtime overrides can feed the engine the intended effective-time curve.
Changes:
- Extend broker-open timestamped account-currency FX rollover logic to support carried full-margin shorts (cell A1) and rename the internal helper accordingly.
- Add/extend unit tests to cover carried 1× short rollover behavior (including margin-call trims and flat-epoch consumption).
- Add a runtime override path in
scripts/run_strategy.pyto load bar-grain FX series JSON (mutually exclusive with daily-close FX JSON).
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| tests/test_affordability_fx.cpp | Adds carried 1× short rollover probes and assertions; updates G6 expectations for short vs leveraged shapes. |
| src/engine_run.cpp | Switches dispatch to the renamed carried-position FX rollover handler. |
| src/engine_fills.cpp | Generalizes carried FX rollover from 1× long-only to full-margin (1×) long/short and adds short-side MTM/margin math. |
| scripts/run_strategy.py | Adds JSON loader for bar-grain FX series overrides and enforces mutual exclusivity with daily-close loader. |
| include/pineforge/engine.hpp | Updates the private engine API declaration and documentation to match the generalized rollover handler. |
Comments suppressed due to low confidence (1)
scripts/run_strategy.py:858
- In the points[] JSON shape, boolean timestamps (True/False) will also be accepted via int(True)/int(False). Reject bool explicitly so invalid producer output can't slip through as a numeric timestamp.
raw_t = item.get("t", item.get("timestamp_ms", item.get("timestamp")))
raw_r = item.get("rate", item.get("c2a1"))
try:
t_ms = int(raw_t)
r = float(raw_r)
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| raw_bytes = path.read_bytes() | ||
| payload = json.loads(raw_bytes) | ||
| points = [] | ||
| if isinstance(payload, dict) and isinstance(payload.get("timestamps_ms"), list) and isinstance(payload.get("rates"), list): |
Comment on lines
+835
to
+841
| try: | ||
| t_ms = int(ts) | ||
| r = float(rate) | ||
| except (TypeError, ValueError) as exc: | ||
| raise ValueError( | ||
| f"invalid account-currency FX series point {ts!r}: {rate!r}" | ||
| ) from exc |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Campaign task
p0-ship-fx-stack-20260731(task 81) — mechanical ship of lead-adjudicated ACCEPT_SHIP (update seq 392, scoreboardsb:59078b18c459).Stacked patches only (no new experiments):
engine-account-currency-fx-series-json.patchsha2563895ef93173e1a7a3e6ae02afa6b3cd4f62ea2e6681f56a0eef3267c665e54bbfx-rollover-short-1x.patchsha25620896f756bc24b074a565d62601a486e089219b18b8b61a8d4c1d5f3811b717bBase:
origin/main@3cdcd36(patches applied clean withgit apply --3way).pr-gate verdict
$PINEFORGE_CAMPAIGN_STATE_DIRpath:/Users/haoliangwen/code/agent-org-harness/var/orgs/pineforge-parity/pr-gate-verdict.json/Users/haoliangwen/code/agent-org-harness/var/orgs/pineforge-parity/progress/.tiers-pre-p0-impl-account-currency-fx-wire-20260731.jsonsha256407675330b44432acc949b0df1c4ae56ef3d26d69e891202d569a9c48fefb63f_tier-grades.jsonsha25659078b18c4595a51ee8dcd9450a8508e959e39807274dc525fd7828bbfed5a00→sb:59078b18c459Missing-as-DOWN accounting vs pre-FX-wire e+s=400 lineage
pr-gate drops vanished rows from the DOWN count. With missing counted as DOWN (briancurry excellent→absent):
6 inherited FX-wire tier demotions (pre-existing; not introduced by A1)
Accepted as residual from task-76 FX enablement; diagnosis queued separately:
briancurry fail-closed caveat
briancurry-egan-s-pure-structure-s-d-strategy-backtest: excellent → missing under A1 design (leveraged fail-closed). Deferred to leveraged L/R cells (needs TV pin). Not an A1 non-target regression vs post-task-76 state (A1: 16 UP / 0 DOWN vs task-76 degraded).FX series runtime input contract
/Users/haoliangwen/code/agent-org-harness/var/orgs/pineforge-parity/baselines/account-currency-fx/c2a1-full-history-bar-grain.jsonccf0e088fc92b839e82d65ebf9458c0aeffb58257fa3257370440a141b319a11baselines/account-currency-fx/PIN.json— engine pinbddddac7491867b4a1b610073c30b6661122967e, codegen pin4b1af93e5594191c2f13e32bba40fbe907505c75Local hard gate
tests/test_affordability_fx: 128 passed / 0 failed (G long regression green) on this branch worktree.Evidence
file:///Users/haoliangwen/code/agent-org-harness/var/orgs/pineforge-parity/progress/p0-verify-task79-a1-20260731/findings.mdvar/orgs/pineforge-parity/worktrees/p0-ship-fx-stack-20260731@447726a