Hey Troy,
Tiingo news data can be emitted when the market is closed. Your algorithm is taking the insights from these overnight emissions and creating market on open orders. If the gap between the market close price and market open price is large, you may get an insufficient margin error.
One way to work around this error is to not emit any insights during market close.
You can accomplish this by returning at the beginning of AlphaModel.Update if the market is closed.
if not algorithm.IsMarketOpen("SPY"):
return insights
You can also consolidate all insights generated overnight in a class variable and then emit them at market open. However keep in mind that QC's PortfolioConstructionModels only take into account the latest insight when creating portfolio targets.
If you want to take into consideration all of the overnight news data when emitting an insight at market open. You could store all the overnight news data, calculate a sentiment, and then emit one insight at market open.
I modified your algorithm to store all overnight insights and emit them at market open, which effectively trades on the latest overnight insight for each symbol.
Best
Rahul