Hi forum,
I'm trying to pull string aliases assigned with Symbol.CreateOption()
I'm assigning randomized strings as aliases to options added to my universe, then using those aliases as indexes in a Dataframe to retrieve data. However, when I try to use the option (which looks like the alias when debugged as a string) to look through the Dataframe, I end up with the contract format: 'AAPL XUERCWCTYX6U|AAPL R735QTJ8XC9X' instead.
The GetAlias() method looks helpful for this, but I'm new and haven't been able to find an example of it's use. I've tried Symbol.GetAlias(option).
for kvp in self.Securities:
symbol = kvp.Key
security = kvp.Value
if security.Symbol.SecurityType == SecurityType.Option:
index = symbol
for option in self.ActiveSecurities:
self.Debug("ind: " + index)
row = self.alertDF.loc[str(index)]
This debug gives me the string I'm looking for, but I get an error that tells me I'm using the contract format to search through my Dataframe instead.
for kvp in self.Securities:
symbol = kvp.Key
security = kvp.Value
if security.Symbol.SecurityType == SecurityType.Option:
self.option = symbol
for option in self.ActiveSecurities:
index = Symbol.GetAlias(self.option)
self.Debug("ind: " + index)
row = self.alertDF.loc[str(index)]
Using GetAlias() like I did to add the option contract to my universe gives me a TypeError exception. The same error happens if I try to use it like self.option.GetAlias()
I'm hoping someone can help me out. Thanks in advance for your time on this.
Varad Kabade
Hi Tomes,
In the above snippet, we are passing the Symbol object instead of the Security identifier and the Symbol for underlying security: To resolve this we recommend using the following :
Best,
Varad Kabade
Def returns
You're awesome - thanks Varad Kabade I'm still wrapping my head around object types and stuff.
Def returns
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!