diff --git a/README.tex.md b/README.tex.md index 01cea370..ca910a1d 100644 --- a/README.tex.md +++ b/README.tex.md @@ -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: diff --git a/finquant/portfolio.py b/finquant/portfolio.py index fe7f96b5..295cd1de 100644 --- a/finquant/portfolio.py +++ b/finquant/portfolio.py @@ -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, @@ -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 @@ -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`` """ @@ -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() @@ -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 @@ -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}" @@ -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 ):