Monte Carlo Simulation with value at risk (VaR) and conditional value at risk (CVaR) in Python

In today's video we follow on from the Monte Carlo Simulation of a Stock Portfolio in Python and calculate the value at risk (VaR) and conditional value at risk (CVaR).
For the existing Monte Carlo Code, please refer to our last video • Monte Carlo Simulation...
★ ★ Code Available on GitHub ★ ★
GitHub: github.com/TheQuantPy
Specific Tutorial Link: github.com/TheQuantPy/youtube...
★ ★ QuantPy GitHub ★ ★
Collection of resources used on QuantPy KZread 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.

Пікірлер: 17

  • @gian_piano
    @gian_piano Жыл бұрын

    awesome video. I am even struggling reading your code and understanding it, it is just admirable how you came up with this code

  • @sebastianbrudersohn5021
    @sebastianbrudersohn50213 жыл бұрын

    Very well done, many thanks!

  • @TheChievovr
    @TheChievovr3 жыл бұрын

    you are back! Great!

  • @anthonypeters7030
    @anthonypeters70302 жыл бұрын

    What would we do if we wanted to calculate min, median, max, and avg return from the 100 simulations?

  • @louisdesmarestz1919
    @louisdesmarestz19193 жыл бұрын

    Thanks for this great video ! Would be awesome if you could also explain the differences in interpreting Historical vs Parametric vs MC VaR and CVaR. From what I understood they measure the same thing but don't have exactly the same meaning.

  • @QuantPy

    @QuantPy

    3 жыл бұрын

    Thanks, will definitely make a video summarising this one. Essentially these are three different models to asses the possible distribution of future returns. The difference between the models are the assumptions on the asset distributions. Historical VaR, makes no assumptions about the distribution (uses historical distribution). Parametric VaR uses a distribution defined by you, and is parametrised in terms of mean and covariance matrices. MC VaR, is a flexible methodology, whereby you could combined various assumptions for each asset.

  • @2255.
    @2255.5 ай бұрын

    very helpful thank you

  • @stevealmond7460
    @stevealmond74605 ай бұрын

    hello. aren't we assuming returns are normally distributed tho?

  • @Suvra2961984
    @Suvra29619843 жыл бұрын

    Helpful video. Please make a video of calculating VaR using Genetic Algorithm in Python. Thanks!

  • @QuantPy

    @QuantPy

    3 жыл бұрын

    Great suggestion! Haven't heard of common use cases for Genetic Algorithm (GA) approach for producing a static portfolio. Just having a quick search in the literature, seems like GA can be used to reduce computation time compared to Linear Programming (LP) methods, over large time horizons for allocation problems.

  • @Suvra2961984

    @Suvra2961984

    2 жыл бұрын

    @@QuantPy The code isn't working. It says no data could be fetched using YahooDailyReader. Any idea how to make it work? Thanks.

  • @QuantPy

    @QuantPy

    2 жыл бұрын

    pip install -upgrade pandas-datareader

  • @superuser8636

    @superuser8636

    Жыл бұрын

    Gillespie's Algorithm is a great example

  • @giulioc.6066
    @giulioc.60662 жыл бұрын

    Thanks for your videos, they are very useful! Could you tell me how to calculate the contribution to the VaR of each individual asset? For example, if the portfolio is made up of 2 assets and the portfolio VaR is 10%, the first asset contributes 3% of VaR to the second asset 7%.

  • @QuantPy

    @QuantPy

    2 жыл бұрын

    Thanks for your question. The way I would visualise the contribution to VaR as you are describing is the same as major trading/market making companies visualise risk contribution. 1. This is by separating VaR by particular classes, so in your example Asset A and then Asset B. 2. Run VaR separately. 3. Run VaR together. 4. The reduction/increase is called 'Diversification Effect' Please see page 98 on Goldman Sachs 2020 Form 10-K for an example where they have separated VaR into asset classes. www.goldmansachs.com/investor-relations/financials/current/annual-reports/2020-annual-report/multimedia/2020/annual-report-2020.pdf

  • @frodewilkensen
    @frodewilkensen Жыл бұрын

    Hi - is there a quick adjustment for me to replicate this code but only for a single security with a specified estimate on volatility?

  • @frodewilkensen

    @frodewilkensen

    Жыл бұрын

    And thank you for the great video!