예제 #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);
예제 #2
0
    def _open_db(self):
        #
        # Open Name Db
        #
        self.nameArray = []
        reader = sql_db_util.open_names();
        for row in reader:
                self.nameArray.append(row)
         
        #
        # Open Price Db
        #
        self.priceArray = []
        reader = sql_db_util.open_reader('stock_prices')
        for row in reader:
                self.priceArray.append(row)

        #
        # Open SMA Db
        #
        self.smaArray = []
        reader = sql_db_util.open_reader('stock_sma')
        for row in reader:
                self.smaArray.append(row)
        #
        # Open 50day SMA
        #
        self.sma50Array = []
        reader = sql_db_util.open_reader('stock_sma50')
        for row in reader:
                self.sma50Array.append(row)
예제 #3
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);