Hello the attached algo, doesn't make any transactions because is not able to retrieve the option chain for the specific symbol. In the loop of the select_options() function, the line if kvp.Key == key, never match because kvp.Key has an '?' before the stock symbol, so the chain does not retrieved for the required symbol.
The correct behaviour I suppose is that kvp.Key would be equal to 'AAPL', or 'NFLX' or 'GOOG' or 'TSLA' without the '?'. How this can be solved? It is a bug?
Quant Dary
Hi Nick,
I also ran into this "issue", I don't think it is a bug as such merely the way QC distinguishes between a Symbol representing a regular equity and a symbol representing an option chain. In my case, in C# I just convert to a string and trim the ? if I trying to compare a possible option chain symbol to a equity symbol. Converting a string back to a Symbol is simple with Symbol(string) if required.
string symb = okvp.Key.ToString(); if (symb.Substring(0,1) == "?") symb = symb.TrimStart('?');
Quant Dary
I should have added if you loop through and log out all Symbols of the securities in a algo which has options in it it will log out both say TSLA and ?TSLA proving one is for the equity and the other for the Option Chain, it will also log out all of the Option Contracts the Option Chain contains.
foreach (KeyValuePair<Symbol, Security> security in Securities) { Log("Symbol: " + security.Key); }
Link Liang
Hi Nicolas,
I cannot run your algorithm because I get "JSONDecodeError". I believe the token for that external resource is not valid for me. However from your description, I believe here is the problem:
the type of kvp.Key is a Symbol, not a string. That is the reason you see "?" when you try to print it right away. To get the ticker string of that symbol, we need kvp.Key.Value.
Hope it helps!
Nicolas Ferrari
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!