示例#1
0
def getHistoricData(symbols, **options):
    ''' 
    get data from Yahoo finance and return pandas dataframe
    Will get OHLCV data frame if sinle symbol is provided. 
    If many symbols are provided, it will return a wide panel
    
    Parameters
    ------------
    symbols: Yahoo finanance symbol or a list of symbols
    sDate: start date (y,m,d)
    eDate: end date (y,m,d)
    adjust : T/[F] adjust data based on adj_close
    
    '''
    
    assert isinstance(symbols,(list,str)), 'Input must be a string symbol or a list of symbols'
    
    if isinstance(symbols,str):
        return getSymbolData(symbols,**options)
    else:
        data = {}
        print 'Downloading data:'
        p = ProgressBar(len(symbols))
        for idx,symbol in enumerate(symbols):
            p.animate(idx+1)
            data[symbol] = getSymbolData(symbol,verbose=False,**options)
        
        return Panel(data)
示例#2
0
    def loadDates(self, dates):
        ''' load multiple dates, concantenating to one DataFrame '''
        tmp = []
        print 'Loading multiple dates for ', self.symbol
        p = ProgressBar(len(dates))

        for i, date in enumerate(dates):
            tmp.append(self.loadDate(date))
            p.animate(i + 1)

        print ''
        return concat(tmp)
示例#3
0
文件: bats.py 项目: syedpeer/pytrade
    def loadData(self):
        ''' load data from zip files '''
        data = []

        pb = ProgressBar(len(self.dates)-1)

        for idx, date in enumerate(self.dates):
            data.append(self.loadDate(date))
            pb.animate(idx)

        self.shortRatio = pd.DataFrame(data)
        return self.shortRatio
 def loadDates(self,dates):
     ''' load multiple dates, concantenating to one DataFrame '''
     tmp =[]
     print 'Loading multiple dates for ' , self.symbol        
     p = ProgressBar(len(dates))
     
     for i,date in enumerate(dates):
         tmp.append(self.loadDate(date))
         p.animate(i+1)
         
     print ''
     return concat(tmp)
示例#5
0
    def downloadData(self, symbols='all'):
        ''' get data from yahoo  '''

        if symbols == 'all':
            symbols = self.symbols

        #store = HDFStore(self.dataFile)
        p = ProgressBar(len(symbols))

        for idx, symbol in enumerate(symbols):

            try:
                df = getHistoricData(symbol, self.startDate, verbose=False)
                if self.autoAdjust:
                    df = _adjust(df, removeOrig=True)

                if len(self.symbols) == 0:
                    self.wp = WidePanel({symbol: df})
                else:
                    self.wp[symbol] = df

            except Exception, e:
                print e
            p.animate(idx + 1)
 def downloadData(self,symbols='all'):
     ''' get data from yahoo  '''
     
     if symbols == 'all':
         symbols = self.symbols
     
     #store = HDFStore(self.dataFile)        
     p = ProgressBar(len(symbols))
     
     for idx,symbol in enumerate(symbols):
         
         try:            
             df = getSymbolData(symbol,sDate=self.startDate,verbose=False)
             if self.autoAdjust:
                 df =  _adjust(df,removeOrig=True)
             
             if len(self.symbols)==0:
                 self.wp = Panel({symbol:df})
             else:
                 self.wp[symbol] = df
         
         except Exception,e:
             print e 
         p.animate(idx+1)