Trading Risk Management: Complete Guide
Position sizing, stop losses, and risk limits. Learn how professional traders protect capital.
🎯 What You'll Learn
- Understand trading risk management principles
- Learn position sizing methods
- Know how to set stop losses
- Calculate and monitor risk metrics
- Implement risk controls in systems
The First Rule: Don’t Lose Money
Markets will eventually move against you. The question is: when that happens, how much do you lose?
Risk management is what keeps you in the game long enough for your edge to play out.
Core Concepts
| Term | Definition |
|---|---|
| Risk | Probability × Impact of loss |
| Position size | Amount invested in a trade |
| Stop loss | Price level to exit losing trade |
| Drawdown | Peak-to-trough decline |
| VaR | Value at Risk-max expected loss |
Position Sizing
How much capital to risk on each trade?
Fixed Fractional
Risk a fixed percentage of capital:
Capital: $100,000
Risk per trade: 1%
Risk amount: $1,000
Stock at $50, stop loss at $45
Risk per share: $5
Position size: $1,000 / $5 = 200 shares
```text
### Kelly Criterion
Mathematically optimal (but aggressive):
```yaml
Kelly % = (p × b - q) / b
where:
p = win probability
q = lose probability (1 - p)
b = win/loss ratio (average win / average loss)
Example:
Win rate (p): 55%
Lose rate (q): 45%
Average win: $1,000
Average loss: $800
b = 1000 / 800 = 1.25
Kelly = (0.55 × 1.25 - 0.45) / 1.25 = 0.2425 / 1.25 ≈ 19%
Use half-Kelly (~9.5%) in practice — full Kelly is theoretically optimal
but requires perfectly accurate probability estimates, which you won't have.
```bash
---
## Stop Losses
**Automatic exit when trade goes wrong.**
### Types
| Type | Trigger |
|------|---------|
| **Fixed** | Price reaches specific level |
| **Trailing** | Follows price up, exits on reversal |
| **Volatility** | Based on ATR (Average True Range) |
| **Time-based** | Exit after X time regardless |
### Setting Stop Levels
```text
Based on volatility (ATR):
ATR = 2% daily
Stop = 2 × ATR = 4%
Based on support:
Entry at $100
Support at $95
Stop at $94 (below support)
```diff
---
## Risk Limits
### Per-Trade Limits
- **Max position size**: Never more than X% of capital
- **Max loss per trade**: 1-2% of capital
### Daily Limits
```yaml
Daily loss limit: 5% of capital
Once hit → Stop trading for the day
Why: Prevents emotional revenge trading
```diff
### Portfolio Limits
- **Max correlation exposure**: Don't have all positions in same sector
- **Max total risk**: Total VaR under threshold
- **Leverage limit**: Max 2-5x depending on strategy
---
## Risk Metrics
### Drawdown
```text
Peak: $1,000,000
Current: $850,000
Drawdown: ($1,000,000 - $850,000) / $1,000,000 = 15%
```text
**Max drawdown** is the largest historical peak-to-trough.
### Sharpe Ratio
```yaml
Sharpe = (Return - Risk-free rate) / Standard deviation
Example:
Annual return: 20%
Risk-free rate: 5%
Volatility: 15%
Sharpe = (20% - 5%) / 15% = 1.0
```bash
| Sharpe | Interpretation |
|--------|---------------|
| < 1.0 | Suboptimal |
| 1.0-2.0 | Good |
| > 2.0 | Excellent |
| > 3.0 | Exceptional (suspicious) |
### Value at Risk (VaR)
```text
95% VaR: Max loss in 95% of days
If 95% VaR = $10,000
→ On 95% of days, you won't lose more than $10,000
→ On 5% of days (1 in 20), you might lose more
```diff
---
## Implementing Risk Controls
### Pre-Trade Checks
```python
def can_trade(order, portfolio):
# Check position limit
if order.value > portfolio.max_position:
return False, "Exceeds position limit"
# Check daily loss
if portfolio.daily_pnl < -portfolio.daily_limit:
return False, "Daily loss limit reached"
# Check concentration
if portfolio.exposure(order.sector) > portfolio.sector_limit:
return False, "Sector concentration limit"
return True, "OK"
```text
### Real-Time Monitoring
```python
def monitor_risk(portfolio):
metrics = {
'pnl': portfolio.pnl(),
'drawdown': portfolio.drawdown(),
'var': portfolio.var_95(),
'exposure': portfolio.gross_exposure()
}
for name, value in metrics.items():
if value > limits[name]:
alert(f"{name} breach: {value}")
Practice Exercises
Exercise 1: Position Sizing (Beginner)
Capital: 100 Stop loss: $95
Calculate position size.
Answer
Risk amount: 1,000 Risk per share: 95 = 1,000 / $5 = 200 shares
Exercise 2: Risk Metrics (Intermediate)
A portfolio had these monthly returns: +5%, +3%, -2%, +4%, -5%, +2%
Calculate:
- Total return
- Max drawdown (within months)
Answer
- Total: 1.05 × 1.03 × 0.98 × 1.04 × 0.95 × 1.02 = 1.0694 = 6.94%
- Max drawdown: In month 5 (−5%), from previous peak = 5%
Exercise 3: Design (Advanced)
Design a risk management system for an automated trading strategy with:
- Position limits
- Daily loss limits
- Correlation checks
- Automatic shutdown
Knowledge Check
-
Why is position sizing important?
-
What is the Kelly Criterion?
-
Why use daily loss limits?
-
What does Sharpe ratio measure?
-
What is Value at Risk (VaR)?
Answers
-
Determines how much you lose when wrong. Too large = one bad trade wipes you out.
-
Formula for optimal bet size based on win rate and win/loss ratio. Often halved due to uncertainty.
-
Prevents revenge trading. After losses, judgment impaired. Limits force a break.
-
Risk-adjusted returns. Return per unit of volatility. Higher = better risk/reward.
-
Maximum expected loss at confidence level. 95% VaR of 10K on 95% of days.
Summary
| Control | Purpose |
|---|---|
| Position sizing | Limit loss per trade |
| Stop losses | Automatic exit |
| Daily limits | Prevent tilt |
| Portfolio limits | Diversification |
| Monitoring | Real-time alerting |
What’s Next?
- HFT Basics - Risk in high-speed trading
- Order Book Basics - Market mechanics
Want to go deeper?
Weekly infrastructure insights for engineers who build trading systems.
Free forever. Unsubscribe anytime.
You're in. Check your inbox.
Questions about this lesson? Working on related infrastructure?
Let's discuss