ffn
ffn copied to clipboard
Daily Mean Hard Coded Definition
self.daily_mean = r.mean() * 252
self.daily_vol = np.std(r, ddof=1) * np.sqrt(252)
# if type(self.rf) is float:
if isinstance(self.rf, float):
self.daily_sharpe = r.calc_sharpe(rf=self.rf, nperiods=252)
self.daily_sortino = calc_sortino_ratio(r, rf=self.rf, nperiods=252)
# rf is a price series
else:
_rf_daily_price_returns = self.rf.to_returns()
self.daily_sharpe = r.calc_sharpe(
rf=_rf_daily_price_returns, nperiods=252
)
self.daily_sortino = calc_sortino_ratio(
r, rf=_rf_daily_price_returns, nperiods=252
)
The yearly return data is hard coded to 252 days which accurately represents trading on the NYSE or other standard markets. However, other markets trade 365 (366) days per year, or somewhere in between (e.g. 6 days a week for futures). The returns should either dynamically adjust based on the time series presented or offer an ability to set the number of trading days.
https://github.com/pmorissette/ffn/pull/145