I have an alpha model that implements OnSecuritiesChanged to maintain a symbolData dictionary. I am noticing that if I run a backtest that has a scheduled universe selection to add AAPL, across 9/1/2014 and 9/2/2014 I get two different symbols that act "kinda" the same:
AAPL R735QTJ8XC9X is added for 9/1/14
AAPL is added for 9/2/14
On 9/2/14 I receive a call to OnSecuritiesChanged to add AAPL, but the former symbol AAPL R735QTJ8XC9X is not removed. From the point of view of dictionary keys, however, both symbols act the same, so on 9/2 the symbolData management code sees AAPL as already being in the dictionary and doesn't add it again.
However, apparently this means that I'm still subscribed to two different symbols. I also have an OnEndOfDay event handler and I'm noticing that it gets called twice for AAPL. I am inferring that this is the result of being subscribed to two different symbols under the hood.
Am I doing something wrong here? So far everything seems to work as long as I make the OnEndOfDay handler idempotent for being called multiple times with the same symbol, but I'm worried something else may break.
Paul Blair
Actually, I'm seeing AAPL being added on 9/3/14, not 9/2/14.
Daniel Chen
Hi Paul,
Most of the time you will not need to work with these encoded strings and only need to work with the first tickers. QuantConnect provides a method for deserializing Symbol objects into easily consumable objects for use by the API. Please check out this page for details. Also, could you post your full algorithm so that we can better help you? Thank you!
Paul Blair
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!