def initializeWorkers(self): ''' initializes workers from scratch ''' # creates 7 dimensional array for ma in self.mas: for md in self.mds: for smooth in self.smooths: for percent in self.percents: for riseTol in self.riseTols: for lossTol in self.lossTols: curKey = (ma, md, smooth, percent, riseTol, lossTol) print curKey # initialize self.workers[curKey] = observer( smooth, md, ma, percent, lossTol, riseTol) # take the first 100 points in data file self.workers[curKey].loadData( self.price_data[0, 0:100].tolist(), self.price_data[1, 0:100].tolist()) # cycle over the rest of the historical data for i in range(100, len(self.price_data[0, :])): self.workers[curKey].step( self.price_data[0, i], self.price_data[1, i])
def initializeWorkers(self): ''' initializes workers from scratch ''' # how many initial data points to load so that moving windows are defined. initialLoadN = 2*max(max(self.mas),max(self.mds),max(self.smooths)) # time this process timer= time.time() # creates 7 dimensional array for ma in self.mas: for md in self.mds: for smooth in self.smooths: for percent in self.percents: for riseTol in self.riseTols: for lossTol in self.lossTols: curKey = (ma,md,smooth,percent,riseTol,lossTol) # visual to see that things are running. print curKey # initialize self.workers[curKey] = observer(smooth,md,ma,percent,lossTol,riseTol) # take the first 100 points in data file self.workers[curKey].loadData(self.price_data[0,0:initialLoadN ].tolist(),self.price_data[1,0:initialLoadN ].tolist()) # cycle over the rest of the historical data for i in xrange(initialLoadN,len(self.price_data[0,:])): self.workers[curKey].step(self.price_data[0,i],self.price_data[1,i]) # Display how long the initialization took. duration = round((time.time() - timer)/60,1) print 'It took %s minutes to intiialize %s observer. %s minutes per observer.' % (duration,self.numWorkers,round(duration/self.numWorkers,2))
def initializeWorkers(self): ''' initializes workers from scratch ''' # how many initial data points to load so that moving windows are defined. initialLoadN = 2*max(max(self.mas),max(self.mds),max(self.smooths)) # time this process timer= time.time() # creates 7 dimensional array for ma in self.mas: for md in self.mds: for smooth in self.smooths: for percent in self.percents: for riseTol in self.riseTols: for lossTol in self.lossTols: curKey = (ma,md,smooth,percent,riseTol,lossTol) # visual to see that things are running. print curKey # initialize self.workers[curKey] = observer(smooth,md,ma,percent,lossTol,riseTol) # take the first 100 points in data file self.workers[curKey].loadData(self.price_data[0,0:initialLoadN ].tolist(),self.price_data[1,0:initialLoadN ].tolist()) # cycle over the rest of the historical data for i in range(initialLoadN,len(self.price_data[0,:])): self.workers[curKey].step(self.price_data[0,i],self.price_data[1,i]) # Display how long the initialization took. duration = round((time.time() - timer)/60,1) print 'It took %s minutes to intiialize %s observer. %s minutes per observer.' % (duration,self.numWorkers,round(duration/self.numWorkers,2))
def initializeWorkers(self): ''' initializes workers from scratch ''' # creates 7 dimensional array for ma in self.mas: for md in self.mds: for smooth in self.smooths: for percent in self.percents: for riseTol in self.riseTols: for lossTol in self.lossTols: curKey = (ma,md,smooth,percent,riseTol,lossTol) print curKey # initialize self.workers[curKey ] = observer(smooth,md,ma,percent,lossTol,riseTol) # take the first 100 points in data file self.workers[curKey].loadData(self.price_data[0,0:100].tolist(),self.price_data[1,0:100].tolist()) # cycle over the rest of the historical data for i in range(100,len(self.price_data[0,:])): self.workers[curKey].step(self.price_data[0,i],self.price_data[1,i])
#!/usr/bin/python ''' This is just a functional test of observer class ''' # These are the modules created for this project from observer import * from common import * # Load data datas= loadData(data='data/test_data.txt') #datas= loadData(data='data/btc_usd_btce.txt') # Not a best performing parameter set -- highlights potential problems # Might show that something is not working as intended . # ma md smooth percent riseTol lossTol # current best: 100 40 10 0.1 0.7 0.1 x = observer(smooth=10,md=40,ma=100,percent=0.1,riseTolerance=0.7,lossTolerance=0.1) # Start with the first 100 points in the set x.loadData(datas[0,0:100].tolist(),datas[1,0:100].tolist()) # "step" through the rest. for i in range(100,len(datas[0,:])): x.step(datas[0,i],datas[1,i]) # Make a plot #x.plot_trades()as
''' # These are the modules created for this project from observer import * from common import * # Load data datas = loadData(data='data/test_data.txt') #datas= loadData(data='data/btc_usd_btce.txt') # Not a best performing parameter set -- highlights potential problems # Might show that something is not working as intended . # ma md smooth percent riseTol lossTol # current best: 100 40 10 0.1 0.7 0.1 x = observer(smooth=10, md=40, ma=100, percent=0.1, riseTolerance=0.7, lossTolerance=0.1) # Start with the first 100 points in the set x.loadData(datas[0, 0:100].tolist(), datas[1, 0:100].tolist()) # "step" through the rest. for i in range(100, len(datas[0, :])): x.step(datas[0, i], datas[1, i]) # Make a plot #x.plot_trades()as