The recurring request sounded simple: keep an existing sequence logic, but add a separate layer that could measure the whole basket and stop it from expanding beyond agreed limits. In practice, the manager had to understand positions opened by more than one path, calculate live exposure, and retain authority when normal exit logic was no longer enough.
The case below combines patterns from several assignments. It describes the engineering problem and public-safe lessons, not a downloadable strategy or a client specification.
Composite control path
A clear supervisor observes first, decides second, and records every intervention.
- 01ObserveIdentify owned positions, directions, volume, floating result, margin, and basket age.
- 02ClassifySeparate normal operation, restricted operation, blocked expansion, and emergency state.
- 03ActAllow, reduce, stop new orders, manage a basket exit, or escalate according to mandate.
- 04RecordLog the trigger, measured state, broker response, and reset requirement.
Shared problem
The entry module knew when it wanted another order, but it did not have a reliable account-wide view. Manual positions, another EA, or failed trade requests could change the real basket. The new layer therefore had to rebuild its view from confirmed platform positions instead of trusting an internal counter.
Constraints
The supervisor could not reveal or rewrite the private entry method. It had to work with clear ownership rules, different broker symbol properties, restarts, and both normal and abnormal execution. It also needed an unambiguous priority when profit targets, basket loss, daily limits, and emergency conditions conflicted.
Composite solution
The resulting pattern separated measurement from action. One part produced a verified snapshot of positions and account conditions. A second part applied fixed thresholds and returned a simple state. The execution layer then carried out the allowed response and confirmed what the broker actually completed.
Lessons
The most valuable improvement was not another recovery rule. It was making the exposure boundary visible, testable, and independent. Tests focused on restarts, missing positions, partial close behaviour, spread shocks, rejected requests, and the transition into and out of blocked states.
Questions you may have
Was this one client project?
No. It is a composite of recurring engineering patterns and does not identify or reproduce any single assignment.
Does a risk manager guarantee the cap?
No. It can enforce intended rules, but gaps, slippage, outages, and rejected orders may exceed planned limits.