Simple Python snippets to get started with the Unravel API for portfolio backtesting and live weight retrieval.
This repository provides transparent, easy-to-understand code examples for:
- Getting Started: Quick setup and basic usage of the Unravel API
- Backtest Validation: Transparent backtesting code to validate portfolio performance
- Live Weights: Simple access to current portfolio allocations
- Transparent backtesting implementation with transaction costs
- Historical portfolio weights retrieval
- Performance visualization
- Real-time portfolio weight access
- Historical weight analysis
- Multi-portfolio support (beta.5, momentum_enhanced, etc.)
- Basic factor analysis using AlphaLens
- Portfolio factor historical data
# Clone the repository
git clone https://github.com/unravel-finance/api-guide.git
cd api-guide
# Install dependencies
pip install -r requirements.txt
# Set up environment variables
export UNRAVEL_API_KEY="your_api_key_here"
pandas
: Data manipulationmatplotlib
: Visualizationrequests
: API callsalphalens-reloaded
: Factor analysisfinml-utils
: Utilities
Run the complete portfolio backtesting example:
replicate_portfolio_backtest.ipynb
This notebook demonstrates:
- Fetching historical portfolio weights
- Getting underlying asset prices
- Running backtests with transaction costs
- Plotting performance results
Get current portfolio allocations:
get_live_weights.ipynb
Analyze portfolio factors:
factor_analysis_altair.ipynb
factor_analysis_carry_enhanced.ipynb
factor_analysis_retail_flow.ipynb
These snippets are licensed under the MIT License - see the LICENSE file for details.