Binomial Option Pricing Model || Theory & Implementation in Python

Sdílet
Vložit
  • čas přidán 8. 07. 2024
  • Today I will introduce the Theory of the Binomial Asset Pricing Model and show how you can implement the binomial tree model to price a European call option in Python. The theory section of this video is long (sorry) and aims at giving you the absolute basics for understanding why and how to derive the discounted expectation of future payoffs under risk-neutral probabilities given the Binomial Model.
    For those who just want to code, please skip ahead to the Python Implementation section. I will take you through two implementations of a simple binomial tree model in Python, one that will use ‘for loops’ to step through each node at each time step (a function I have defined as binomial tree slow), and the other (binomial tree fast) will vectorize these steps using numpy arrays, improving overall computation time as N time steps increase. Although not necessary for the example today, using numpy arrays and vectorizing our calculations will improve computations as we delve deeper into financial mathematics and implementation heading forward.
    In this tutorial series we will be breaking down the theory described and published in Steven Shreve’s book’s Stochastic Calculus for Finance I & II. As a guide for implementing these concepts in Python, we will refer to the numerical methods and practices outlined in Les Clewlow & Chris Strickland’s book Implementing Derivatives Models.
    00:00 Intro
    00:50 Theory || What is Arbitrage? - Type I & II
    04:20 Theory || No Arbitrage Pricing - The Law of One Price
    05:47 Theory || One-period Binomial Model
    11:00 Theory || Deriving the discounted expectation of future payoffs under risk-neutral probabilities
    20:10 Theory || No Arbitrage Conditions
    24:10 Theory || Multi-period Binomial Model
    29:50 Python Implementation || Binomial Tree Slow
    41:12 Python Implementation || Binomial Tree Fast
    46:55 Python Implementation || Comparing the Slow vs Fast Implementation
    ★ ★ Code Available on GitHub ★ ★
    GitHub: github.com/TheQuantPy
    Specific Tutorial Link: github.com/TheQuantPy/youtube...
    ★ ★ QuantPy GitHub ★ ★
    Collection of resources used on QuantPy CZcams channel. github.com/thequantpy
    ★ ★ Discord Community ★ ★
    Join a small niche community of like-minded quants on discord. / discord
    ★ ★ Support our Patreon Community ★ ★
    Get access to Jupyter Notebooks that can run in the browser without downloading python.
    / quantpy
    ★ ★ ThetaData API ★ ★
    ThetaData's API provides both realtime and historical options data for end-of-day, and intraday trades and quotes. Use coupon 'QPY1' to receive 20% off on your first month.
    www.thetadata.net/
    ★ ★ Online Quant Tutorials ★ ★
    WEBSITE: quantpy.com.au
    ★ ★ Contact Us ★ ★
    EMAIL: pythonforquants@gmail.com
    Disclaimer: All ideas, opinions, recommendations and/or forecasts, expressed or implied in this content, are for informational and educational purposes only and should not be construed as financial product advice or an inducement or instruction to invest, trade, and/or speculate in the markets. Any action or refraining from action; investments, trades, and/or speculations made in light of the ideas, opinions, and/or forecasts, expressed or implied in this content, are committed at your own risk an consequence, financial or otherwise. As an affiliate of ThetaData, QuantPy Pty Ltd is compensated for any purchases made through the link provided in this description.

Komentáře • 28

  • @frederikwoite3916
    @frederikwoite3916 Před rokem +5

    You are beyond skilled in both teaching and QF!

  • @nielsenhari
    @nielsenhari Před 2 lety +6

    Thank you so much
    I get it now. You explained everything in 30min very clear, and there is our teacher taking weeks and I got nothing.
    Good job!!!

  • @teroliikala
    @teroliikala Před 2 lety +1

    Brilliant channel. Keep it up!

  • @Picklpickls
    @Picklpickls Před 2 lety +1

    It is an amazing video!

  • @benardkiplimo3508
    @benardkiplimo3508 Před 7 měsíci

    Well done!
    Thank you for the video

  • @georgekollias3442
    @georgekollias3442 Před 4 měsíci

    great video, simplicity at its best :)

  • @user-hy7ei1bk1h
    @user-hy7ei1bk1h Před rokem

    Hey I think it's great work here and now that I've started my financial engineering masters I can finally understand this. Just one thing tho - in the risk-neutral probabilities coding part, I think it should be u = np.exp(sigma * np.sqrt(T / N)), d = 1 / u, qu = (R - d) / (u - d)... I think there was a mixup somewhere

    • @gatsbyliu1084
      @gatsbyliu1084 Před rokem

      I am on my way study financial engineering master too :), so good to see another person in manadarin name

  • @KazekageKidd
    @KazekageKidd Před 3 lety +2

    Fantastic lesson mate., really like this approach.

  • @topticktom
    @topticktom Před 4 měsíci +1

    Didn"t understand any of it, but I did enjoy the 49 minutes anyways

  • @samuraifx_
    @samuraifx_ Před 11 hodinami

    Why does the bank account not decrease in value when going to the down state

  • @aniruddhvasishta8334
    @aniruddhvasishta8334 Před rokem +1

    At 32:49 -- won't you get a recombining tree even if ud is not 1 since if the stock price goes up then down the price will be udS_0 whereas if it goes down then up you'll get duS_0 which are the same thing? In these cases it's just not true that S_2 = S_0 but I don't see why that's an issue.

  • @gutefrage9425
    @gutefrage9425 Před 2 lety

    I understand it but what is it good for? How to apply it?

  • @chykeinvesting9429
    @chykeinvesting9429 Před 2 lety +1

    hey this was so great, I actually am using this to help me secure a quant position at a trading desk... I am just confused on one part, can i schedule a one on one?

  • @daves1413
    @daves1413 Před rokem +1

    In 15:36 you say "bank account (Su-Sd)". I think it should be "stock units" not "bank account units" for your beta, no?

  • @PJokerLP
    @PJokerLP Před rokem

    Hey, thanks for your video.
    But shouldn't type 2 arbitrage (3:36) be defined as P(V_T>=V_0) = 1, since your definition allows for losing money by having V_0 > 0.
    Greetings and stay healthy
    Marcel

  • @joshuakendrick3528
    @joshuakendrick3528 Před 25 dny

    How does the coding change for American options?

  • @jayjayf9699
    @jayjayf9699 Před 2 dny

    If you have a 4 step time tree the number of nodes does not equal N+1

  • @wqw9475
    @wqw9475 Před 2 lety

    Hi very nice video but I think you have forgotten to take the max between the expectation and the payoff for each node.

    • @jonathonemerick2084
      @jonathonemerick2084 Před 2 lety

      That’s the pricing formula for American style options not European style

    • @wqw9475
      @wqw9475 Před 2 lety

      @@jonathonemerick2084 For European you never need to take the max. I mean exactly for the US kind the author forgot to take the max for each node.

    • @QuantPy
      @QuantPy  Před 2 lety

      This video was for European pricing only. No max required for each node?
      Please check another video for American style option pricing czcams.com/video/K2Iy8bCmXjk/video.html

    • @wqw9475
      @wqw9475 Před 2 lety

      @@jonathonemerick2084 ok I got it because that's for European pricing. I thought it's for American kind. Thanks for your response.

    • @wqw9475
      @wqw9475 Před 2 lety

      @@QuantPy Yes I get it now since I was working on American side so I thought this example too. Thanks for the response.

  • @annog6673
    @annog6673 Před 2 lety

    You flipped the meaning of alpha and beta right on the middle and got a little bit confused there, didn't you? Or is there a meaning behind using beta for the weighting of stock and calling it bank account weighting?

    • @QuantPy
      @QuantPy  Před 2 lety

      The alpha and beta terms are just constants. In the video I've assigned Beta as the number of Shares and Alpha as the number of bank account units. Feel free to use your own constants and go through the math 👍