I want so select an ATM options with expiry near to 30, 60, 90 and 180 days. I know how to sort the options in respect of strikes and then just take the option that is nearest to the underlying price. But first I need to make four list for the respective expiry dates.

My question is how to add or substract a python date to x.Expiry if x is a option contract and get the days. Also how to get the actual date within the OnData function.

Author