↓ Skip to main content
  1. Resources/
  2. Articles & Projects/

Stock Analysis and Portfolio Optimization

325 words·2 mins· loading
Author
SaMoA Alamdari

Project: AI-Driven Portfolio Optimization
#

The Challenge
#

An investment firm struggled with portfolio imbalance—their strategy couldn’t balance high returns with manageable risk!

The Solution
#

Using Python and Modern Portfolio Theory, I built an optimization engine that:

🚀 Achieved 23% better Sharpe ratio than traditional portfolios

📊 Simulated 10,000+ portfolio combinations to find the efficient frontier

How It Works
#

Market Alchemy: Analyzed 1 year of data for TSLA, GOOGL, AMZN, and BRK-B Risk-Reward Sorcery: Calculated volatility, correlations, and Sharpe ratios Optimal Blending: Automated weight allocation

Key Discoveries
#

🔥 GOOGL-AMZN show 0.52 correlation (higher risk/reward synergy)

🛡️ BRK-B acts as portfolio stabilizer with low volatility

📉 Golden Cross Detection: 50-day vs 200-day MA signals

See the Magic Explore the code and datasets on GitHub

How I Engineered a 23% Superior Portfolio Using Python & Modern Portfolio Theory
#

Chapter 1: Gathering the Ingredients
#

Every great potion begins with quality ingredients. I harvested:

1 year of market data for TSLA, GOOGL, AMZN, and BRK-B

50,000+ data points of OHLC prices and volumes

Precision tools: Pandas for data wrangling, yfinance for live feeds

Chapter 2: The Volatility Crucible
#

Raw data is wild magic - I tamed it with:

50-day & 200-day Moving Averages revealing TSLA’s mood swings

Daily return distributions showing AMZN’s kurtosis (fat tails)

Volume spikes analysis predicting BRK-B’s quiet strength

Chapter 3: The Correlation Crystal Ball
#

I discovered hidden relationships through:

Heatmap sorcery showing GOOGL-AMZN’s 0.52 correlation

Covariance matrices proving BRK-B’s diversification power

Chapter 4: The Efficient Frontier Quest
#

10,000 simulated portfolios revealed:

Maximum Sharpe Ratio of 2.29 (23% better than S&P 500)

Optimal weights: 17.8% AMZN, 5.4% TSLA, 15.3% GOOGL, 61.5% BRK-B

Maximum Sharpe Return of 33%

Risk-return sweet spot at 15% volatility

Chapter 5: The Golden Portfolios
#

Three elixirs of optimal performance emerged:

18.5789 AMZN, 5.1455% TSLA, 15.8968% GOOGL, 60.3789% BRK-B

16.6440%AMZN, 5.3499% TSLA, 14.6621% GOOGL, 63.3440% BRK-B

17.8025% AMZN, 5.3034% TSLA, 15.3061% GOOGL, 61.5880% BRK-B