Option Pricing Calculator using the Binomial Pricing Method (No Libraries Required)

Overview

Binomial Option Pricing Calculator

Option Pricing Calculator using the Binomial Pricing Method (No Libraries Required)

Background

A derivative is a financial instrument that derives its value from the price of an underlying asset. An option gives the owner the ability to buy or sell the underlying asset at pre-determined price. An option that allows the holder to buy the asset at the pre-determined price (also known as the exercise or strike price) is called a call option. An option that lets the owner sell the underlying asset at the strike price is called a put option. There are three key types of options, a European option allows the holder to exercise ('redeem') the option only at maturity of the option. An American option can be exercised any time before maturity. A Bermudan option is exercisable at pre-deteremined dates decided at the creation of the option.

The binomial pricing method is one of the three most common methods used to value options - the others being the Black-Scholes model and a Monte Carlo simulation. The method predicts the price of the underlying asset at intervals (branches) between now and maturity of the option contract. This creates a tree showing the price movements of the asset, which can be used to find the fair value of the option. Unlike Black-Scholes, the binomial method allows the intrinsic value of the option to be calculated prior to maturity, better representing the value of American and Bermudan options which have the option of early exercise.

Pricing options using this method is done by:

  1. Determining the magnitude that stock prices will rise or fall between each branch.
  2. Calculating the probability that the stock price will move upwards or downward.
  3. Forming the binomial stock price tree with the specified number of branches.
  4. Calculate the payoff of the option at maturity.
  5. Working backwards, value the option by discounting the value of the option at the following nodes using. If the option is American or Bermudan and exercisible at that branch, then the value of the option if it was exercised is calculated, if it is greater than the discoutned value, it becomes the calculated value of the branch.
  6. The value derived at the top of the tree is the fair value of the option today.

Features of the Script

  • Does not require any libraries - it will work in base python3 and immune to changes in libraries
  • Option type is specified as a parameter allowing easy implementations
  • Returns and displays the calculated stock tree

The following assumptions are made by the model:

  • No dividends are paid across the option's life
  • Risk-Free rate is constant across the option's life
  • The price will move up or down each period

Variables and Paramaters

The variables required are:

Name Symbol Description
Stock Price s The current price of the underlying asset (time 0)
Exercise Price x The strike price of the option contract
Time to Maturity t The time until maturity of the option contract (in years)
Risk-Free Rate r The current risk-free rate
Branches/Steps b The number of branches used to value the option
Volatility v The volatility of the price movements in the underlying asset

Optional variables are:

Name Symbol Description
Option Nationality nat 'A' for American (default), 'B' for Bermudan, 'E' for European
Option Type typ 'C' for Call (default), 'P' for Put
Print Results prnt True to enable printing (default), False to disable
Exercisible Periods exP The branches that a Bermudan option can be exercised

Related Projects

Beta calculator with stock data downloader: https://github.com/sammuhrai/beta-calculator

Disclaimer

Script is for educational purposes and is not to be taken as financial advice.

Owner
sammuhrai
sammuhrai
Probabilistic reasoning and statistical analysis in TensorFlow

TensorFlow Probability TensorFlow Probability is a library for probabilistic reasoning and statistical analysis in TensorFlow. As part of the TensorFl

3.8k Jan 05, 2023
This module is used to create Convolutional AutoEncoders for Variational Data Assimilation

VarDACAE This module is used to create Convolutional AutoEncoders for Variational Data Assimilation. A user can define, create and train an AE for Dat

Julian Mack 23 Dec 16, 2022
A model checker for verifying properties in epistemic models

Epistemic Model Checker This is a model checker for verifying properties in epistemic models. The goal of the model checker is to check for Pluralisti

Thomas Träff 2 Dec 22, 2021
Demonstrate the breadth and depth of your data science skills by earning all of the Databricks Data Scientist credentials

Data Scientist Learning Plan Demonstrate the breadth and depth of your data science skills by earning all of the Databricks Data Scientist credentials

Trung-Duy Nguyen 27 Nov 01, 2022
Elasticsearch tool for easily collecting and batch inserting Python data and pandas DataFrames

ElasticBatch Elasticsearch buffer for collecting and batch inserting Python data and pandas DataFrames Overview ElasticBatch makes it easy to efficien

Dan Kaslovsky 21 Mar 16, 2022
Tokyo 2020 Paralympics, Analytics

Tokyo 2020 Paralympics, Analytics Thanks for checking out my app! It was built entirely using matplotlib and Tokyo 2020 Paralympics data. This applica

Petro Ivaniuk 1 Nov 18, 2021
Retentioneering 581 Jan 07, 2023
scikit-survival is a Python module for survival analysis built on top of scikit-learn.

scikit-survival scikit-survival is a Python module for survival analysis built on top of scikit-learn. It allows doing survival analysis while utilizi

Sebastian Pölsterl 876 Jan 04, 2023
Weather Image Recognition - Python weather application using series of data

Weather Image Recognition - Python weather application using series of data

Kushal Shingote 1 Feb 04, 2022
Fancy data functions that will make your life as a data scientist easier.

WhiteBox Utilities Toolkit: Tools to make your life easier Fancy data functions that will make your life as a data scientist easier. Installing To ins

WhiteBox 3 Oct 03, 2022
Driver Analysis with Factors and Forests: An Automated Data Science Tool using Python

Driver Analysis with Factors and Forests: An Automated Data Science Tool using Python 📊

Thomas 2 May 26, 2022
Snakemake workflow for converting FASTQ files to self-contained CRAM files with maximum lossless compression.

Snakemake workflow: name A Snakemake workflow for description Usage The usage of this workflow is described in the Snakemake Workflow Catalog. If

Algorithms for reproducible bioinformatics (Koesterlab) 1 Dec 16, 2021
Churn prediction with PySpark

It is expected to develop a machine learning model that can predict customers who will leave the company.

3 Aug 13, 2021
High Dimensional Portfolio Selection with Cardinality Constraints

High-Dimensional Portfolio Selecton with Cardinality Constraints This repo contains code for perform proximal gradient descent to solve sample average

Du Jinhong 2 Mar 22, 2022
Port of dplyr and other related R packages in python, using pipda.

Unlike other similar packages in python that just mimic the piping syntax, datar follows the API designs from the original packages as much as possible, and is tested thoroughly with the cases from t

179 Dec 21, 2022
📊 Python Flask game that consolidates data from Nasdaq, allowing the user to practice buying and selling stocks.

Web Trader Web Trader is a trading website that consolidates data from Nasdaq, allowing the user to search up the ticker symbol and price of any stock

Paulina Khew 21 Aug 30, 2022
ped-crash-techvol: Texas Ped Crash Tech Volume Pack

ped-crash-techvol: Texas Ped Crash Tech Volume Pack In conjunction with the Final Report "Identifying Risk Factors that Lead to Increase in Fatal Pede

Network Modeling Center; Center for Transportation Research; The University of Texas at Austin 2 Sep 28, 2022
Data Intelligence Applications - Online Product Advertising and Pricing with Context Generation

Data Intelligence Applications - Online Product Advertising and Pricing with Context Generation Overview Consider the scenario in which advertisement

Manuel Bressan 2 Nov 18, 2021
PyTorch implementation for NCL (Neighborhood-enrighed Contrastive Learning)

NCL (Neighborhood-enrighed Contrastive Learning) This is the official PyTorch implementation for the paper: Zihan Lin*, Changxin Tian*, Yupeng Hou* Wa

RUCAIBox 73 Jan 03, 2023