Hi all, I am new to QuantConnect and now learning the algorithmic framework by reading docs and source code. I have found some places in the implementation of MeanVarianceOptimizationPortfolioConstructionModel that do not make sense to me. But I am unsure whether those are real issues or just my misunderstanding.

  1. Within the OnSecuritiesChanged method, when a security is added, it initializes the symbolData of the security using its historical data. But I do not understand why traling period is self.lookback * self.period instead of self.lookback + self.period. Although they should result in the same symbolData, the latter is more efficient when self.lookback is greater than 1. 

 

def OnSecuritiesChanged(self, algorithm, changes):
        '''Event fired each time the we add/remove securities from the data feed
        Args:
            algorithm: The algorithm instance that experienced the change in securities
            changes: The security additions and removals from the algorithm'''

        # clean up data for removed securities
        super().OnSecuritiesChanged(algorithm, changes)
        for removed in changes.RemovedSecurities:
            symbolData = self.symbolDataBySymbol.pop(removed.Symbol, None)
            symbolData.Reset()

        # initialize data for added securities
        symbols = [x.Symbol for x in changes.AddedSecurities]
        for symbol in [x for x in symbols if x not in self.symbolDataBySymbol]:
            self.symbolDataBySymbol[symbol] = self.MeanVarianceSymbolData(symbol, self.lookback, self.period)

        history = algorithm.History[TradeBar](symbols, self.lookback * self.period, self.resolution)
        for bars in history:
            for symbol, bar in bars.items():
                symbolData = self.symbolDataBySymbol.get(symbol).Update(bar.EndTime, bar.Value)

 

2. If I understand correctly, the current implementation estimates the expected return and covariance using historical forecasts from insights. However, in my view, forecasts of alpha models are usually very noisy, which makes the estimates inaccurate. In fact, since we have have historical returns available, why not just use them for estimation? For example, it makes more sense to me if we use actual historical returns to estimate covariance, and use current forecasts as the expected return.