Discussing the article: "Machine Learning Under Constraint (Part 2): Calibrating Position Size to the Remaining Drawdown Budget"

 

Check out the new article: Machine Learning Under Constraint (Part 2): Calibrating Position Size to the Remaining Drawdown Budget.

We present a rule-set-aware calibration chain that turns the remaining risk budget into a calibrated sigmoid scale for position sizing. It computes a ceiling from stop loss pct and safety factor, back-solves w at a reference divergence, and flattens size progressively as the budget shrinks. The paper also clarifies where leverage caps must be applied in production: at the lots conversion, since risk-based sizing alone does not enforce max leverage.

Part 1 of this series tackled the foundational problem of abstraction. It replaced FundedNext's rigid, hardcoded rule constants with an explicit PropFirmRuleSet and refactored PropFirmAccountState to compute the remaining risk budget (risk_budget_pct) dynamically. With that refactor in place, the system can correctly interpret the daily and overall loss limits for any loaded program—whether it follows the fixed 5% daily limit of FundedNext, the variable scaling of a dynamic drawdown program, or a custom proprietary structure. However, as noted in the conclusion of Part 1, computation without consumption is inert. The account state knows exactly how much leash remains, but the position sizing engine was still looking at the old, hardcoded rules.

This article bridges that gap by implementing the consumer of that knowledge: the WParamCalibrator. This calibrator takes the abstract risk_budget_pct and translates it into a concrete sigmoid w parameter. This w-parameter is then fed into PropFirmAwareSizer, which scales every new position continuously between full size and zero as the daily budget erodes. This architecture is deliberately modular: the calibrator does not care whether the underlying program uses a daily limit, an overall limit, or a trailing maximum drawdown. It only sees the consolidated remaining budget fraction. This separation of concerns means that when we introduce a new prop firm rule set in the future, the sizing logic remains untouched.

This installation covers the calibration chain in detail. It explains why a sigmoid is used instead of a hard threshold, derives the calibration math, and visualizes the output across the full daily budget range. The article also identifies a gap found during a deep-dive review: the sizer validates max_leverage but never enforces it. Rather than patching this oversight haphazardly, I scope where the fix properly belongs. Finally, the article includes a dedicated tuning guide for the safety_factor—a parameter that quants often misconstrue as a static constant when it is, in fact, highly strategy-dependent.

Author: Patrick Murimi Njoroge