Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 

Repository files navigation

Volatility Framework

Python Quantitative finance Research

Research-oriented Python framework for building, evaluating, and comparing volatility forecasting models with a common object-oriented interface.

Problem

Volatility experiments can become difficult to compare when each notebook uses different model code, metrics, and forecasting conventions. This project creates a small reusable framework so baseline models can be tested in the same way.

What It Includes

Area Implementation
Model interface Abstract BaseVolatilityModel with fit() and predict() methods
EWMA model RiskMetrics-style exponentially weighted moving average volatility
Rolling model Rolling-window variance baseline
Metrics QLIKE loss for variance forecast evaluation
Notebooks Demo, EWMA sanity check, and EWMA vs rolling backtest notebooks
Packaging Installable volaframe package through setup.py

Repository Structure

volatility-framework/
  volaframe/
    models/
      base.py
      ewma.py
      rolling.py
    metrics/
      qlike.py
  notebooks/
    01_ewma_sanity_check.ipynb
    02_backtest_ewma_vs_rolling.ipynb
    02_framework_demo.ipynb
  requirements.txt
  setup.py

Quick Start

cd volatility-framework
python -m venv .venv
source .venv/bin/activate
pip install -r requirements.txt
pip install -e .

Windows PowerShell:

cd volatility-framework
python -m venv .venv
.\.venv\Scripts\Activate.ps1
pip install -r requirements.txt
pip install -e .

Example

import numpy as np
from volaframe.metrics import qlike
from volaframe.models import EWMAVolatilityModel, RollingVarianceModel

returns = np.random.normal(0, 0.01, size=500)

ewma = EWMAVolatilityModel(lambda_=0.94).fit(returns)
rolling = RollingVarianceModel(window=21).fit(returns)

realized_var = returns ** 2
ewma_loss = qlike(realized_var[-len(ewma.volatility_):], ewma.volatility_ ** 2).mean()
rolling_loss = qlike(realized_var[-len(rolling.volatility_):], rolling.volatility_ ** 2).mean()

print(ewma.predict(h=5))
print(rolling.predict(h=5))
print(ewma_loss, rolling_loss)

Portfolio Value

This repository shows framework-style Python work: common interfaces, reusable model classes, experiment notebooks, and quantitative evaluation metrics. It is small, but it demonstrates how research code can be organized into something cleaner than one-off notebooks.

About

Python framework for reusable volatility forecasting experiments and QLIKE evaluation.

Topics

Resources

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages