Skip to main content

Client for the Aperiodic Factors API (factors.aperiodic.io): cross-sectional crypto factors, portfolios and risk signals

Project description

Aperiodic Factors Client

A Python client library for the Aperiodic Factors API, providing convenient wrappers for cross-sectional crypto factor data, portfolio weights/returns and risk signals.

Installation

pip install aperiodic-factors

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 aperiodic_factors

# Set your API key
api_key = "your-api-key-here"

# Get historical portfolio weights
historical_weights = aperiodic_factors.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 = aperiodic_factors.get_live_weights(
    id="your-portfolio-id",
    api_key=api_key,
)

# Get portfolio returns
returns = aperiodic_factors.get_portfolio_returns(
    id="your-portfolio-id",
    api_key=api_key,
    start_date="2024-01-01",
)

# Get portfolio tickers
tickers = aperiodic_factors.get_tickers(
    id="momentum",  # Portfolio factor identifier without universe specifier
    api_key=api_key,
    universe_size="full",
)

# Get historical factors
factors = aperiodic_factors.get_portfolio_factors_historical(
    id="momentum",
    tickers=["BTC", "ETH"],
    api_key=api_key,
)

# Get live factors (latest factor data)
live_factors = aperiodic_factors.get_portfolio_factors_live(
    id="momentum",
    tickers=["BTC", "ETH"],
    api_key=api_key,
)

# Get historical universe
universe = aperiodic_factors.get_historical_universe(
    size="full",
    start_date="2024-01-01",
    end_date="2024-12-31",
    api_key=api_key,
)

Configuration

Variable Required Default Description
APERIODIC_API_KEY yes Your Aperiodic Factors API key
APERIODIC_BASE_URL no https://factors.aperiodic.io Override the API base URL
CF_ACCESS_CLIENT_ID no Cloudflare Access service-token id (protected environments)
CF_ACCESS_CLIENT_SECRET no Cloudflare Access service-token secret

Requirements

  • Python 3.9+
  • pandas >= 2.0.0
  • numpy >= 1.3.0
  • requests >= 2.25.0

Testing

The test suite exercises the live API, so it needs a valid API key. Tests that require it are skipped automatically when APERIODIC_API_KEY is not set.

# Install with test dependencies
pip install -e ".[tests]"

# Run all tests
export APERIODIC_API_KEY="your_api_key_here"
pytest tests/ -v

License

MIT License

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

aperiodic_factors-0.1.1.tar.gz (11.4 kB view details)

Uploaded Source

Built Distribution

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

aperiodic_factors-0.1.1-py3-none-any.whl (13.2 kB view details)

Uploaded Python 3

File details

Details for the file aperiodic_factors-0.1.1.tar.gz.

File metadata

  • Download URL: aperiodic_factors-0.1.1.tar.gz
  • Upload date:
  • Size: 11.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: Hatch/1.17.1 {"ci":true,"cpu":"x86_64","distro":{"id":"noble","libc":{"lib":"glibc","version":"2.39"},"name":"Ubuntu","version":"24.04"},"implementation":{"name":"CPython","version":"3.12.13"},"installer":{"name":"hatch","version":"1.17.1"},"openssl_version":"OpenSSL 3.0.13 30 Jan 2024","python":"3.12.13","system":{"name":"Linux","release":"6.17.0-1018-azure"}} HTTPX2/2.7.0

File hashes

Hashes for aperiodic_factors-0.1.1.tar.gz
Algorithm Hash digest
SHA256 7e331ebaf340c811da9a0fd1a2c40e89155304f46f046eeb8035120e3fb27584
MD5 d6daa85123e1baf832bc1438904ab736
BLAKE2b-256 f740d8a6fcdd09b5d39ad6b272bd7305788e1bdcb1691b1ab73113611143f766

See more details on using hashes here.

File details

Details for the file aperiodic_factors-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: aperiodic_factors-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 13.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: Hatch/1.17.1 {"ci":true,"cpu":"x86_64","distro":{"id":"noble","libc":{"lib":"glibc","version":"2.39"},"name":"Ubuntu","version":"24.04"},"implementation":{"name":"CPython","version":"3.12.13"},"installer":{"name":"hatch","version":"1.17.1"},"openssl_version":"OpenSSL 3.0.13 30 Jan 2024","python":"3.12.13","system":{"name":"Linux","release":"6.17.0-1018-azure"}} HTTPX2/2.7.0

File hashes

Hashes for aperiodic_factors-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 104ad65787176e58079b9c8899aeabc70dd1601a3edd7ade1cfc0d79afd236ff
MD5 6fb915b0fc7a3088d8126b61ec53ca26
BLAKE2b-256 8ebb8a65065d666f6508cd58aa8dc6cd3245091cb343bfcb8ed74dc62479feac

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