def test_partial_month(self): start = datetime.datetime( year=1991, month=1, day=1, hour=0, minute=0, tzinfo=pytz.utc) #1992 and 1996 were leap years total_days = 365 * 5 + 2 end = start + datetime.timedelta(days=total_days) trading_env90s = TradingEnvironment( self.benchmark_returns, self.treasury_curves, period_start=start, period_end=end ) returns = factory.create_returns(total_days, trading_env90s) returns = returns[:-10] # truncate the returns series to end mid-month metrics = risk.RiskReport(returns, trading_env90s) total_months = 60 self.check_metrics(metrics, total_months, start)
def check_year_range(self, start_date, years): if(start_date.month <= 2): ld = calendar.leapdays(start_date.year, start_date.year + years) else: # because we may catch the leap of the last year, # and i think this func is [start,end) ld = calendar.leapdays(start_date.year, start_date.year + years + 1) returns = factory.create_returns(365 * years + ld, self.trading_env08) metrics = risk.RiskReport(returns, self.trading_env) total_months = years * 12 self.check_metrics(metrics, total_months, start_date)
def check_year_range(self, start_date, years): if(start_date.month <= 2): ld = calendar.leapdays(start_date.year, start_date.year + years) else: # because we may catch the leap of the last year, # and i think this func is [start,end) ld = calendar.leapdays(start_date.year, start_date.year + years + 1) returns = factory.create_returns(365 * years + ld, self.sim_params08) metrics = risk.RiskReport(returns, self.sim_params) total_months = years * 12 self.check_metrics(metrics, total_months, start_date)
def test_partial_month(self): start = datetime.datetime( year=1991, month=1, day=1, hour=0, minute=0, tzinfo=pytz.utc) #1992 and 1996 were leap years total_days = 365 * 5 + 2 end = start + datetime.timedelta(days=total_days) sim_params90s = SimulationParameters( period_start=start, period_end=end ) returns = factory.create_returns(total_days, sim_params90s) returns = returns[:-10] # truncate the returns series to end mid-month metrics = risk.RiskReport(returns, sim_params90s) total_months = 60 self.check_metrics(metrics, total_months, start)