Skip to main content
github-cover

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

Unravel Finance

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

VS Code launch configurations

The repository now includes:

  • Pytest: all tests
  • one Endpoint: ... launch entry for each exported client endpoint

Each endpoint launch uses sensible defaults based on the existing test suite and reads UNRAVEL_API_KEY from .env. If you want to tweak a call without editing code, pass JSON overrides when prompted, for example:

{"as_of":"latest"}

or

{"start_date":"2024-01-01","end_date":"2024-01-07"}

Test Categories

  • Portfolio Functions: Tests portfolio-related API calls using momentum_enhanced.40 portfolio
  • 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.

Metadata

Release files for unravel-client 3.0.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for unravel-client 3.0.2
File Size Uploaded Provenance Actions
unravel_client-3.0.2.tar.gz 11.9 kB Without provenance Details for unravel_client-3.0.2.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for unravel-client 3.0.2
File Interpreter ABI Platform Actions
unravel_client-3.0.2-py3-none-any.whl Python 3 none any Details for unravel_client-3.0.2-py3-none-any.whl

Total release size: 25.5 kB

Release files / unravel_client-3.0.2.tar.gz

Download URL unravel_client-3.0.2.tar.gz
Size 11.9 kB
Tags Source
SHA-256 checksum
How to use checksums
53a1717611ff806501a7bec85b6346c6c1fe5e3307e974336973f7a449e3ec6b
BLAKE2b-256 checksum
How to use checksums
9d08f5b2e541244b3440e8c1308f468eb514cdc411a56113ca6c25ab56a3bfdf
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via Hatch/1.16.5 cpython/3.12.13 HTTPX/0.28.1

Release files / unravel_client-3.0.2-py3-none-any.whl

Download URL unravel_client-3.0.2-py3-none-any.whl
Size 13.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
370c7cea148a5bde5b2bad806e535f79e0c11c3c3d6bdd4503f1bd462a8b3da1
BLAKE2b-256 checksum
How to use checksums
084bf50bd633951e003cb6b3640a82f6e25147cbda3fe3e0dbbf4db02449a8b9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via Hatch/1.16.5 cpython/3.12.13 HTTPX/0.28.1

Security for unravel-client 3.0.2

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page