Skip to main content

Systematic research framework for tactical credit strategies

Project description

Aponyx

PyPI version Python 3.12 License: MIT

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

Aponyx provides a type-safe, reproducible research environment for tactical fixed-income strategies. Built for investment professionals who need clean separation between strategy logic, data infrastructure, and backtesting workflows.

Key Features

  • Type-safe data loading with schema validation (Parquet, CSV, Bloomberg Terminal)
  • Modular signal framework with composable transformations and registry management
  • Deterministic backtesting with transaction cost modeling and comprehensive metrics
  • Interactive visualization with Plotly charts (equity curves, signals, drawdown)
  • Production-ready persistence with metadata tracking and versioning
  • Strategy governance with centralized registry and configuration management

Installation

From PyPI (Recommended)

pip install aponyx

Optional dependencies:

# Visualization (Plotly, Streamlit)
pip install aponyx[viz]

# Bloomberg Terminal support (requires manual blpapi install)
pip install aponyx[bloomberg]

# Development tools
pip install aponyx[dev]

From Source

Requires Python 3.12 and uv:

git clone https://github.com/stabilefrisur/aponyx.git
cd aponyx
uv sync                    # Install dependencies
uv sync --extra viz        # Include visualization
uv run python examples/backtest_demo.py

Bloomberg Terminal Setup (Optional)

Note: Bloomberg data loading requires an active Terminal session and manual blpapi installation.

  1. Download blpapi from Bloomberg's API Library
  2. Install: pip install path/to/blpapi-*.whl
  3. Install Bloomberg extra: pip install aponyx[bloomberg]

File-based data loading (FileSource) works without Bloomberg dependencies.

Quick Start

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

# Load validated market data
cdx_df = fetch_cdx(FileSource("data/raw/cdx_data.parquet"), security="cdx_ig_5y")
etf_df = fetch_etf(FileSource("data/raw/etf_data.parquet"), security="hyg")

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

# Run backtest with transaction costs
backtest_config = BacktestConfig(
    entry_threshold=1.5,
    exit_threshold=0.75,
    transaction_cost_bps=1.0
)
results = run_backtest(signal, cdx_df["spread"], backtest_config)

# Compute performance metrics
metrics = compute_performance_metrics(results.pnl, results.positions)

# Analyze results
print(f"Sharpe Ratio: {metrics.sharpe_ratio:.2f}")
print(f"Max Drawdown: ${metrics.max_drawdown:,.0f}")
print(f"Hit Rate: {metrics.hit_rate:.2%}")

Bloomberg Terminal alternative:

from aponyx.data import BloombergSource

source = BloombergSource()
cdx_df = fetch_cdx(source, security="cdx_ig_5y")

Architecture

Aponyx follows a layered architecture with clean separation of concerns:

Layer Purpose Key Modules
Data Load, validate, transform market data fetch_cdx, fetch_vix, fetch_etf, FileSource, BloombergSource
Models Generate signals for independent evaluation compute_cdx_etf_basis, compute_cdx_vix_gap, SignalRegistry
Backtest Simulate execution and compute metrics run_backtest, BacktestConfig, StrategyRegistry
Visualization Interactive charts and dashboards plot_equity_curve, plot_signal, plot_drawdown
Persistence Save/load data with metadata registry save_parquet, load_parquet, DataRegistry

Data Flow

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

Examples

Each example demonstrates a specific workflow with synthetic data:

python examples/data_demo.py          # Data loading and validation
python examples/models_demo.py        # Signal generation and catalog
python examples/backtest_demo.py      # Complete backtest workflow
python examples/visualization_demo.py # Interactive charts (requires viz extra)
python examples/persistence_demo.py   # Data I/O and registry
python examples/bloomberg_demo.py     # Bloomberg Terminal integration

Documentation

Document Description
Python Guidelines Code standards and best practices
CDX Overlay Strategy Investment thesis and pilot implementation
Signal Registry Usage Signal management workflow
Visualization Design Chart architecture and patterns
Logging Design Logging conventions and metadata
Caching Design Cache layer architecture
Adding Data Providers Provider extension guide

What's Included

Implemented

  • ✅ Type-safe data loading with schema validation (Parquet, CSV, Bloomberg)
  • ✅ Modular signal framework with registry and catalog management
  • ✅ Deterministic backtesting with transaction costs and comprehensive metrics
  • ✅ Interactive Plotly visualizations (equity curves, signals, drawdown)
  • ✅ Strategy governance with centralized registry and versioning
  • ✅ Metadata tracking and reproducibility controls
  • ✅ Comprehensive test suite with >90% coverage

Pilot Signals

Three signals for CDX overlay strategies:

  1. CDX-ETF Basis - Flow-driven mispricing from cash-derivative basis
  2. CDX-VIX Gap - Cross-asset risk sentiment divergence
  3. Spread Momentum - Short-term continuation in credit spreads

Roadmap

  • 🔜 Streamlit dashboard (architecture defined, implementation pending)
  • 🔜 Advanced attribution charts (performance decomposition)
  • 🔜 Multi-asset portfolio backtesting
  • 🔜 Position sizing and risk budgeting

Development

Running Tests

pytest                              # All tests
pytest --cov=aponyx                # With coverage
pytest tests/models/                # Specific module

Code Quality

black src/ tests/                   # Format code
ruff check src/ tests/              # Lint
mypy src/                          # Type check

All tools are configured in pyproject.toml with project-specific settings.

Design Philosophy

Core Principles

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

Signal Convention

All signals follow a consistent sign convention for interpretability:

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

This ensures clarity when evaluating signals independently or combining them in future research.

Requirements

  • Python 3.12 (no backward compatibility with 3.11 or earlier)
  • Modern type syntax (str | None, not Optional[str])
  • Optional: Bloomberg Terminal with blpapi for live data

Contributing

Contributions welcome! This is a research framework under active development.

  • Code standards: See Python Guidelines
  • Testing: All new features require unit tests
  • Documentation: NumPy-style docstrings required

License

MIT License - see LICENSE for details.

Links


Maintained by stabilefrisur
Version: 0.1.2
Last Updated: November 2, 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.3.tar.gz (40.5 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.3-py3-none-any.whl (57.6 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for aponyx-0.1.3.tar.gz
Algorithm Hash digest
SHA256 3418c5aea5bfa7e8c276cb144b5252678e0e80c9690dc5c55ccf6d53d26e990f
MD5 8d685d992a21915db0bebb0d52f5b4f0
BLAKE2b-256 729b0747c215c1da27c8bc0ac428cdc522fe3e9f2903f6e34c1ccfcdeac6c7a2

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for aponyx-0.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 8a9b82bd58d0ce76caea39ae7de00266b0ff4b0bfbc6c0061e477ab883f17430
MD5 3001cbd47825558641fc6656e167445a
BLAKE2b-256 b3861935a4dea6e54f15620756dba4483993f0625892fa48f7c88f4b5ae4a98f

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