Discussing the article: "Machine Learning Under Constraint (Part 1): A Configurable Rule Set for Prop-Firm Position Sizing"

 

Check out the new article: Machine Learning Under Constraint (Part 1): A Configurable Rule Set for Prop-Firm Position Sizing.

Hardcoded prop-firm rules lock the sizer to one program. This article factors those rules into a PropFirmRuleSet and refactors PropFirmAccountState and the sizing modifiers to consume it, including dynamic versus fixed daily limits and the news-window profit-credit haircut. Parity against the original FundedNext behavior is validated on a simulated equity path, so you can retarget sizing by configuration instead of rewriting code.

A prop-firm account is not sized like an ordinary one. Every position has to address two questions instead of one: how large should this trade be, given the model's confidence, and how large can it be, given how much of today's loss budget or the account's overall drawdown allowance is already spent. Get the second question wrong and the first one stops mattering — the account is disqualified before the edge has a chance to play out.

Part 11 of the MetaTrader 5 Machine Learning Blueprint series answered that second question with PropFirmAwareSizer, a sizer that shrinks positions automatically as the loss budget is consumed, with no manual threshold logic required. It works well. It also has a narrower problem than its name suggests: every rule it enforces — the phase profit targets, the daily loss limit and whether that limit expands with intraday profit, the overall floor, the news-window profit-credit haircut — is a constant copied from one program, FundedNext's Stellar 2-Step Challenge. The class is called PropFirmAwareSizer, not FundedNextAwareSizer, but until this article it could only size positions correctly for the firm it was written against. This article assumes familiarity with prop-firm challenge mechanics — phases, daily and overall loss limits, funded status — but not with Part 11's specific code; every place the refactor touches that code directly, this article shows the relevant before-and-after rather than assuming you have it memorized.

That gap is not obvious when reading Part 11 in isolation. It becomes obvious when a reader on a different program — a fixed, non-expanding daily limit; a different profit-credit haircut; a different phase structure — tries to reuse the code and discovers the rules are wired into class bodies instead of being passed as arguments. Generalizing the sizer at that point means editing bet_sizing/prop_firm_sizer.py directly, not writing a configuration. Tracing exactly which constants that generalization touches also turns up something Part 11's own test coverage never caught: three of its seven rule constants were declared and never read by any method at all, a finding Section 8 covers in full.

This article opens a new series, Machine Learning Under Constraint, rather than an extension of the MetaTrader 5 Machine Learning Blueprint. The intended reader is narrower: someone already committed to a funded-account program, for whom the daily loss budget is the primary sizing constraint, not an optional risk overlay. The series treats prop-firm trading as what it structurally is for that reader: a constrained optimization problem with a convex payoff, not an ordinary sizing problem with extra bookkeeping. This article lays the groundwork the rest of the series depends on. It factors Part 11's hardcoded rules into an explicit PropFirmRuleSet, refactors PropFirmAccountState and the sizing modifiers to consume it, and validates the refactor against the original hardcoded implementation over a simulated equity path. Later parts revisit each modifier in turn: the w-parameter calibration chain, the phase-progress de-risking factor, the news-window haircut, and the stop-loss ceiling under the optimal trading rule search from Part 15.

Author: Patrick Murimi Njoroge