Skip to content

Add constrained historical fills with retained holdings and a cash ledger - #88

Merged
initial-d merged 2 commits into
mainfrom
codex/constrained-execution-20261121
Nov 21, 2026
Merged

initial-d merged 2 commits into
mainfrom
codex/constrained-execution-20261121

Conversation

@initial-d

Copy link
Copy Markdown
Owner

Summary

A portfolio can request zero weight for a halted asset while still holding it. Complete-fill accounting treats that request as a sale and can fund replacement purchases with proceeds that never existed. Add opt-in constrained historical rebalancing that retains blocked holdings and marks their subsequent returns.

Requests use the existing complete-fill post-fee NAV solve as a reference. Directional permissions and optional per-asset currency caps restrict fills; permitted sales fund pro-rata purchases and their one-way fees. Record requested, executed and unfilled trades, separate permission/cap/cash causes, and actual weights and cash. Requests expire each row and are recomputed from actual holdings.

mlquant backtest --accounting constrained reuses saved artifacts and applies observed-price/volume and supplied directional price-band gates without forward labels. Reports retain the policy and OOS mask hashes. Existing modes keep their defaults and released constraints retain bit-identical ledger arrays. This is a close-mark research policy with same-row sale proceeds; queue, settlement, impact and live execution are outside its scope.

Type of change

  • Feature
  • Test or benchmark
  • Refactor

Reproducibility

  • Added regression tests and independent Decimal reconstruction.
  • Documented target-reference and execution assumptions.
  • No private data, credentials or large generated artifacts.
  • Solo contribution.

Validation

  • Full local suite: 512 passed, with two existing LibreSSL/CVXPY environment warnings.
  • Ruff on src, tests and the new audit script; git diff --check passed.
  • Four independent 60-digit Decimal cases, including 500x200 synthetic arrays; maximum absolute error 7.77e-16.
  • Cash conservation, directional/cap controls, future-input mutation, released-constraint exact compatibility, and OOS CLI halt/resumption tests passed.
  • CI also runs the constrained CLI after the full synthetic pipeline.

Synthetic audit and raw ledgers. Both gain and loss outcomes from locked exits are retained. This is engineering evidence; no market performance snapshot was revalidated.

@initial-d
initial-d merged commit d84711a into main Nov 21, 2026
3 checks passed
@initial-d
initial-d deleted the codex/constrained-execution-20261121 branch November 21, 2026 08:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant