Skip to content

Add cash-paid cost-aware rebalancing from actual marked holdings - #90

Merged
initial-d merged 2 commits into
mainfrom
codex/cost-aware-rebalance-20261123
Nov 23, 2026
Merged

initial-d merged 2 commits into
mainfrom
codex/cost-aware-rebalance-20261123

Conversation

@initial-d

Copy link
Copy Markdown
Owner

Summary

The existing portfolio objective considers expected returns and risk but pays trading costs only afterwards. Add opt-in cash-paid rebalancing that plans from actual marked holdings with fees inside both its mean-variance objective and funding constraint. Weak forecasts can leave the account unchanged; permissions and monetary caps restrict the plan before trading.

Each row marks actual holdings, estimates covariance using strictly prior return rows, optimizes, executes through the existing self-financing constrained ledger, and carries actual fills/cash forward. A monetary position-value cap permits existing drift to remain without increasing its value. Failed or infeasible solves hold exact positions and record the reason. The cached convex problem is DPP; solver status and feasible baseline selection remain inspectable.

mlquant rebalance reuses saved return forecasts and the panel, optionally derives strictly lagged monetary caps, and writes separate reports/full ledgers. Planning and execution use one fee rate. Legacy fixed-target and Markowitz defaults remain unchanged. This is a long-only historical mark-price policy with same-row sale proceeds, not a live or calibrated exchange execution system.

Type of change

  • Feature
  • Refactor
  • Test or benchmark

Reproducibility

  • Added analytic optima, cash conservation, actual-state feedback and future-mutation checks.
  • Documented pre-trade monetary limit units, forecasts, failures and execution assumptions.
  • No private data, credentials or large generated account artifacts committed.
  • Solo contribution.

Validation

  • Full local suite: 588 passed, with two existing LibreSSL/CVXPY warnings.
  • Ruff on src/tests/audit script and git diff --check passed.
  • 15 independent one-asset global analytic optima; maximum holding-fraction error 8.59e-9.
  • Three 200x30 synthetic cases with the SAME actual execution fee in aware and fee-blind-planning controls. Independent 60-digit Decimal reconstruction: maximum currency error 1.31e-8 on initial capital one million.
  • All 100 decisions per case optimized with zero failed holds; actual CLI agrees with the direct constrained case.
  • Cash-paid entry/exit thresholds, no-trade regions, locked holdings, caps, actual marked-state feedback, strictly prior covariance, failed/warmup exact holds, solver fallback, DPP reuse and future-input mutation passed.
  • CI also reuses its complete synthetic pipeline for the new CLI.

Raw audit and all controls. Reduced fees do not guarantee higher realized returns; controls retain both directions. Synthetic forecasts contain no intended alpha, and no public-data snapshot is revalidated.

@initial-d
initial-d merged commit 199a548 into main Nov 23, 2026
3 checks passed
@initial-d
initial-d deleted the codex/cost-aware-rebalance-20261123 branch November 23, 2026 00:42
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