Quantopian's community platform is shutting down. Please read this post for more information and download your code.
Back to Community
Value at Risk - Historical Simulation

Here is my shot at doing Historical Simulation to find the Value at Risk of your portfolio.
Due to the method it is not a great method for risk management - but can get you in the ball park.
i.e. aiming for a 5% VaR level - I found the predicted VaR was exceeded between 1-10% of the time.

This could be handy in allocating capital to algorithms proportional some multiple of the VaR value in order to limit losses.

5 responses

Here is View 1: Predicted VaR vs change in portfolio value
The change in portfolio value should break through VaR, VaRprob % of the time

Here is View 2: Compare predicted VaR exceptions to expected exceptions - make sure you uncomment all 3 lines
Note ExceedVaREvent is an indicator function: 0.1 for VaR exception at that time, 0 otherwise

That is fantastic. VaR work has been on my "get to this someday" list for a while - I'm delighted you're taking a crack at it. Thank you!

Disclaimer

The material on this website is provided for informational purposes only and does not constitute an offer to sell, a solicitation to buy, or a recommendation or endorsement for any security or strategy, nor does it constitute an offer to provide investment advisory services by Quantopian. In addition, the material offers no opinion with respect to the suitability of any security or specific investment. No information contained herein should be regarded as a suggestion to engage in or refrain from any investment-related course of action as none of Quantopian nor any of its affiliates is undertaking to provide investment advice, act as an adviser to any plan or entity subject to the Employee Retirement Income Security Act of 1974, as amended, individual retirement account or individual retirement annuity, or give advice in a fiduciary capacity with respect to the materials presented herein. If you are an individual retirement or other investor, contact your financial advisor or other fiduciary unrelated to Quantopian about whether any given investment idea, strategy, product or service described herein may be appropriate for your circumstances. All investments involve risk, including loss of principal. Quantopian makes no guarantees as to the accuracy or completeness of the views expressed in the website. The views are subject to change, and may have become unreliable for various reasons, including changes in market conditions or economic circumstances.

Very very cool! When used with an actual strategy, one could use this to optimize position sizing to stay within predefined VaR limits.

Hi newbie here - any guidance how I can update to the new version - thank you
error
"98 Warning Undefined name 'batch_transform' 98 Error Runtime exception: NameError: name 'batch_transform' is not defined
batch_transform is no longer supported. Please use history instead.