Hi, I'm new here.
Here's what I try to do.
1. I only trade on the 4th Monday of the month
2. I only look at the monthly contract, to be exact 1 month from now, and at the beginning of the hour (not by the minute)
3. I want to get strike price between 0.9*price and 1.1*price
I wonder what is the best way to do it. I have the following code. Even though my start date is 2015/8/24, but I found the program start on 2015/9/14, not sure why.
Thanks.
Dan
-----------------------------------------
import pandas as pd
class QuantumVentralAutosequencers(QCAlgorithm):
def Initialize(self):
self.SetStartDate(2015, 8, 24) #Set Start Date
self.SetEndDate(2015, 9, 19) #Set End Date
self.SetCash(100000) #Set Strategy Cash
equity = self.AddEquity("QQQ", Resolution.Minute) # Add the underlying stock: QQQ
option = self.AddOption("QQQ", Resolution.Minute) # Add the option corresponding to underlying stock
self.symbol = option.Symbol
option.SetFilter(-10, +10, timedelta(26), timedelta(32))
def OnData(self, slice):
for i in slice.OptionChains:
self.Log(str(self.Time))
# print(i.key)
if i.Key != self.symbol: continue
optionchain = i.Value
self.Log("underlying price:" + str(optionchain.Underlying.Price))
df = pd.DataFrame([[x.Right,float(x.Strike),x.Expiry,float(x.BidPrice),float(x.AskPrice)] for x in optionchain],
index=[x.Symbol.Value for x in optionchain],
columns=['type(call 0, put 1)', 'strike', 'expiry', 'ask price', 'bid price'])
# self.Log(str(df))