Skip to content

Commit

Permalink
Merge pull request #184 from YasserHassan/patch-2
Browse files Browse the repository at this point in the history
Match net worth calculation in test to tested method in TestRiskAdjustedReturns
  • Loading branch information
notadamking committed Feb 11, 2020
2 parents d822c16 + 9051ff8 commit eab1a0e
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
2 changes: 2 additions & 0 deletions tensortrade/rewards/risk_adjusted_returns.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ def __init__(self, return_algorithm: str = 'sharpe', risk_free_rate: float = 0.,
self._target_returns = self.default('target_returns', target_returns)

def _return_algorithm_from_str(self, algorithm_str: str) -> Callable[[pd.DataFrame], float]:
assert algorithm_str in ['sharpe', 'sortino']

if algorithm_str == 'sharpe':
return self._sharpe_ratio
elif algorithm_str == 'sortino':
Expand Down
4 changes: 2 additions & 2 deletions tests/tensortrade/unit/rewards/test_risk_adjusted_returns.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class TestRiskAdjustedReturns:
def test_sharpe_ratio(self, net_worths):
scheme = RiskAdjustedReturns(return_algorithm='sharpe', risk_free_rate=0)

returns = net_worths.diff()
returns = net_worths.pct_change()

sharpe_ratio = scheme._sharpe_ratio(returns)

Expand All @@ -31,7 +31,7 @@ def test_sortino_ratio(self, net_worths):
target_returns=0
)

returns = net_worths.diff()
returns = net_worths.pct_change()

sortino_ratio = scheme._sortino_ratio(returns)

Expand Down

0 comments on commit eab1a0e

Please sign in to comment.