Ampyfin
End-to-end ensemble trading framework that trains, backtests, and promotes validated strategies to live execution.
Install / Use
/learn @AmpyFin/AmpyfinREADME
AmpyFin Trading System
| Category | Badges |
| ----------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| Project |
|
| CI/CD |
|
| Quality |
|
| Package |
|
| Meta |
|
Introduction
AmpyFin is an advanced AI-powered trading system designed to trade within the NASDAQ-100. It leverages machine learning and algorithmic trading strategies to make data-driven investment decisions.
Mission
The primary goal of AmpyFin as an open source project is to:
- Democratize Algorithmic Trading: Make proven trading frameworks available for everyone to use freely
- Provide Transparency: Offer insights into how machine learning can be applied to financial markets
- Fill a Gap: Contribute to the open source community where there are few published frameworks for effective trading systems
- Enable Collaboration: Create a platform for traders and developers to build upon and improve together
While there are many theoretical trading models in academic literature, AmpyFin aims to bridge the gap between theory and practice with a working implementation that the community can use, study, and enhance.
Tutorial Playlist
For a comprehensive guide on how to use AmpyFin, check out our YouTube tutorial playlist.
Documentation
📚 Comprehensive documentation is now available! Check out the detailed guides in the docs/ folder:
- Configuration Guide - Complete setup instructions, risk management, and parameter tuning
- Trading Strategies - 100+ TA-Lib indicators, strategy categories, and custom development
- Database Schema - MongoDB collections, SQLite structure, and data management
- API Integration - Broker APIs, data providers, and external services
- Troubleshooting Guide - Common issues, solutions, and debugging techniques
Features
Data Collection
- yfinance: Primary source for historical price data and technical indicators
Data Storage
- MongoDB: Securely stores all data and trading logs for historical analysis
Machine Learning
AmpyFin uses a ranked ensemble learning system that dynamically evaluates each strategy's performance and adjusts their influence in the final decision accordingly.
Trading Strategies
- Mean Reversion: Predicts asset prices will return to their historical average
- Momentum: Capitalizes on prevailing market trends
- Arbitrage: Identifies and exploits price discrepancies between related assets
- AI-Driven Custom Strategies: Continuously refined through machine learning
Dynamic Ranking System
Each strategy is evaluated based on performance metrics and assigned a weight using a sophisticated ranking algorithm. The system adapts to changing market conditions by prioritizing high-performing strategies.
Architecture
Core Components
| Component | Description |
| --------------------- | ----------------------------------------------- |
| control.py | Configuration interface for trading parameters |
| TradeSim/main.py | Training and testing environment for strategies |
| TradeSim/trading.py | Executes trades based on algorithmic decisions |
| TradeSim/ranking.py | Evaluates and ranks trading strategies |
| strategies/* | Implementation of various trading algorithms |
| utilites/* | General Utility functions |
| dbs/* | Create SQLite DBs of prices and decisions |
Installation
Prerequisites
- Python 3.8+
- MongoDB
- TA-Lib
Setup
- Clone the repository
git clone https://github.com/AmpyFin/ampyfin.git
cd ampyfin
- Install dependencies
pip install -r requirements.txt
- Install TA-Lib
TA-Lib is required for technical indicators. Choose one of these installation options:
Option 1: Use pre-built binaries (Recommended for Windows users)
- Download the appropriate wheel file for your Python version from here
- Install it with pip:
pip install <downloaded-wheel-file>.whl
Option 2: Build from source (For Linux/Mac users)
- Follow the instructions on the TA-Lib Python repository
- Set up MongoDB
MongoDB is used for storing trading data and strategy results. Here's how to set it up:
-
Option A: MongoDB Atlas (Cloud-hosted, recommended for beginners)
- Create a free account at MongoDB Atlas
- Create a new cluster (the free tier is sufficient)
- Set up database access (username/password)
- Add your IP address to the network access whitelist
- Get your connection string, which will look like:
mongodb+srv://<username>:<password>@cluster0.mongodb.net/ampyfin
-
Option B: Local MongoDB Installation
- Download and install MongoDB Community Edition
- Start the MongoDB service
- Your connection string will be:
mongodb://localhost:27017/ampyfin
- Configure API keys
You need to sign up for the following services to obtain API keys:
- Alpaca - For trading execution
- Weights & Biases - For experiment tracking
Create a .env file based on the template:
API_KEY = "your_alpaca_api_key"
API_SECRET = "your_alpaca_secret_key"
BASE_URL = "https://paper-api.alpaca.markets" # Paper trading (safe for testing)
# BASE_URL = "https://api.alpaca.markets" # Live trading (uses real money)
WANDB_API_KEY = "your_wandb_api_key"
MONGO_URL = "your_mongo_connection_string"
⚠️ IMPORTANT: The default configuration uses Alpaca's paper trading environment. To switch to live trading (using real money), change the BASE_URL to "https://api.alpaca.markets". Only do this once you've thoroughly tested your strategies and understand the risks involved.
- Run the setup script
python setup.py
This initializes the database structure required for AmpyFin.
Usage
Running the System
Start the ranking and trading systems in separate terminals:
cd TradeSim
python ranking.py
python trading.py
Training and Testing
These are separate operations that can be performed within the TradeSim module:
Training
- Set the mode in
control.py:
mode = 'train'
- Run the training module:
python TradeSim/main.py
Testing
- Set the mode in
control.py:
mode = 'test'
- Run the testing module:
python TradeSim/main.py
Deploying a Model
- Set the mode in
control.py:
mode = 'push'
- Push your model to MongoDB:
python TradeSim/main.py
Important Notes
For live trading, it's recommended to:
- Train the system by running
ranking.pyfor at least two weeks, or - Train using the TradeSim module and push changes to MongoDB before executing trades
This ensures the system has properly ranked strategies before making investment decisions.
Documentation
Comprehensive documentation is available in the docs/ folder:
- Configuration Guide - Detailed configuration parameters and setup instructions
- Trading Strategies - Complete gui
Related Skills
claude-opus-4-5-migration
108.9kMigrate prompts and code from Claude Sonnet 4.0, Sonnet 4.5, or Opus 4.1 to Opus 4.5
model-usage
348.2kUse CodexBar CLI local cost usage to summarize per-model usage for Codex or Claude, including the current (most recent) model or a full model breakdown. Trigger when asked for model-level usage/cost data from codexbar, or when you need a scriptable per-model summary from codexbar cost JSON.
TrendRadar
50.9k⭐AI-driven public opinion & trend monitor with multi-platform aggregation, RSS, and smart alerts.🎯 告别信息过载,你的 AI 舆情监控助手与热点筛选工具!聚合多平台热点 + RSS 订阅,支持关键词精准筛选。AI 智能筛选新闻 + AI 翻译 + AI 分析简报直推手机,也支持接入 MCP 架构,赋能 AI 自然语言对话分析、情感洞察与趋势预测等。支持 Docker ,数据本地/云端自持。集成微信/飞书/钉钉/Telegram/邮件/ntfy/bark/slack 等渠道智能推送。
mcp-for-beginners
15.8kThis open-source curriculum introduces the fundamentals of Model Context Protocol (MCP) through real-world, cross-language examples in .NET, Java, TypeScript, JavaScript, Rust and Python. Designed for developers, it focuses on practical techniques for building modular, scalable, and secure AI workflows from session setup to service orchestration.
