Giter Club home page Giter Club logo

option-contract-webpage's Introduction

Black Scholes Model in Python

Alex Habegger

This is a Python implementation of the Black Scholes Model for option pricing and a collection of helper functions for calculating option Greeks and implied volatility. The code also includes an essential MySQL database interaction to upload option data.

Overview

The Black-Scholes Model is a mathematical model for pricing European options. It makes certain assumptions:

  • No dividends are paid out during the life of the option.
  • Markets are random (i.e., market movements cannot be predicted).
  • There are no transaction costs in buying the option.
  • The risk-free rate and volatility of the underlying asset are known and constant.
  • The returns on the underlying asset are log-normally distributed.
  • The option is European and can only be exercised at expiration.

Usage

The main functions provided by this code are:

  • black_scholes(s, k, t, v, rf, div, cp): Price an option using the Black-Scholes model.
  • call_price(s, k, t, v, rf, div): Calculate the price of a call option.
  • put_price(s, k, t, v, rf, div): Calculate the price of a put option.
  • call_delta, call_gamma, call_vega, call_theta, call_rho: Calculate the Greeks for call options.
  • put_delta, put_gamma, put_vega, put_theta, put_rho: Calculate the Greeks for put options.
  • call_implied_volatility(Price, S, K, T, r): Calculate the implied volatility for call options.
  • put_implied_volatility(Price, S, K, T, r): Calculate the implied volatility for put options.

Database Interaction

The code includes functions to interact with a MySQL database:

  • sql_upload(ticker): Upload options data for a given ticker to a MySQL database.
  • clear_all_tables(): Clear all tables in the MySQL database.
  • clear_table(tablename): Clear a specific table in the MySQL database.

Disclaimer

This project is part of an academic exercise and is not intended for commercial use.

option-contract-webpage's People

Contributors

ahabegger avatar

Watchers

 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.