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
Retail-Sim is python package to easily create synthetic dataset of retaile store.

Retailer's Sale Data Simulation Retail-Sim is python package to easily create synthetic dataset of retaile store. Simulation Model Simulator consists

Corca AI 7 Sep 30, 2022
CRISP: Critical Path Analysis of Microservice Traces

CRISP: Critical Path Analysis of Microservice Traces This repo contains code to compute and present critical path summary from Jaeger microservice tra

Uber Research 110 Jan 06, 2023
Average time per match by division

HW_02 Unzip matches.rar to access .json files for matches. Get an API key to access their data at: https://developer.riotgames.com/ Average time per m

11 Jan 07, 2022
Stream-Kafka-ELK-Stack - Weather data streaming using Apache Kafka and Elastic Stack.

Streaming Data Pipeline - Kafka + ELK Stack Streaming weather data using Apache Kafka and Elastic Stack. Data source: https://openweathermap.org/api O

Felipe Demenech Vasconcelos 2 Jan 20, 2022
Implementation in Python of the reliability measures such as Omega.

OmegaPy Summary Simple implementation in Python of the reliability measures: Omega Total, Omega Hierarchical and Omega Hierarchical Total. Name Link O

Rafael Valero Fernández 2 Apr 27, 2022
Exploratory data analysis

Exploratory data analysis An Exploratory data analysis APP TAPIWA CHAMBOKO 🚀 About Me I'm a full stack developer experienced in deploying artificial

tapiwa chamboko 1 Nov 07, 2021
Display the behaviour of a realtime program with a scope or logic analyser.

1. A monitor for realtime MicroPython code This library provides a means of examining the behaviour of a running system. It was initially designed to

Peter Hinch 17 Dec 05, 2022
Developed for analyzing the covariance for OrcVIO

about This repo is developed for analyzing the covariance for OrcVIO environment setup platform ubuntu 18.04 using conda conda env create --file envir

Sean 1 Dec 08, 2021
A meta plugin for processing timelapse data timepoint by timepoint in napari

napari-time-slicer A meta plugin for processing timelapse data timepoint by timepoint. It enables a list of napari plugins to process 2D+t or 3D+t dat

Robert Haase 2 Oct 13, 2022
Useful tool for inserting DataFrames into the Excel sheet.

PyCellFrame Insert Pandas DataFrames into the Excel sheet with a bunch of conditions Install pip install pycellframe Usage Examples Let's suppose that

Luka Sosiashvili 1 Feb 16, 2022
💬 Python scripts to parse Messenger, Hangouts, WhatsApp and Telegram chat logs into DataFrames.

Chatistics Python 3 scripts to convert chat logs from various messaging platforms into Pandas DataFrames. Can also generate histograms and word clouds

Florian 893 Jan 02, 2023
A program that uses an API and a AI model to get info of sotcks

Stock-Market-AI-Analysis I dont mind anyone using this code but please give me credit A program that uses an API and a AI model to get info of stocks

1 Dec 17, 2021
Validated, scalable, community developed variant calling, RNA-seq and small RNA analysis

Validated, scalable, community developed variant calling, RNA-seq and small RNA analysis. You write a high level configuration file specifying your in

Blue Collar Bioinformatics 917 Jan 03, 2023
Sensitivity Analysis Library in Python (Numpy). Contains Sobol, Morris, Fractional Factorial and FAST methods.

Sensitivity Analysis Library (SALib) Python implementations of commonly used sensitivity analysis methods. Useful in systems modeling to calculate the

SALib 663 Jan 05, 2023
Pizza Orders Data Pipeline Usecase Solved by SQL, Sqoop, HDFS, Hive, Airflow.

PizzaOrders_DataPipeline There is a Tony who is owning a New Pizza shop. He knew that pizza alone was not going to help him get seed funding to expand

Melwin Varghese P 4 Jun 05, 2022
PySpark bindings for H3, a hierarchical hexagonal geospatial indexing system

h3-pyspark: Uber's H3 Hexagonal Hierarchical Geospatial Indexing System in PySpark PySpark bindings for the H3 core library. For available functions,

Kevin Schaich 12 Dec 24, 2022
Data Analytics: Modeling and Studying data relating to climate change and adoption of electric vehicles

Correlation-Study-Climate-Change-EV-Adoption Data Analytics: Modeling and Studying data relating to climate change and adoption of electric vehicles I

Jonathan Feng 1 Jan 03, 2022
Full automated data pipeline using docker images

Create postgres tables from CSV files This first section is only relate to creating tables from CSV files using postgres container alone. Just one of

1 Nov 21, 2021
An ETL framework + Monitoring UI/API (experimental project for learning purposes)

Fastlane An ETL framework for building pipelines, and Flask based web API/UI for monitoring pipelines. Project structure fastlane |- fastlane: (ETL fr

Dan Katz 2 Jan 06, 2022
Senator Trades Monitor

Senator Trades Monitor This monitor will grab the most recent trades by senators and send them as a webhook to discord. Installation To use the monito

Yousaf Cheema 5 Jun 11, 2022