Modifies python example algorithms to show implicit convertion benefits

This commit is contained in:
AlexCatarino
2017-06-15 18:40:34 +01:00
parent 6ca9d7cf14
commit 6242706342
22 changed files with 189 additions and 212 deletions
+6 -7
View File
@@ -33,9 +33,8 @@ class ScheduledEventsAlgorithm(QCAlgorithm):
self.SetEndDate(2013,10,11) #Set End Date
self.SetCash(100000) #Set Strategy Cash
# Find more symbols here: http://quantconnect.com/data
equity = self.AddEquity("SPY")
self.spy = equity.Symbol
self.AddEquity("SPY")
# events are scheduled using date and time rules
# date rules specify on what dates and event will fire
# time rules specify at what time on thos dates the event will fire
@@ -49,11 +48,11 @@ class ScheduledEventsAlgorithm(QCAlgorithm):
# schedule an event to fire every trading day for a security the
# time rule here tells it to fire 10 minutes after SPY's market open
self.Schedule.On(self.DateRules.EveryDay(self.spy), self.TimeRules.AfterMarketOpen(self.spy, 10), Action(self.EveryDayAfterMarketOpen))
self.Schedule.On(self.DateRules.EveryDay("SPY"), self.TimeRules.AfterMarketOpen("SPY", 10), Action(self.EveryDayAfterMarketOpen))
# schedule an event to fire every trading day for a security the
# time rule here tells it to fire 10 minutes before SPY's market close
self.Schedule.On(self.DateRules.EveryDay(self.spy), self.TimeRules.BeforeMarketClose(self.spy, 10), Action(self.EveryDayAfterMarketClose))
self.Schedule.On(self.DateRules.EveryDay("SPY"), self.TimeRules.BeforeMarketClose("SPY", 10), Action(self.EveryDayAfterMarketClose))
# schedule an event to fire on certain days of the week
self.Schedule.On(self.DateRules.Every(DayOfWeek.Monday, DayOfWeek.Friday), self.TimeRules.At(12, 0), Action(self.EveryMonFriAtNoon))
@@ -65,13 +64,13 @@ class ScheduledEventsAlgorithm(QCAlgorithm):
# schedule an event to fire at the beginning of the month, the symbol is optional
# if specified, it will fire the first trading day for that symbol of the month,
# if not specified it will fire on the first day of the month
self.Schedule.On(self.DateRules.MonthStart(self.spy), self.TimeRules.AfterMarketOpen(self.spy), Action(self.RebalancingCode))
self.Schedule.On(self.DateRules.MonthStart("SPY"), self.TimeRules.AfterMarketOpen("SPY"), Action(self.RebalancingCode))
def OnData(self, data):
'''OnData event is the primary entry point for your algorithm. Each new data point will be pumped in here.'''
if not self.Portfolio.Invested:
self.SetHoldings(self.spy, 1)
self.SetHoldings("SPY", 1)
def SpecificTime(self):