How logandeboo/pairs_trading works
This repository is a Python research and backtesting system for US equity pairs trading. Its main workflow loads price history, selects candidate pairs using return history and statistical filters, simulates spread-based positions, and calculates portfolio performance after transaction costs. The tree and sampled code also show universe and risk-factor support. The README is empty, and some implementation excerpts are partial, so the graph omits uncertain internal wiring and does not imply that the separate backtesting implementation is complete.
Main entry points: backtest.py Backtest engine · pair_selection.py Pair selection · strategy_pipeline.py Strategy pipeline · data_loader.py Data loader
Components 17
Market data
- Price history
data/adj_close_price_data - Risk returns
data/risk_factor_returns - Data loader
src/data_loader.py
Universe and selection
- US universe
src/universe/universe.py - Stock model
src/stock.py - Stock pair
src/pair.py - Pair selection
src/pair_selection.py
Trading simulation
- Strategy pipeline
src/strategy_pipeline.py - Statistical utilities
src/statistical_utils.py - Backtest engine
src/backtest/backtest.py - Backtest config
src/backtest/backtest_config.py - Backtest result
src/backtest/backtest_result.py
Risk and performance
- Risk factor
src/risk/risk_factor.py - Risk factor set
src/risk/risk_factors.py - Performance analysis
src/performance.py - Visualization
src/visualization.py
Other components
- Researcher
Connections 21
- Researcher → Strategy pipeline: runs workflow
- Strategy pipeline → Data loader: loads prices
- Data loader → Price history: reads prices
- Strategy pipeline → Pair selection: selects pairs
- Pair selection → Statistical utilities: tests statistics
- Pair selection → Stock pair: creates pairs
- US universe → Data loader: loads stock prices
- US universe → Stock model: creates stocks
- US universe → Price history: reads constituents data
- Pair selection → Risk factor set: uses risk factors
- Risk factor set → Risk factor: creates factors
- Risk factor → Risk returns: reads returns
- Strategy pipeline → Backtest engine: simulates pairs
- Backtest engine → Pair selection: requests pairs
- Backtest engine → Statistical utilities: calculates spreads
- Backtest engine → Data loader: filters price history
- Backtest engine → Backtest config: uses settings
- Performance analysis → Backtest engine: requests returns
- Performance analysis → Backtest result: builds metrics
- Researcher → Performance analysis: requests analysis
- Researcher → Visualization: views results