Skip to content

Commit

Permalink
updating tests and analysis
Browse files Browse the repository at this point in the history
  • Loading branch information
PietropaoloFrisoni committed Aug 22, 2023
1 parent 98f3696 commit 026749e
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 4 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,7 @@ look at the examples provided in `./example`.
- Value at Risk,
- Sharpe Ratio,
- Sortino Ratio,
- Treynor Ratio,
- Beta parameter,
- R squared coefficient.

Expand Down
2 changes: 1 addition & 1 deletion example/Example-Build-Portfolio-from-web.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@
#
# In the below example we are using `yfinance` to download stock data. We specify the start and end date of the stock prices to be downloaded.
# We also provide the optional parameter `market_index` to download the historical data of a market index.
# `FinQuant` can use them to calculate the beta parameter and R squared coefficient, measuring the portfolio's daily volatility and relationship compared to the market.
# `FinQuant` can use them to calculate the Treynor Ratio, beta parameter, and R squared coefficient, measuring the portfolio's daily volatility compared to the market.

# <codecell>

Expand Down
6 changes: 3 additions & 3 deletions finquant/quants.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ def sortino_ratio(

def treynor_ratio(
exp_return: FLOAT, beta: FLOAT_OPTIONAL, risk_free_rate: FLOAT = 0.005
) -> FLOAT:
) -> FLOAT_OPTIONAL:
"""Computes the Treynor Ratio.
:param exp_return: Expected Return of a portfolio
Expand All @@ -138,7 +138,7 @@ def treynor_ratio(
:rtype: :py:data:`~.finquant.data_types.FLOAT`
:return: Treynor Ratio as a floating point number:
``(exp_return - risk_free_rate) / float(beta)``
``(exp_return - risk_free_rate) / beta``
"""
# Type validations:
type_validation(
Expand All @@ -147,7 +147,7 @@ def treynor_ratio(
risk_free_rate=risk_free_rate,
)
if beta is None:
return np.nan
return None
else:
res_treynor_ratio: FLOAT = (exp_return - risk_free_rate) / beta
return res_treynor_ratio
Expand Down
1 change: 1 addition & 0 deletions tests/test_market.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,3 +41,4 @@ def test_Market():
assert pf.market_index.name == "^GSPC"
assert pf.beta is not None
assert pf.rsquared is not None
assert pf.treynor is not None

0 comments on commit 026749e

Please sign in to comment.