Hi, I'm running the  “BasicTemplateFuturesFrameworkAlgorithm” in Algorithm.Python directory. 

The source code is as follows.


    def filter(self, filter):
       '''Defines the futures chain universe filter'''
       return (filter.front_month()
                     .only_apply_filter_at_market_open())

class ConstantFutureContractAlphaModel(ConstantAlphaModel):
   '''Implementation of a constant alpha model that only emits insights for future symbols'''
   def __init__(self, _type, direction, period):
       super().__init__(_type, direction, period)

   def should_emit_insight(self, utc_time, symbol):
       # only emit alpha for future symbols and not underlying equity symbols
       if symbol.security_type != SecurityType.FUTURE:
           return False

       return super().should_emit_insight(utc_time, symbol)

class SingleSharePortfolioConstructionModel(PortfolioConstructionModel):
   '''Portfolio construction model that sets target quantities to 1 for up insights and -1 for down insights'''
   def create_targets(self, algorithm, insights):
       targets = []
       for insight in insights:
           targets.append(PortfolioTarget(insight.symbol, insight.direction))
       return targets


 

I have a question on the ConstantFutureContractAlphaModel. In the should_emit_insight, it uses should_emit_insight in ConstantAlphaModel. 

In the should_emit_insight in ConstantAlphaModel listed below


 

def should_emit_insight(self, utc_time, symbol):
       if symbol.is_canonical():
           # canonical futures & options are none tradable
           return False

       generated_time_utc = self.insights_time_by_symbol.get(symbol)

       if generated_time_utc is not None:
           # we previously emitted a insight for this symbol, check it's period to see
           # if we should emit another insight
           if utc_time - generated_time_utc < self.period:
               return False

       # we either haven't emitted a insight for this symbol or the previous
       # insight's period has expired, so emit a new insight now for this symbol
       self.insights_time_by_symbol[symbol] = utc_time
       return True


 

It checked if the symbol is canonical. (is_canonical). 

 

  1. What does is_canonical do? 

2. are all the futures are canonical?