# kidquant/pairs-trading-with-python architecture

> Architecture diagram of the GitHub repository kidquant/pairs-trading-with-python, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-11). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/kidquant/pairs-trading-with-python
- Repository: https://github.com/kidquant/pairs-trading-with-python

## Overview

This repository is a Jupyter notebook demonstrating an equity pairs-trading workflow: obtain historical Yahoo Finance data, test stationarity and cointegration, screen a portfolio for a pair, and form signal features and labels. The README documents these stages and the data source, but the notebook contents were not provided, so internal implementation details and additional data-flow links cannot be verified.

Main entry points: [`PairsTrading.ipynb`](https://github.com/kidquant/pairs-trading-with-python/blob/master/PairsTrading.ipynb) (Pairs trading notebook)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_data["Market Data"]
  node_yahoo["Yahoo Finance"]
  node_yfinance["yFinance retrieval"]
  node_notebook["Pairs trading notebook<br/>[PairsTrading.ipynb]"]
end

subgraph group_analysis["Pair Analysis"]
  node_stationarity["Stationarity model<br/>[PairsTrading.ipynb]"]
  node_cointegration["Cointegration model<br/>[PairsTrading.ipynb]"]
  node_pair_screen["Portfolio pair screening<br/>[PairsTrading.ipynb]"]
end

subgraph group_signals["Trading Signals"]
  node_signal_features["Signal features and labels<br/>[PairsTrading.ipynb]"]
end

node_user(("Notebook user"))

node_user -->|"runs"| node_notebook
node_yahoo -->|"provides history"| node_yfinance
node_yfinance -->|"retrieves data"| node_notebook
node_notebook -->|"tests stationarity"| node_stationarity
node_notebook -->|"tests cointegration"| node_cointegration
node_notebook -->|"screens portfolio"| node_pair_screen
node_notebook -->|"forms features"| node_signal_features

click node_notebook "https://github.com/kidquant/pairs-trading-with-python/blob/master/PairsTrading.ipynb"
click node_stationarity "https://github.com/kidquant/pairs-trading-with-python/blob/master/PairsTrading.ipynb"
click node_cointegration "https://github.com/kidquant/pairs-trading-with-python/blob/master/PairsTrading.ipynb"
click node_pair_screen "https://github.com/kidquant/pairs-trading-with-python/blob/master/PairsTrading.ipynb"
click node_signal_features "https://github.com/kidquant/pairs-trading-with-python/blob/master/PairsTrading.ipynb"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_yahoo,node_yfinance,node_notebook,node_user toneBlue
class node_stationarity,node_cointegration,node_pair_screen toneAmber
class node_signal_features toneMint
```

## Components

### Market Data

- **Yahoo Finance**
- **yFinance retrieval**
- [Pairs trading notebook](https://github.com/kidquant/pairs-trading-with-python/blob/master/PairsTrading.ipynb): `PairsTrading.ipynb`

### Pair Analysis

- [Stationarity model](https://github.com/kidquant/pairs-trading-with-python/blob/master/PairsTrading.ipynb): `PairsTrading.ipynb`
- [Cointegration model](https://github.com/kidquant/pairs-trading-with-python/blob/master/PairsTrading.ipynb): `PairsTrading.ipynb`
- [Portfolio pair screening](https://github.com/kidquant/pairs-trading-with-python/blob/master/PairsTrading.ipynb): `PairsTrading.ipynb`

### Trading Signals

- [Signal features and labels](https://github.com/kidquant/pairs-trading-with-python/blob/master/PairsTrading.ipynb): `PairsTrading.ipynb`

### Other components

- **Notebook user**

## Connections

- Notebook user → Pairs trading notebook: runs (evidence: `README.md`)
- Yahoo Finance → yFinance retrieval: provides history (evidence: `README.md`)
- yFinance retrieval → Pairs trading notebook: retrieves data (evidence: `README.md`)
- Pairs trading notebook → Stationarity model: tests stationarity (evidence: `README.md`)
- Pairs trading notebook → Cointegration model: tests cointegration (evidence: `README.md`)
- Pairs trading notebook → Portfolio pair screening: screens portfolio (evidence: `README.md`)
- Pairs trading notebook → Signal features and labels: forms features (evidence: `README.md`)
