change the resolution of option history request to minute

This commit is contained in:
Jing Wu
2018-04-12 16:54:57 -04:00
parent 4fee2a8f3f
commit 4c86c5f3df
2 changed files with 12 additions and 10 deletions
@@ -45,7 +45,7 @@ class BasicTemplateOptionsHistoryAlgorithm(QCAlgorithm):
option.PriceModel = OptionPriceModels.CrankNicolsonFD()
option.SetFilter(-2,2, timedelta(0), timedelta(180))
self.SetBenchmark("GOOG")
self.SetBenchmark(lambda x: 0)
def OnData(self,slice):
if not self.Portfolio.Invested:
@@ -69,11 +69,11 @@ class BasicTemplateOptionsHistoryAlgorithm(QCAlgorithm):
contract.ImpliedVolatility))
def OnSecuritiesChanged(self, changes):
if changes == None: return
for change in changes.AddedSecurities:
history = self.History(change.Symbol, 10, Resolution.Hour).sort_index(level='time', ascending=False)[:3]
for i in range(len(history)):
self.Log("History: " + str(history.iloc[i].name[0])
+ ": " + str(history.iloc[i].name[1])
+ " > " + str(history.iloc[i]['close']))
# only print options price
if change.Symbol.Value == "GOOG": return
history = self.History(change.Symbol, 10, Resolution.Minute).sort_index(level='time', ascending=False)[:3]
for index, row in history.iterrows():
self.Log("History: " + str(index[3])
+ ": " + index[4].strftime("%m/%d/%Y %I:%M:%S %p")
+ " > " + str(row.close))