alfars: From epsilon to alpha.
Informed by data; Enlightened by research; Engineered with AI; Executed with algorithms.
High-performance quant workflow with Rust core and Python bindings.
Features
Core Backtesting
- High Performance: Rust core with parallel computation (8-10x speedup)
- Flexible API: NumPy arrays and Pandas Series support
- Complete Features: qcut(N) grouping, long-short portfolios, IC calculation, factor analysis
- Alphalens Compatibility: Similar API design for easy migration
- Extensible: Modular design with custom weights, grouping, and commission models
Intelligent Factor Mining (v0.4.0)
- Expression System: AST-based expression builder for custom factor computation
- Lazy Evaluation: Polars-style delayed computation with query optimization
- Genetic Programming: Auto-discover high-performance factor expressions
- Dimension System: Type-safe factor expressions to prevent invalid calculations
- Persistence: Factor library management with search, caching, and versioning
- Meta-Learning: Intelligent GP parameter recommendations based on historical data
Interactive Lab (v0.4.0)
- One-Command Launch:
alfars labstarts all services automatically - Visual Backtest: Interactive charts for NAV, IC, and quantile returns
- Browser-based: Access via http://localhost:5173
- ClickHouse Support: Connect to ClickHouse for historical market data
Installation
Requirements
- Rust: 1.70+ (
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh) - Python: 3.8+
- uv (recommended):
pip install uv
Install from Source
# Clone repository
# Option 1: Full installation with Python bindings
# Option 2: Rust-only server (no Python extension needed)
Using pip (future releases)
Quick Start
Basic Usage
# Generate sample data
, = 100, 200
=
= * 0.01 + * 0.005
# Run quantile backtest
=
Start Interactive Lab
# Option 1: Python FastAPI server (requires maturin develop first)
# Option 2: Rust HTTP server (recommended - no Python dependency)
&&
Then open http://localhost:5173 in your browser.
Genetic Programming Factor Mining
# Create GP engine
=
# Set available columns
# Prepare data
=
=
# Mine factors
=
Expression System
# Build factor expressions
= /
=
# Lazy evaluation
=
=
=
Persistence & Meta-Learning
# Factor library
=
=
# Meta-learning recommendations
=
=
Performance Benchmarks
| Data Size | Rust | Python | Speedup |
|---|---|---|---|
| 100×200 | 5.2ms | 42.1ms | 8.1× |
| 500×500 | 68.3ms | 1.2s | 17.6× |
| 1000×1000 | 312ms | 8.7s | 27.9× |
Test environment: AMD Ryzen 7 5800X, 32GB RAM
Project Structure
alfars/
├── Cargo.toml # Rust project config
├── pyproject.toml # Python project config
├── src/
│ ├── lib.rs # Core + Python bindings
│ ├── al/ # Alpha file parser + factor store
│ ├── backtest/ # Backtest engine
│ ├── data/ # Data source abstraction
│ ├── expr/ # Expression system (AST, optimizer, registry)
│ ├── gp/ # Genetic programming + history + metalearning
│ ├── lazy/ # Lazy evaluation engine
│ ├── types/ # Series and DataFrame types
│ ├── persistence.rs # Persistence manager
│ └── bin/server.rs # Rust HTTP server
├── alfars/ # Python package
│ ├── __init__.py
│ ├── lab.py # Interactive lab launcher
│ └── server.py # FastAPI server
├── frontend/ # Interactive UI (Vite + TypeScript)
├── assets/ # Static assets (logo, etc.)
└── tests/ # Test suite
Development
# Format code before committing
# Run tests
# Build release
Version History
v0.4.0 (Current)
- Interactive Lab: One-command
alfars labfor visual factor research - GP Parallelization: Rayon-based parallel fitness evaluation
- Improved GP Engine: Bug fixes for IC calculation, cumulative returns
- Dimension System: Type-safe factor expressions
- ClickHouse Integration: Direct database connectivity for historical data
- Rust HTTP Server: Standalone server without Python dependency
v0.2.0
- Expression system with AST-based builder
- Lazy evaluation engine (Polars-style)
- Genetic programming factor mining
- Persistence and factor library management
- Meta-learning recommendations
v0.1.0
- High-performance quantile backtesting
- Alphalens-compatible API
- NumPy/Pandas dual interface
License
MIT License