Skip to content

Commit

Permalink
adding descriptions
Browse files Browse the repository at this point in the history
  • Loading branch information
PietropaoloFrisoni committed Jul 28, 2023
1 parent cb5e276 commit 7bd24f2
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 14 deletions.
1 change: 1 addition & 0 deletions README.tex.md
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,7 @@ look at the examples provided in `./example`.
- Expected Returns,
- Volatility,
- Sharpe Ratio,
- Sortino Ratio,
- Value at Risk.

It also shows how to extract individual stocks from the given portfolio. Moreover it shows how to compute and visualise:
Expand Down
26 changes: 12 additions & 14 deletions finquant/portfolio.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,10 @@
- daily log returns of the portfolio's stocks,
- Expected (annualised) Return,
- Volatility,
- Sharpe Ratio,
- Downside Risk,
- Value at Risk,
- Sharpe Ratio,
- Sortino Ratio,
- Beta parameter (optional),
- skewness of the portfolio's stocks,
- Kurtosis of the portfolio's stocks,
Expand Down Expand Up @@ -93,8 +95,8 @@ def __init__(self):
self.expected_return = None
self.volatility = None
self.downside_risk = None
self.sharpe = None
self.var = None
self.sharpe = None
self.sortino = None
self.skew = None
self.kurtosis = None
Expand Down Expand Up @@ -188,14 +190,6 @@ def add_stock(self, stock: Stock) -> None:
- ``stocks``: ``dictionary``, adds an entry for ``stock``
- ``data``: ``pandas.DataFrame``, adds a column of stock prices from ``stock``
Also, the following instance variables are (re-)computed:
- ``expected_return``: Expected Return of the portfolio
- ``volatility``: Volatility of the portfolio
- ``sharpe``: Sharpe Ratio of the portfolio
- ``skew``: Skewness of the portfolio's stocks
- ``kurtosis``: Kurtosis of the portfolio's stocks
:Input:
:stock: an object of ``Stock``
"""
Expand Down Expand Up @@ -236,8 +230,8 @@ def _update(self):
self.expected_return = self.comp_expected_return(freq=self.freq)
self.volatility = self.comp_volatility(freq=self.freq)
self.downside_risk = self.comp_downside_risk(freq=self.freq)
self.sharpe = self.comp_sharpe()
self.var = self.comp_var()
self.sharpe = self.comp_sharpe()
self.sortino = self.comp_sortino()
self.skew = self._comp_skew()
self.kurtosis = self._comp_kurtosis()
Expand Down Expand Up @@ -700,8 +694,11 @@ def properties(self):
- Expected Return,
- Volatility,
- Downside Risk,
- Value at Risk (VaR),
- Confidence level of VaR,
- Sharpe Ratio,
- Value at Risk,
- Sortino Ratio,
- Beta (optional),
- skewness,
- Kurtosis
Expand All @@ -719,10 +716,10 @@ def properties(self):
string += f"\nPortfolio Expected Return: {self.expected_return:0.3f}"
string += f"\nPortfolio Volatility: {self.volatility:0.3f}"
string += f"\nPortfolio Downside Risk: {self.downside_risk:0.3f}"
string += f"\nPortfolio Sharpe Ratio: {self.sharpe:0.3f}"
string += f"\nPortfolio Value at Risk: {self.var:0.3f}"
string += f"\nPortfolio Value at Risk: {self.var:0.3f}"
string += f"\nConfidence level of Value at Risk: "
string += f"{self.var_confidence_level * 100:0.2f} %"
string += f"\nPortfolio Sharpe Ratio: {self.sharpe:0.3f}"
string += f"\nPortfolio Sortino Ratio: {self.sortino:0.3f}"
if self.beta is not None:
string += f"\nPortfolio Beta: {self.beta:0.3f}"
Expand Down Expand Up @@ -1254,6 +1251,7 @@ def build_portfolio(**kwargs):
or pf.volatility is None
or pf.downside_risk is None
or pf.sharpe is None
or pf.sortino is None
or pf.skew is None
or pf.kurtosis is None
):
Expand Down

0 comments on commit 7bd24f2

Please sign in to comment.