Hi All,

I am currently trying to testing the Alpha model with insight. The testing is simple, i get 3 stocks from coarse universe every backtest days. All stocks for a given days will trigger a insight up. 

 

Below is how i pick the stock from coarse universe 

    def TestFilter(self, universe):
        selected = []
        
        universe = [c for c in universe if c.HasFundamentalData] 
        universe = sorted(universe, key=lambda c: c.DollarVolume, reverse=True)[100:103]
        for coarse in universe:
            selected.append(coarse.Symbol)
            self.Log(f"[LOG->ADDED] {self.Time}: {coarse.Symbol}")
            
        return selected

 

I fire the insight in my alpha model

    def Update(self, algo, slice):
        insights = []

        for symbol in slice.Keys:
            if slice.ContainsKey(symbol) and slice[symbol] is not None:
                insights.append(Insight.Price(symbol, timedelta(minutes=30), InsightDirection.Up, None, None, None, 0.05))
                algo.Log(f"[LOG->INSIGHT] -> {algo.Time} {symbol} Up")

        return insights

 

3 stocks are added and 3 insights are fired => As expected

2014-03-25 00:00:00 [LOG->ADDED] 2014-03-25 00:00:00: LYB UQRGJ93635GL
2014-03-25 00:00:00 [LOG->ADDED] 2014-03-25 00:00:00: JAZZ TT3D85SDWEW5
2014-03-25 00:00:00 [LOG->ADDED] 2014-03-25 00:00:00: AIG R735QTJ8XC9X

2014-03-25 00:00:00 [LOG->INSIGHT] -> 2014-03-25 00:00:00 AIG R735QTJ8XC9X Up
2014-03-25 00:00:00 [LOG->INSIGHT] -> 2014-03-25 00:00:00 JAZZ TT3D85SDWEW5 Up
2014-03-25 00:00:00 [LOG->INSIGHT] -> 2014-03-25 00:00:00 LYB UQRGJ93635GL Up

 

However, in the next day, interesting things happens. I added 3 stocks again but it fired 6 insights, together with those yesterday (but my insight period was 30mins, i don't expect i see them again in the next day. 

2014-03-26 00:00:00 [LOG->ADDED] 2014-03-26 00:00:00: ICPT VAO9ZBE1SEAT
2014-03-26 00:00:00 [LOG->ADDED] 2014-03-26 00:00:00: ILMN RWQR2INKP0TH
2014-03-26 00:00:00 [LOG->ADDED] 2014-03-26 00:00:00: MCK R735QTJ8XC9X
2014-03-26 00:00:00 [LOG->INSIGHT] -> 2014-03-26 00:00:00 AIG R735QTJ8XC9X Up       ← not expected as i didn't get this stock from coarse universe
2014-03-26 00:00:00 [LOG->INSIGHT] -> 2014-03-26 00:00:00 JAZZ TT3D85SDWEW5 Up       ← not expected as i didn't get this stock from coarse universe
2014-03-26 00:00:00 [LOG->INSIGHT] -> 2014-03-26 00:00:00 LYB UQRGJ93635GL Up       ← not expected as i didn't get this stock from coarse universe
2014-03-26 00:00:00 [LOG->INSIGHT] -> 2014-03-26 00:00:00 ICPT VAO9ZBE1SEAT Up
2014-03-26 00:00:00 [LOG->INSIGHT] -> 2014-03-26 00:00:00 ILMN RWQR2INKP0TH Up
2014-03-26 00:00:00 [LOG->INSIGHT] -> 2014-03-26 00:00:00 MCK R735QTJ8XC9X Up

 

Can anyone help to explain how does it happen and how to resolve the issue? I would like to fired the insight if and only if it is returned from my coarse universe for a given day