mirror of
https://github.com/wassname/catalyst.git
synced 2026-08-02 12:30:45 +08:00
TST: Make TradingEnvironment resources static
This commit is contained in:
@@ -64,11 +64,6 @@ class TestRisk(WithTradingEnvironment, ZiplineTestCase):
|
||||
treasury_curves=self.env.treasury_curves,
|
||||
)
|
||||
|
||||
@classmethod
|
||||
def init_class_fixtures(cls):
|
||||
cls.TRADING_CALENDAR_PRIMARY_CAL = 'NYSE'
|
||||
super(TestRisk, cls).init_class_fixtures()
|
||||
|
||||
def test_factory(self):
|
||||
returns = [0.1] * 100
|
||||
r_objects = factory.create_returns_from_list(returns, self.sim_params)
|
||||
@@ -393,18 +388,18 @@ class TestRisk(WithTradingEnvironment, ZiplineTestCase):
|
||||
pd.Timestamp("1991-01-01", tz='UTC')
|
||||
)
|
||||
|
||||
# 2008 and 2012 were leap years
|
||||
# 1992 and 1996 were leap years
|
||||
total_days = 365 * 5 + 2
|
||||
end_session = start_session + datetime.timedelta(days=total_days)
|
||||
sim_params = SimulationParameters(
|
||||
sim_params90s = SimulationParameters(
|
||||
start_session=start_session,
|
||||
end_session=end_session,
|
||||
trading_calendar=self.trading_calendar,
|
||||
)
|
||||
|
||||
returns = factory.create_returns_from_range(sim_params)
|
||||
returns = factory.create_returns_from_range(sim_params90s)
|
||||
returns = returns[:-10] # truncate the returns series to end mid-month
|
||||
metrics = risk.RiskReport(returns, sim_params,
|
||||
metrics = risk.RiskReport(returns, sim_params90s,
|
||||
trading_calendar=self.trading_calendar,
|
||||
treasury_curves=self.env.treasury_curves,
|
||||
benchmark_returns=self.env.benchmark_returns)
|
||||
|
||||
Reference in New Issue
Block a user