126126 self.set_start_date(2024, 9, 1)
127127 self.set_end_date(2024, 12, 31)
128128 self.set_cash(1000000)
129+ self.settings.daily_precise_end_time = False
129130 self.set_benchmark("SPY")
130131 self.set_portfolio_construction(EqualWeightingPortfolioConstructionModel())
131132 self.set_execution(ImmediateExecutionModel())
165166 def build_model(self) -> None:
166167 qb = self
167168 # Call the History method with list of tickers, time argument(s), and resolution to request historical data for the symbol.
168- history = qb.history(list(self.symbols.keys()), datetime(2015, 1, 1), datetime.now() , Resolution.DAILY)
169+ history = qb.history(list(self.symbols.keys()), datetime(2015, 1, 1), self.time , Resolution.DAILY)
169170
170171 # Call SPY history as reference
171- spy = qb.history(["SPY"], datetime(2015, 1, 1), datetime.now() , Resolution.DAILY)
172+ spy = qb.history(["SPY"], datetime(2015, 1, 1), self.time , Resolution.DAILY)
172173
173174 # Call the History method with list of buyback tickers, time argument(s), and resolution to request buyback data for the symbol.
174- history_buybacks = qb.history(list(self.symbols.values()), datetime(2015, 1, 1), datetime.now() , Resolution.DAILY)
175+ history_buybacks = qb.history(list(self.symbols.values()), datetime(2015, 1, 1), self.time , Resolution.DAILY)
175176
176177 # Select the close column and then call the unstack method to get the close price dataframe.
177178 df = history['close'].unstack(level=0)
242243
243244 # Long if the prediction predict price goes up, short otherwise. Do opposite for SPY (active return)
244245 if prediction > 0.5:
245- insights.append( Insight.price(row.index[i].split(".")[0] , timedelta(days=1), InsightDirection.UP) )
246+ insights.append( Insight.price(row.index[i].underlying , timedelta(days=1), InsightDirection.UP) )
246247 insights.append( Insight.price("SPY", timedelta(days=1), InsightDirection.DOWN) )
247248 else:
248- insights.append( Insight.price(row.index[i].split(".")[0] , timedelta(days=1), InsightDirection.DOWN) )
249+ insights.append( Insight.price(row.index[i].underlying , timedelta(days=1), InsightDirection.DOWN) )
249250 insights.append( Insight.price("SPY", timedelta(days=1), InsightDirection.UP) )
250251
251252 self.emit_insights(insights)</ pre >
252- </ div >
253+ </ div >
0 commit comments