Value-at-Risk (VaR) Calculator Class in Python

As part of my self-development, I wanted to rework a script, which are typically one-offs, and turn it into a reusable component, although there are existing packages for VaR. As such, this is currently a work in progress. This code is a Python-based class for VaR calculations, and for those unfamiliar with VaR, it is an acronym for value at risk, the worst case loss in a period for a particular probability. It is a reworking of prior work with scripted VaR calculations, implementing various high-level good practices, e.g., hiding/encapsulation, do-not-repeat-yourself (DRY), dependency injection, etc.

Features:
  • Requires data frame of stock returns, factor returns, and stock weights
  • Expose a method to calculate and return a single VaR number for different variance types
  • Expose a method to calculate and return an array of VaR values by confidence level
  • Expose a method to calculate and plot an array of VaR values by confidence level
Still to do:
  • Dynamic factor usage
Note: Data to validate this class is available from my Google Drive Public folder.

Popular posts from this blog

Charting Correlation Matrices in R

Neural Networks (Part 4 of 4) - R Packages and Resources

Performance Improvements in R: Vectorization & Memoisation