Example #1
0
    def update_sma_db(self):
        stocks = sql_db_util.open_reader('stock_sma')
        self.smaArray = [];

        writeArray = [];
        for arr2 in stocks:
            newarr = [];
            symbol = arr2[0]
            sma = self._calc_200_day_sma(symbol)
            newarr.append(symbol)
            newarr.append(sma)
            newarr.extend(arr2[1:self.numSma])
            self.smaArray.append(newarr)
            writeArray.append([symbol,sma]);

        sql_db_util.write_daily_values('stock_sma',writeArray);

        writeArray = [];
        stocks = sql_db_util.open_reader('stock_sma50')
        self.sma50Array = [];
        for arr2 in stocks:
            newarr50 = [];
            symbol = arr2[0]
            sma50 = self._calc_50_day_sma(symbol)
            newarr50.append(symbol)
            newarr50.append(sma50)
            newarr50.extend(arr2[1:self.numSma])
            self.sma50Array.append(newarr50)
            writeArray.append([symbol,sma50]);

        sql_db_util.write_daily_values('stock_sma50',writeArray);
Example #2
0
 def update_price_db(self):
     self.priceArray = []
     updatedPriceArray = self._fetch_updated_prices();
     writeArray = [];
     stocks = sql_db_util.open_reader('stock_prices')
     lIndex = 0;
     for arr2 in stocks:
         newarr = [];
         symbol = arr2[0]
         price = updatedPriceArray[lIndex];
         #print symbol,price
         newarr.append(symbol)
         newarr.append(price)
         newarr.extend(arr2[1:240])
         self.priceArray.append(newarr)
         writeArray.append([symbol,price]);
         lIndex = lIndex + 1;
     
     sql_db_util.write_daily_values('stock_prices',writeArray);