Skip to content

Define deterministic pre-risk callback state #46

Description

@stefan-jansen

Findings: BR-008.

Define the position, pending-order, and price state visible to on_before_risk for each execution
mode and make guarded entry behavior deterministic. Supported callback logic must not double-enter
because an earlier eligible order has not yet updated positions.

Primary surfaces: Engine.run, Strategy, Broker pending-order queries and processing, execution
semantics documentation and callback contract tests.

Acceptance:

  • The retained next-bar guarded-entry reproduction produces the documented exposure rather than
    twenty shares from two unintended submissions.
  • Same-bar and next-bar callback traces assert invocation order and visible positions and orders.
  • Legitimate explicit pyramiding remains possible through a documented operation.
  • Existing strict-profile timing is unchanged except where it embodied the defect.

Dependencies: Issues 1-4.


Plan reference: /home/stefan/ml4t/libraries/ml4t-backtest-dev/.workspace/work/backtest-stable-release/milestone-1/plan.md - Issue 6 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