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
Anomaly Detection with R

AnomalyDetection R package AnomalyDetection is an open-source R package to detect anomalies which is robust, from a statistical standpoint, in the pre

Twitter 3.5k Dec 27, 2022
collect training and calibration data for gaze tracking

Collect Training and Calibration Data for Gaze Tracking This tool allows collecting gaze data necessary for personal calibration or training of eye-tr

Pascal 5 Dec 17, 2022
Processo de ETL (extração, transformação, carregamento) realizado pela equipe no projeto final do curso da Soul Code Academy.

Processo de ETL (extração, transformação, carregamento) realizado pela equipe no projeto final do curso da Soul Code Academy.

Débora Mendes de Azevedo 1 Feb 03, 2022
Gaussian processes in TensorFlow

Website | Documentation (release) | Documentation (develop) | Glossary Table of Contents What does GPflow do? Installation Getting Started with GPflow

GPflow 1.7k Jan 06, 2023
BErt-like Neurophysiological Data Representation

BENDR BErt-like Neurophysiological Data Representation This repository contains the source code for reproducing, or extending the BERT-like self-super

114 Dec 23, 2022
A simplified prototype for an as-built tracking database with API

Asbuilt_Trax A simplified prototype for an as-built tracking database with API The purpose of this project is to: Model a database that tracks constru

Ryan Pemberton 1 Jan 31, 2022
Maximum Covariance Analysis in Python

xMCA | Maximum Covariance Analysis in Python The aim of this package is to provide a flexible tool for the climate science community to perform Maximu

Niclas Rieger 39 Jan 03, 2023
Pyspark project that able to do joins on the spark data frames.

SPARK JOINS This project is to perform inner, all outer joins and semi joins. create_df.py: load_data.py : helps to put data into Spark data frames. d

Joshua 1 Dec 14, 2021
Accurately separate the TLD from the registered domain and subdomains of a URL, using the Public Suffix List.

tldextract Python Module tldextract accurately separates the gTLD or ccTLD (generic or country code top-level domain) from the registered domain and s

John Kurkowski 1.6k Jan 03, 2023
A Numba-based two-point correlation function calculator using a grid decomposition

A Numba-based two-point correlation function (2PCF) calculator using a grid decomposition. Like Corrfunc, but written in Numba, with simplicity and hackability in mind.

Lehman Garrison 3 Aug 24, 2022
A Python and R autograding solution

Otter-Grader Otter Grader is a light-weight, modular open-source autograder developed by the Data Science Education Program at UC Berkeley. It is desi

Infrastructure Team 93 Jan 03, 2023
Elementary is an open-source data reliability framework for modern data teams. The first module of the framework is data lineage.

Data lineage made simple, reliable, and automated. Effortlessly track the flow of data, understand dependencies and analyze impact. Features Visualiza

898 Jan 09, 2023
Efficient matrix representations for working with tabular data

Efficient matrix representations for working with tabular data

QuantCo 70 Dec 14, 2022
Projeto para realizar o RPA Challenge . Utilizando Python e as bibliotecas Selenium e Pandas.

RPA Challenge in Python Projeto para realizar o RPA Challenge (www.rpachallenge.com), utilizando Python. O objetivo deste desafio é criar um fluxo de

Henrique A. Lourenço 1 Apr 12, 2022
Data analysis and visualisation projects from a range of individual projects and applications

Python-Data-Analysis-and-Visualisation-Projects Data analysis and visualisation projects from a range of individual projects and applications. Python

Tom Ritman-Meer 1 Jan 25, 2022
Titanic data analysis for python

Titanic-data-analysis This Repo is an analysis on Titanic_mod.csv This csv file contains some assumed data of the Titanic ship after sinking This full

Hardik Bhanot 1 Dec 26, 2021
This is a python script to navigate and extract the FSD50K dataset

FSD50K navigator This is a script I use to navigate the sound dataset from FSK50K.

sweemeng 2 Nov 23, 2021
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
CINECA molecular dynamics tutorial set

High Performance Molecular Dynamics Logging into CINECA's computer systems To logon to the M100 system use the following command from an SSH client ss

J. W. Dell 0 Mar 13, 2022
PyStan, a Python interface to Stan, a platform for statistical modeling. Documentation: https://pystan.readthedocs.io

PyStan PyStan is a Python interface to Stan, a package for Bayesian inference. Stan® is a state-of-the-art platform for statistical modeling and high-

Stan 229 Dec 29, 2022