Complete installation and setup instructions for the Regime-Based Multi-Asset Allocation Strategy.
- Operating System: Windows 10+, macOS 10.14+, or Linux (Ubuntu 18.04+)
- Python: 3.8 or higher
- RAM: 4 GB minimum
- Storage: 500 MB free space
- Internet: Required for data download
- Python: 3.9 or 3.10
- RAM: 8 GB or more
- Storage: 1 GB free space
git clone https://github.com/I-am-Uchenna/regime-allocation-strategy.git
cd regime-allocation-strategy# Create virtual environment
python -m venv venv
# Activate (choose based on your OS)
# Windows:
venv\Scripts\activate
# macOS/Linux:
source venv/bin/activatepip install --upgrade pip
pip install -r requirements.txtpython regime_allocation_strategy.pyIf you use Anaconda or Miniconda:
# Create conda environment
conda create -n regime-strategy python=3.9
# Activate environment
conda activate regime-strategy
# Install dependencies
pip install -r requirements.txt
# Run strategy
python regime_allocation_strategy.pyFor cloud-based execution:
- Upload
regime_allocation_strategy.pyto Google Drive - Open Google Colab: https://colab.research.google.com
- Create new notebook
- Run:
!pip install yfinance hmmlearn
# Upload your script or copy-paste the code
%run regime_allocation_strategy.pypython --version
# Should show: Python 3.8.x or higherpython -c "import numpy; print(f'NumPy: {numpy.__version__}')"
python -c "import pandas; print(f'Pandas: {pandas.__version__}')"
python -c "import yfinance; print(f'yfinance: {yfinance.__version__}')"
python -c "import hmmlearn; print(f'hmmlearn: {hmmlearn.__version__}')"Expected output (versions may vary):
NumPy: 1.24.x
Pandas: 2.0.x
yfinance: 0.2.x
hmmlearn: 0.3.x
Create a test script test_install.py:
import numpy as np
import pandas as pd
import yfinance as yf
from hmmlearn import hmm
print("✓ All core dependencies imported successfully!")
# Quick data test
try:
data = yf.download('SPY', start='2024-01-01', end='2024-01-31', progress=False)
print(f"✓ Data download working! Retrieved {len(data)} rows")
except Exception as e:
print(f"✗ Data download failed: {e}")Run: python test_install.py
Solution:
python -m ensurepip --upgrade
python -m pip install --upgrade pipSolution:
# Use --user flag
pip install --user -r requirements.txtSolution:
# Install build tools first
# Windows:
# Download Visual Studio Build Tools
# macOS:
xcode-select --install
# Linux:
sudo apt-get install python3-dev
# Then retry:
pip install hmmlearnSolution:
# Update yfinance
pip install --upgrade yfinance
# If still failing, try alternative:
pip install yfinance==0.2.28Solution:
# Install backend
pip install PyQt5
# Or use non-interactive backend
# Add to top of script:
import matplotlib
matplotlib.use('Agg')Solution:
- Reduce data period in script
- Close other applications
- Use 64-bit Python
- Upgrade RAM if possible
Error: Microsoft Visual C++ 14.0 is required
Solution: Download and install Microsoft C++ Build Tools
Error: SSL: CERTIFICATE_VERIFY_FAILED
Solution:
# Run Python's certificate installer
/Applications/Python\ 3.x/Install\ Certificates.commandError: ImportError: libGL.so.1
Solution:
sudo apt-get install python3-tk
sudo apt-get install libgl1-mesa-glxFor advanced users who want to customize paths:
# Create .env file
echo "DATA_PATH=./data" >> .env
echo "OUTPUT_PATH=./output" >> .env
echo "CACHE_PATH=./cache" >> .env- Use faster data source (if available):
# Cache downloaded data
import pandas as pd
data.to_pickle('cached_data.pkl')
# Later: data = pd.read_pickle('cached_data.pkl')- Reduce HMM iterations for testing:
# In script, change:
hmm_model = hmm.GaussianHMM(n_components=2, n_iter=100) # Instead of 1000- Multi-core processing (future enhancement):
# Install joblib
pip install joblibTo update to the latest version:
# Pull latest changes
git pull origin main
# Update dependencies
pip install --upgrade -r requirements.txt# Deactivate virtual environment
deactivate
# Remove virtual environment
rm -rf venv # Linux/macOS
# or
rmdir /s venv # Windows
# Remove repository
cd ..
rm -rf regime-allocation-strategyAfter successful installation:
- Run the strategy:
python regime_allocation_strategy.py - Check output folder: Review generated PNG files
- Read the code: Understand the implementation
- Modify parameters: Experiment with different settings
- Contribute: See CONTRIBUTING.md
If you encounter issues not covered here:
- Check existing issues
- Create a new issue with:
- Your OS and Python version
- Complete error message
- Steps you've tried
- Include output from verification steps
Last Updated: January 2025
Tested On: Windows 11, macOS 14, Ubuntu 22.04