sortino filters out nan in rolling returns
This commit is contained in:
parent
0fec9abac0
commit
18b60bd608
@ -574,8 +574,10 @@ def sortino_ratio(
|
||||
"closest": closest,
|
||||
"date_format": date_format,
|
||||
}
|
||||
average_rr_ts = time_series_data.calculate_rolling_returns(**common_params, annual_compounded_returns=False)
|
||||
average_rr = statistics.mean(average_rr_ts.values)
|
||||
average_rr_ts = time_series_data.calculate_rolling_returns(
|
||||
**common_params, annual_compounded_returns=False, if_not_found="nan"
|
||||
)
|
||||
average_rr = statistics.mean(filter(lambda x: str(x) != "nan", average_rr_ts.values))
|
||||
annualized_average_rr = (1 + average_rr) ** (365 / interval_days) - 1
|
||||
|
||||
excess_returns = annualized_average_rr - risk_free_rate
|
||||
|
Loading…
Reference in New Issue
Block a user