Skip to content

Commit

Permalink
using OPTIONAL data type
Browse files Browse the repository at this point in the history
  • Loading branch information
PietropaoloFrisoni committed Aug 22, 2023
1 parent 4b5995e commit 9b87e01
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 6 deletions.
1 change: 0 additions & 1 deletion finquant/data_types.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,6 @@ def process_data(data: ARRAY_OR_DATAFRAME) -> FLOAT:

# Numeric types
FLOAT = Union[np.floating, float]
FLOAT_OPTIONAL = Union[FLOAT, None]
INT = Union[np.integer, int]
NUMERIC = Union[INT, FLOAT]

Expand Down
4 changes: 2 additions & 2 deletions finquant/portfolio.py
Original file line number Diff line number Diff line change
Expand Up @@ -511,14 +511,14 @@ def comp_sortino(self) -> FLOAT:
self.expected_return, self.downside_risk, self.risk_free_rate
)

def comp_treynor(self) -> FLOAT:
def comp_treynor(self) -> Optional[FLOAT]:
"""Compute and return the Treynor Ratio of the portfolio.
:type freq: :py:data:`~.finquant.data_types.FLOAT`
:return: The Treynor Ratio of the portfolio.
"""
# compute the Treynor Ratio of the portfolio
treynor: FLOAT = treynor_ratio(
treynor: Optional[FLOAT] = treynor_ratio(
self.expected_return, self.beta, self.risk_free_rate
)
self.treynor = treynor
Expand Down
6 changes: 3 additions & 3 deletions finquant/quants.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"""


from typing import Tuple
from typing import Tuple, Optional

import numpy as np
import pandas as pd
Expand Down Expand Up @@ -123,8 +123,8 @@ def sortino_ratio(


def treynor_ratio(
exp_return: FLOAT, beta: FLOAT_OPTIONAL, risk_free_rate: FLOAT = 0.005
) -> FLOAT_OPTIONAL:
exp_return: FLOAT, beta: Optional[FLOAT], risk_free_rate: FLOAT = 0.005
) -> Optional[FLOAT]:
"""Computes the Treynor Ratio.
:param exp_return: Expected Return of a portfolio
Expand Down

0 comments on commit 9b87e01

Please sign in to comment.