Update Python regression tests to match C# equivalents
This commit is contained in:
@@ -32,8 +32,8 @@ from datetime import datetime
|
||||
class CoarseFineFundamentalRegressionAlgorithm(QCAlgorithm):
|
||||
|
||||
def Initialize(self):
|
||||
self.SetStartDate(2014,4,1) #Set Start Date
|
||||
self.SetEndDate(2014,4,30) #Set End Date
|
||||
self.SetStartDate(2014,3,24) #Set Start Date
|
||||
self.SetEndDate(2014,4,7) #Set End Date
|
||||
self.SetCash(50000) #Set Strategy Cash
|
||||
|
||||
self.UniverseSettings.Resolution = Resolution.Daily
|
||||
@@ -47,14 +47,15 @@ class CoarseFineFundamentalRegressionAlgorithm(QCAlgorithm):
|
||||
self.numberOfSymbolsFine = 2
|
||||
|
||||
# return a list of three fixed symbol objects
|
||||
def CoarseSelectionFunction(self, coarse):
|
||||
def CoarseSelectionFunction(self, coarse):
|
||||
tickers = [ "GOOG", "BAC", "SPY" ]
|
||||
|
||||
if self.Time < datetime(2014, 4, 5):
|
||||
dt = datetime(self.Time.year, self.Time.month, self.Time.day)
|
||||
if dt < datetime(2014, 4, 1):
|
||||
tickers = [ "AAPL", "AIG", "IBM" ]
|
||||
|
||||
|
||||
return [ Symbol.Create(x, SecurityType.Equity, Market.USA) for x in tickers ]
|
||||
|
||||
|
||||
|
||||
# sort the data by P/E ratio and take the top 'NumberOfSymbolsFine'
|
||||
def FineSelectionFunction(self, fine):
|
||||
@@ -76,12 +77,12 @@ class CoarseFineFundamentalRegressionAlgorithm(QCAlgorithm):
|
||||
|
||||
# we want 50% allocation in each security in our universe
|
||||
for security in self.changes.AddedSecurities:
|
||||
self.SetHoldings(security.Symbol, 0.5)
|
||||
self.Debug("Purchased Stock: " + str(security.Symbol.Value))
|
||||
if (security.Fundamentals.EarningRatios.EquityPerShareGrowth.OneYear > 0.25):
|
||||
self.SetHoldings(security.Symbol, 0.5)
|
||||
self.Debug("Purchased Stock: " + str(security.Symbol.Value))
|
||||
|
||||
self.changes = None
|
||||
|
||||
|
||||
# this event fires whenever we have changes to our universe
|
||||
def OnSecuritiesChanged(self, changes):
|
||||
self.changes = changes
|
||||
Reference in New Issue
Block a user