Coder Social home page Coder Social logo

geometric-brownian-paths-and-corresponding-greeks's Introduction

Geometric-Brownian-Paths-and-Corresponding-Greeks

This Python code implements a financial option pricing model using the Black-Scholes (BS) formula and generates multiple stock price paths using the Geometric Brownian Motion (GBM) process. The code also plots various option-related surfaces using matplotlib.

The code begins by importing necessary libraries, including NumPy, matplotlib, and scipy.stats. It defines an enumeration class OptionType to represent the type of options (CALL or PUT). The main functions in the code are as follows:

GeneratePathsGBM: This function generates multiple stock price paths using the Geometric Brownian Motion (GBM) process. It takes parameters such as the number of paths (NoOfPaths), the number of time steps (NoOfSteps), the time to maturity (T), risk-free interest rate (r), volatility (sigma), and initial stock price (S_0).

BS_Call_Put_Option_Price: This function calculates the Black-Scholes option price for either a call or a put option. It takes parameters such as the option type (CP), initial stock price (S_0), strike price (K), volatility (sigma), time to maturity (t), maturity time (T), and risk-free interest rate (r).

BS_Delta: This function computes the Delta value for a call or put option. Delta measures the sensitivity of the option price to changes in the underlying stock price.

BS_Gamma: This function calculates the Gamma value for an option. Gamma represents the rate of change of Delta concerning changes in the underlying stock price.

BS_Vega: This function computes the Vega value for an option. Vega indicates the sensitivity of the option price to changes in volatility.

mainCalculation: This function is the main part of the code. It sets up parameters for the simulation and then generates stock price paths using GeneratePathsGBM. After that, it prepares lambda functions for option price calculations, and it calculates and stores the values of call and put options, Delta, Gamma, and Vega for different stock prices and times. Finally, it plots various option-related surfaces using matplotlib.

Overall, this code demonstrates how to use the Black-Scholes formula to price call and put options and provides insights into the behavior of option prices and Greeks (Delta, Gamma, and Vega) under different scenarios of stock prices and time to maturity.

geometric-brownian-paths-and-corresponding-greeks's People

Contributors

aim-it4 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.