예제 #1
0
    def update_sma_db(self):
        stocks = db_util.open_reader('sma')
        self.smaArray = []

        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)

        writer = db_util.open_writer('sma')
        writer.writerows(self.smaArray)

        stocks = db_util.open_reader('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)

        writer = db_util.open_writer('sma50')
        writer.writerows(self.sma50Array)
예제 #2
0
	def update_sma_db(self):
    		stocks = db_util.open_reader('sma')
    		self.smaArray = [];

    		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)

    		writer = db_util.open_writer('sma');
    		writer.writerows(self.smaArray);

    		stocks = db_util.open_reader('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)

    		writer = db_util.open_writer('sma50');
    		writer.writerows(self.sma50Array);
예제 #3
0
def _populate_sma_db(smalist):
    priceArray = [];
    for ix1 in smalist:
	[smaVal,priceVal] = _calc_historical_200_day_sma(ix1);
	smaArray.append(smaVal)
	priceArray.append(priceVal)
    writer = db_util.open_writer('sma');
    writer.writerows(smaArray);
    writer = db_util.open_writer('price');
    writer.writerows(priceArray);
예제 #4
0
    def populate_sma_db(self, smalist):
        self.priceArray = []
        for ix1 in smalist:
            [smaVal, priceVal] = self._calc_historical_200_day_sma(ix1)
            self.smaArray.append(smaVal)
            self.priceArray.append(priceVal)

        writer = db_util.open_writer('sma')
        writer.writerows(self.smaArray)
        writer = db_util.open_writer('price')
        writer.writerows(self.priceArray)
예제 #5
0
    def populate_sma_db(self, smalist):
        self.priceArray = []
        for ix1 in smalist:
            [smaVal, priceVal] = self._calc_historical_200_day_sma(ix1)
            self.smaArray.append(smaVal)
            self.priceArray.append(priceVal)

        writer = db_util.open_writer("sma")
        writer.writerows(self.smaArray)
        writer = db_util.open_writer("price")
        writer.writerows(self.priceArray)
예제 #6
0
    def re_order_based_on_names(self):
        self._open_db()
        newPriceArray = []
        newSmaArray = []
        for ix1 in self.nameArray:
            newPriceArray.append(self._find_price_list(ix1[0]))
            newSmaArray.append(self._find_sma_list(ix1[0]))

        writer = db_util.open_writer('sma')
        writer.writerows(newSmaArray)
        writer = db_util.open_writer('price')
        writer.writerows(newPriceArray)
예제 #7
0
def _add_to_sma_db(smalist):
    for ix1 in smalist:
	if _find_price_list(symbol):
	else:
	    [smaVal,priceVal] = _calc_historical_200_day_sma(ix1);
	    smaArray.append(smaVal)
	    priceArray.append(priceVal)

    writer = db_util.open_writer('sma');
    writer.writerows(smaArray);
    writer = db_util.open_writer('price');
    writer.writerows(priceArray);
예제 #8
0
	def re_order_based_on_names(self):
	    self._open_db();
	    newPriceArray = []
	    newSmaArray = []
	    for ix1 in self.nameArray:
		newPriceArray.append(self._find_price_list(ix1[0]))
		newSmaArray.append(self._find_sma_list(ix1[0]))

    	    writer = db_util.open_writer('sma');
    	    writer.writerows(newSmaArray)
    	    writer = db_util.open_writer('price');
    	    writer.writerows(newPriceArray)
예제 #9
0
    def run_price_check(self, priceRow):
        symbol = priceRow[0]
        curPrice = float(priceRow[1])
        for i in range(2, len(priceRow)):
            newPrice = float(priceRow[i])
            if (((abs(curPrice - newPrice)) / newPrice) > 0.3):
                print "Found Break %s %s %s" % (symbol, curPrice, newPrice)
            curPrice = newPrice

            writer = db_util.open_writer('sma')
            writer.writerows(self.smaArray)
            writer = db_util.open_writer('price')
            writer.writerows(self.priceArray)
예제 #10
0
    def run_price_check(self, priceRow):
        symbol = priceRow[0]
        curPrice = float(priceRow[1])
        for i in range(2, len(priceRow)):
            newPrice = float(priceRow[i])
            if ((abs(curPrice - newPrice)) / newPrice) > 0.3:
                print "Found Break %s %s %s" % (symbol, curPrice, newPrice)
            curPrice = newPrice

            writer = db_util.open_writer("sma")
            writer.writerows(self.smaArray)
            writer = db_util.open_writer("price")
            writer.writerows(self.priceArray)
예제 #11
0
    def _add_to_sma_db(self, smalist):
        for ix1 in smalist:
            if self._find_price_list(ix1) == 0:
                print "Adding ", ix1
                [smaVal, priceVal] = self._calc_historical_200_day_sma(ix1)
                name = yahoostock.get_name(ix1)
                self.smaArray.append(smaVal)
                self.priceArray.append(priceVal)
                self.nameArray.append([ix1, name])

        writer = db_util.open_writer("sma")
        writer.writerows(self.smaArray)
        writer = db_util.open_writer("price")
        writer.writerows(self.priceArray)
        writer = db_util.open_writer_fixed("names")
        writer.writerows(self.nameArray)
예제 #12
0
    def _add_to_sma_db(self, smalist):
        for ix1 in smalist:
            if self._find_price_list(ix1) == 0:
                print 'Adding ', ix1
                [smaVal, priceVal] = self._calc_historical_200_day_sma(ix1)
                name = yahoostock.get_name(ix1)
                self.smaArray.append(smaVal)
                self.priceArray.append(priceVal)
                self.nameArray.append([ix1, name])

        writer = db_util.open_writer('sma')
        writer.writerows(self.smaArray)
        writer = db_util.open_writer('price')
        writer.writerows(self.priceArray)
        writer = db_util.open_writer_fixed('names')
        writer.writerows(self.nameArray)
예제 #13
0
 def run_fix_split_checks(self):
     self._open_db()
     newPriceArray = []
     for ix1 in self.priceArray:
         newPriceArray.append(self.run_price_check(ix1))
     writer = db_util.open_writer('price')
     writer.writerows(newPriceArray)
     self._update_sma_array_to_40_days()
예제 #14
0
	def run_fix_split_checks(self):
	    self._open_db();
	    newPriceArray = []
	    for ix1 in self.priceArray:
		newPriceArray.append(self.run_price_check(ix1))
            writer = db_util.open_writer('price');
    	    writer.writerows(newPriceArray);
	    self._update_sma_array_to_40_days()
예제 #15
0
	def run_fix_split_checks(self):
	    self.update_and_open_db()
	    newPriceArray = []
	    self._read_split_file()
	    for ix1 in self.priceArray:
		newPriceArray.append(self.adj_row_price(ix1))
            writer = db_util.open_writer('price');
    	    writer.writerows(newPriceArray);
	    self._update_sma_array_to_40_days()
예제 #16
0
	def _update_sma50_array_to_40_days(self):
		self._open_db()
    		self.sma50Array = [];

    		for arr2 in self.priceArray:
		    self.sma50Array.append(_gen_sma50_array_for_40_days(arr2))

    		writer = db_util.open_writer('sma50');
    		writer.writerows(self.sma50Array);
예제 #17
0
 def run_fix_split_checks(self):
     self.update_and_open_db()
     newPriceArray = []
     self._read_split_file()
     for ix1 in self.priceArray:
         newPriceArray.append(self.adj_row_price(ix1))
     writer = db_util.open_writer('price')
     writer.writerows(newPriceArray)
     self._update_sma_array_to_40_days()
예제 #18
0
    def _update_sma50_array_to_40_days(self):
        self._open_db()
        self.sma50Array = []

        for arr2 in self.priceArray:
            self.sma50Array.append(_gen_sma50_array_for_40_days(arr2))

        writer = db_util.open_writer('sma50')
        writer.writerows(self.sma50Array)
예제 #19
0
	def _add_to_sma_db(self,smalist):
    		for ix1 in smalist:
			print ix1
			if self._find_price_list(ix1) == 0:
				print 'Adding ',ix1
	    			[smaVal,priceVal] = self._calc_historical_200_day_sma(ix1);
				name = yahoostock.get_name(ix1)
	    			self.smaArray.append(smaVal)
	    			self.priceArray.append(priceVal)
		    		self.nameArray.append([ix1,name])
	    			self.sma50Array.append(self._gen_sma50_array_for_40_days(priceVal))
	
    		writer = db_util.open_writer('sma');
    		writer.writerows(self.smaArray);
    		writer = db_util.open_writer('price');
    		writer.writerows(self.priceArray);
		writer = db_util.open_writer_fixed('names')
		writer.writerows(self.nameArray)
		writer = db_util.open_writer_fixed('sma50')
		writer.writerows(self.sma50Array)
예제 #20
0
    def update_price_db(self):
        stocks = db_util.open_reader('price')
        self.priceArray = []
        for arr2 in stocks:
            newarr = []
            symbol = arr2[0]
            price = self._fetch_price(symbol)
            print symbol, price
            newarr.append(symbol)
            newarr.append(price)
            newarr.extend(arr2[1:240])
            self.priceArray.append(newarr)

        writer = db_util.open_writer('price')
        writer.writerows(self.priceArray)
예제 #21
0
def update_price_db():
    stocks = db_util.open_reader('price')
    priceArray = []
    for arr2 in stocks:
  	newarr = [];
	symbol = arr2[0]
	price = _fetch_price(symbol)
	newarr.append(symbol)
	newarr.append(price)
	for i in range(1,239):
	    newarr.append(arr2[i])
	priceArray.append(newarr)
     
    writer = db_util.open_writer('price');
    writer.writerows(priceArray);
예제 #22
0
    def update_sma_db(self):
        stocks = db_util.open_reader("sma")
        self.smaArray = []

        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)

        writer = db_util.open_writer("sma")
        writer.writerows(self.smaArray)
예제 #23
0
    def update_price_db(self):
        stocks = db_util.open_reader("price")
        self.priceArray = []
        for arr2 in stocks:
            newarr = []
            symbol = arr2[0]
            price = self._fetch_price(symbol)
            print symbol, price
            newarr.append(symbol)
            newarr.append(price)
            newarr.extend(arr2[1:240])
            self.priceArray.append(newarr)

        writer = db_util.open_writer("price")
        writer.writerows(self.priceArray)
예제 #24
0
def update_price_db():
    stocks = db_util.open_reader('price')
    priceArray = []
    for arr2 in stocks:
        newarr = []
        symbol = arr2[0]
        price = _fetch_price(symbol)
        newarr.append(symbol)
        newarr.append(price)
        for i in range(1, 239):
            newarr.append(arr2[i])
        priceArray.append(newarr)

    writer = db_util.open_writer('price')
    writer.writerows(priceArray)
예제 #25
0
	def _update_sma_array_to_40_days(self):
		self._open_db()
    		self.smaArray = [];

    		for arr2 in self.priceArray:
		    retArray = [];
		    retArray.append(arr2[0])
		    for i in range (1,self.numSma+1):
	    	        sma = 0.0
	    	        for mm in range (i,i+200):
			    sma += float(arr2[mm]);
	    	        sma = sma / 200.0
	    	        retArray.append(sma)
		    self.smaArray.append(retArray)

    		writer = db_util.open_writer('sma');
    		writer.writerows(self.smaArray);
예제 #26
0
    def _update_sma_array_to_40_days(self):
        self._open_db()
        self.smaArray = []

        for arr2 in self.priceArray:
            retArray = []
            retArray.append(arr2[0])
            for i in range(1, self.numSma + 1):
                sma = 0.0
                for mm in range(i, i + 200):
                    sma += float(arr2[mm])
                sma = sma / 200.0
                retArray.append(sma)
            self.smaArray.append(retArray)

        writer = db_util.open_writer('sma')
        writer.writerows(self.smaArray)
예제 #27
0
	def update_price_db(self):
    		self.priceArray = []
	        updatedPriceArray = self._fetch_updated_prices();
    		stocks = db_util.open_reader('price')
		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)
			lIndex = lIndex + 1;
     	
    		writer = db_util.open_writer('price');
    		writer.writerows(self.priceArray);
예제 #28
0
    def update_price_db(self):
        self.priceArray = []
        updatedPriceArray = self._fetch_updated_prices()
        stocks = db_util.open_reader('price')
        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)
            lIndex = lIndex + 1

        writer = db_util.open_writer('price')
        writer.writerows(self.priceArray)
예제 #29
0
def update_sma_db():
    stocks = db_util.open_reader('sma')
    writeArray = []

    if len(priceArray) == 0:
        update_price_db()

    for arr2 in stocks:
        newarr = []
        symbol = arr2[0]
        sma = _calc_200_day_sma(symbol)
        newarr.append(symbol)
        newarr.append(sma)
        for i in range(1, 29):
            newarr.append(arr2[i])
        writeArray.append(newarr)

    writer = db_util.open_writer('sma')
    writer.writerows(writeArray)
예제 #30
0
def update_sma_db():
    stocks = db_util.open_reader('sma')
    writeArray = [];

    if len(priceArray) == 0:
	update_price_db()

    for arr2 in stocks:
  	newarr = [];
	symbol = arr2[0]
	sma = _calc_200_day_sma(symbol)
	newarr.append(symbol)
	newarr.append(sma)
	for i in range(1,29):
	    newarr.append(arr2[i])
	writeArray.append(newarr)
     
    writer = db_util.open_writer('sma');
    writer.writerows(writeArray);
예제 #31
0
def _populate_price_db():
    someArray = []
    for ix1 in emalist:
        someArray.append(_fetch_historical_200_day_ema(ix1))
    writer = db_util.open_writer('ema')
    writer.writerows(someArray)
예제 #32
0
def _populate_price_db():
    someArray = [];
    for ix1 in emalist:
	someArray.append(_fetch_historical_200_day_ema(ix1))
    writer = db_util.open_writer('ema');
    writer.writerows(someArray);