Back

Implied volatility in Python

Is it possible to get an option's implied volatility in Python?

For example BasicTemplateOptionsHistoryAlgorithm.cs works fine in C#,  printing out option Greeks and IV, but BasicTemplateOptionsHistoryAlgorithm.py is giving the following: Runtime Error: Python.Runtime.PythonException: KeyError : 'Level symbol must be same as name (None)'

It also looks like option.PriceModel cannot be set in the Python code.

Update Backtest








Thanks for the message Turbo. We'll look into it.

Bugs reported to the forums get lost :) Please send support tickets for this.

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 TurboDzyl, you can set the PriceModel by import the library

from QuantConnect.Securities.Option import OptionPriceModels

The updated backtest code attached

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.


Thanks Jing, Jared! Now it works as it should.

0

However the Greeks delta, gamma and theta are still showing 0, is there an equally simple solution for that?

0

Never mind, seems to be working now. 

Am I correct that option data is only available in minute resolution? If so, is there a way to access the slice object on a larger resulotion (day or hour)? I've looked into consolidators but they seem to provide a bar object only.

1

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