Exemple #1
0
	def create_moving_avg_simple(self, num_history_pts):
		self.output_table_name = self.output_table_name.replace("TREND", "POINT")
		self.output_table_name = self.output_table_name.replace("CANDLE", "POINT")
		self.output_table_name = self.output_table_name + self.SIMPLE_AVG + "_" + str(num_history_pts)
		
		if self.to_save:
			##if already exists, drop it first and then recreate
			if DBManager.exists_table(self.output_table_name):
				DBManager.drop_table(self.output_table_name)
			
			pt = PointTable(self.output_table_name)
			pt.save()
		
		points = self.input_points 
		mv = MovingAverage(self.output_table_name, points)
		pt_array = mv.simple(num_history_pts)
		
		if self.to_save:
			self.save_pts(pt_array)
		
		## possible delete the temporary point table created from candle
		##if CandleTable.TEMP in self.input_point_table_name:
		##	DBManager.drop_table(self.input_point_table_name)
		
		return pt_array
    def calc_vol_tables(self):
        if self.calc_stats:
            self.strat_stat_array = []
            self.ss_tn = StratStatTable.calc_name(self.table_name, self.NAME)
            if DBManager.exists_table(self.ss_tn):
                DBManager.drop_table(self.ss_tn)
            sst = StratStatTable(self.ss_tn)
            sst.save()

        pt_name = CandleTable.to_point_table(self.table_name, "volume")
        pt_close = CandleTable.to_point_table(self.table_name, "close")
        self.points = PointTable.get_point_array(pt_name)
        self.points_close = PointTable.get_point_array(pt_close)
        pt_name_1 = "TEMP1"
        mv1 = MovingAverage(pt_name_1, self.points)
        pt_name_2 = "TEMP2"
        mv2 = MovingAverage(pt_name_2, self.points)
        self.vol_pts_short = mv1.simple(self.VOL_PERIOD_SHORT)
        self.vol_pts_long = mv2.simple(self.VOL_PERIOD_LONG)

        ##pp = PointPopulator(self.table_name)
        ##self.stddev_pts_short = pp.create_stddev(self.STDDEV_PERIOD_SHORT)
        ##self.stddev_pts_long = pp.create_stddev(self.STDDEV_PERIOD_LONG)
        DBManager.drop_matching_tables("TEMP")