Skip to content

unravel-finance/api-guide

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Unravel API Snippets

Simple Python snippets to get started with the Unravel API for portfolio backtesting and live weight retrieval.

Purpose

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

What's Included

📊 Portfolio Backtesting

  • Transparent backtesting implementation with transaction costs
  • Historical portfolio weights retrieval
  • Performance visualization

⚡ Live Portfolio Data

  • Real-time portfolio weight access
  • Historical weight analysis
  • Multi-portfolio support (beta.5, momentum_enhanced, etc.)

🔍 Factor Analysis

  • Basic factor analysis using AlphaLens
  • Portfolio factor historical data

Installation

# 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"

Dependencies

  • pandas: Data manipulation
  • matplotlib: Visualization
  • requests: API calls
  • alphalens-reloaded: Factor analysis
  • finml-utils: Utilities

Quick Start

1. Portfolio Backtesting

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

2. Live Portfolio Weights

Get current portfolio allocations:

get_live_weights.ipynb

3. Factor Analysis

Analyze portfolio factors:

factor_analysis_altair.ipynb
factor_analysis_carry_enhanced.ipynb
factor_analysis_retail_flow.ipynb

License

These snippets are licensed under the MIT License - see the LICENSE file for details.

Releases

No releases published

Packages

No packages published

Contributors 2

  •  
  •