Repository navigation
C ABI: strategy_initial_capital, so the report writer names simple_proportional_overflow in every run - #565
Merged
Merged
Conversation
…oportional_overflow in every run Adds the read-only export `double strategy_initial_capital(pf_strategy_t)`: the capital the configured run uses (the staged native specification before a run begins, the engine's stored capital otherwise), NaN for a null handle. The report writer reads it once per run, behind a missing-symbol guard, and uses it as E0 in the annualisation diagnostics, so `simple_proportional_overflow` is named exactly whenever the compounded form is not finite, also where the first curve mark cannot prove the capital. A library without the export keeps the earlier behaviour byte for byte. Documentation: the wording that 34f9b3a added about the writer being unable to prove the initial capital, and that "a later release may remove the gap by reading the capital from the engine", is replaced by the exact behaviour (`docs/design/selected-window-wire-v1.3-revision-3.1.md`, `docs/pages/report-schema.md`). The sentences removed are named here on purpose: "E0 is the first mark only where the run proves it is the initial capital", "Where it cannot prove the initial capital the writer cannot recompute the compounded form, guesses none and names nothing", "In that case (a run of one day or more whose compounded form is not finite, with an unproven first mark)", "A later release may remove the gap by reading the capital from the engine", "No kernel state, public POD member, header ABI, or runtime export is added", "The initial capital it needs is the first mark only where the run proves it". All six came with 34f9b3a. Also corrects the comment in src/engine_metrics.cpp that described the one-day-boundary ranking inversion backwards (it is compounded > simple). Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
… edit The initial-capital change adds lines to docker/run_json.py, which moves the nine places the caller page of the report-sink descriptor cites in it. Only the line numbers change; each citation keeps its symbol. Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
luisleo526
marked this pull request as ready for review
October 27, 2026 20:24
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.
What
Adds the C ABI export
double strategy_initial_capital(pf_strategy_t), so the report writer can namesimple_proportional_overflowexactly, in every run.Before,
docker/run_json.pynamed that reason indiagnostics.annualizationonly when it could prove the first curve mark was the initial capital (the selected-window anchor, or an ordinary run whose first mark had no open profit and no trade entered at bar 0). In every other run of one day or more whose compoundedcagrwas not finite, the reportedcagrwas the simple proportional value the kernel computed, but the reason was silently absent. The revision-3.1 note said a later release could close the gap by reading the capital from the engine; this is that release.strategy_initial_capitalreturns the capital the configured run uses: the staged native specification before a run begins, the engine's stored capital otherwise. It returns NaN for a null handle (the same sentinel asstrategy_current_equity) and adds no kernel state.docker/run_json.pyreads it once per run behind a missing-symbol guard and uses it as the initial capital when it is finite and positive. A library without the export keeps the earlier behaviour byte for byte. The subday branch, every existing absence, the overflow handling and the simplecagrvalue are unchanged.src/engine_metrics.cppthat described the one-day-boundary ranking inversion backwards now says what the documentation says (compounded above simple); no code in that file changed.Verification
docker/run_json.pyat base, the new end-to-end testtest_initial_capital_export_closes_the_unproven_overflow_gapfails (the reason is absent); on the base tree the new C test and checker lists fail to build and check for the missing export.strategy_configure_native_v1the first accessor returned the engine's member default, because the native route only stages the specification and copies the capital at the start of the run. The accessor now reads the staged specification; the C test asserts it for a reused host as well.🤖 Generated with Claude Code