Hi,

Trying to figure out the framework algorithms, in particular this bit of code from the documentation:

# Define alpha model as a composite of the rsi and ema cross models
self.SetAlpha(CompositeAlphaModel([RsiAlphaModel(), EmaCrossAlphaModel()]))


class CompositeAlphaModel:

# Updates this alpha model with the latest data from the algorithm. This is
# called each time the algorithm receives data for subscribed securities.
# This method patches this call through the each of the wrapped models.
self.Update(algorithm, data):
return List<Insight>
# Event fired each time the we add/remove securities from the data feed. This
# method patches this call through the each of the wrapped models.
self.OnSecuritiesChanged(algorithm, changes):
pass

 

I couldn't find a CompositeAlphaModel.py on Github only CompositeAlphaModel.cs but trying to insert that code directly into my algorithm or import it with: 

from QuantConnect.Algorithm.Framework.Alphas import CompositeAlphaModel

didn't work, both results gave the error message below:

During the algorithm initialization, the following exception has occurred: NotImplementedException : IAlphaModel.Update must be implemented. Please implement this missing method on <class 'list'>
at QuantConnect.Algorithm.Framework.Alphas.AlphaModelPythonWrapper..ctor (Python.Runtime.PyObject model) [0x00052] in <3f615569dfef474bba414f7d7810702f>:0
at QuantConnect.Algorithm.Framework.Alphas.CompositeAlphaModel..ctor (Python.Runtime.PyObject[] alphaModels) [0x0004d] in <3f615569dfef474bba414f7d7810702f>:0
at QuantConnect.Algorithm.Framework.Alphas.CompositeAlphaModel..ctor (Python.Runtime.PyObject alphaModel) [0x00000] in <3f615569dfef474bba414f7d7810702f>:0
at (wrapper managed-to-native) System.Reflection.MonoCMethod.InternalInvoke(System.Reflection.MonoCMethod,object,object[],System.Exception&)
at System.Reflection.MonoCMethod.InternalInvoke (System.Object obj, System.Object[] parameters) [0x00002] in <2e7c1c96edae44d496118948ca617c11>:0
at Initialize in main.py:line 46
NotImplementedException : IAlphaModel.Update must be implemented. Please implement this missing method on <class 'list'>
at QuantConnect.Algorithm.Framework.Alphas.AlphaModelPythonWrapper..ctor (Python.Runtime.PyObject model) [0x00052] in <3f615569dfef474bba414f7d7810702f>:0
at QuantConnect.Algorithm.Framework.Alphas.CompositeAlphaModel..ctor (Python.Runtime.PyObject[] alphaModels) [0x0004d] in <3f615569dfef474bba414f7d7810702f>:0
at QuantConnect.Algorithm.Framework.Alphas.CompositeAlphaModel..ctor (Python.Runtime.PyObject alphaModel) [0x00000] in <3f615569dfef474bba414f7d7810702f>:0
at (wrapper managed-to-native) System.Reflection.MonoCMethod.InternalInvoke(System.Reflection.MonoCMethod,object,object[],System.Exception&)
at System.Reflection.MonoCMethod.InternalInvoke (System.Object obj, System.Object[] parameters) [0x00002] in <2e7c1c96edae44d496118948ca617c11>:0

 

 

Also, secondary question once I get this part working. Based on this sentence in the documentation:

"Provides an implementation of QuantConnect.Algorithm.Framework.Alphas.IAlphaModel that combines multiple alpha models into a single alpha model and properly sets each insights 'SourceModel' property"

Does this mean that I can access which alpha model generated by looking at Insight.SourceModel? If so then what type of data does that return to me?

My goal here is that because I have multiple alphas generating insights on the same security I don't want them to overwrite eachother. It seems most the example code in the documentatino is been geared towards single alpha insights that are designed to overwrite previous insights as a new one appears. I'm having a hard time writing a custom portoflio construction model based on multiple alphas that are possibly firing on different timeframes. For example, if one alpha out of 3 gives a down insight on SPY that doesn't mean I want my portfolio to sell all SPY.