Skip to content

HR-Freak/Crypto-Portfolio-Simulation-Optimization

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

38 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸ“Š Crypto Portfolio Simulation & Optimisation

πŸš€ Project Overview

This project analyses historical cryptocurrency market data to explore return, volatility, drawdowns, diversification, correlation with traditional markets, and portfolio optimisation strategies.

The goal is to understand how crypto assets behave individually and in combination, and to evaluate whether diversification improves risk-adjusted performance.

This is not just an analysis, it is a full data product, combining:

  • πŸ“ˆ Exploratory Data Analysis
  • βš™οΈ Financial metric engineering
  • 🎲 Monte Carlo portfolio simulation
  • πŸ—„οΈ SQL database layer
  • πŸ“Š Tableau dashboards
  • 🌐 Streamlit interactive application

πŸ’Ό Business Context & Motivation

Cryptocurrency markets are extremely volatile, unpredictable, and driven by rapid regime changes.

While they offer high return potential, they also expose investors to:

  • sharp drawdowns
  • unstable short-term movements
  • shifting correlations

Traditional diversification principles don’t always hold in crypto markets.

This project explores whether data-driven portfolio construction can improve investment outcomes by balancing:

  • return πŸ“ˆ
  • risk ⚠️
  • diversification πŸ”€

🎯 Project Objectives

  • Identify top-performing cryptocurrencies
  • Evaluate risk-adjusted performance
  • Measure volatility and drawdowns
  • Analyse time-based trends (short vs long term)
  • Evaluate diversification benefits
  • Compare crypto with S&P 500
  • Optimise portfolios (Max Sharpe / Min Volatility)
  • Compare strategies vs BTC and Equal Weight

πŸ“¦ Dataset

Data collected via Yahoo Finance API (yfinance)

πŸͺ™ Assets

  • BTC (Bitcoin)
  • ETH (Ethereum)
  • BNB (Binance Coin)
  • SOL (Solana)
  • ADA (Cardano)
  • XRP
  • DOT (Polkadot)
  • DOGE (Dogecoin)
  • LTC (Litecoin)

πŸ“Š Benchmark

  • S&P 500

⏱ Frequency

  • Daily data

βš™οΈ Analytical Pipeline

1️⃣ Data Collection

  • Python + yfinance API

2️⃣ Data Cleaning

  • Missing values handling
  • Time alignment
  • Data consistency

3️⃣ Feature Engineering

  • Daily & cumulative returns
  • Annual return & volatility
  • Rolling returns (30D / 90D)
  • Rolling volatility
  • Maximum drawdown
  • Correlation (static & dynamic)
  • Best & worst months/years

4️⃣ Portfolio Simulation 🎲

Monte Carlo simulation generates thousands of portfolios:

  • Expected return
  • Volatility
  • Sharpe ratio

Outputs:

  • Max Sharpe portfolio
  • Min Volatility portfolio
  • Efficient frontier

5️⃣ SQL Database πŸ—„οΈ

  • Database creation
  • Table structure
  • CSV ingestion
  • Validation queries

6️⃣ Tableau Dashboard πŸ“Š

  • Market overview
  • Risk analysis
  • Time-based trends
  • Correlation analysis
  • Portfolio insights

7️⃣ Streamlit Application 🌐

Interactive app where users can:

  • Select assets
  • Build portfolios
  • Input exact weights
  • Auto-adjust to 100%
  • Compare strategies
  • Explore Monte Carlo simulation
  • Visualise performance

πŸ“ Key Metrics

Asset-Level

  • Annual return
  • Volatility
  • Sharpe ratio
  • Maximum drawdown
  • Rolling metrics
  • Correlation

Portfolio-Level

  • Expected return
  • Portfolio volatility
  • Sharpe ratio
  • Drawdown
  • Growth over time
  • Optimal weights

πŸ” Key Findings

πŸ“ˆ Performance

  • BNB & SOL β†’ strongest risk-adjusted returns
  • DOGE β†’ high returns but extreme volatility
  • BTC β†’ more stable but lower upside

⚠️ Risk

  • All assets show extreme drawdowns
  • Risk is not just volatility; downside is significant

⏳ Time Behaviour

  • Short-term = unstable and spike-driven
  • Long-term = clearer performance trends

πŸ”— Correlation

  • Low/moderate with S&P 500
  • Increases during crises β†’ diversification weakens

🧠 Portfolio Optimisation

  • Max Sharpe = best risk-return balance
  • Min Vol = safer but lower returns
  • Diversification improves stability

🧠 Key Takeaways

  • High returns = high risk
  • Not all crypto is equal
  • Diversification helps, but fails under stress
  • Portfolio construction matters
  • Everything is a trade-off βš–οΈ

πŸ”„ From Analysis to Application

This project goes beyond static analysis.

It becomes a decision-support tool where users can:

  • test strategies
  • simulate portfolios
  • explore outcomes interactively

🌐 Project Outputs

πŸ”— Streamlit App

πŸ‘‰ https://streamlit-link

πŸ”— Tableau Dashboard

πŸ‘‰ https://tableau-link

πŸ”— Presentation Deck

πŸ‘‰https://presentation-link


πŸ—‚ Project Structure

Crypto-Portfolio-Simulation-Optimization/
β”‚
β”œβ”€β”€ data/
β”‚   β”œβ”€β”€ raw/
β”‚   β”‚   └── crypto_prices_raw.csv
β”‚   └── processed/
β”‚       β”œβ”€β”€ annual_returns_by_coin.csv
β”‚       β”œβ”€β”€ best_worst_months.csv
β”‚       β”œβ”€β”€ best_worst_years.csv
β”‚       β”œβ”€β”€ correlation_with_sp500.csv
β”‚       β”œβ”€β”€ crypto_prices_processed.csv
β”‚       β”œβ”€β”€ crypto_prices_processed_time_enriched.csv
β”‚       β”œβ”€β”€ crypto_sp500_merged.csv
β”‚       β”œβ”€β”€ crypto_summary_metrics.csv
β”‚       β”œβ”€β”€ max_sharpe_portfolio.csv
β”‚       β”œβ”€β”€ min_volatility_portfolio.csv
β”‚       β”œβ”€β”€ monthly_returns_by_coin.csv
β”‚       └── portfolio_simulations.csv
β”‚
β”œβ”€β”€ notebooks/
β”‚   β”œβ”€β”€ 01_data_collection.ipynb
β”‚   β”œβ”€β”€ 02_data_cleaning_and_returns.ipynb
β”‚   β”œβ”€β”€ 03_risk_metrics.ipynb
β”‚   β”œβ”€β”€ 04_portfolio_simulation.ipynb
β”‚   └── 05_time_based_analysis.ipynb
β”‚
β”œβ”€β”€ sql/
β”‚   β”œβ”€β”€ 01_create_database.sql
β”‚   β”œβ”€β”€ 02_create_tables.sql
β”‚   β”œβ”€β”€ 03_load_data.sql
β”‚   └── 04_validation_queries.sql
β”‚
β”œβ”€β”€ streamlit_app/
β”‚   β”œβ”€β”€ app.py
β”‚   β”œβ”€β”€ charts.py
β”‚   β”œβ”€β”€ data_loader.py
β”‚   └── utils.py
β”‚
β”œβ”€β”€ tableau/
β”‚   └── Crypto Portfolio Simulation.twbx
β”‚
β”œβ”€β”€ reports/
β”‚   └── figures/
β”‚
β”œβ”€β”€ README.md
└── requirements.txt

πŸ›  Tools & Technologies

  • Python 🐍
  • pandas
  • NumPy
  • yfinance
  • MySQL
  • Tableau
  • Streamlit
  • Plotly

πŸ“¬ Contact

πŸ‘©β€πŸ’» Marisa Oliveira

πŸ“§ marisaisabel27@hotmail.com
πŸ”— https://www.linkedin.com/in/marisa-oliveira-business-data-analyst


⚠️ Disclaimer

Cryptocurrency markets are highly volatile and unpredictable.

This project is for educational purposes only and does not constitute financial advice.

About

This project analyses historical cryptocurrency data to evaluate risk, return, and diversification across major assets. Using statistical analysis and portfolio simulation techniques, the project aims to identify optimal crypto portfolio allocations based on risk-adjusted performance, create an interactive dashboard that helps investors.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors