fmilthaler / FinQuant

A program for financial portfolio management, analysis and optimisation.
MIT License
1.34k stars 190 forks source link

New feature: Value at Risk (VaR) #106

Closed PietropaoloFrisoni closed 12 months ago

PietropaoloFrisoni commented 1 year ago

The Value at Risk (VaR) is a way to evaluate the risk of a portfolio. It measures the potential loss that a portfolio can have over a certain period with a specified confidence level. With respect to the beta parameter, variance, etc., VaR uses a probability distribution, and it assumes that returns are normally distributed.

Using the variance-covariance method, we want to compute the portfolio's value at risk (VaR) over the selected period (the 'freq' variable). The Monte Carlo approach is left for further development.

fmilthaler commented 1 year ago

Awesome :)

I'll probably have a closer look at it over the weekend.

Just some minor things for now:

To automate the above 2 steps, I recently added some scripts

to the repo.

You can run isort $(git ls-files '*.py') to sort all imports in all python files that are under version control.

That way, you don't have to worry about my CDO and can only focus on the new features you are interested in.

Btw, thank you once again for your hard work. Hope you are learning more and more about finance that way. :)

fmilthaler commented 1 year ago

Forgot to mention, you'd have to install isort first. I added it to requirements_dev.txt a few days ago. So you can simply install it with pip install -e .[dev]

fmilthaler commented 1 year ago

UPDATE: About the .git/hooks/pre-commit script. I just figured out, that it does not apply the black and isort changes to the commit... But, the README updates work. For now, you can however use black and isort manually:

black $(git ls-files '*.py')
isort $(git ls-files '*.py')

Apologies for spamming you with messages and most of them were bugged ;)

PietropaoloFrisoni commented 1 year ago

Thanks, Frank. I'll go over these steps soon. Yes, I'm learning more about finance this way. Thank you so much!

fmilthaler commented 1 year ago

I'd like to add one more request: Could you also please add this to one of the examples with a bit of text, like you did for the beta parameter?

PietropaoloFrisoni commented 1 year ago

Thank you for the review and the improvements. Please feel free to ask for any clarification/double-check. It is useful for me as well since I am not a field expert myself : )

I'd like to add one more request: Could you also please add this to one of the examples with a bit of text, like you did for the beta parameter?

Sure, I'll go over it asap.

All the best

fmilthaler commented 12 months ago

Very good, and thank you very much for adding the new feature to the example Example-Analysis. :)