I've got historical data for a spy option chain which looks as follows
UnderlyingSymbol UnderlyingPrice Exchange OptionRoot \
SPY 289.84 * SPY180904C00150000
Type Expiration DataDate Strike Last Bid \
call 09/04/2018 09/04/2018 150.0 136.71 139.86
Ask Volume OpenInterest T1OpenInterest
140.12 0 251 0
I am trying to calculate for hedge purposes the underlying future/forward associated with each expiration date. My attempt would be to group put and calls by expiration and strike. Take the difference between put mid price and call mid and add the minimum difference of each group to the strike. Python code would look like this
df['Price'] = (df['Bid'].values + df['Ask'].values) / 2
df['Maturity'] = (df['Expiration'] - df['DataDate']).dt.days / 365
c = df[df.Type == 'call'].groupby(['Expiration','Strike'])['Price'].first()
p = df[df.Type == 'put'].groupby(['Expiration','Strike'])['Price'].first()
df = df.join((c - p).rename('CP_diff'), on=['Expiration','Strike'])
df = df[~df.CP_diff.isna()]
df['Forward'] = df['CP_diff'].values + df['Strike']
Would my approach be valid as a crude approximation? What other possibilities would I have, besides pulling the data from bloomberg.