Skip to content

Latest commit

 

History

History
67 lines (55 loc) · 2.14 KB

File metadata and controls

67 lines (55 loc) · 2.14 KB

TradingBot

A simple, practical Python framework for backtesting intraday trading strategies on real or synthetic data. It includes a small set of strategies, a realistic backtester (bid/ask, latency, fees), and basic analytics.

Features

  • Data: Yahoo Finance intraday download (no API key), CSV input, or synthetic data
  • Strategies: Mean reversion, momentum, market making (extensible via BaseStrategy)
  • Backtester: Bid/ask matching, latency, slippage, transaction fees, average-cost P&L
  • Metrics & Plots: Sharpe, drawdown, win rate, equity curve and drawdown charts
  • CLI: Single entry point with sensible defaults

Installation

git clone <your-repo-url>
cd TradingBot
pip install -r requirements.txt

Quick Start

# Run with real market data from Yahoo Finance (e.g., AAPL)
python main.py --symbol AAPL

# Choose a different strategy and parameters
python main.py --symbol TSLA --strategy momentum --lookback 30 --threshold 0.002

# Market making with position limits
python main.py --symbol SPY --strategy market_making --max-position 200

More Options

# Show all CLI options
python main.py -h

# Advanced configuration example
python main.py \
  --symbol NVDA \
  --strategy mean_reversion \
  --lookback 120 \
  --threshold 0.8 \
  --latency-ms 100 \
  --fee-per-share 0.001 \
  --slippage-bps 5 \
  --period 5d

Project Structure

  • main.py — CLI entry point
  • data_loader.py — Yahoo Finance download, CSV I/O, synthetic data
  • backtester.py — Core execution (bid/ask, latency, fees, slippage, P&L)
  • strategies/base.py, mean_reversion.py, momentum.py, market_making.py
  • metrics.py — Sharpe, drawdown, win rate, etc.
  • plotting.py — Equity, drawdown, exposure, P&L distribution
  • tests/ — Basic pytest for a synthetic run

Extending

  • Add a strategy by subclassing strategies/base.py and implementing on_tick()
  • Add a data source under data_sources/ implementing the base interface

Development

pytest -q

Disclaimer

This project is for educational and research purposes only. It is not investment advice and not intended for live trading.