I created a notebook to illustrate a problem showing symbol names. CHV and CVX refer to the same underlying security. CHV changed its ticker to CVX some time ago. The problem is this: when I access data for CVX or CHV, I don't see a way to get the current ticker for the symbol. Is there a way I can get from c as defined in the notebook below to CVX? I'd like to be able to log the current ticker for symbols when backtesting rather than the outdated ticker that I currently get.
Varad Kabade
Hi Sunil Mishra,
The ticker which we used to add the security is the current ticker of the symbol. We can access it by the following method:
Note that we can add the data frame key by the Symbol object, string representation of the symbol when we add the security manually.
Best,
Varad Kabade
Sunil Mishra
I understand how to get symbols present in the history. Please look again at my example again. I register three securities, get back two. That's because CVH was the old ticker for CVX. Instead of getting back CVX as the ticker for the symbol though I get back CVH. How can I access the current ticker for a symbol instead?
There are several symbols for which quantconnect returns an older ticker, rather than the latest.
Sunil
Alexandre Catarino
Hi Sunil Mishra ,
The History request is only returning data of 2 securities because the look-back period is not enough to fetch CHV data, since it has traded from 2007-03-17 to 2008-12-20:
The current ticker is the ticker that we use in the AddEquity method.
Sunil Mishra
Hello Alexandre Catarino
Thanks for the response. I'll provide a simpler interaction that illustrates the problem more clearly.
I don't add CHV at all. And I get a history response with CHV in it. I hope this illustrates the problem more clearly. Given a symbol, I would like to obtain the current stock ticker for the symbol. Quantconnect appears to default to presenting old stock tickers for many symbols.
Sunil
David Avraamides
Sunil,
I believe the identifier you are seeing is simply the unique internal identifier associated with the current price series for CVX. It looks like CHV (Chevron) was renamed to CVX (Chevron Texaco) at some point. (This is why tickers are such an unreliable identifier for stocks - they are renamed and or reused all the time.) These identifiers are explained here: https://www.quantconnect.com/docs/key-concepts/security-identifiers
Below you can see that when you add CVX, you are indeed adding the symbol CVX and the prices you show line up with CVX price history.
Sunil Mishra
Hi David,
Thanks for the explanation for why things behave this way. I'd like to know though how I can translate the CHV I get back from the history function to CVX, when the call I had originally made to history was with the ticker CVX.
Sunil
David Avraamides
Hi Sunil,
It appears you would need to keep track of that yourself since the History data frame doesn't include the full Symbol object, only the unique identifier as a string. You could track this mapping yourself after adding a symbol and looking up its history, like so:
Alexandre Catarino
Hi Sunil Mishra ,
The historical data request returns a multi-index data frame where the Security Identifier is one of the indices, Please check out the docs, under Security Identifier for more detail.
These data frames are enhanced by QuantConnect/Lean in order to use the current ticker or the Symbol object:
Sunil Mishra
Alexandre Catarino I really appreciate your attempts at helping me. There are things in your code that I wasn't aware of. But it doesn't help me with my use case. As I run my algorithms I like logging parts of the output, and validating those outputs against charts etc. from other services. That's just easier for me to do.
When the history function returns me chv, that imposes on me an extra layer of effort where I have to go through and figure out what the current ticker for chv is. chv/cvx is relatively simple, as this is a major company. Others that I have had trouble with include SAI, WTW, HB, and dozens of others. It would be nice if there were an API to fetch the current ticker for a symbol given an exchange and/or region. There must be something like this in quantconnect as you're clearly able to resolve chv and cvx to the same underlying symbol.
Sunil
Alexandre Catarino
Hi Sunil Mishra ,
Please let clarify one point: the History function does not return CHV. It returns the Security Identifier for CVX which “permtick” (the first ticker that represented the security) is CHV.
You can use the following code to rename the index:
Sunil Mishra
Hello Alexandre Catarino
Of course you're right, the history function returns symbols not tickers. I was playing fast and loose with my writing.
Your suggestion though does not solve my problem, which is as follows:
If at the end of (3) I have included the symbol for chevron, I would like the log statement to say CVX, not CHV. Given the current behavior of quantconnect, I always get CHV. And as I've said before, there are many symbols for which QuantConnect does not report the current ticker, but a historic one. It isn't practical for me to build a mapping of symbols to current ticker. Can QuantConnect provide me with one, if not actually report the current ticker for each symbol? The code I have presented thus far is a much simplified version of what I'm doing, and is there only to illustrate the problem. I don't want something that satisfies only the context of the code, that's not going to help me.
Sunil
Alexandre Catarino
Hi Sunil Mishra ,
QuantConnect/Lean does not report the “historic ticker”. It uses a Symbol object that is composed of the Security Identifier, and the ticker. The ticker value depends on how the security is added to the algorithm,
If we use Universe Selection to select Chevron before the ticker change on Oct 09th, 2001, we will get:
symbol.ID → CHV R735QTJ8XC9X
symbol.Value → CHV
On the other hand, if Universe Select picks Chevron after Oct 9th, 2001, the values are:
symbol.ID → CHV R735QTJ8XC9X
symbol.Value → CVX
In order to get the current ticker for every available security that is currently trading, we can use:
Sunil Mishra
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!