Skip to content

ChypherC0d3/AlgoStrategy

Repository files navigation

AlgoStrategy

Open-source quantitative trading framework for detecting and exploiting market inefficiencies across all asset classes via Interactive Brokers TWS API.

Architecture

AlgoStrategy/
├── config.py              # Global configuration & universes
├── ib_connector.py        # IB TWS API wrapper (ib_insync)
├── quant_math.py          # FFD, HMM, GARCH, OU process
├── scanners/
│   ├── pairs_cointegration.py   # Stat arb: Engle-Granger + OU
│   ├── etf_nav_arbitrage.py     # ETF premium/discount
│   ├── futures_basis.py         # Cash-futures basis
│   ├── options_parity.py        # Put-call parity violations
│   └── microstructure.py        # OFI, VWAP, volume anomalies
├── execution/
│   ├── position_sizer.py        # Half-Kelly + correlation
│   ├── order_manager.py         # Smart routing, TWAP, brackets
│   └── risk_manager.py          # DD limits, VaR, kill switch
├── analytics/
│   ├── stats.py                 # Sharpe, Sortino, CAGR, etc.
│   └── reporter.py              # HTML dashboard (auto-refresh)
└── fund_v2.py             # Crypto momentum strategy (standalone)

Scanners

Scanner Strategy Expected Sharpe Asset Classes
Pairs Cointegration Engle-Granger stat arb with OU half-life 0.8-1.3 ETFs, Stocks
ETF NAV Arbitrage Premium/discount vs theoretical NAV 0.5-0.8 ETFs
Futures Basis Cash-futures basis vs cost of carry 0.5-0.9 Futures
Options Parity Put-call parity violation detection 0.8-1.2 Options
Microstructure OFI + VWAP deviation + volume anomalies 0.3-0.6 All

Quick Start

Prerequisites

  • Python 3.10+
  • Interactive Brokers TWS or IB Gateway running
  • API enabled in TWS (Edit > Global Configuration > API > Settings)

Install

git clone https://github.com/CypherC0d3/AlgoStrategy.git
cd AlgoStrategy
pip install -r requirements.txt

Run (Paper Trading)

# Test IB connection
python ib_connector.py

# Run pairs scanner (offline mode - no IB needed)
python -m scanners.pairs_cointegration

# Run all scanners
python main.py

Offline Mode

All scanners work without IB connection using yfinance historical data:

from scanners import PairsScanner
scanner = PairsScanner(connector=None)  # No IB
signals = scanner.scan()

Risk Management

  • Max 3% per position (Half-Kelly)
  • 5% daily drawdown limit
  • 15% monthly drawdown limit
  • 3x max gross leverage
  • Portfolio VaR at 95% confidence
  • Emergency kill switch (flatten all)

Contributing

See CONTRIBUTING.md for guidelines on adding new scanners.

Disclaimer

This software is for educational and research purposes only. Trading involves substantial risk of loss. Past performance does not guarantee future results. Always validate with paper trading before risking real capital.

License

MIT License - see LICENSE

About

No description, website, or topics provided.

Resources

License

Contributing

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages