You have six fundamental factors:
28: inputs = [morningstar.income_statement.ebit,
29: morningstar.valuation.enterprise_value]
48: inputs = [morningstar.operation_ratios.roe,]
62: inputs = [mstar.income_statement.ebit, mstar.valuation.enterprise_value,
63: mstar.operation_ratios.roic]
But I don't think that's enough to explain your performance. Simon might be on the right track, this bit of code could probably be written more efficiently using pandas data manipulation operations:
for stock in yesterday:
yesterday[stock]['date'] = today_date
yesterday[stock]['pct_change'] = pct_change[stock]
context.hist.append(yesterday[stock])
Other things I've noticed in running backtests, if you're trading without a good liquidity filter, an open order might take a very long time to fill, which would cause it to keep the backtest engine busy. The code you have in your notebook has an initial_screen
filter that is used in the notebook. Consider adding the filter to the pipeline screen. You could also rule out this possibility by zero'ing the slippage model.
Sunil