Simulating the Heston Model with Python | Stochastic Volatility Modelling

Поділитися
Вставка
  • Опубліковано 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 closed-form solution once you have the characteristic function. So, discretisation of the SDE is not required for valuing a European option, however if you would like to value other option types with complex features using the Heston model than you can use the following code.
    Written Tutorial on Medium: / simulating-the-heston-...
    ★ ★ Code Available on GitHub ★ ★
    GitHub: github.com/TheQuantPy
    Specific Tutorial Link: github.com/TheQuantPy/youtube...
    Great resource for explanation here in how to complete the Euler Discretization:
    - Euler and Milstein Discretization by Fabrice Douglas Rouah frouah.com/finance%20notes/Eu...
    00:00 Intro
    00:53 Heston Model Dynamics
    02:15 Monte Carlo Simulation and SDE Discretization
    05:03 Heston Model Simulation in Python
    10:00 Visualising the asset price density and volatility smile
    ★ ★ 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.

КОМЕНТАРІ • 35

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

    I love these videos btw. So many times in grad school they are like, "here is a model, figure it out on your own. You will be tested on it but we won't tell you what it means or how to do it." These videos are very helpful.

  • @prestonhanzely5322
    @prestonhanzely5322 2 роки тому +7

    Great video and explanations. Stochastic calculus is a hard to open door that when opened, reveals a lot about markets

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

      100% agree. You don't actually know what's happening until you go through it to understand what's actually going on and what the assumptions even mean.

  • @PiyapartB
    @PiyapartB 6 місяців тому

    Appreciate your content. You just saved my life!!! I am doing master in quantitative finance and just found your channel. Your code and explanation are well clarified and really help me with the coursework. I couldn't imagine If I didn't find your video at the first place.

  • @mountaindrew_
    @mountaindrew_ 2 роки тому +5

    Thank you very much for all the content you create on your channel! And by the way, a video about Girsanov’s theorem would be really nice!

  • @kevinmak1996
    @kevinmak1996 2 роки тому +3

    Great video! Can’t wait for the calibration video coming up :)

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

    Can't wait for the next tutorial! Thank you, very helpful

  • @kilocesar
    @kilocesar 2 місяці тому

    Yes finally an excelent chanel with deep content. please make a video about change in meaasure

  • @pritamsarkar2075
    @pritamsarkar2075 10 місяців тому

    I would very much appreciate a video series discussing rigorously the stochastic picture in finance. I have a background in Statistical Physics from where I learned about Random Processes. Now I believe a very thorough analytics as well as real world stochastic modelling would be very beneficial for many enthusiasts like me. I will look forward to this.
    Moreover, out of many YT resources I have found your contents, most reasonable and analytical. Thank you for your contribution.

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

    Thank you for the good video. 😉 Your explanation and code are very intuitive and concise to me. ❤❤

  • @evanhong1690
    @evanhong1690 6 місяців тому

    thanks for your work! They help me a lot

  • @jamesguan5225
    @jamesguan5225 6 місяців тому

    Really appreciating the content! For other audience who might potentially use milstein scheme from the reference, there is a typo in equation (18) ,in the "Fabrice Douglas Rouah" reference provided in the video description. I think it should be 0.5 * St * Vt * dt (Zs**2 - 1); The simulation would be just wrong using the original equation.

  • @OpenQuant
    @OpenQuant 10 місяців тому

    Great explanation!

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

    AHHHHH. We just finished up Derivatives in my MFE. This is awesome. For parameters are you guys going to do MLE on the historical data? Can't wait to see it!

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

    Thank you for the great video again. I just wanted to understand that how did you get parameter combination as initial value for heston and monte carlo? If I remember it correctly you might have answered it some video, but these parameter combinations can be found out using argmax(MLE) OR using machine learning NN and other non-linear machine learning models as output with input as market observable prices which then sampled over by uniform sampling method like Latin hypercube sampling?
    Is my understanding correct that black volatility surface can also be created using numerical iterative methods like newton rhapson method and also via Machine Learning NN and other classical machine learning models?
    Why we use MC method for simulating Stochastic Volatility Modelling equation rather than other numerical methods like Finite di erence, COS method and numerical integration?
    Why to use any of these classical models like heston to find option price when the prices can be sourced from bloomberg and other readily available tools easily and then later trained via machine learning ensemble models to get the model calibrated parameters for valuing an option in future date?

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

    Nice video. A question - how to estimate heston parameters using only underlying price data? Example: to compute IV of an option on xyz asset that don't have any options market. Would you suggest to look into any other model?

  • @quant-prep2843
    @quant-prep2843 Рік тому

    please start a discord server! its not a request , its an order. your channel is so great

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

      Thanks, have a discord server through patreon link in description

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

    Thank you for these great videos (btw I was being sarcastic/cheeky when i mentioned the pyvollib vectorized lib), but I was wondering what you did regarding the ValueError you get when you try to compute S_p, v_p/S_n, v_n via the heston function.
    ValueError: operands could not be broadcast together with shapes (252, ), (100_000, ) (underscore mine, for readability)

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

      nvm, I had a typo. used np.full(shape = (N + 1, N), fill_value = S0) instead of N+1, M

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

    Please make a content on Girsanov's theorem

  • @caetanogarelii6657
    @caetanogarelii6657 2 місяці тому

    Can you explain what measures and the risk neutral measure are? It's mentioned a lot but they're hard to understand.

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

    Do you have a video or code for pricing put option using Heston model?

  • @user-wp5gw3jl4s
    @user-wp5gw3jl4s Рік тому

    Please tell me why there is dt associated with Wt in the integral form. Isn't it should be just Wt? In the code Wt = sqrt(t)*Zt looks good for me though.

  • @Prof.OrtizRamirez
    @Prof.OrtizRamirez 2 роки тому

    Accurate and fast explanation. I got this when run first part of code "ModuleNotFoundError: No module named '_testcapi'", how can i fix this? thanks in advance

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

      github.com/vollib/py_vollib/issues/11

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

    Just an FYI, you have a typo on the Heston model simulation page on your website. It says dS_i+1 instead of S_i+1 in the Euler Discretisation section

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

      Legend, thanks for update. Sometimes it's hard to pick these up when writing in latex
      $\Large S_{i+1} = S_i e^{(r-\frac{v_i}{2}) \Delta t + \sqrt{v_{i}}\Delta tW^\mathbb{Q}_{S,i+1}}$

  • @pearsonmudzingwa597
    @pearsonmudzingwa597 6 місяців тому

    How do you price Delta, American and European Options using Heston Model?

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

    Possible to make a video on GARCH?

  • @user-kn1lf4dn9v
    @user-kn1lf4dn9v 8 місяців тому

    please make a post with details

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

    Pleas I want python code for currency options pricing using Heston model

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

    Do you teach ?

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

    Can you help with quantitative finance jobs? I am looking for roles in quantitative finance and have a master in financial engineering but the problem is that I had a family emergency and now there is a gap since I graduated. No firm is giving me an interview now as the gap is 14 months now.