def tmp2pf(self):
        fieldids = {}
        strsql = "select fieldid, size, avg(max_price), std(max_price), avg(min_price), \
std(min_price) from trade.pf_bollinger group by fieldid, size;" 
        generator = sql.g_get_data(strsql)
        for row in generator:
            (fieldid, size, avg_max, std_max, avg_min, std_min) = row
            fieldids["%s-%d" % (fieldid, size)] = 1
Example #2
0
    def tmp2pf(self):
        fieldids = {}
        strsql = "select tmp_fieldid, size, avg(max_price), std(max_price), avg(min_price), \
std(min_price) from trade.%s group by tmp_fieldid, size;" % (self.table_name) 
        generator = sql.g_get_data(strsql)
        for row in generator:
            (fieldid, size, avg_max, std_max, avg_min, std_min) = row
            
            fieldids["%s-%d" % (fieldid, size)] = "%d%d%d%d" % \
                (self._f2d(avg_max), self._f2d(std_max), self._f2d(avg_min), self._f2d(std_min))
        
        strsql = ""
        for k in fieldids.keys():
            (fieldid, size) = fieldids[k].split("-")
            strsql = "%s\nupdate trade.%s set fieldid = '%s' where tmp_fieldid = %s and size = %s;" % \
                (strsql, self.table_name, fieldid, size)
Example #3
0
 def set_prediction(self):
     (indexes, dates, open, high, low, close, volume) = self.data
     startd = dates[0]
     endd = dates[-1]
     condlist = []
     condlist.append("code=%s" % (self.code))
     condlist.append("date>=%s" % (startd))
     condlist.append("date<=%s" % (endd))
     condlist.append("accuracy>=%s" % (str(self.min_accuracy)))
     #condlist.append("last_update<=%s" % (startd)) 
     strwhere = sql.list2wheresql(condlist)
     strsql = "select date, last_update, accuracy, down_peak, not_peak, up_peak \
     from trade.prediction %s \
     order by date, last_update;" % (strwhere)
     g_data = sql.g_get_data(strsql)
     prediction = {}
     for row in g_data:
         (date, last_update, accuracy, down_peak, not_peak, up_peak) = row
         prediction[date] = {"last_update":last_update, "value":[down_peak, not_peak, up_peak]}
     self.prediction = prediction