ffn icon indicating copy to clipboard operation
ffn copied to clipboard

Daily Mean Hard Coded Definition

Open staymadson opened this issue 2 years ago • 1 comments

            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.

staymadson avatar Jun 09 '22 19:06 staymadson

https://github.com/pmorissette/ffn/pull/145

timkpaine avatar Jun 09 '22 19:06 timkpaine