← Back to Wiki

Portfolio Optimization

Systematic portfolio construction using factor analysis, stock selection methodologies, and rebalancing strategies applied to S&P 500 stocks.

Overview

Portfolio optimization combines quantitative factor analysis with systematic stock selection to build diversified portfolios. Our system implements 30 different strategies across multiple categories, each with distinct selection criteria and rebalancing frequencies.

Key Components:

  • Factor calculation for all S&P 500 stocks
  • 30 systematic portfolio construction strategies
  • Multiple rebalancing frequencies (weekly, monthly, quarterly)
  • Risk-adjusted performance metrics
  • Category-based strategy comparison

Factor Analysis

Factors are quantitative metrics that capture different aspects of stock behavior and performance.

Momentum Factors

Measure price trends over different timeframes (1M, 3M, 6M, 12M). Positive momentum indicates upward price movement.

Formula: (Current Price / Price N days ago) - 1

Volatility Factors

Measure price fluctuation using standard deviation of returns. Lower volatility indicates more stable price movement.

Formula: StdDev(Returns) × √252 (annualized)

Quality Factors

Sharpe ratio measures risk-adjusted returns. Higher values indicate better return per unit of risk taken.

Formula: (Mean Return / StdDev of Returns) × √252

Trend Factors

Price relative to moving averages (SMA50, SMA200). Values > 1 indicate price above average (uptrend).

Technical Indicators

RSI (Relative Strength Index) measures overbought/oversold conditions. RSI < 30 = oversold, RSI > 70 = overbought.

Strategy Categories

Momentum Strategies

Select stocks with strongest recent price performance. Based on the principle that trending stocks tend to continue their trend.

  • 1-Month Momentum Top 10: Fastest recent movers
  • 3-Month Momentum Top 15: Medium-term trend followers
  • 6-Month Momentum Top 20: Intermediate trend capture
  • 12-Month Momentum Top 10: Long-term winners

Low Volatility Strategies

Focus on stocks with stable price movements. Low volatility stocks often provide better risk-adjusted returns.

  • Low Volatility 20D: Shortest-term stability
  • Low Volatility 60D: Medium-term stability
  • Low Vol + High Momentum: Stable stocks with positive trends

Quality Strategies

Select stocks with superior risk-adjusted performance and resilience.

  • High Sharpe Ratio: Best risk-adjusted returns
  • Low Drawdown: Minimal peak-to-trough declines
  • Quality Composite: Combined quality metrics

Trend Following Strategies

Use moving averages to identify and follow established trends.

  • Above SMA50 + Momentum: Short-term uptrends
  • Above SMA200: Long-term uptrends
  • Golden Cross: SMA50 crosses above SMA200

Mean Reversion Strategies

Capitalize on temporary price dislocations and oversold conditions.

Multi-Factor Strategies

Combine multiple factors for more robust stock selection.

Risk Parity Strategies

Weight stocks inversely to their risk metrics for balanced risk exposure.

Rebalancing

Rebalancing is the process of periodically adjusting portfolio holdings to maintain target allocations or update stock selections based on current factor values.

Weekly Rebalancing

Most aggressive approach. Captures short-term opportunities but incurs higher transaction costs. Best for highly liquid, momentum-driven strategies.

Examples: Oversold RSI, Aggressive Momentum

Monthly Rebalancing

Balanced approach between capturing factor changes and managing costs. Most common frequency for momentum and trend strategies.

Examples: 1M/3M Momentum, Above SMA50, Volume strategies

Quarterly Rebalancing

Lower turnover approach. Suitable for quality, low volatility, and long-term strategies. Minimizes transaction costs.

Examples: 6M/12M Momentum, Quality, Low Vol, Defensive

Performance Metrics

Total Return

Percentage gain or loss over the backtest period. Measures absolute performance.

Sharpe Ratio

Risk-adjusted return metric. Higher is better. Values > 1 are good, > 2 are excellent.

Formula: (Portfolio Return - Risk-free Rate) / Portfolio Volatility

Volatility

Annualized standard deviation of returns. Measures portfolio risk. Lower is more stable.

Maximum Drawdown

Largest peak-to-trough decline. Measures worst-case loss scenario. Important for risk management.

Implementation Guide

1. Run Portfolio Optimizer

python engine/src/portfolio_optimizer.py

2. View Results

Navigate to /portfolios to see:

  • 30 strategy performance comparisons
  • Risk-return scatter plots
  • Category-based analysis
  • Individual equity curves
  • Stock factor analysis

3. Customize Strategies

Edit portfolio_optimizer.py to:

  • Add new factor calculations
  • Create custom selection rules
  • Modify rebalancing frequencies
  • Adjust portfolio sizes

Best Practices

Related Topics