I am trying to create a universe for my pairs trading alpha model, and I would like to create a manual universe with several pairs of assets. Something like this:
symbols = [ [asset1A, asset1B], [asset2A, asset2B] ]
self.SetUniverseSelection( ManualUniverseSelectionModel(symbols) )
It looks like this is not working because the ManualUniverseSelectionModel is accepting a list of Symbol objects, not a list of lists. Is there any way to accomplish what I am trying to do?
Rahul Chowdhury
Hey Riley,
Instead of defining the pairs in the main class, you should first pass in all the symbols into ManualUniverseSelectionModel and then define the pairs in your AlphaModel.
You can accomplish this is by creating a data structure which stores how the assets are paired. Then using that data structure as a reference for keeping track of the corresponding pair for each asset.
For example, assuming that that Asset1A, Asset2A, Asset1B, and Asset2B are Symbol objects, you can initialize a a list of tuples which defines the pairs.
class MyAlphaModel(AlphaModel): def __init__(self): self.pairs = [(Asset1A,Asset1B), (Asset2A,Asset2B)]
Then in Update you can iterate through each pair.
class MyAlphaModel(AlphaModel): .... Update(self, algorithm, data): insights = [] for pair in self.pairs: symbolA = pair[0] symbolB = pair[1] # Generate Insights return insights
Â
Riley Bolen
The material on this website is provided for informational purposes only and does not constitute an offer to sell, a solicitation to buy, or a recommendation or endorsement for any security or strategy, nor does it constitute an offer to provide investment advisory services by QuantConnect. In addition, the material offers no opinion with respect to the suitability of any security or specific investment. QuantConnect makes no guarantees as to the accuracy or completeness of the views expressed in the website. The views are subject to change, and may have become unreliable for various reasons, including changes in market conditions or economic circumstances. All investments involve risk, including loss of principal. You should consult with an investment professional before making any investment decisions.
To unlock posting to the community forums please complete at least 30% of Boot Camp.
You can continue your Boot Camp training progress from the terminal. We hope to see you in the community soon!