def __init__(self, market_path): self.market_num = 0 self.markets = [] self.test_markets = [] self.adjust = [] self.comp = [] file = open(market_path, 'r') for line in file: try: self.markets.append( stock_state.Stock_state('./stock_data/' + line[:-1] + '_train.csv', 1., action_num=ACTIONS)) adj = self.markets[-1].GetAdjust() self.test_markets.append( stock_state.Stock_state('./stock_data/' + line[:-1] + '_test.csv', 1., action_num=ACTIONS, Adjust=adj)) self.markets[-1].SetMinLen(self.test_markets[-1].GetSize()) self.adjust.append(adj) self.market_num += 1 self.comp.append(line[:-1]) except: raise "stock data of comp. " + line[:-1] + "not found!" file.close()
def __init__(self, market_path): self.market_num = 0 self.markets = [] self.test_markets = [] self.adjust = [] self.comp = [] train_range = getYear("training") test_range = getYear("testing") file = open(market_path, 'r') for line in file: try: self.markets.append( stock_state.Stock_state('./stock_data/' + line[:-1] + '.csv', bids=1., action_num=ACTIONS, DAY_RANGE=DAYS_RANGE, start_y=train_range[0], end_y=train_range[1])) adj = self.markets[-1].GetAdjust() self.test_markets.append( stock_state.Stock_state('./stock_data/' + line[:-1] + '.csv', bids=1., action_num=ACTIONS, DAY_RANGE=DAYS_RANGE, start_y=test_range[0], end_y=test_range[1], Adjust=adj)) # self.markets[-1].SetMinLen(self.test_markets[-1].GetSize()) self.adjust.append(adj) self.market_num += 1 self.comp.append(line[:-1]) except IOError: raise Exception("stock data of comp. " + line[:-1] + "not found!") except ValueError as e: raise Exception("error: " + str(e)) file.close()