Heston Model Calibration in the "Real" World with Python - S&P500 Index Options

Поділитися
Вставка
  • Опубліковано 12 чер 2024
  • The Heston model is a useful model for simulating stochastic volatility and its effect on the potential paths an asset can take over the life of an option. It's popular because of:
    - easy closed-form solution for European option pricing
    - no risk of negative variances
    - incorporation of leverage effect
    This allows for more effective modeling than the Black-Scholes formula allows due to its restrictive assumption of constant volatility.
    One of the nice things about the Heston model for European option prices is that there is a semi-analytical closed-form solution once you have the characteristic function. In this video we will go through the mathematics of the characteristic funciton for European Option prices, implement this numerical integration in python and then calibrate the model to real world index option prices.
    We will be using the S&P500 Index Options to calibrate the risk-neutral Heston Model. As a stochastic volatility model, the heston model can incorporate the real-world volatility smile within it's pricing dynamics.
    Here I have drawn on a number of academic papers/online resources for reference:
    - Heston Girsanov's Formula: quant.stackexchange.com/quest...
    - Heston PDE : uwspace.uwaterloo.ca/bitstrea...
    - Heston Characteristic Eq :www.maths.univ-evry.fr/pages_...
    - Heston Implementation : hal.sorbonne-universite.fr/ha...
    - Heston Calibration : / build-the-heston-model...
    ★ ★ Code Available on GitHub ★ ★
    GitHub: github.com/TheQuantPy
    Specific Tutorial Link: github.com/TheQuantPy/youtube...
    00:00 Intro
    00:45 The Mathematics Explained
    09:05 Python Implementation of Semi-Analytical Solution
    14:00 Real World Data - Options & Yield Curve
    19:50 Heston Model Calibration
    ★ ★ QuantPy GitHub ★ ★
    Collection of resources used on QuantPy UA-cam 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.

КОМЕНТАРІ • 43

  • @derekwu210
    @derekwu210 2 роки тому

    I'll be doing SOA (Society of Actuary)'s QFI Quantitative Finance exam in a few weeks. this video connected the dots for me. Thanks so much!

  • @qiguosun129
    @qiguosun129 5 місяців тому

    This lecture is really deep but intuitive. If I write a research paper, it will be pleasure to cite your work.

  • @anetesperon4526
    @anetesperon4526 2 роки тому +12

    This was amazing!! Could you go over how Heston model calibration for American options would look like, but with JUMPS added to the model, please?

  • @ramonaalexandra1994
    @ramonaalexandra1994 2 роки тому

    Amazing! thank you so much!

  • @Med.El-amine
    @Med.El-amine 11 місяців тому

    You are amazing and exceptional ❤🎉

  • @houssamabella263
    @houssamabella263 Рік тому

    thank you so much this video help me

  • @bryan-9742
    @bryan-9742 2 роки тому +1

    This is great

  • @fritmore
    @fritmore 7 місяців тому +2

    great walkthrough ur code thx
    but still waiting for the AMERICAN Heston model!!!

  • @mohamadghrayeb6923
    @mohamadghrayeb6923 2 роки тому

    A bates extension on this would be amazing and a bit easy since it only adds the jump component!

  • @annami797
    @annami797 Рік тому

    Great topic, thank you! Could you describe the dataset you had. Did you have a historical data (if yes how long) or just actual prices with maturities?

  • @junhuiwoo8966
    @junhuiwoo8966 2 роки тому +1

    what a great video so useful to me thanks.
    Can you give me a lecture on SABR model ?

  • @raki7881
    @raki7881 3 місяці тому

    thanks. Great informative video. what changes if instead of calls if need to calibrate for put prices?

  • @baijuthomas3716
    @baijuthomas3716 2 роки тому +1

    Could you compare the Heston vs the Bachelier model at some point because it sounds like the Pros (aside from the Brownian vs random process between them) of Heston is similar to Bach so trying to understand the use case for model selection here, do you select the model based on the properties of the underlying instrument. Thanks.

  • @mountaindrew_
    @mountaindrew_ Рік тому

    Hello! Are you assuming the pure expectations hypothesis at 15:15 when you say you want to use the present term structure to discount at risk free?

  • @calvinyao1424
    @calvinyao1424 Рік тому

    Awesome video! I am doing a course project on this topic. Somehow I could not get to the same integrand as yours. Mine is the same as the one shown in the paper Not-so-complex logarithms in the Heston model. How did you remove the discount factor from the second part of the integrand? Also the entry before the first part that I got is e^{-r*\tau}.

    • @ohotnik_na_shalavvvvv4223
      @ohotnik_na_shalavvvvv4223 Рік тому

      I got the same thing. do you understand how did he remove the discount factor from the second part of the integrand?

  • @chymoney1
    @chymoney1 2 роки тому +4

    How does the Heston model actually play out when used for options trading? I think it is certainly beautiful as a math person, but I have heard many say the fine-tuning of the hyper parameters make the Heston model rather cumbersome to use in practice, so many just stick with Black-Scholes, or a modified Black-Scholes or use local volatility model. Also I have wondered since we are calibrating the Heston model from a price surface which was calculated from the Black-Scholes model, how can it be a better predictor? These are just some naive questions as a beginner quant. Great video thank you for your time.

    • @michelebellipanni2373
      @michelebellipanni2373 2 роки тому +1

      It is not a problem of prediction. The sense of using option volatility quotes to get prices with black & scholes is to consistently calibrate a model (Heston, Variance gamma, etc.) to the market. Obviously none of us will price a derivative instrument better than the market does (the investment Banks models used for this purpose are very sophisticated), so your goal is to build a model that is consistent with the market for pricing new derivatives for your bank's client , which are not listed in a ordinary market.

    • @chymoney1
      @chymoney1 2 роки тому +1

      @@michelebellipanni2373 If I understood correctly; you’re saying it is pointless to use Heston to for vanilla options and only useful for exotic options.

    • @michelebellipanni2373
      @michelebellipanni2373 2 роки тому +2

      If the vanilla instruments you are talking about are quoted, you'll use the realized implied- volatility and the Black & Scholes formula because it's a closed form and It works Faster (time in finance Is a very importante asset) . Heston is an amazing mathematical model and gives US much more than just a price. But obviously in all these discourses it is necessary (also in the construction of stochastic models) take a position .Let's say that the use of Heston could be convenient but It depend on the purpose. (Trading, Hedging,build new instruments,ecc..)
      I don't know if I have explained myself well, I am an Italian student and I do my best with English.

    • @chymoney1
      @chymoney1 2 роки тому

      @@michelebellipanni2373 Your English is great and thanks that makes sense.

  • @user-lj8mf1tu6v
    @user-lj8mf1tu6v 2 місяці тому

    Hi I'm not understand about what you mention, bj can combine to b and uj can combine to u, can you explain more further in detail, thank you!

  • @ZEU666
    @ZEU666 7 місяців тому

    In the parameters, how can we set a proper x0 for each of the parameters?

  • @bachpham5357
    @bachpham5357 Рік тому

    Can you do the same for Double Heston Model ?

  • @armandcharlesngabirano3795
    @armandcharlesngabirano3795 2 роки тому

    I have a very important question: when the rates are negative like in Europe; can the Heston model help in pricing a European type of options?

    • @QuantPy
      @QuantPy  2 роки тому

      The blackscholes or Heston model does not make the assumption of positive interest rates r > 0. So you can definitely use negative interest rates, just be aware your borrowing rate is likely different from your lending rate

  • @dodge7750
    @dodge7750 Рік тому

    Thank u can you do the same with Excell data,please?

  • @lightningblade9347
    @lightningblade9347 2 роки тому

    Thank you so much for the tutorial! I have a question if you don't mind: Can the data you used be found free in yahoo finance?

    • @QuantPy
      @QuantPy  2 роки тому

      Options data can be tricky, but if you find a free resource feel free to use the data of course

    • @sewliboral1400
      @sewliboral1400 Рік тому

      @@QuantPy Where can i find the data from free resource

  • @chaozhou3777
    @chaozhou3777 23 дні тому

    Tried to run the Jupyter Notebook but EOD returned error message: "Only EOD data allowed for free users. Please, contact our support team"

  • @atreyadas4453
    @atreyadas4453 2 роки тому

    What is the unit for Kappa in the Heston Model?

    • @QuantPy
      @QuantPy  2 роки тому +1

      variance is unitless, and so is kappa

  • @user-pi9bp8ji1t
    @user-pi9bp8ji1t 7 місяців тому

    Awesome video, but I noticed there is a mistake in one integral form, the e^rt should be e^-rt and placed before integral.

    • @QuantPy
      @QuantPy  7 місяців тому

      Thanks for watching, I’ve double checked the calcs, looks ok to me - can’t tell what you mean. But if you still think there’s an error, tell me which line you think should be changed: quantpy.com.au/stochastic-volatility-models/heston-model-calibration-to-option-prices/
      Thanks

    • @user-pi9bp8ji1t
      @user-pi9bp8ji1t 7 місяців тому

      @@QuantPy I think one integral formula should be changed to '$\large C(S_0, K, v_0, \tau) = \frac{1}{2}(S_0 - Ke^{-r \tau}) + \frac{1}{\pi} \int^\inf_0 \Re [ e^{-r\tau} (\frac{\varphi(\phi-i)}{i\phi K^{i\phi}} - K\frac{\varphi(\phi)}{i\phi K^{i\phi}} )] d\phi$'. I have double checked this formula with two integral form.

    • @user-pi9bp8ji1t
      @user-pi9bp8ji1t 7 місяців тому

      @@QuantPy And I have another question, some books and papers just set lambda equal to zero,but Heston original paper and your videos don't,could you explain what is the difference?

    • @QuantPy
      @QuantPy  7 місяців тому

      In the real world the market price of risk needs to be accounted for. There will nearly always be a difference between risk neutral value and the premium you have to pay in the market place for purchasing this product/hedge ect.

    • @user-pi9bp8ji1t
      @user-pi9bp8ji1t 7 місяців тому +1

      @@QuantPy So in general, I can just set lambda to be zero when I use Heston model

  • @ekiller1103
    @ekiller1103 Рік тому

    How can I apply this having yahoo finance as a parameter?

  • @aymaneleboss
    @aymaneleboss 11 місяців тому

    10:22 I do think it's Real(exp(-r*tau .... and not Real(exp(r*tau...
    We divide by phi(-i) which is E(exp(x)) under the risk neutral measure which is S0 *exp(r*tau)

  • @DeejayGabin
    @DeejayGabin Рік тому

    Easier to read rates using pandas.read_csv using the link to download CSV file

  • @aarondelarosa3146
    @aarondelarosa3146 9 місяців тому

    Hello Jonathan. I'm facing serious issues to replicate your code. Specially those related to download data from EodHistoricalData using my API. I can't download Options Data. Can I send you the code by email, so you can fix it?