Skip to content

utterwqlnut/options-pricing-tool

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

28 Commits
 
 
 
 

Repository files navigation

Options Pricing Tool

This project is an options pricing tool, meant to provide visualizations and options pricing data through black scholes and other pricing models. To get stock time series data, the alpha vantage api is used, and for visualizations we use Matplotplusplus. Required External Libraries: [https://github.com/nlohmann/json], [https://github.com/alandefreitas/matplotplusplus], [https://github.com/libcpr/cpr]

Black Scholes Model (Done)

Defined as $C=N(d_1)S-N(d_2)Ke^{-rt}$ and $P=C-S+K*e^{-rt}$. With $d_1=\frac{\ln{\frac{S}{K}}+(r+\sigma^2/2)t}{\sigma\sqrt(t)}$ and $d_2=d_1-\sigma\sqrt{t}$ We use historical volatility of user-defined window $w$ for implied volatility.

Screenshot 2025-05-27 at 4 52 14 PM

Here is a generated visualization for AAPL stock.

Monte Carlo Model (Done)

Numerical technique to approximate option price by simulating many possible stock paths. Unlike typical monte carlo methods which follow the geometric brownian motion, this model will sample from a user-defined probability distribution during the wiener process. This makes the model more generalizable and applicable to different market scenarios.

Screenshot 2025-06-02 at 2 41 32 AM

AAPL Monte Carlo paths with right skewed distribution sampling

Wiener Process (Done)

$$dS=\mu S_t dt + \sigma S_t dW_t$$

$$dW_t = \sqrt{dt} \cdot Z$$

Typically $Z \sim N(0,1)$ however in our model Z samples from the user defined distribution.

Sampling (Done)

Because we need to support a variety of probability distributions, we will be using accept-reject sampling.

Suppose we have an uknown distribution $f(x)$ we wish to sample from. We then use a proposal distribution $h(x)$ (In our case it is a uniform distribution) which is easier to sample from and acts as a container around $f(x)$, meaning there is some constant c such that $f(x) \leq ch(x)$.

The algorithm then follows

  1. Draw candidate $z$ from $h(x)$ and $\mu$ from $U(0,1)$
  2. If $\mu \leq \frac{f(z)}{ch(z)}$ than $z$ is a valid draw, otherwise go back to 1.

Usage

If you are on a system other than MacOS you may need to edit the MakeFile. To compile and run the script do

make
./run_script

To choose a probability distribution for monte carlo, edit the class "PDF" in helpers/math.cpp filling in the max_density on the PDF, min and max domains of the PDF, and the PDF function.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published