Skip to content

longtuge-w/Delta-Hedge-Method-for-Options

Repository files navigation

Delta-Hedge-Method-for-Options

Delta Hedging Strategy Implementation

This repository contains a comprehensive C++ and Python-based implementation of the Delta Hedging strategy using the Black-Scholes model. The project provides functionalities to simulate stock price paths, implement delta hedging, and visualize results.

Table of Contents

Files Overview

  1. Header Files (*.h): These files define the structure and prototypes of various functionalities.

    • BSModel.h: Contains functions related to the Black-Scholes model.
    • DataRow.h: Defines the structure and functions for data rows related to option contracts.
    • utils.h: Provides utility functions for searching and CSV export.
    • test.h: Contains the main logic and testing suite for the project.
  2. Implementation Files (*.cpp): These files provide the actual implementation of the functions.

    • BSModel.cpp: Black-Scholes model computations.
    • DataRow.cpp: Functions for managing data rows.
    • utils.cpp: Utility function implementations.
    • main.cpp: The main driver for the program.
  3. Python Visualization (main.py): A script to visualize the stock price paths and hedging errors using the pandas, matplotlib, and seaborn libraries.

Setup and Requirements

  1. C++ Compiler: Ensure you have a C++ compiler installed (e.g., g++).
  2. Python Environment: Requires Python 3.x with pandas, matplotlib, and seaborn installed.

Implementation Guide

  1. Compilation: Compile the C++ program using:

    g++ -o main BSModel.cpp DataRow.cpp utils.cpp main.cpp
  2. Execution: Run the compiled program:

    ./main
  3. User Interaction: The program will prompt you to select functionalities and provide necessary inputs. Follow the prompts to provide relevant parameters.

  4. Results: After computation, the program will generate CSV files with results.

Visualization

After obtaining CSV outputs, you can visualize the results:

  1. Execute the Python script:

    python main.py
  2. The script will read CSV files and generate visualizations such as stock price paths and histograms of hedging errors.

Support and Contributions

For issues, recommendations, or contributions, please open a GitHub issue or submit a pull request.


Note: Always ensure you understand the code and adjust parameters as per your specific requirements.