Client API for unravel.finance, multi-factor, market-neutral crypto portfolios and cross-sectional factors
Project description
Unravel Client
A Python client library for accessing the Unravel Finance API, providing convenient wrappers for multi-factor, market-neutral crypto portfolio data and risk signals.
Installation
pip install unravel-client
Features
- Portfolio Data: Access historical and live portfolio weights
- Cross-section Factors: Access cross-sectional factors as raw data
- Risk Signals: Retrieve normalized risk factor series for cryptocurrencies
- Easy Integration: Simple API calls with pandas DataFrame/Series returns
Quick Start
import unravel_client
# Set your API key
api_key = "your-api-key-here"
# Get historical portfolio weights
historical_weights = unravel_client.get_portfolio_historical_weights(
id="your-portfolio-id",
api_key=api_key,
start_date="2024-01-01",
end_date="2024-12-31"
)
# Get current portfolio weights
live_weights = unravel_client.get_live_weights(
id="your-portfolio-id",
api_key=api_key
)
# Get normalized risk signals
risk_signal = unravel_client.get_normalized_series(
ticker="BTC",
series="meta_risk",
api_key=api_key,
start_date="2024-01-01"
)
# Get portfolio returns
returns = unravel_client.get_portfolio_returns(
id="your-portfolio-id",
api_key=api_key,
start_date="2024-01-01"
)
# Get portfolio tickers
tickers = unravel_client.get_tickers(
id="momentum", # Portfolio factor identifier without universe specifier
api_key=api_key,
universe_size="full"
)
# Get historical factors
factors = unravel_client.get_portfolio_factors_historical(
id="momentum", # Portfolio factor identifier without universe specifier
tickers=["BTC", "ETH"],
api_key=api_key
)
# Get live factors (latest factor data)
live_factors = unravel_client.get_portfolio_factors_live(
id="momentum",
tickers=["BTC", "ETH"],
api_key=api_key
)
# Get price data (deprecated endpoint)
price = unravel_client.get_price(
ticker="BTC",
api_key=api_key,
start_date="2024-01-01"
)
# Get historical universe
universe = unravel_client.get_historical_universe(
size="full",
start_date="2024-01-01",
end_date="2024-12-31",
api_key=api_key
)
Requirements
- Python 3.11+
- pandas >= 2.0.0
- numpy >= 1.3.0
- requests >= 2.25.0
- tqdm >= 4.66.4
License
MIT License
Authors
Testing
The test suite uses real API endpoints to ensure the library works correctly with the actual Unravel API.
Setting up Environment Variables
You need to set up environment variables for testing:
# Required: Your Unravel API key
export UNRAVEL_API_KEY="your_api_key_here"
Running Tests
# Install with test dependencies
pip install -e ".[tests]"
# Run all tests
pytest tests/ -v
# Run specific test categories
pytest tests/test_unravel_client.py::TestRiskSignalFunctions -v
pytest tests/test_unravel_client.py::TestErrorHandling -v
Test Categories
- Portfolio Functions: Tests portfolio-related API calls using
momentum_enhanced.40portfolio - Cross-Sectional Factors: Tests factor API calls
- Error Handling: Tests error handling for invalid requests
- Data Types: Tests data type conversion and validation
CI/CD
The GitHub Actions workflow automatically runs tests using secrets:
UNRAVEL_API_KEY: Your API key
Support
For issues and questions, please visit our GitHub repository.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file unravel_client-2.0.5.tar.gz.
File metadata
- Download URL: unravel_client-2.0.5.tar.gz
- Upload date:
- Size: 8.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: python-httpx/0.28.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
eca1f7c2d4647eae593d940fb615b6b96808e60b7f7bf931f742a80b2defaecf
|
|
| MD5 |
53e8b507cf9cb5d791808788ac71cae7
|
|
| BLAKE2b-256 |
d271032bde3cc36b3bb448a52b12c5137a7c9497ace7638e6f067aa9dec1178c
|
File details
Details for the file unravel_client-2.0.5-py3-none-any.whl.
File metadata
- Download URL: unravel_client-2.0.5-py3-none-any.whl
- Upload date:
- Size: 12.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: python-httpx/0.28.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3b76f1a59eaa2cb6f5f05f7d00e97d3e1a33c347a5519be2fda8e261014d3389
|
|
| MD5 |
e9669b5c03f27e3ffc86a48b374e23fa
|
|
| BLAKE2b-256 |
819270d54a613d23da33bf0a3e3d2c99cf33f0123ce492b9f261a5584e9e7beb
|