Skip to content

Commit

Permalink
fix issue #58
Browse files Browse the repository at this point in the history
  • Loading branch information
ranaroussi committed Jan 5, 2021
1 parent 43325a2 commit bf4d4f0
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
4 changes: 3 additions & 1 deletion quantstats/reports.py
Expand Up @@ -284,7 +284,9 @@ def metrics(returns, benchmark=None, rf=0., display=True,
"but a multi-column DataFrame was passed")

blank = ['']
df = _pd.DataFrame({"returns": _utils._prepare_returns(returns, rf)})
df = _utils._prepare_returns(returns, rf)
df.columns = ["returns"]

if benchmark is not None:
blank = ['', '']
df["benchmark"] = _utils._prepare_benchmark(
Expand Down
3 changes: 3 additions & 0 deletions quantstats/utils.py
Expand Up @@ -173,6 +173,9 @@ def to_excess_returns(returns, rf, nperiods=None):
Returns:
* excess_returns (Series, DataFrame): Returns - rf
"""
if isinstance(rf, int):
rf = float(rf)

if not isinstance(rf, float):
rf = rf[rf.index.isin(returns.index)]

Expand Down

0 comments on commit bf4d4f0

Please sign in to comment.