Adaptive position sizer
Sizes a position from the market regime and confidence, held between a floor and a cap.
The sizer takes a regime label from a regime detector and a confidence score, and turns them into a position size. Each regime sets a base size: 2.0 for consolidation, 1.0 for a volatility breakout, 3.0 for a strong uptrend, 0.5 for a strong downtrend, and 1.5 for choppy range trading. The base is multiplied by confidence, then clamped between min_size and max_size. In the sample run on SPY one-minute bars the output was 3.0 on every bar, the cap, so that run shows the clamp at work, not the regime or confidence.
How to read it
- The line sits in its own pane below the price, in size units between min_size and max_size.
- A flat line at the top means the cap binds: base size times confidence is at or above max_size. With defaults the sample held at 3.0 for the whole month.
- Steps follow regime changes from the detector; confidence scales each step before the limits apply.
What it outputs
- Position size
- Size multiplier for the position, clamped between min_size and max_size. Defaults give 0.5 to 3.0.
Settings
- max_size
- Sets the cap on size. Raising it lets strong regimes reach bigger sizes; lowering it flattens the top of the line at the new level. If it falls below min_size, the output is always min_size.
- min_size
- Sets the floor on size. Raising it lifts weak bars, such as a low-confidence downtrend (base 0.5), to that level; lowering it lets them size smaller. If it rises above max_size, the output is always min_size.
Pitfalls
- The sample on SPY sat at the 3.0 cap on every bar, so it says nothing about live regime or confidence. The regime cut-offs sit in the detector's own module.
- Confidence is documented as 0 to 1 but the code does not check it. A confidence above 1 pushes size to the cap sooner.
- The parameter ranges allow inverted or negative limits. When max_size falls below min_size, the output is always min_size, whatever the regime or confidence.