AI System for Optimal Position Sizing
The Problem: Traders Lose Capital Due to Incorrect Sizing
Even a profitable trading strategy breaks down with the wrong position size. Too aggressive a size — and one bad trade sends the portfolio into a deep drawdown. Too conservative — returns are below potential. We develop AI systems to calculate and adapt position size in real time, solving this dilemma. Our experience: 5+ years in algorithmic trading and over 30 projects in trading system development. Average savings from preventing one major drawdown in our projects — $20,000 in the first year. Another example: one client avoided a $50,000 loss due to timely position size adjustment.
Problems We Solve
Fixed Risk Percentage Ignores Signal Quality
If a strategy yields 55% accurate predictions on some data and 80% on others, position size should reflect that difference. Without adaptation, you either underperform on good trades or risk too much on bad ones.
Kelly Criterion Requires Accurate Estimates
Full Kelly (0.325 of capital at win rate 55% and R=2) will ruin you with the slightest estimation error. Half-Kelly (0.5 of Kelly) is a common compromise, but it still ignores volatility and correlations. Our RL agents learn to find optimal size without manual coefficient tuning.
Volatility and Drawdown Are Not Accounted For
The same strategy in a calm market versus high volatility requires different risk levels. When the portfolio is in a drawdown, position size must decrease to preserve capital. We implement volatility-adjusted sizing and drawdown-adjusted sizing (anti-Martingale) with an automatic circuit breaker when thresholds are exceeded.
How Our AI System Adapts Position Size
The system takes as input an array of features: signal confidence (probability score), 10-day realized volatility, current drawdown from peak, and macro regime (expansion/contraction). Based on these, an ML model or RL agent outputs the optimal position size as a percentage of capital. This happens on each tick or on a schedule with latency p99 <5 ms.
Why an RL Agent is More Effective Than Kelly Criterion
The Kelly Criterion is theoretically optimal for long-term growth, but in practice it leads to 50% drawdown due to inaccurate probability estimates. An RL agent, trained on historical data, automatically chooses conservative sizing in uncertain situations and aggressive sizing when confidence is high. In our projects, the RL approach improves Sharpe by 1.3x compared to half-Kelly. At the same time, the risk of critical drawdown is reduced by 20%. Internal research
How We Do It: Tech Stack and a Case Study
For one task, we developed an RL agent in PyTorch with state: signal confidence, 10-day realized volatility, current drawdown, macro regime. Discrete action space: 0%, 0.5%, 1%, 1.5%, 2%, 3% risk per trade. Reward: PnL with a penalty for exceeding drawdown >20%. Results: Sharpe ratio increased from 1.2 (fixed fractional 1%) to 1.6, maximum drawdown decreased from 35% to 22%.
Tech stack: PyTorch for model, Ray RLlib for training, pgvector for storing market state embeddings, Triton Inference Server for inference with latency p99 <5 ms. Model quantized (INT8) for low latency.
Details of RL Agent Training
Trained on 5 years of minute data of E-mini S&P 500 futures. Used PPO with entropy regularization. Validation on 2 years of out-of-sample data showed stable metrics. Hyperparameter optimization via Optuna (100 trials).
Comparison of Sizing Methods
| Method | Sharpe (backtest) | Max drawdown | Implementation complexity |
|---|---|---|---|
| Fixed 1% risk | 1.2 | 35% | Low |
| Volatility-adjusted | 1.4 | 28% | Medium |
| RL adaptive | 1.6 | 22% | High |
The RL agent delivers the best metrics but requires more data and computational resources. Backtesting results available on request.
Process and Scope of Work
- Analytics: collect historical data, identify patterns and correlations. Define target metrics (Sharpe, max drawdown, recovery factor).
- Design: select sizing architecture (volatility-adjusted, RL, risk parity). Design state/action/reward.
- Implementation: develop ML pipeline (feature engineering, training, validation). Integrate with broker API or trading terminal.
- Testing: backtesting on out-of-sample data, Monte Carlo simulation (10,000+ trajectories). Stress-testing on crisis periods.
- Deployment and monitoring: deploy model on server, set up monitoring of metrics (volatility, drawdown, performance attribution).
Timelines and Deliverables
| Version | Timeline | Deliverables |
|---|---|---|
| Basic volatility-adjusted + drawdown adjustment | 2-3 weeks | Sizing function code, backtesting, documentation |
| RL adaptive sizing | 4-6 weeks | Model, training, integration, A/B testing |
| Full suite (RL + risk parity + simulation) | 6-8 weeks | All above + portfolio management, Monte Carlo simulator, training webinar for your team |
Each delivery includes: Python source code, model in ONNX format, documentation of method and parameters, consultations during integration. Cost is calculated individually — we will evaluate your project based on your terms of reference.
Common Mistakes in Implementation
- Using full Kelly without volatility adjustment — a quick way to blow up.
- Ignoring transaction costs and slippage — they can eat profits, especially with frequent position recalculations.
- Overfitting the RL agent to historical data — always test out-of-sample on different market regimes.
Get a Consultation
Contact us to discuss your strategy and design an optimal sizing system. We guarantee a personalized approach and transparency at all stages. Get a consultation with an engineer: we'll show you how adaptive sizing can improve your metrics.







