Back

Option symbol changes when it's removed from universe

Hi,

I can't figure out why when I remove an option symbol from the universe, its symbol changes to something else.

I attached the python code where I logged security symbol when security is added or removed and here's an example of what's logged:

2019-01-02 09:31:00 Added:SPY 190118P00246000, Underlying:SPY R735QTJ8XC9X, Strike:246.0, Type: 1, Date:2019-01-18 00:00:00
2019-01-03 00:00:00 Removed:SPY 310F3UW6H4U06|SPY R735QTJ8XC9X, Underlying:SPY R735QTJ8XC9X, Strike:246.0, Type: 1, Date:2019-01-18 00:00:00

Option symbol was `SPY   190118P00246000` when it's added but it became `SPY 310F3UW6H4U06|SPY R735QTJ8XC9X` when it's removed.

Can anyone explain why it's like this? Is it a bug?

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.


Hi Joseph Cheung2 ,

Lean has a SymbolCache class that provides a string->Symbol mapping to allow for user-defined strings to be lifted into a Symbol. When a security is added to the algorithms, a string representation is added to the symbol cache for mapping. In the Options' case, the string representation follows the OSI symbology. 

Consequently, when we get the string of an option's Symbol, we get its OSI ticker. When an option is removed from the algorithm, it is also removed from the symbol cache. In this case, when we print the string of an option's Symbol, we get the string representation of its SecurityIdentifier.

However, the OSI ticker is also present as Symbol.Value, so if we use:

for removed in changes.RemovedSecurities:
if removed.Symbol.SecurityType == SecurityType.Option:
algorithm.Debug("Removed:{}, Underlying:{}, Strike:{}, Type: {}, Date:{}".format(
removed.Symbol.Value,
removed.Symbol.ID.Underlying,
removed.Symbol.ID.StrikePrice,
removed.Symbol.ID.OptionRight,
removed.Symbol.ID.Date))

we will get the desired ticker.

1

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