Skip to content

Repository files navigation

Systematic Options Research & Backtesting Engine

This repository contains a production-quality research and backtesting system for systematic options strategies, implemented in Python with a focus on clarity, extensibility, and quant-grade engineering practices.

High-Level Architecture

  • strategy_engine/config.py: Central configuration and dataclasses for experiment setup.
  • strategy_engine/pricing.py: Black–Scholes European option pricing, analytic Greeks, and implied volatility.
  • strategy_engine/data.py: Market data pipeline (equities via yfinance, realized volatility estimation, caching).
  • strategy_engine/strategy.py: Systematic options strategy definitions (signals and target positions).
  • strategy_engine/risk.py: Greeks-based portfolio risk management (delta/gamma/vega/theta limits and rebalancing).
  • strategy_engine/backtest.py: Daily backtester with PnL, expiries/assignment, and transaction costs.
  • strategy_engine/analytics.py: Performance analytics, plots, and CSV export.
  • research/summary_report.ipynb: Optional Jupyter notebook for exploratory analysis and reporting.

Installation

cd "/Users/divyanshbarodiya/Desktop/Strategy Engine"
python -m venv .venv
source .venv/bin/activate  # On Windows: .venv\Scripts\activate
pip install -r requirements.txt

Quick Start

python -m strategy_engine.run_example

This will:

  • Download equity data for a chosen underlying
  • Estimate realized volatility
  • Run a simple systematic cash-secured put strategy with Greeks-based risk controls
  • Produce:
    • Equity curve and drawdown plots
    • Greeks time series and exposure summaries
    • CSV exports of daily PnL and exposures

Important Note on Risk and Results

This repository intentionally demonstrates how a systematic short-options strategy can fail under leverage and margin stress if strict risk controls are not enforced.

The backtest highlights:

  • Margin utilization spikes: Portfolio can exceed available capital under stress
  • Forced liquidation: Deep drawdowns leading to capital exhaustion
  • Dominant residual PnL: Jump risk and early assignment effects not captured by Greeks attribution alone

This behavior is expected and is part of the research objective—to show the importance of robust risk management and margin discipline in options trading. In production, these scenarios would trigger hard stops and dynamic deleveraging.

Design Principles

  • Research-grade, not toy: Code is structured to match how a trading desk research stack would evolve.
  • Modular: Clear separation between pricing, data, strategy, risk, backtesting, and analytics.
  • Config-driven: Strategy, risk, and backtest parameters are configured via typed config objects.
  • Extensible: Easy to plug in new strategies (e.g., delta-neutral strangles, gamma overlays).

Future Improvements

  • Enforce hard margin caps and dynamic deleveraging: Add circuit breakers that force position reduction when margin utilization exceeds thresholds
  • Separate liquidation and jump PnL in attribution: Decompose residual PnL into discrete event-driven components
  • Volatility regime-aware position sizing: Scale notional per trade based on realized vol percentile and tail risk metrics
  • Enhanced early assignment modeling: More sophisticated probability models based on dividend timing and extrinsic value decay

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages