Authors: Nicholas Nguyen [1010900474], Jay Patel [1010960872], Nelson Siu [1010940608]
MAT292 Project analyzing Bitcoin price spreads between Bitfinex and Gemini exchanges using a Delay Differential Equation (DDE) framework.
MAT292-Project/
│
├── data/ # Data files
│ ├── Bitfinex Week - minute ticker - Sheet1.csv # Raw Bitfinex data (minute resolution)
│ ├── Gemini Week - minute ticker - Sheet1.csv # Raw Gemini data (minute resolution)
│ ├── interpolated_second_data.csv # Interpolated second-resolution data
│ ├── synchronized_spread_data.csv # Synchronized spread time series
│ └── calibration_results.csv # Parameter estimates from calibration
│
├── figures/ # Generated plots
│ ├── mid_prices.png # Price series from both exchanges
│ ├── spread.png # Spread time series
│ └── fig_k_and_tau.png # k estimates vs lag with critical delays
│
├── Python Scripts # Analysis pipeline
│ ├── process_spread.py # [1] Synchronize data and compute spread
│ ├── interpolate.py # [2] Interpolate minute data to seconds
│ ├── calibrate_k_tau.py # [3] Estimate k, τ, and compute τ_c
│ ├── plot_price_series.py # Visualize exchange price series
│ ├── plot_spread.py # Visualize spread dynamics
│ └── plot_k_tau.py # Plot k and critical delay estimates
│
├── LaTeX Files # Report generation
│ ├── matproject.tex # Main LaTeX document
│ └── *.aux, *.fdb_latexmk, *.fls # LaTeX auxiliary files
│
├── requirements.txt # Python dependencies
├── context.md # Project context and rubric
└── README.md # This file
Source Data:
- Bitcoin (BTC-USD) price data from Bitfinex and Gemini exchanges
- Time period: March 9–17, 2022 (one week)
- Original resolution: 1 minute (OHLC data)
- Processed resolution: 1 second (via linear interpolation)
- Python 3.7 or higher
- pip package manager
-
Clone or download this repository
-
Create a virtual environment (recommended):
python -m venv .venv
-
Activate the virtual environment:
- Windows (PowerShell):
.venv\Scripts\Activate.ps1
- Windows (Command Prompt):
.venv\Scripts\activate.bat
- macOS/Linux:
source .venv/bin/activate
- Windows (PowerShell):
-
Install dependencies:
pip install -r requirements.txt
Run the scripts in the following order to reproduce all results:
python process_spread.py- Loads raw Bitfinex and Gemini data
- Computes mid-prices
- Synchronizes timestamps
- Calculates spread (mA - mB)
- Output:
data/synchronized_spread_data.csv
python interpolate.py- Performs linear interpolation from minute to second resolution
- Generates high-frequency approximation
- Output:
data/interpolated_second_data.csv
python calibrate_k_tau.py- Estimates empirical delay (τ_emp) via cross-correlation
- Estimates mean-reversion rate (k̂) using multiple methods
- Computes critical delay (τ_c = π/(2k̂))
- Performs sensitivity analysis across different lag assumptions
- Output:
data/calibration_results.csv, console summary
python plot_price_series.py # Price series from both exchanges
python plot_spread.py # Spread dynamics over time
python plot_k_tau.py # Parameter estimates vs lag- Outputs: Figures saved to
figures/directory
# Plot mid-prices from both exchanges
python plot_price_series.py
# Plot the spread time series
python plot_spread.py
# Plot k estimates and critical delays
python plot_k_tau.pyData Files:
data/synchronized_spread_data.csv- Aligned mid-prices and spread from both exchangesdata/interpolated_second_data.csv- Second-resolution interpolated datadata/calibration_results.csv- Estimated parameters (k, τ_emp, τ_c)
Figures:
figures/mid_prices.png- Bitfinex and Gemini price seriesfigures/spread.png- Spread time series visualizationfigures/fig_k_and_tau.png- Parameter sensitivity analysis
All dependencies are listed in requirements.txt:
requests
pandas
matplotlib
numpy
scipy