Skip to main content

Systematic research framework for tactical credit strategies

Project description

Aponyx

PyPI version Python 3.13+ License: MIT

A modular Python framework for developing and backtesting systematic credit strategies.

⚠️ Bloomberg Terminal Required: Data loading via BloombergSource requires an active Bloomberg Terminal session. File-based alternatives (FileSource) are also supported.

Quick Start

Installation from PyPI

pip install aponyx

# Optional: visualization dependencies
pip install aponyx[viz]

Installation from Source

Requires Python 3.13+ and uv for environment management.

# Clone repository
git clone https://github.com/stabilefrisur/aponyx.git
cd aponyx

# Create virtual environment with uv
uv venv
source .venv/Scripts/activate  # Windows: .venv\Scripts\activate

# Install dependencies
uv sync

# Install visualization dependencies (optional)
uv sync --extra viz

# Run examples
uv run python examples/backtest_demo.py

Basic Usage

from aponyx.data import fetch_cdx, fetch_etf, FileSource, BloombergSource
from aponyx.models import compute_cdx_etf_basis, SignalConfig
from aponyx.backtest import run_backtest, BacktestConfig

# Load market data with validation (file-based)
cdx_df = fetch_cdx(FileSource("data/raw/cdx_data.parquet"), index_name="CDX_IG_5Y")
etf_df = fetch_etf(FileSource("data/raw/etf_data.parquet"), ticker="HYG")

# Or use Bloomberg Terminal (requires active session and xbbg package)
# source = BloombergSource()
# cdx_df = fetch_cdx(source, index_name="CDX_IG", tenor="5Y")
# etf_df = fetch_etf(source, ticker="HYG")

# Generate signal
signal_config = SignalConfig(lookback=20, min_periods=10)
signal = compute_cdx_etf_basis(cdx_df, etf_df, signal_config)

# Run backtest
backtest_config = BacktestConfig(entry_threshold=1.5, exit_threshold=0.75)
results = run_backtest(signal, cdx_df["spread"], backtest_config)
print(f"Sharpe Ratio: {results.metrics['sharpe_ratio']:.2f}")

Project Structure

aponyx/
├── src/aponyx/       # Core framework
│   ├── data/              # Data loading, validation, transformation
│   ├── models/            # Signal generation for credit strategies
│   ├── backtest/          # Backtesting engine and metrics
│   ├── visualization/     # Plotly charts and Streamlit dashboard
│   ├── persistence/       # Parquet/JSON I/O and registry
│   └── config/            # Configuration and constants
├── examples/              # Runnable demonstrations
├── tests/                 # Unit tests
└── docs/                  # Architecture and design docs

Key Layers

Layer Purpose Entry Point
Data Load, validate, transform market data aponyx.data
Models Generate signals for independent evaluation aponyx.models
Backtest Simulate execution and compute metrics aponyx.backtest
Visualization Interactive charts and dashboards aponyx.visualization
Persistence Save/load data with metadata registry aponyx.persistence

Documentation

Getting Started

Strategy & Architecture

Design Guides

Features

Type-safe data loading with schema validation
Modular signal framework with composable transformations
Deterministic backtesting with transaction cost modeling
Interactive visualization with Plotly charts (equity, signals, drawdown)
Parquet-based persistence with JSON metadata registry
Comprehensive logging with run metadata tracking
Bloomberg Terminal integration via xbbg wrapper (included by default, requires active Terminal session)

Planned Features:

  • 🔜 Streamlit dashboard (stub exists, not yet implemented)
  • 🔜 Advanced attribution charts (stubs with NotImplementedError)

Development

Running Tests

# All tests
uv run pytest

# With coverage
uv run pytest --cov=aponyx --cov-report=term-missing

# Specific module
uv run pytest tests/models/

Code Quality

# Format code
uv run black src/ tests/

# Lint
uv run ruff check src/ tests/

# Type check
uv run mypy src/

Examples

Each example demonstrates a specific layer with synthetic data:

uv run python examples/data_demo.py          # Data loading and transformation
uv run python examples/models_demo.py        # Signal generation
uv run python examples/backtest_demo.py      # Complete backtest workflow
uv run python examples/visualization_demo.py # Interactive charts (requires viz extra)
uv run python examples/persistence_demo.py   # Data I/O and registry

Design Principles

  1. Modularity - Separate data, models, backtest, and persistence layers
  2. Reproducibility - Deterministic outputs with seed control and metadata logging
  3. Type safety - Strict type hints and runtime validation
  4. Simplicity - Prefer functions over classes, explicit over implicit
  5. Transparency - Clear separation between strategy logic and infrastructure

Architecture Notes

Signal Convention

All model signals follow a consistent sign convention:

  • Positive values → Long credit risk (buy CDX / sell protection)
  • Negative values → Short credit risk (sell CDX / buy protection)

This convention ensures clear interpretation when evaluating signals individually or when combining signals in future experiments.

Data Flow

Raw Data (Parquet/CSV)
    ↓
Data Layer (load, validate, transform)
    ↓
Models Layer (signal computation)
    ↓
Backtest Layer (simulation, metrics)
    ↓
Persistence Layer (save results, metadata)

License

MIT License - see LICENSE for details.

Contributing

This is a research project under active development. See Python Guidelines for code standards.


Maintained by stabilefrisur
Version 0.1.0 | Last Updated: October 31, 2025

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

aponyx-0.1.0.tar.gz (36.4 kB view details)

Uploaded Source

Built Distribution

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

aponyx-0.1.0-py3-none-any.whl (51.7 kB view details)

Uploaded Python 3

File details

Details for the file aponyx-0.1.0.tar.gz.

File metadata

  • Download URL: aponyx-0.1.0.tar.gz
  • Upload date:
  • Size: 36.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.5

File hashes

Hashes for aponyx-0.1.0.tar.gz
Algorithm Hash digest
SHA256 ef564b8c2a7fea7d2e4add36e9197c0d5e413563f7931159ff30ca14511deacb
MD5 8d0af6b7da2b62edb9dcab5521302e4d
BLAKE2b-256 7e299e9a1d50053f45440e929913abc847388bb6d6c34539f6c76e99983f9061

See more details on using hashes here.

File details

Details for the file aponyx-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: aponyx-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 51.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.5

File hashes

Hashes for aponyx-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 f9e31d02a0cb7284dd264c4436678c6080f7707e364ed9070599c9e522a74d05
MD5 b1c57d4aa0b40197c29e6c7923f6287d
BLAKE2b-256 32995930e4bd98cbed8dd2c5c84c649561e67bc290f0362a414ff28fcd4051fa

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