Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
cash (int): Amount of starting cash
portfolio (prophet.portfolio.Portfolio): Starting portfolio
Return:
prophet.backtest.BackTest
"""
# Setup
if not end:
today = dt.date.today()
end = dt.datetime.combine(today, dt.time())
if not self._order_generator:
raise ProphetException("Must set an order generator by calling"
"set_order_generator.")
timestamps = trading_days[(trading_days >= start) &
(trading_days <= end)]
effective_start = timestamps[0]
data = self._generate_data(start=effective_start,
end=end,
lookback=lookback)
# Run backtest
return backtest(cash=cash,
data=data,
start=effective_start,
end=end,
slippage=slippage,
commission=commission,
portfolio=initial_portfolio,
order_generator=self._order_generator,
def get_data_start(self, start, lookback):
start_index = trading_days.get_loc(start)
return trading_days[start_index - lookback]