Giter VIP home page Giter VIP logo

option-pricing's Introduction

Option Pricing

The repository is a re-factorization (and some extensions) of the code for an FNCE40009 Advanced Derivative Securities assignment.

This repository is mainly designed for those who want to study option pricing. It is built purely on standard NumPy and SciPy packages.

I've tried my best to utilize the speed offered by NumPy array operations rather than using multiple for-loops, without sacrificing the ability to refer the code back to the equations in the textbook.

Debug/Improvements/AddOns will be implemented from time to time.

If you have any questions or want to report a bug, please open an issue. I am open to any corrections/suggestions. If you like it, or if it benefits you in some way, kindly give it a star ๐Ÿ˜Š.


Reference: most of this repository implements algorithms described in the following textbook.

@book{mcdonald2013derivatives,
  title={Derivatives markets (3rd edition)},
  author={McDonald, Robert Lynch},
  year={2013},
  publisher={Pearson Education}
}

Binomial Excel Illustration



Black-Scholes-Merton (BSM)

How to use: example_BSM.py

  • Chapter 12.1: European call call_value(), European put put_value()
  • Chapter 12.2: (class) GarmanKohlhagenForex
  • Chapter 12.5: implied volatility assume BSM model implied_vol()
  • Chapter 21.5: Merton jump diffusion merton_jump_diffusion()
  • Chapter 22: Exotic options (barrier options) cash_or_nothing_barrier_options()
  • Appendix 12.B: delta(), gamma(), theta(), vega(), rho(), psi()

Monte Carlo Simulation

How to use: example_monte_carlo.py

  • Chapter 18 & 19.3: stock_price_simulation()
  • Chapter 19.8: stock_price_simulation_with_poisson_jump()

The final predicted price is the average of all simulated prices at time T (column T).

Stock price S h 2h 3h ... T-h T
simulation 1 S1,T
simulation 2 S2,T
simulation 3 S3,T
... ...
  • vasicek() and cox_ingersoll_ross_model(): stochastic interest rate (work-in-progress).
  • heston(): stochastic volatility.

Note: the default case is two tables with constant values. Call these two functions before running stock_price_simulation().

Interest rate r h 2h 3h ... T-h T
simulation 1 r1,T
simulation 2 r2,T
simulation 3 r3,T
... ...
Volatility ฯƒ h 2h 3h ... T-h T
simulation 1 ฯƒ1,T
simulation 2 ฯƒ2,T
simulation 3 ฯƒ3,T
... ...
  • Chapter 19.4: european_call() & european_put()
  • Chapter 14.2 & 19.4: asian_avg_price()
  • Chapter 19.6: american_option_longstaff_schwartz(), Longstaff & Schwartz (2001).
  • Chapter 14 & 23: exotic options, e.g. barrier_option()
  • Chapter 23, exercise 23.12: look_back_european()

More References:

  • Merton, R. C. (1976). Option pricing when underlying stock returns are discontinuous. Journal of financial economics, 3(1-2), 125-144.
  • Garman, M. B. and Kohlhagen, S. W. (1983). "Foreign Currency Option Values." Journal of International Money and Finance 2, 231-237.
  • Longstaff, F. A., & Schwartz, E. S. (2001). Valuing American options by simulation: a simple least-squares approach. The review of financial studies, 14(1), 113-147.

For Fun:

Alt

option-pricing's People

Contributors

hsjharvey avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  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.