MCPcopy
hub / github.com/quantopian/zipline / test_normal

Method test_normal

tests/test_benchmark.py:108–141  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

106 })
107
108 def test_normal(self):
109 days_to_use = self.sim_params.sessions[1:]
110
111 source = BenchmarkSource(
112 self.asset_finder.retrieve_asset(1),
113 self.trading_calendar,
114 days_to_use,
115 self.data_portal
116 )
117
118 # should be the equivalent of getting the price history, then doing
119 # a pct_change on it
120 manually_calculated = self.data_portal.get_history_window(
121 [1],
122 days_to_use[-1],
123 len(days_to_use),
124 "1d",
125 "close",
126 "daily",
127 )[1].pct_change()
128
129 # compare all the fields except the first one, for which we don't have
130 # data in manually_calculated
131 for idx, day in enumerate(days_to_use[1:]):
132 self.assertEqual(
133 source.get_value(day),
134 manually_calculated[idx + 1]
135 )
136
137 # compare a slice of the data
138 assert_series_equal(
139 source.get_range(days_to_use[1], days_to_use[10]),
140 manually_calculated[1:11]
141 )
142
143 def test_asset_not_trading(self):
144 benchmark = self.asset_finder.retrieve_asset(3)

Callers

nothing calls this directly

Calls 5

get_valueMethod · 0.95
get_rangeMethod · 0.95
BenchmarkSourceClass · 0.90
retrieve_assetMethod · 0.80
get_history_windowMethod · 0.45

Tested by

no test coverage detected