Skip to content

Reconcile partial-close costs exactly #42

Description

@stefan-jansen

Findings: BR-018, BR-019.

Define and enforce one auditable entry-cost allocation rule for partial exits and remaining
positions. Remove the known invariant opt-out and replace portfolio-scale tolerances with bounds
derived from numeric precision and declared share rounding.

Primary surfaces: fill execution, position and trade construction, rebalance execution,
tests/helpers/invariants.py, book-parity contracts.

Acceptance:

  • The retained 1 percent commission rebalance reproducer has no $909 discrepancy.
  • Fill costs equal realized-trade costs plus residual-position costs exactly within the documented
    numeric bound.
  • Scale-in, partial-close, scale-out, reversal, long, short, fractional, integer, and futures tests
    pass the same invariant without opt-outs.
  • Full accounting and contract suites pass.

Dependencies: Issue 1.


Plan reference: /home/stefan/ml4t/libraries/ml4t-backtest-dev/.workspace/work/backtest-stable-release/milestone-1/plan.md - Issue 2 in milestone 0.1.0-m1 - Financial correctness and auditability.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions