I figured that there were two tickers that apparently have the same symbol code:
HTZ WBUEIDIFRPET
SNHNL WBUEIDIFRPET
First is Hertz Global Holdings, Inc. (HTZ) NYSE
second cannot be found on Yahoo Finance, but another source claims it is Senior Housing Properties Trust (SNHNL) on NASDAQ. I'm not sure if it is working or delisted. But there is no such data in QC data library, only for SNHN. But SNHN has different code V8HI7U4JO1GL
I don't think this is how it should be? At least I always assumed tickers have unique codes and use them as dict keys. But in my case I got both tickers at the same time slice and they clashed.
Yuri Lopukhov
I found another code like this:
CCH.U WYFPRLNUYVZ9
EDTXU WYFPRLNUYVZ9
ESTC WYFPRLNUYVZ9
OCCI WYFPRLNUYVZ9
CTACU WYFPRLNUYVZ9
Jared Broad
Hi Yuri - The whole string "SNHNL WBUEIDIFRPET" is the symbol code, not the tail section. The first string is the ticker it was listed with at the time the stock IPO'd. Some people try and string-split the symbol code and assume the first half is its current ticker - this is not correct and will result in weirdnessTM. We recommend always using the symbol object as its safest. Check out this documentation about the Symbol object.
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.
Yuri Lopukhov
But I am using Symbol object as the dict key, like this:
for x in coarse: if x.Symbol not in self.symbols: self.symbolData[x.Symbol] = SymbolData(x.Symbol)
Yuri Lopukhov
Maybe there is some other error, I'll try to isolate the issue in a separate algo tomorrow.
Yuri Lopukhov
ok, yes, it was a different thing. For some reason some symbols had two (or more) different values provided for the coarse function. Maybe it was related to them having the same code part with other symbols, but not in my code I think.
This is two separate entries in coarse collection in my coarse function, symbols are the same, time is the same, but other fields are different:
I'm not sure why is that, which of these is correct and how do I choose one? Is this situation expected to happen?
Code:
class DuplicateSymbolsInvestigation(QCAlgorithm): def Initialize(self): self.SetStartDate(2019, 10, 1) self.SetCash(100000) self.UniverseSettings.Resolution = Resolution.Daily self.AddUniverse(self.CoarseSelectionFunction, self.FineSelectionFunction) self.symbols = {} def CoarseSelectionFunction(self, coarse): # initialize stock data and update SMA, avg dollar volume and score processed = [] for x in coarse: if "CTACU" in str(x.Symbol): self.Debug(x) self.Debug(x.Symbol) if x.Symbol in processed: raise Exception(f"{x.Symbol} is duplicated") else: processed.append(x.Symbol) return [x.Symbol for x in coarse] def FineSelectionFunction(self, fine): return [x.Symbol for x in fine]
Shile Wen
Hi Yuri,
I've confirmed this issue and have reported this issue to the data team.
Best,
Shile Wen
Yuri Lopukhov
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!