DEV Community

Henry Lin
Henry Lin

Posted on

Lesson 15: Strategy Portfolio and Diversification

Lesson 15: Strategy Portfolio and Diversification

โฑ Duration: 1.5 hours
๐ŸŽฏ Learning Objectives: Learn to build strategy portfolios
๐Ÿ“š Difficulty: โญโญโญ Strategy Optimization


๐Ÿ“– Course Overview

"Don't put all your eggs in one basket" - this investment principle also applies to quantitative trading. This lesson will teach you how to build multi-strategy investment portfolios, reduce risk through strategy diversification, and improve return stability.


15.1 Why Combine Strategies?

Risks of Single Strategy

Case: Using Trend Strategy Only

2025 Q1 (Bull Market): +25% โœ…
2025 Q2 (Ranging Market): -8% โŒ
2025 Q3 (Bull Market): +18% โœ…
2025 Q4 (Bear Market): -12% โŒ

Annual Total Return: +23% - 20% = +19.1%
Max Drawdown: -12%
High return volatility, poor experience
Enter fullscreen mode Exit fullscreen mode

Case: Using Strategy Portfolio

Strategy Portfolio:
  - 50% Trend Strategy
  - 30% Mean Reversion Strategy
  - 20% Breakout Strategy

2025 Q1 (Bull Market):
  Trend: +25% โ†’ Contributes +12.5%
  Mean Reversion: +5% โ†’ Contributes +1.5%
  Breakout: +15% โ†’ Contributes +3%
  Portfolio: +17% โœ…

2025 Q2 (Ranging Market):
  Trend: -8% โ†’ Contributes -4%
  Mean Reversion: +18% โ†’ Contributes +5.4%
  Breakout: +2% โ†’ Contributes +0.4%
  Portfolio: +1.8% โœ… (Avoided losses!)

Annual Total Return: +20.5%
Max Drawdown: -3.5% (Significantly reduced!)
More stable returns, better experience
Enter fullscreen mode Exit fullscreen mode

Advantages of Strategy Portfolios

  1. Reduce Drawdowns

    • Single strategy drawdown: -12%
    • Portfolio strategy drawdown: -3.5%
    • 71% drawdown reduction!
  2. Smooth Return Curve

    • No big ups and downs in single quarters
    • Less psychological pressure
    • Easier to stick with
  3. Adapt to Different Market Conditions

    • Bull markets have trend strategies
    • Ranging markets have mean reversion
    • Bear markets have conservative strategies
  4. Increase Trading Opportunities

    • Other strategies supplement when single strategy has few signals
    • Improve capital utilization

15.2 Strategy Correlation Analysis

What is Strategy Correlation?

Definition: The degree of synchronization between two strategies' returns.

Correlation Coefficient:

+1.0: Perfectly positive correlation (move up and down together)
0.0: No correlation
-1.0: Perfectly negative correlation (when one rises, the other falls)
Enter fullscreen mode Exit fullscreen mode

Impact of Correlation on Portfolios

High Correlation Portfolio (โŒ Not Recommended):

Strategy A: Trend Strategy (EMA Crossover)
Strategy B: Trend Strategy (MACD)
Correlation: 0.95

Q1 Performance:
  Strategy A: +20%
  Strategy B: +18%
  Portfolio: +19%

Q2 Performance:
  Strategy A: -10%
  Strategy B: -9%
  Portfolio: -9.5% (No diversification effect!)
Enter fullscreen mode Exit fullscreen mode

Low Correlation Portfolio (โœ… Recommended):

Strategy A: Trend Strategy
Strategy B: Mean Reversion Strategy
Correlation: 0.25

Q1 Performance:
  Strategy A: +20%
  Strategy B: +5%
  Portfolio: +12.5%

Q2 Performance:
  Strategy A: -10%
  Strategy B: +15%
  Portfolio: +2.5% (Successful hedging!)
Enter fullscreen mode Exit fullscreen mode

How to Calculate Strategy Correlation

Method 1: Quarterly Return Correlation

import numpy as np
from scipy.stats import pearsonr

# Quarterly returns for Strategy A and B
returns_A = [20, -10, 15, -5]  # Q1-Q4
returns_B = [5, 15, 8, 12]

# Calculate correlation
correlation, p_value = pearsonr(returns_A, returns_B)
print(f"Correlation: {correlation:.2f}")
Enter fullscreen mode Exit fullscreen mode

Method 2: Daily Return Correlation

# Assume daily return data is available
daily_returns_A = [0.5, -0.3, 1.2, ...]  # 90 days
daily_returns_B = [0.2, 0.8, -0.5, ...]

correlation = np.corrcoef(daily_returns_A, daily_returns_B)[0, 1]
Enter fullscreen mode Exit fullscreen mode

Correlation Guidelines

Correlation Diversification Effect Recommendation
> 0.8 Very Poor โŒ Avoid combining
0.5-0.8 Poor โš ๏ธ Combine cautiously
0.2-0.5 Good โœ… Recommended combination
-0.2-0.2 Excellent โœ… Ideal combination
< -0.2 Outstanding โญ Best combination

15.3 Multi-Strategy Capital Allocation

1. Equal Weight Allocation (Simplest)

Principle: Each strategy allocated same capital.

Configuration:

Total Capital: $10,000
Number of Strategies: 3

Strategy A: $3,333
Strategy B: $3,333
Strategy C: $3,334
Enter fullscreen mode Exit fullscreen mode

Advantages:

  • โœ… Simple and direct
  • โœ… No calculation needed

Disadvantages:

  • โŒ Doesn't consider strategy quality differences
  • โŒ Doesn't consider risk differences

Suitable for: When strategy performance is similar


2. Score-Based Allocation (Recommended)

Principle: Allocate capital based on strategy scores.

Calculation Method:

Strategy A: Score 9.0
Strategy B: Score 8.0
Strategy C: Score 7.0
Total Score: 24.0

Strategy A Allocation = 9.0 / 24.0 = 37.5%
Strategy B Allocation = 8.0 / 24.0 = 33.3%
Strategy C Allocation = 7.0 / 24.0 = 29.2%

Total Capital $10,000:
  Strategy A: $3,750
  Strategy B: $3,333
  Strategy C: $2,917
Enter fullscreen mode Exit fullscreen mode

Advantages:

  • โœ… Better-performing strategies get more capital
  • โœ… Reasonably optimizes overall returns

Disadvantages:

  • โš ๏ธ Scores may become outdated
  • โš ๏ธ Requires regular adjustment

3. Risk Parity Allocation (Advanced)

Principle: Let each strategy contribute equal risk.

Calculation Method:

Strategy A: Volatility 10%, Score 9.0
Strategy B: Volatility 15%, Score 8.0
Strategy C: Volatility 20%, Score 7.0

# Risk Contribution = Capital Allocation ร— Volatility
# Goal: Make each strategy's risk contribution equal

Assume target portfolio volatility is 12%

Strategy A Allocation = 12% / 10% = 1.2 ร— base position
Strategy B Allocation = 12% / 15% = 0.8 ร— base position
Strategy C Allocation = 12% / 20% = 0.6 ร— base position

After normalization:
  Strategy A: 46.2%
  Strategy B: 30.8%
  Strategy C: 23.0%
Enter fullscreen mode Exit fullscreen mode

Advantages:

  • โœ… Risk balanced
  • โœ… Professional allocation

Disadvantages:

  • โŒ Complex calculation
  • โŒ Needs volatility data
  • โŒ Not suitable for beginners

4. Core-Satellite Configuration (Practical)

Principle: Core assets seek stability, satellite assets seek high returns.

Configuration:

Total Capital: $10,000

Core Assets (70%): $7,000
  โ”œโ”€ High-score Strategy A (S Grade): $4,000 (40%)
  โ””โ”€ High-score Strategy B (A Grade): $3,000 (30%)

Satellite Assets (30%): $3,000
  โ”œโ”€ Test Strategy C (B Grade): $1,500 (15%)
  โ”œโ”€ Test Strategy D (B Grade): $1,000 (10%)
  โ””โ”€ Experimental Strategy E (C Grade): $500 (5%)
Enter fullscreen mode Exit fullscreen mode

Advantages:

  • โœ… Balances returns and risk
  • โœ… Core assets protect principal
  • โœ… Satellite assets pursue excess returns
  • โœ… Allows trying new strategies

Suitable for:

  • Experienced traders
  • Capital > $10,000
  • Want to explore new strategies

15.4 Strategy Portfolio Construction Practice

Step 1: Select Candidate Strategies

Criteria:

  • โœ… Score > 7.0
  • โœ… Pass out-of-sample validation
  • โœ… Different strategy types

Candidate Strategy Pool:

1. MomentumTrendStrategy (Trend, S Grade, 9.36 points)
2. MeanReversionStrategy (Mean Reversion, A Grade, 8.52 points)
3. BreakoutTrendStrategy (Breakout, A Grade, 8.18 points)
4. ADXTrendStrategy (Trend, B Grade, 7.85 points)
5. GridTradingStrategy (Grid, B Grade, 7.42 points)
Enter fullscreen mode Exit fullscreen mode

Step 2: Correlation Analysis

Test Correlations:

# Backtest all strategies, record daily/weekly returns
freqtrade backtesting -c config.json --strategy MomentumTrendStrategy --timerange 20250101-20250930
freqtrade backtesting -c config.json --strategy MeanReversionStrategy --timerange 20250101-20250930
# ...

# Analyze correlations (need to export data and analyze with Python)
Enter fullscreen mode Exit fullscreen mode

Correlation Matrix:

                 | Momentum | MeanRev | Breakout | ADX  | Grid
Momentum         | 1.00     | 0.25    | 0.72     | 0.85 | 0.15
MeanReversion    | 0.25     | 1.00    | 0.30     | 0.22 | 0.68
Breakout         | 0.72     | 0.30    | 1.00     | 0.68 | 0.28
ADX              | 0.85     | 0.22    | 0.68     | 1.00 | 0.18
Grid             | 0.15     | 0.68    | 0.28     | 0.18 | 1.00
Enter fullscreen mode Exit fullscreen mode

Analysis Conclusion:

  • โŒ Momentum and ADX highly correlated (0.85) โ†’ Don't select both
  • โœ… Momentum and MeanReversion low correlation (0.25) โ†’ Good combination
  • โœ… Momentum and Grid low correlation (0.15) โ†’ Good combination

Step 3: Build Investment Portfolio

Plan A: Conservative (Recommended for Beginners)

Total Capital: $10,000

Core (80%):
  โ”œโ”€ MomentumTrendStrategy: $5,000 (50%)
  โ””โ”€ MeanReversionStrategy: $3,000 (30%)

Testing (20%):
  โ””โ”€ BreakoutTrendStrategy: $2,000 (20%)

Expected Performance:
  - Annual Return: 60-80%
  - Max Drawdown: 5-8%
  - Sharpe Ratio: 2.5-3.0
Enter fullscreen mode Exit fullscreen mode

Plan B: Balanced (Recommended for Intermediate)

Total Capital: $10,000

Core (60%):
  โ”œโ”€ MomentumTrendStrategy: $3,000 (30%)
  โ””โ”€ MeanReversionStrategy: $3,000 (30%)

Growth (30%):
  โ”œโ”€ BreakoutTrendStrategy: $2,000 (20%)
  โ””โ”€ ADXTrendStrategy: $1,000 (10%)

Experimental (10%):
  โ””โ”€ GridTradingStrategy: $1,000 (10%)

Expected Performance:
  - Annual Return: 80-120%
  - Max Drawdown: 8-12%
  - Sharpe Ratio: 2.0-2.5
Enter fullscreen mode Exit fullscreen mode

Plan C: Aggressive (For Experienced)

Total Capital: $10,000

Balanced Allocation:
  โ”œโ”€ MomentumTrendStrategy: $2,500 (25%)
  โ”œโ”€ MeanReversionStrategy: $2,000 (20%)
  โ”œโ”€ BreakoutTrendStrategy: $2,000 (20%)
  โ”œโ”€ ADXTrendStrategy: $1,500 (15%)
  โ”œโ”€ GridTradingStrategy: $1,500 (15%)
  โ””โ”€ Other Strategies: $500 (5%)

Expected Performance:
  - Annual Return: 100-150%
  - Max Drawdown: 12-18%
  - Sharpe Ratio: 1.5-2.0
Enter fullscreen mode Exit fullscreen mode

Step 4: Backtest Verify Portfolio

Test Each Strategy Separately:

freqtrade backtesting -c config_momentum.json --strategy MomentumTrendStrategy --timerange 20250101-20250930
freqtrade backtesting -c config_meanrev.json --strategy MeanReversionStrategy --timerange 20250101-20250930
Enter fullscreen mode Exit fullscreen mode

Simulate Portfolio Performance:

# Calculate portfolio returns
momentum_return = 0.23  # 23%
meanrev_return = 0.15   # 15%

# 50% + 30% allocation
portfolio_return = (0.23 ร— 0.50) + (0.15 ร— 0.30) = 0.16 = 16%

# Calculate portfolio drawdown (simplified)
momentum_drawdown = 0.05  # 5%
meanrev_drawdown = 0.03   # 3%

# AssumeไธๅฎŒๅ…จๅŒๆญฅ (correlation 0.25)
portfolio_drawdown โ‰ˆ 0.04 = 4% (between the two)
Enter fullscreen mode Exit fullscreen mode

Step 5: Dynamic Rebalancing

Why Rebalancing is Needed?

Initial Configuration (2025-01-01):
  Strategy A: $5,000 (50%)
  Strategy B: $5,000 (50%)

After 3 months (2025-03-31):
  Strategy A: $6,500 (30% growth) โ†’ 54.2%
  Strategy B: $5,500 (10% growth) โ†’ 45.8%

Deviated from target configuration! Need rebalancing.
Enter fullscreen mode Exit fullscreen mode

Rebalancing Methods:

Method 1: Regular Rebalancing (Recommended)

Frequency: 1st of each month
Action: Adjust capital back to target proportions

Example:
  Total Capital: $12,000
  Target: A=50%, B=50%

  Action:
    Withdraw from Strategy A: $6,500 - $6,000 = $500
    Add to Strategy B: $5,500 + $500 = $6,000
Enter fullscreen mode Exit fullscreen mode

Method 2: Threshold Rebalancing

Trigger Condition: Deviation from target > 10%

Example:
  Target: A=50%, B=50%
  Actual: A=55%, B=45%
  Deviation: 5% (not triggered)

  Actual: A=62%, B=38%
  Deviation: 12% (trigger rebalancing)
Enter fullscreen mode Exit fullscreen mode

Method 3: No Rebalancing (Let Profits Run)

Philosophy: Give more capital to better-performing strategies

Advantages:
  - โœ… Follow the trend
  - โœ… Reduce trading costs

Disadvantages:
  - โŒ Risk concentration
  - โŒ May miss mean reversion opportunities
Enter fullscreen mode Exit fullscreen mode

๐Ÿ’ก Practical Tasks

Task 1: Build Your Strategy Portfolio

Based on what you've learned, build your investment portfolio:

# My Strategy Investment Portfolio

## Total Capital
$_______

## Risk Preference
โ˜ Conservative  โ˜ Balanced  โ˜ Aggressive

## Strategy Configuration

### Core Assets (____%)
1. ___________ Strategy: $_______ (___%)
   - Score: _____
   - Suitable Market Conditions: _____

2. ___________ Strategy: $_______ (___%)
   - Score: _____
   - Suitable Market Conditions: _____

### Growth/Satellite Assets (____%)
3. ___________ Strategy: $_______ (___%)
   - Score: _____
   - Suitable Market Conditions: _____

4. ___________ Strategy: $_______ (___%)
   - Score: _____
   - Suitable Market Conditions: _____

## Expected Targets
- Annual Return Target: _____%
- Acceptable Max Drawdown: _____%
- Target Sharpe Ratio: _____

## Rebalancing Plan
- Frequency: โ˜ Monthly  โ˜ Quarterly  โ˜ When deviation > 10%
- Next Rebalancing Date: _____
Enter fullscreen mode Exit fullscreen mode

Task 2: Calculate Strategy Correlations

Select 2-3 strategies, backtest the same time period, calculate their correlations:

# Export daily returns for each strategy
# Use numpy or pandas to calculate correlations

import numpy as np

strategy1_returns = [...]  # Daily returns for strategy 1
strategy2_returns = [...]  # Daily returns for strategy 2

correlation = np.corrcoef(strategy1_returns, strategy2_returns)[0, 1]
print(f"Correlation: {correlation:.2f}")

# Judge
if correlation > 0.7:
    print("โš ๏ธ Highly correlated, not suitable for combination")
elif 0.2 < correlation < 0.7:
    print("โœ… Moderately correlated, can combine")
else:
    print("โญ Low or negative correlation, ideal combination")
Enter fullscreen mode Exit fullscreen mode

Task 3: Simulate Portfolio Backtest

Calculate expected performance of your strategy portfolio:

# Assume 3 strategies
strategies = {
    'MomentumTrend': {'return': 0.23, 'drawdown': 0.05, 'sharpe': 3.5, 'weight': 0.50},
    'MeanReversion': {'return': 0.15, 'drawdown': 0.03, 'sharpe': 2.8, 'weight': 0.30},
    'Breakout': {'return': 0.18, 'drawdown': 0.06, 'sharpe': 2.5, 'weight': 0.20}
}

# Calculate portfolio return (weighted average)
portfolio_return = sum(s['return'] * s['weight'] for s in strategies.values())
print(f"Portfolio Expected Return: {portfolio_return:.1%}")

# Calculate portfolio risk (simplified, assume correlation 0.3)
portfolio_risk = sum(s['drawdown'] * s['weight'] for s in strategies.values()) * 0.8
print(f"Portfolio Expected Drawdown: {portfolio_risk:.1%}")

# Estimate Sharpe
portfolio_sharpe = sum(s['sharpe'] * s['weight'] for s in strategies.values())
print(f"Portfolio Expected Sharpe: {portfolio_sharpe:.2f}")
Enter fullscreen mode Exit fullscreen mode

๐Ÿ“š Strategy Portfolio Best Practices

1. Golden Combination Templates

Trend + Mean Reversion (Most Classic)

60% Trend Strategy (good in bull/bear markets)
40% Mean Reversion Strategy (good in ranging markets)

Correlation: 0.2-0.4 (ideal)
Suitable for: All market conditions
Risk: Low-Medium
Recommendation: โญโญโญโญโญ
Enter fullscreen mode Exit fullscreen mode

Trend + Breakout + Mean Reversion (All-Purpose)

40% Trend Strategy
30% Breakout Strategy
30% Mean Reversion Strategy

Correlation: 0.3-0.5
Suitable for: All market conditions
Risk: Medium
Recommendation: โญโญโญโญ
Enter fullscreen mode Exit fullscreen mode

2. Strategy Number Recommendations

Account Capital Recommended Strategies Reason
< $5,000 1-2 Too little capital, diversification effect not obvious
$5,000-$20,000 2-3 Moderate diversification, easy to manage
$20,000-$50,000 3-5 Full diversification, controllable risk
> $50,000 5-10 Professional-level diversification, recommend portfolio management

3. Common Mistakes

Mistake 1: Over-Diversification

โŒ 10 strategies, each 10%
Result: Complex management, returns averaged out, lose advantages

โœ… 3-5 high-quality strategies, focus allocation
Enter fullscreen mode Exit fullscreen mode

Mistake 2: Similar Strategy Combination

โŒ 3 trend strategies combined
Result: High correlation (0.8+), no diversification effect

โœ… Trend + Mean Reversion + Breakout, different types combined
Enter fullscreen mode Exit fullscreen mode

Mistake 3: Ignoring Rebalancing

โŒ Set portfolio and never adjust
Result: Configuration drift, risk out of control

โœ… Regular rebalancing (monthly or quarterly)
Enter fullscreen mode Exit fullscreen mode

๐Ÿ“Œ Key Points Summary

  1. Strategy portfolios reduce risk: Drawdowns can be reduced by 50-70%
  2. Choose low-correlation strategies: Correlation < 0.5 is best
  3. Core-satellite configuration: 70% core + 30% satellite
  4. Regular rebalancing: Monthly or when deviation > 10%
  5. Moderate strategy numbers: 3-5 is most suitable
  6. Trend + Mean Reversion: Most classic combination

๐ŸŽ‰ Part Three Summary

Congratulations! You have completed Part Three: Strategy Optimization (Lessons 11-15)

You learned:

  • โœ… Lesson 11: Using Hyperopt to optimize strategy parameters
  • โœ… Lesson 12: Deep analysis of different strategy types
  • โœ… Lesson 13: Establishing scientific strategy scoring system
  • โœ… Lesson 14: Mastering risk and capital management methods
  • โœ… Lesson 15: Building multi-strategy investment portfolios

Next Part Preview:
Part Four: Real-time Signals and Paper Trading (Lessons 16-20)

In Part Four, you will learn:

  • Lesson 16: Real-time signal monitoring
  • Lesson 17: Telegram notification configuration
  • Lesson 18: Web UI and API usage
  • Lesson 19: Visualization analysis tools
  • Lesson 20: Paper trading verification

Preparation:

  • โœ… Complete strategy portfolio design
  • โœ… Prepare to enter paper trading stage
  • โœ… Ensure stable network environment

๐ŸŽฏ Learning Assessment Criteria:

  • โœ… Understand importance of strategy portfolios
  • โœ… Can analyze strategy correlations
  • โœ… Can build reasonable investment portfolios
  • โœ… Master rebalancing methods

After completing Part Three, you have acquired complete strategy optimization capabilities! Ready to enter the final stage before live tradingโ€”real-time signal monitoring and paper trading! ๐Ÿš€๐ŸŽŠ

Top comments (0)