Back

Accessing ContractMultiplier in Data.Market.OptionContract vs Securities.Option.Option

How come the Option class has a ContractMultiplier attribute whereas the OptionContract class doesn't? ContractMultiplier (or possibly ContractUnitOfTrade as well) just say how many shares are returned for each option.

It's not clear what the Securities.Option.Option class is? It appears to be a collection of all the possible option added to universe but not one specific option. Whereas Data.Market.OptionContract is more clearly a specific option contract with a set strike price and expiry. The kind of thing that I'd like to be able to access the ContractMultiplier for, just because occasionally the multiplier is different!

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 Hello,

In LEAN, the multiplier should always be the same in Securities.Option.Option. Could you give us an example when the multiplier is different so that we can better assist you?

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.


Not every option contract will have 100 as its multiplier. But the way the code is set up, the multiplier appears to assigned on an equity wide basis, i.e. all options for GOOG will have a multiplier of 100. Whereas in reality the multiplier might be different on a contract by contract basis for different options on the same underlying equity. I'll see if I can dredge up an example somewhere with a link.

0

So for example when there is a stock split or a special dividend the multiplier will be different. In the Interactive Brokers API there's a field for multiplier on each contract https://interactivebrokers.github.io/tws-api/classIBApi_1_1Contract.html . At the moment I've only been messing around with backtesting and reading the documentation but it looked like this information might not be available according to the QuantConnect docs. 

0

Hi Hello,

Thank you for the additional information.

Within Securities.Option.Option, there are multiple option contracts for the same underlying stock with different expiry and strike price. In LEAN, These option contracts have the same multiplier. Regarding the scenario you raised about a stock split or a special dividend, this group of option contracts would be adjusted and have a different multiplier timewise. But, they still have the same multiplier group-wise.

Please let me know if there's an example that the multiplier should be different within the contracts group so that I can assist you further.

Best,

Xin

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.


So let's say we have an securities.option.option object which has been initialized to cover all the options for a given underlying security. And separately we have a portfolio object containing some purchased options, so a bunch of securities.option.optionholding objects. How is it possible to access securities.option.option objects for the individual options rather than as a group? I'm not sure which methods or attributes to use to access the individual option objects within the group. https://www.quantconnect.com/lean/documentation/topic27617.html

0

Hi Henry,

When the algorithm subscribes to receive data from a given Option, AddOption(string ticker), a "canonical" Security is created:

#In Initialize
canonicalOption = self.AddOption("AAPL")
canonicalSymbol = canonicalOption.Symbol
canonicalOption.SetFilter(-2, 2, timedelta(0), timedelta(180))

During runtime, the engine will dynamically subscribe and unsubscribe to receive data from option contracts that fall under the filter criteria. For each new subscription, a new Option object will be created and added to QCAlgorithm.Securities. These Option objects will share the same properties of the canonical security (resolution, contract multiplier, lot size, etc,,,):

def Initialize(self):
option = self.AddOption("AAPL")
self.Debug(f'{option.Symbol}: Contract Multiplier: {option.SymbolProperties.ContractMultiplier}')


OptionContract object is not or derived from the Option (which derived from Security) object. Its sole purpose is to gather in one place/object prices, open interest, greeks, implied volatility, theoretical price, and underlying price. 
Finally, OptionHoldings object purpose is for purchasing and holding a market item which manages the asset portfolio.

Since all these objects share the same Symbol object and are saved in Dictionaries keyed by Symbol, it is easy to navigate across the algorithm to get the properties we need.

In the QCAlgorithm.Securities, we can find all the Option objects:

for kv in self.Securities:
symbol = kv.Key
security = kv.Value # can be Equity or Option object
if security.Type != SecurityType.Option:
continue
# logic to find the desired Option object

Hope it helps!

2

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.


ok great! 

So the answer effectively is it's possible to access securities using the self.Securities variable. 

"These Option objects will share the same properties of the canonical security (resolution, contract multiplier, lot size, etc,,,):"

This part doesn't sound great, as different contracts may have different multipliers than the canonical value, but maybe it will work differently if the data is being pulled from interactive brokers.

Thanks for the help!

0

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