Skip to content
 
 

Repository files navigation

AlphaPy - Modernized Edition

Python 3.11-3.13 License Build System Package Manager

AlphaPy is a machine learning framework for both speculators and data scientists, modernized for Python 3.11+ with the latest package versions while preserving all original functionality.

Fork Information: This is a modernized fork of ScottfreeLLC/AlphaPy with the primary goal of updating the codebase for Python 3.13 support and modernizing the build system while maintaining 100% backward compatibility.

🚀 Modernization Overview

This modernized fork maintains 100% compatibility with the original API and behavior while updating the infrastructure for modern Python development:

What's Been Modernized

  • Python 3.11-3.13 support (tested and confirmed working)
  • Modern build system using pyproject.toml (replaced setup.py)
  • Updated dependencies to latest stable versions
  • Replaced pyfolio with actively maintained pyfolio-reloaded
  • Package manager support for uv, pip, poetry, etc.
  • Optional TensorFlow - now in a separate dependency group
  • Code compliance improvements with ruff linting and formatting
  • Fixed deprecations for Python 3.10+ compatibility

What's Preserved

  • All original functionality intact
  • API compatibility - no breaking changes
  • Algorithm support - all original ML algorithms
  • Pipeline behavior - identical processing logic
  • Configuration format - same YAML structure

📦 Installation

Using uv (Recommended)

# Clone the repository
git clone https://github.com/yourusername/AlphaPy.git
cd AlphaPy

# Install with uv (recommended - excludes TensorFlow)
uv sync --all-groups --no-group tensorflow

# Or install specific groups
uv sync --group dev --group test --group ml-extras

# Add TensorFlow if needed (Linux/Windows only)
uv sync --group tensorflow

Using pip

# Install in development mode
pip install -e .

# Install with all ML libraries
pip install -e ".[ml-extras]"

# Install with TensorFlow support
pip install -e ".[tensorflow]"

macOS Users - System Requirements

XGBoost OpenMP Dependency

XGBoost requires OpenMP to be installed on macOS. Without it, you'll get an error when importing XGBoost:

Library not loaded: /usr/local/opt/libomp/lib/libomp.dylib

Solution:

brew install libomp

If you still get errors after installing, you may need to:

# Reinstall XGBoost
uv pip uninstall xgboost
uv sync --group ml-extras

# Or set the library path
export DYLD_LIBRARY_PATH=/usr/local/opt/libomp/lib:$DYLD_LIBRARY_PATH

Note: This is a system dependency that cannot be installed via Python packages. It must be installed separately using Homebrew.

🔧 Dependency Groups

The modernized version organizes dependencies into logical groups:

Group Description Install Command
core Essential dependencies (always installed) uv sync
ml-extras XGBoost, LightGBM, CatBoost uv sync --group ml-extras
tensorflow TensorFlow & Keras (optional, heavy) uv sync --group tensorflow
dev Development tools (pytest, ruff, mypy) uv sync --group dev
docs Documentation generation uv sync --group docs

🎯 Features

AlphaPy provides a comprehensive ML framework for:

  • Machine Learning Models using scikit-learn, XGBoost, LightGBM, CatBoost, and optionally Keras/TensorFlow
  • Ensemble Methods with blending and stacking
  • Market Analysis with MarketFlow for financial markets
  • Sports Prediction with SportFlow for sporting events
  • Trading Systems and portfolio analysis
  • Feature Engineering with extensive transformations
  • AutoML capabilities with hyperparameter optimization

📊 Core Components

Model Pipeline

# Traditional usage remains unchanged
from alphapy.model import Model
from alphapy.data import get_data

# Create and run model exactly as before
model = Model(specs)

MarketFlow

# Analyze markets
mflow

SportFlow

# Predict sporting events
sflow

🔄 Migration from Original AlphaPy

If you're migrating from the original AlphaPy:

  1. No code changes required - Your existing code will work as-is
  2. Configuration files remain the same (YAML format unchanged)
  3. Import statements are identical
  4. Model outputs are compatible

Key Improvements for Developers

Aspect Original Modernized
Python Version 3.7-3.8 3.11-3.13*
Build System setup.py pyproject.toml
Dependencies Pinned old versions Latest stable
TensorFlow Required Optional
Package Manager pip only uv, pip, poetry
Code Quality Mixed Linted with ruff

*Python 3.13 support depends on all dependencies being compatible

🧪 Testing

# Run tests
uv run pytest

# Run with coverage
uv run pytest --cov=alphapy

# Run linting
uv run ruff check alphapy/

# Run formatting
uv run ruff format alphapy/

# Type checking
uv run mypy alphapy/

📚 Documentation

Original documentation is available at:

Build documentation locally:

cd docs/
make html

🤝 Compatibility Promise

This modernized version maintains:

  • Identical API - All functions, classes, and methods unchanged
  • Same behavior - Algorithms produce identical results
  • Configuration compatibility - Existing YAML files work
  • Output format - Same file formats and structures

🛠️ Development

Setting up for development

# Install all development dependencies
uv sync --all-groups

# Run code quality checks
uv run ruff check alphapy/
uv run ruff format alphapy/ --check
uv run mypy alphapy/

# Run tests
uv run pytest

Available Commands

# Main pipeline
alphapy [--train | --predict]

# Market analysis
mflow

# Sports prediction  
sflow

📋 Requirements

Minimum Requirements

  • Python 3.11+
  • NumPy < 2.0 (for compatibility)
  • scikit-learn >= 1.3.0
  • pandas >= 2.1.0

Optional ML Libraries

  • XGBoost >= 2.0.0 (requires brew install libomp on macOS)
  • LightGBM >= 4.1.0
  • CatBoost >= 1.2.0
  • TensorFlow >= 2.15.0 (optional, heavy dependency)

🔮 Python 3.13 Support

We aim to support Python 3.13 as soon as all critical dependencies are compatible. Current blockers:

  • NumPy (currently supports up to 3.12)
  • TensorFlow (currently supports up to 3.12)
  • Some scientific computing libraries

Track Python 3.13 compatibility in issue #XXX.

🐛 Known Issues

  1. XGBoost on macOS: Requires OpenMP (brew install libomp)
  2. TensorFlow on Apple Silicon: May require special installation
  3. Deprecation warnings: From pandas-datareader (upstream issue)

📝 License

This project maintains the original Apache License, Version 2.0. See LICENSE file for details.

🙏 Acknowledgments

Original AlphaPy created by ScottFree Analytics LLC (Mark Conway & Robert D. Scott II)

This modernization preserves their excellent work while updating it for contemporary Python development.

🔗 Links


Note: This is a modernization effort that maintains full backward compatibility. The core algorithms, logic, and behavior of AlphaPy remain unchanged. Only the build system, dependencies, and Python compatibility have been updated.

About

Python AutoML for Trading Systems and Sports Betting

Resources

Code of conduct

Contributing

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages