Refactors options algorithms
AddEquity and SetDataNormalization calls were removed because they are not mandatory since PostInitialize calls them.
This commit is contained in:
@@ -14,14 +14,12 @@
|
||||
from clr import AddReference
|
||||
AddReference("System")
|
||||
AddReference("QuantConnect.Algorithm")
|
||||
AddReference("QuantConnect.Indicators")
|
||||
AddReference("QuantConnect.Common")
|
||||
|
||||
from System import *
|
||||
from QuantConnect import *
|
||||
from QuantConnect.Algorithm import *
|
||||
from QuantConnect.Indicators import *
|
||||
from datetime import datetime
|
||||
from datetime import datetime, timedelta
|
||||
|
||||
### <summary>
|
||||
### Options Open Interest data regression test.
|
||||
@@ -31,23 +29,17 @@ from datetime import datetime
|
||||
class OptionOpenInterestRegressionAlgorithm(QCAlgorithm):
|
||||
|
||||
def Initialize(self):
|
||||
|
||||
self.SetCash(1000000)
|
||||
self.SetStartDate(2014,06,05)
|
||||
self.SetEndDate(2014,06,06)
|
||||
equity = self.AddEquity("twx")
|
||||
option = self.AddOption("twx")
|
||||
Underlying = equity.Symbol
|
||||
self.OptionSymbol = option.Symbol
|
||||
# set our strike/expiry filter for this option chain
|
||||
option.SetFilter(-10, 10, TimeSpan.Zero, TimeSpan.FromDays(365*2))
|
||||
# use the underlying equity as the benchmark
|
||||
self.SetBenchmark(Underlying)
|
||||
equity.SetDataNormalizationMode(DataNormalizationMode.Raw)
|
||||
|
||||
''' Event - v3.0 DATA EVENT HANDLER: (Pattern) Basic template for user to override
|
||||
for receiving all subscription data in a single event
|
||||
<param name="slice">The current slice of data keyed by symbol string</param> '''
|
||||
option = self.AddOption("TWX")
|
||||
|
||||
# set our strike/expiry filter for this option chain
|
||||
option.SetFilter(-10, 10, timedelta(0), timedelta(365*2))
|
||||
|
||||
# use the underlying equity as the benchmark
|
||||
self.SetBenchmark("TWX")
|
||||
|
||||
def OnData(self, slice):
|
||||
if not self.Portfolio.Invested:
|
||||
@@ -63,11 +55,6 @@ class OptionOpenInterestRegressionAlgorithm(QCAlgorithm):
|
||||
if slice.Time.date() == datetime(2014, 06, 6).date():
|
||||
self.MarketOrder(contract.Symbol, 1)
|
||||
self.MarketOnCloseOrder(contract.Symbol, -1)
|
||||
|
||||
|
||||
# Order fill event handler. On an order fill update the resulting information is passed to this method.
|
||||
# </summary>
|
||||
# <param name="orderEvent">Order event details containing details of the events</param>
|
||||
|
||||
|
||||
def OnOrderEvent(self, orderEvent):
|
||||
self.Log(str(orderEvent))
|
||||
Reference in New Issue
Block a user