Back

Removing Tickers From Manual Universe

If you have a manual universe set off a list of symbols, if you remove an element from that list does it automatically get removed from the universe or somehow update off of that list?  Or does it take in that list once and that is the static universe you have no matter what happens to that list afterward.  Long story short, I'm looking to remove elements from my manual universe after I've defined it haha.  Let me know if I'm doing things right by just removing the element from the symobols list passed into the manual universe.

Update Backtest







0

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.


Manual universe selection is called at the beginning of the algorithm, so removing an element from the list that was a parameter will not update the universe. That being said, what is the reason for removing a symbol from the universe? Is it for computational efficiency? If this is a critical part of the algorithm, then manual universe selection might not be the best universe selection model.

In order to remove a security from the universe, the method RemoveSecurity(Symbol) from QCAlgorithm can be called.

1

Gurumeher,

I am working with the FineFundamental universe and I'd like to add the SPY manually to the universe after I applied the coarse and fine filter. Is it possible to add a single stock to the universe? I have not been successful in doing so. My goal is to perform beta calculations with stocks in the univerrse as part of my algorithm.

I use these instructions to set up my universe.

self.UniverseSettings.Resolution = Resolution.Daily 

self.UniverseSettings.DataNormalizationMode = DataNormalizationMode.Adjusted  

self.UniverseSettings.FillForward = True

self.UniverseSettings.ExtendedMarketHours = True

self.SetUniverseSelection(FineFundamentalUniverseSelectionModel(self.SelectCoarse,self.SelectFine))

self.AddEquity('SPY')

 

0

Hi! I have a similar question as Goofball regarding Manual and Liquid Universes

Basically, I have 2 universes I want to work with - the Liquid Universe, and the Manual Universe.

In my algorithm, when it sends out orders for the Liquid Universe, I use the following:

for security in self.changes.AddedSecurities:

if not security.Invested:

self.SetHoldings(security.Symbol, .05)

The problem with this, is that the securities within the Manual Universe are also contained within "self.changes.AddedSecurities" which I just realized, so the following code would also allocate 5% to each security in the Manual Universe instead of just the Liquid Universe.

self.SetHoldings(security.Symbol, .05)

Is there some way to exclude the securities within the Manual Universe from being included when calling "for security in self.changes.AddedSecurities:"? Or is there another solution for this?

 

Thank you!

0

I actually found a solution to have a specific security included in my universe (e.g., SPY). I added the extra security at the end of the SelectFine filter. This way it always gets included in the universe at the end of the filtering process.

class TestAlgo(QCAlgorithm):

    def Initialize(self):
***typical initialization****
# create an extra symbol
spy = Symbol.Create('SPY', SecurityType.Equity, Market.USA)

def SelectCoarse(self, coarse):
          ***typical filtering for coarse univers****            
     symbols_coarse = [list of symbols after coarse filter]
          return symbols_coarse

  def SelectFine(self, fine):
          ***typical filtering for fine universe****            
          symbols_fine = [list of symbols after fine filter]

          #add bm symbol
          symbols_fine.append(self.spy)            
          return symbols_fine

 

0

Hi Vncne,

In OnSecuritiesChanged, when looping over the added securities, we can check if our added security’s Symbol is in the list of symbols used for the Manual Universe, and if so, continue. I’ve shown how to do this in the attached backtest.

Best,
Shile Wen

0

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.


Update Backtest





0

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.


Loading...

This discussion is closed