Hi,
Please, help! My algo is getting stuck after running for some time.
Here is the simplified code that causes this:
import itertools
import pandas as pd
STOCKS = ['A', 'AABA', 'AAPL', 'ABT', 'ALGN', 'AMAT', 'AMZN', 'AVGO', 'AVY', 'BA',
'BAC', 'BAX', 'BDX', 'BHGE', 'BKNG', 'C', 'CA', 'CAT', 'CBS', 'CLX',
'CREE', 'CTSH', 'CVX', 'DE', 'DOV', 'DWDP', 'DXC', 'DXCM', 'ELY', 'EMN',
'ERIC', 'ESRX', 'ETN', 'EW', 'GE', 'GM', 'GRMN', 'HAL', 'HIG', 'HMC',
'HON', 'HPQ', 'HRS', 'IBM', 'INTC', 'IP', 'ITW', 'JNJ', 'JPM', 'KMB',
'KO', 'LMT', 'MA', 'MAT', 'MDLZ', 'MDT', 'MET', 'MMM', 'MON', 'MSFT',
'MSI', 'MU', 'NCR', 'NKE', 'NOC', 'ORCL', 'PFE', 'PG', 'PGR', 'PRU',
'PX', 'QCOM', 'ROK', 'RTN', 'SEE', 'SLB', 'SNE', 'SON', 'STX', 'SYK',
'T', 'TEL', 'TER', 'TEVA', 'TGT', 'TXN', 'TXT', 'UNCH', 'UNCH', 'UNH',
'UTX', 'V', 'VRX', 'VZ', 'WHR', 'WRK', 'WY', 'XLNX', 'XOM', 'XRX']
class TestAlgorithm(QCAlgorithm):
def Initialize(self):
self.SetStartDate(2003, 7, 1)
self.SetEndDate(2018, 4, 1)
self.symbols = [self.AddEquity(stock, Resolution.Daily).Symbol \
for stock in STOCKS]
self.Schedule.On(self.DateRules.MonthStart("AAPL"),
self.TimeRules.BeforeMarketClose("AAPL", 60),
Action(self.justdoit))
self.SetRunMode(RunMode.Series)
self.SetWarmUp(300, Resolution.Daily)
def justdoit(self):
self.Debug('Time: %s' % self.Time)
for period1, period2 in itertools.product([21, 42, 63, 84], [168, 189, 210]):
hist1 = self.History(STOCKS, period1, Resolution.Daily).close.unstack(level=0)
hist2 = self.History(STOCKS, period2, Resolution.Daily).close.unstack(level=0)
As you can see the code calls History and converts the output to the dataframe. There is nothing special in it except that it's done in a loop for combinations of periods. It works just fine for some time and then it simply stucks without producing any errors. Usually it happens after 16 iterations. It's 100% reproducible.
Any ideas what could be the reason of this?
Regards,
Ed