This is an AI trading bot
README
AI Trading System
A modular, production-oriented AI-powered quantitative trading system written in Python.
It combines historical market data, rich technical feature engineering, machine-learning signal generation, volatility-targeted position sizing, stop-loss / take-profit rules, and a multi-asset backtester with realistic transaction costs.
Disclaimer: This is research / educational software only.
It is not financial advice. Past performance does not guarantee future results.
Always paper-trade and fully understand the risks before using real capital.
Fresh Clone – Exact Commands Buyers Run
git clone <repo-url> ai_trading_system
cd ai_trading_system
python -m venv .venv
source .venv/bin/activate # Windows: .venv\Scripts\activate
pip install -r requirements.txt
pip install -r requirements-dev.txt
# THIS IS THE CRITICAL COMMAND – must succeed
pytest tests/ -v --cov=src --cov-report=term-missing
# Alternative
make test
Run tests in a completely isolated container
docker compose run --rm test
# or
make docker-test
Run the trading pipeline
python main.py
# or
make run
What the Test Suite Covers
| File | What it tests |
|---|---|
tests/test_smoke.py |
Imports, config loading, basic objects |
tests/test_data_fetcher.py |
Data fetching + caching (mocked) |
tests/test_features.py |
Technical feature engineering |
tests/test_predictor.py |
ML model fit / predict / save / load |
tests/test_signal.py |
Signal generation from probabilities |
tests/test_risk.py |
Position sizing, stops, drawdown checks |
tests/test_backtest.py |
Full backtest engine + metrics |
All tests run without network access or external credentials.
Project Structure
ai_trading_system/
├── .github/workflows/ci.yml # Lint + type + test on every push
├── config/config.yaml
├── src/
│ ├── data/
│ ├── features/
│ ├── models/
│ ├── strategies/
│ ├── risk/
│ ├── backtest/
│ ├── portfolio/
│ └── utils/
├── tests/ # Full pytest suite
├── main.py
├── Dockerfile # Multi-stage (production + test)
├── docker-compose.yml
├── Makefile
├── pytest.ini
├── requirements.txt # Pinned runtime
├── requirements-dev.txt
├── requirements-lock.txt
├── pyproject.toml
├── .env.example
├── CONTRIBUTING.md
└── README.md
Development Commands
make help
make install-dev
make test
make lint
make format
make ci # full local CI
make docker-test # tests inside Docker
make docker-run # pipeline inside Docker
Configuration
Edit config/config.yaml for symbols, model type, risk limits, etc.
Copy .env.example → .env only if you later add live broker keys (never commit secrets).
CI
GitHub Actions (.github/workflows/ci.yml) runs on every push and pull request:
- Multi-Python matrix (3.10 / 3.11 / 3.12)
- Ruff lint + format check
- Full pytest suite with coverage
- Bandit + Safety security scans
Extending
- New model → implement
fit/predict_proba/save/loadinsrc/models/ - Change prediction target → edit
_create_targetinSignalPredictor - Live trading → replace backtester with a broker connector
License
MIT
39 files
every file readable free; the clone is the same bytes, packaged and agent-payable
.github/1
config/1
src/16
- src/__init__.py42 B
- src/backtest/__init__.py54 B
- src/backtest/engine.py11 KB
- src/data/__init__.py33 B
- src/data/fetcher.py3 KB
- src/features/__init__.py38 B
- src/features/engineer.py4 KB
- src/portfolio/__init__.py38 B
- src/portfolio/manager.py2 KB
- src/risk/__init__.py33 B
- src/risk/manager.py4 KB
- src/strategies/__init__.py36 B
- src/strategies/signal.py1 KB
- src/utils/__init__.py77 B
- src/utils/config.py701 B
- src/utils/logger.py988 B
tests/7
- .env.example382 B
- .gitignore361 B
- .pre-commit-config.yaml389 B
- CONTRIBUTING.md731 B
- Dockerfile831 B
- Makefile2 KB
- README.md4 KB
- docker-compose.yml554 B
- main.py7 KB
- pyproject.toml732 B
- pytest.ini216 B
- requirements-dev.txt195 B
- requirements-lock.txt457 B
- requirements.txt255 B