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:

  1. import numpy as np
  2. from datetime import timedelta
  3. from QuantConnect.Securities.Option import OptionPriceModels
  4. ### <summary>
  5. ### Basic template algorithm simply initializes the date range and cash. This is a skeleton
  6. ### framework you can use for designing an algorithm.
  7. ### </summary>
  8. class BasicTemplateAlgorithm(QCAlgorithm):
  9. '''Basic template algorithm simply initializes the date range and cash'''
  10. def Initialize(self):
  11. self.SetStartDate(2017, 6, 1)
  12. self.SetEndDate(2017, 6, 15)
  13. self.SetWarmUp(timedelta(60)) # Warm up technical indicators
  14. self.AddEquity("IBM", Resolution.Minute)
  15. self.Schedule.On(self.DateRules.EveryDay("IBM"),self.TimeRules.AfterMarketOpen("IBM", 30),Action(self.add_option))
  16. self.Schedule.On(self.DateRules.EveryDay("IBM"),self.TimeRules.AfterMarketOpen("IBM", 60),Action(self.print_first_hour))
  17. def OnData(self, slice):
  18. self.option_data = slice
  19. def add_option(self):
  20. self.option = self.AddOption("IBM", Resolution.Minute)
  21. self.option.SetFilter(-3, +3, timedelta(0), timedelta(30))
  22. self.option.PriceModel = OptionPriceModels.CrankNicolsonFD()
  23. def print_first_hour(self):
  24. for chain in self.option_data.OptionChains.Values:
  25. self.Log(f'{self.Time}--> Values of Delta: {[x.Greeks.Delta for x in chain]}')
+ Expand

 

Thanks.

 

Author

Abhishek Gupta

June 2021