Example #1
0
 def deleteSymbols(self, request):
     symbolkeys = []
     for sym in StockSymbol.query():
         symbolkeys.append(sym.key)
     
     ndb.delete_multi(symbolkeys)
     message = 'All Symbols Deleted'      
     return StockSymbolCountMessage(message=message)
Example #2
0
 def store(self):
     STOCK_DIR = os.path.join('polarityData', 'stock_symbols')
     NASDAQ_FILE = os.path.join(STOCK_DIR, 'CompanylistNASDAQ.csv')
     with open(NASDAQ_FILE, 'rb') as f:
         reader = csv.reader(f)
         for row in reader:
             symbol = row[0]
             name = row[1]
             if(str.strip(symbol) != '' and str.strip(name) != ''):
                 stock = StockSymbol(symbol = symbol, companyName = name, exchange = 'NASDAQ') 
                 self.symbollist.append(stock)
             
         #query = StockSymbol.query(StockSymbol.exchange == 'NASDAQ')
         #print 'NASDAQ Symbols Count:', query.count()
     
     AMEX_FILE = os.path.join(STOCK_DIR, 'CompanylistAMEX.csv')
     with open(AMEX_FILE, 'rb') as f:
         reader = csv.reader(f)
         for row in reader:
             symbol = row[0]
             name = row[1]
             if(str.strip(symbol) != '' and str.strip(name) != ''):
                 stock = StockSymbol(symbol = symbol, companyName = name, exchange = 'AMEX')
                 self.symbollist.append(stock)
                 
         #query = StockSymbol.query(StockSymbol.exchange == 'AMEX')
         #print 'AMEX Symbols Count:', query.count()
     
     NYSE_FILE = os.path.join(STOCK_DIR, 'CompanylistNYSE.csv')
     with open(NYSE_FILE, 'rb') as f:
         reader = csv.reader(f)
         for row in reader:
             symbol = row[0]
             name = row[1]
             if(str.strip(symbol) != '' and str.strip(name) != ''):
                 stock = StockSymbol(symbol = symbol, companyName = name, exchange = 'NYSE')
                 self.symbollist.append(stock)
                 
         #query = StockSymbol.query(StockSymbol.exchange == 'NYSE')
         #print 'NYSE Symbols Count:', query.count()
     
     ndb.put_multi(self.symbollist)
     
     query = StockSymbol.query()
     print 'Symbols Count Added in NDB:', query.count(), 'Symbols Count in List:', len(self.symbollist)
     
Example #3
0
 def getSymbolCount(self, request):
     query = StockSymbol.query()
     return StockSymbolCountMessage(message=str(query.count()))
Example #4
0
 def getSymbols(self, request):
     symbols = []
     for sym in StockSymbol.query():
         symbols.append(StockSymbolMessage(symbol=sym.symbol, companyName=sym.companyName, exchange=sym.exchange))
     
     return StockSymbolList(items=symbols)