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.
This modernized fork maintains 100% compatibility with the original API and behavior while updating the infrastructure for modern Python development:
- ✅ Python 3.11-3.13 support (tested and confirmed working)
- ✅ Modern build system using
pyproject.toml(replacedsetup.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
rufflinting and formatting - ✅ Fixed deprecations for Python 3.10+ compatibility
- ✅ 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
# 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# 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]"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 libompIf 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_PATHNote: This is a system dependency that cannot be installed via Python packages. It must be installed separately using Homebrew.
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 |
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
# 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)# Analyze markets
mflow# Predict sporting events
sflowIf you're migrating from the original AlphaPy:
- No code changes required - Your existing code will work as-is
- Configuration files remain the same (YAML format unchanged)
- Import statements are identical
- Model outputs are compatible
| 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
# 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/Original documentation is available at:
Build documentation locally:
cd docs/
make htmlThis 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
# 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# Main pipeline
alphapy [--train | --predict]
# Market analysis
mflow
# Sports prediction
sflow- Python 3.11+
- NumPy < 2.0 (for compatibility)
- scikit-learn >= 1.3.0
- pandas >= 2.1.0
- XGBoost >= 2.0.0 (requires
brew install libompon macOS) - LightGBM >= 4.1.0
- CatBoost >= 1.2.0
- TensorFlow >= 2.15.0 (optional, heavy dependency)
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.
- XGBoost on macOS: Requires OpenMP (
brew install libomp) - TensorFlow on Apple Silicon: May require special installation
- Deprecation warnings: From pandas-datareader (upstream issue)
This project maintains the original Apache License, Version 2.0. See LICENSE file for details.
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.
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.