Hi,
The below code is not able to fetch delta for options for initial 1-2 days. I am using WarmUp Period but that is not able to help delta calculation. Is there a way to manually warmup options delta calculations as well in this case or any better idea to achieve this:
import numpy as np
from datetime import timedelta
from QuantConnect.Securities.Option import OptionPriceModels
### <summary>
### Basic template algorithm simply initializes the date range and cash. This is a skeleton
### framework you can use for designing an algorithm.
### </summary>
class BasicTemplateAlgorithm(QCAlgorithm):
'''Basic template algorithm simply initializes the date range and cash'''
def Initialize(self):
self.SetStartDate(2017, 6, 1)
self.SetEndDate(2017, 6, 15)
self.SetWarmUp(timedelta(60)) # Warm up technical indicators
self.AddEquity("IBM", Resolution.Minute)
self.Schedule.On(self.DateRules.EveryDay("IBM"),self.TimeRules.AfterMarketOpen("IBM", 30),Action(self.add_option))
self.Schedule.On(self.DateRules.EveryDay("IBM"),self.TimeRules.AfterMarketOpen("IBM", 60),Action(self.print_first_hour))
def OnData(self, slice):
self.option_data = slice
def add_option(self):
self.option = self.AddOption("IBM", Resolution.Minute)
self.option.SetFilter(-3, +3, timedelta(0), timedelta(30))
self.option.PriceModel = OptionPriceModels.CrankNicolsonFD()
def print_first_hour(self):
for chain in self.option_data.OptionChains.Values:
self.Log(f'{self.Time}--> Values of Delta: {[x.Greeks.Delta for x in chain]}')
Thanks.
Varad Kabade
Hi Abhishek Gupta,
To resolve the issue, please move the add option code to the Initialize method. Why do you need to use the scheduled event method to add an option? We do not recommend it. Refer to the attached backtest.
Is there a way to manually warmup options delta calculations as well in this case or any better idea to achieve this:
To calculate the Delta of options contracts, we need to ensure the volatility model of the underlying security is warmed up.
Best,
Varad Kabade
Abhishek Gupta
Hi Varad Kabade,
Thanks for you response.
Adding options in initialize works great for few symbols, however for larger lists(>50 or more), algo is not able to handle this much data and runs endlessly.
Hence, my solution was to schedule and add and remove options on the fly, however not getting values of delta in this case.
Regards,
Abhishek
Varad Kabade
Hi Abhishek Gupta,
To get delta values, we need to ensure the volatility model of the underlying security is warmed up. Refer to this thread for more information.
Best,
Varad Kabade
Abhishek Gupta
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!