Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New feature: Value at Risk (VaR) #106

Merged
merged 16 commits into from
Jul 23, 2023

Conversation

PietropaoloFrisoni
Copy link
Collaborator

@PietropaoloFrisoni PietropaoloFrisoni commented Jul 18, 2023

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.

We want to compute the value at risk (VaR) of the portfolio over the selected period of time (the 'freq' variable).
@PietropaoloFrisoni PietropaoloFrisoni marked this pull request as draft July 18, 2023 15:32
@PietropaoloFrisoni PietropaoloFrisoni changed the title Starting to work on new feature (VaR) New feature: Value at Risk (VaR) Jul 19, 2023
@PietropaoloFrisoni PietropaoloFrisoni requested review from fmilthaler and removed request for fmilthaler July 19, 2023 13:18
@PietropaoloFrisoni PietropaoloFrisoni marked this pull request as ready for review July 19, 2023 13:23
@fmilthaler
Copy link
Owner

fmilthaler commented Jul 19, 2023

Awesome :)

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

Just some minor things for now:

  • you can update the file version to:
version=0.4.0
release=0.4.0

and with that, you should update the release number references in README.md and README.tex.md as well (but that is now automated, read more about below)

  • I saw that you took care of the imports manually. You can automate this as well (more below).

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
Copy link
Owner

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
Copy link
Owner

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
Copy link
Collaborator Author

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

finquant/portfolio.py Outdated Show resolved Hide resolved
Copy link
Owner

@fmilthaler fmilthaler left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I left a few questions (for my own understanding), and a few minor changes.
Overall very good and I'm grateful for this addition.

@fmilthaler
Copy link
Owner

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?

converting string into f string

Co-authored-by: Frank Milthaler <fmilthaler@users.noreply.github.com>
@PietropaoloFrisoni
Copy link
Collaborator Author

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

finquant/portfolio.py Outdated Show resolved Hide resolved
@fmilthaler
Copy link
Owner

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

@fmilthaler fmilthaler merged commit 0b496a6 into fmilthaler:master Jul 23, 2023
2 checks passed
fmilthaler added a commit that referenced this pull request Jul 24, 2023
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.

---------

Co-authored-by: Frank Milthaler <fmilthaler@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants