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.
-
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.
-
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.
-
Python Visualization (
main.py
): A script to visualize the stock price paths and hedging errors using thepandas
,matplotlib
, andseaborn
libraries.
- C++ Compiler: Ensure you have a C++ compiler installed (e.g.,
g++
). - Python Environment: Requires Python 3.x with
pandas
,matplotlib
, andseaborn
installed.
-
Compilation: Compile the C++ program using:
g++ -o main BSModel.cpp DataRow.cpp utils.cpp main.cpp
-
Execution: Run the compiled program:
./main
-
User Interaction: The program will prompt you to select functionalities and provide necessary inputs. Follow the prompts to provide relevant parameters.
-
Results: After computation, the program will generate CSV files with results.
After obtaining CSV outputs, you can visualize the results:
-
Execute the Python script:
python main.py
-
The script will read CSV files and generate visualizations such as stock price paths and histograms of hedging errors.
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.