def load(self,fn): infile = itrade_csv.read(None,os.path.join(itrade_config.dirUserData,'%s.matrix.txt' % fn)) if infile: # scan each line to read each quote for eachLine in infile: item = itrade_csv.parse(eachLine,1) if item: if len(item)>4: #print 'addKey:new fmt: %s : %s : %s : %s '% (item[0],item[2],item[3],item[5]) ref = None # be sure the market is loaded quotes.loadMarket(item[3]) if item[0]=='': quote = quotes.lookupTicker(ticker=item[2],market=item[3],place=item[5]) if quote: ref = quote.key() if not ref: ref = quote_reference(isin=item[0],ticker=item[2],market=item[3],place=item[5]) if not self.addKey(ref): print 'load (new format): %s/%s : quote not found in quotes list ! (ref=%s)' % (item[0],item[2],ref) elif len(item)<=4: print 'old matrix format : not supported anymore'
def load(self, fn): infile = itrade_csv.read( None, os.path.join(itrade_config.dirUserData, '%s.matrix.txt' % fn)) if infile: # scan each line to read each quote for eachLine in infile: item = itrade_csv.parse(eachLine, 1) if item: if len(item) > 4: #print 'addKey:new fmt: %s : %s : %s : %s '% (item[0],item[2],item[3],item[5]) ref = None # be sure the market is loaded quotes.loadMarket(item[3]) if item[0] == '': quote = quotes.lookupTicker(ticker=item[2], market=item[3], place=item[5]) if quote: ref = quote.key() if not ref: ref = quote_reference(isin=item[0], ticker=item[2], market=item[3], place=item[5]) if not self.addKey(ref): print 'load (new format): %s/%s : quote not found in quotes list ! (ref=%s)' % ( item[0], item[2], ref) elif len(item) <= 4: print 'old matrix format : not supported anymore'
# ============================================================================ # Test # ============================================================================ if __name__ == '__main__': setLevel(logging.INFO) # load extensions import itrade_ext itrade_ext.loadExtensions(itrade_config.fileExtData, itrade_config.dirExtData) from itrade_quotes import quotes, initQuotesModule initQuotesModule() quotes.loadMarket('EURONEXT') quotes.loadMarket('NASDAQ') quote = quotes.lookupTicker('AAPL', 'NASDAQ') info('test1 %s' % quote) quote = quotes.lookupTicker('OSI', 'EURONEXT') info('test2 %s' % quote) trades = Trades(quote) trades.load('import/Cortal-2005-01-07.txt') trades.load('import/Cortal-2005-01-14.txt') trades.load('import/Cortal-2005-01-21.txt') info('test3 %s' % trades.trade(date(2005, 01, 04)))
self.m_bollDn[i] = -1.0 # ============================================================================ # Test # ============================================================================ if __name__=='__main__': setLevel(logging.INFO) # load extensions import itrade_ext itrade_ext.loadExtensions(itrade_config.fileExtData,itrade_config.dirExtData) from itrade_quotes import quotes, initQuotesModule initQuotesModule() quotes.loadMarket('EURONEXT') quotes.loadMarket('NASDAQ') quote = quotes.lookupTicker('AAPL','NASDAQ') info('test1 %s' % quote ) quote = quotes.lookupTicker('OSI','EURONEXT') info('test2 %s' % quote ) trades = Trades(quote) trades.load('import/Cortal-2005-01-07.txt') trades.load('import/Cortal-2005-01-14.txt') trades.load('import/Cortal-2005-01-21.txt') info('test3 %s' % trades.trade(date(2005,01,04)))