Skip to main content

Client API for unravel.finance, multi-factor, market-neutral crypto portfolios and cross-sectional factors

Project description

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

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

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.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

unravel_client-2.1.0.tar.gz (9.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

unravel_client-2.1.0-py3-none-any.whl (13.6 kB view details)

Uploaded Python 3

File details

Details for the file unravel_client-2.1.0.tar.gz.

File metadata

  • Download URL: unravel_client-2.1.0.tar.gz
  • Upload date:
  • Size: 9.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: Hatch/1.16.1 cpython/3.11.14 HTTPX/0.28.1

File hashes

Hashes for unravel_client-2.1.0.tar.gz
Algorithm Hash digest
SHA256 b90a0e9ea3bc41928f739df632a7600e8800c1ab3ef1cf4ce5b817b1fac4b49c
MD5 95ce84aa0a90a8141803d4692d4f7ac0
BLAKE2b-256 2a7820680b66db3010f05ab552eb61ece74d617e04cd2ff7feee84846091fd29

See more details on using hashes here.

File details

Details for the file unravel_client-2.1.0-py3-none-any.whl.

File metadata

  • Download URL: unravel_client-2.1.0-py3-none-any.whl
  • Upload date:
  • Size: 13.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: Hatch/1.16.1 cpython/3.11.14 HTTPX/0.28.1

File hashes

Hashes for unravel_client-2.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 b3ea4186373f8316febd100cc981e288c01ab930df551a440778111db74aef19
MD5 62c9dc28fcb07347cc7478274804521d
BLAKE2b-256 46cfbff38c28194d41546c83e8c7153d2b8ac0ac01585f59df46ba854c94c88e

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page