from clr import AddReference
AddReference("System")
AddReference("QuantConnect.Algorithm")
AddReference("QuantConnect.Common")
from System import *
from QuantConnect import *
from QuantConnect.Algorithm import *
from QuantConnect.Indicators import *
from QuantConnect.Data.Market import TradeBar
import numpy as np
import decimal as d
from datetime import timedelta, datetime
class OptionsAlgorithm(QCAlgorithm):
def Initialize(self):
self.SetStartDate(2015, 1, 1)
self.SetEndDate(2018, 12, 1)
self.SetCash(50000)
self.SetBrokerageModel(BrokerageName.InteractiveBrokersBrokerage)
self.equity = self.AddSecurity(SecurityType.Equity, "DGAZ", Resolution.Minute)
self.syl = self.equity.Symbol
self.counter = 5
self.Schedule.On(self.DateRules.EveryDay(),self.TimeRules.At(9, 35),Action(self.Rebalance))
def Rebalance(self):
self.counter +=1
if self.counter >= 5:
self.SetHoldings(self.syl, 0.1)
self.counter = 0
#end