Repository navigation
fix: session filter, short weight cap, futures multiplier in cash checks, CAGR overflow - #129
Open
quantum-like wants to merge 5 commits into
Open
quantum-like wants to merge 5 commits into
quantum-like wants to merge 5 commits into
Conversation
CME-style sessions open on the calendar day before their session date. The filter expanded the schedule start but not the end, so a bar on that open was removed whenever the frame's latest UTC date was still the prior day. Co-authored-by: quantum-like <quantum-like@users.noreply.github.com>
min() only upper-bounds a weight, so a short target more negative than the configured cap was left unchanged. Apply the cap as a magnitude limit. Co-authored-by: quantum-like <quantum-like@users.noreply.github.com>
The open cash check treated notional as price times quantity and then skipped the gatekeeper. A one-lot futures buy could fill and drive cash negative. Scale the projected debit by the contract multiplier. Co-authored-by: quantum-like <quantum-like@users.noreply.github.com>
Sequential fills treat a reserved order as already validated and skip the gatekeeper. The shadow reserved price times quantity, so a futures order could fill for many times the reserved cash. Reserve price times quantity times multiplier. Co-authored-by: quantum-like <quantum-like@users.noreply.github.com>
A one-minute equity gain made (final/initial) ** (1/years) exceed the float range and raise OverflowError while assembling run metrics. Return infinity for that overflow and leave finite windows unchanged. Co-authored-by: quantum-like <quantum-like@users.noreply.github.com>
This branch has not been deployed
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.
Owning issue
Closes #128
Outcome
5 correctness fixes, one commit each, each with a focused test:
filter_to_trading_sessionsextended the exchange schedule one day before the first bar but stopped on the last UTC date. Overnight sessions such as the CME equity open start on the calendar day before their session date, so a bar in that open was dropped when the frame ended on the prior UTC date. The schedule end is now also extended by one day. Test:tests/test_calendar.py::test_filter_keeps_overnight_open_before_session_date. (3f6eac0)TargetWeightExecutorappliedmax_single_weightwithmin(), which caps long targets only; a −50% target with a 25% cap stayed at −50%. Short targets are now floored at-max_single_weight. Test:tests/execution/test_rebalancer.py::test_max_single_weight_caps_short_targets. (abc0c4c)tests/test_config_wiring.py::test_next_bar_simple_cash_check_includes_contract_multiplier. (e78288d)tests/test_config_wiring.py::test_buying_power_reservation_includes_contract_multiplier. (cd49c85)cagr()raisedOverflowErrorwhen a very short window was annualized (e.g. a one-minute move from 100,000 to 101,000), which abortedEquityCurve.to_dict(). That case now returns infinity; finite windows use the same formula as before. Test:tests/test_equity_curve.py::test_short_window_cagr_does_not_overflow. (c9397df)Compatibility
Results change only in the cases above (overnight-session bars kept, short targets capped, futures orders sized with the multiplier, overflowing CAGR reported as
inf).Verification
mainand passes with its fix)ruff format --checkis clean on the changed files andruff checkreports nothing new in them versusmain, but I did not run the full pre-commit suite)typasses (not run on this branch)pytestexcluding benchmarks: 2198 passed, 9 skipped before; 2194 passed, 9 skipped, 9 failed after.The 9 failures are the retained-evidence checks in
tests/contracts/test_parity_claim_generation.pyandtests/contracts/test_real_strategy_runner.py. They hash the engine source files and compare against pins invalidation/CORRECTNESS_RESULTS.jsonandvalidation/REAL_STRATEGY_RESULTS.json, so any engine source edit changes them. Refreshing those pins needs a re-derived cross-framework run that I could not do, so I left the published evidence files untouched. They are not behavior regressions, but they will need your refresh before merge.Documentation and release
No documentation changes. The behavior changes above may be worth a line in the next patch-release notes.
Amir