def predict2tmp(self):
     old_code = ""
     dl, ol, hl, ll, cl, vl = ([], [], [], [], [], [])
     kabuka_generator = kf.g_get_kabuka(self.meigaras, self.startd, self.endd)
 
     for line in kabuka_generator:
         (code, date, open, high, low, close, volume) = line
         if code != old_code and old_code != "":
             if self.chart_prg == "gen_bollinger_field":
                 tpl = gen_pf_bollinger(dl, ol, hl, ll, cl, vl)
                 if len(tpl) == 4:
                     (d, X, Y) = tpl
                 else:
                     continue
             if len(X) > 0:
                 labels = np.array(self.classifier.predict(X))
             else:
                 continue
             data = []
             for i in range(len(d)):
                 data.append([old_code, d[i], "", labels[i], Y[i][0], Y[i][1]])
             if len(data) > 0:
                 tbl.arr2table(data, self.table_name)
             data = []
             dl, ol, hl, ll, cl, vl = ([], [], [], [], [], [])
         
         dl.append(date)
         ol.append(open)
         hl.append(high)
         ll.append(low)
         cl.append(close)
         vl.append(volume)
         
         old_code = code
Esempio n. 2
0
 def get_data(self, code):
     g = kf.g_get_kabuka([code])
     
     kabuka = []
     dates = {}
     i = 0
     for row in g:
         (code, date, open, high, low, close, vol) = row
         kabuka.append(close)
         dates[date] = i
         i += 1
         
     regressions = vct.get_moving_regression(kabuka, self.trend_days)    
     return dates, np.array(kabuka), regressions
Esempio n. 3
0
 def learn(self):
     old_code = ""
     dl, ol, hl, ll, cl, vl = ([], [], [], [], [], [])
     X = []
     kabuka_generator = kf.g_get_kabuka(self.meigaras, self.startd, self.endd)
 
     for line in kabuka_generator:
         (code, date, open, high, low, close, volume) = line
         if code != old_code and old_code != "":
             if self.chart_prg == "gen_bollinger_field":
                 tpl = gen_pf_bollinger(dl, ol, hl, ll, cl, vl, False)
             if self.chart_prg == "gen_pnf_field":
                 tpl = gen_pf_pnf(dl, ol, hl, ll, cl, vl, False)
             if self.chart_prg == "gen_ichimoku_field":
                 tpl = gen_pf_ichimoku(dl, hl, ll, cl)
                 
             if len(tpl) > 0:
                 (d, sz, xx) = tpl
             else:
                 old_code = code
                 continue
             debug = False
             if debug:
                 labels = self.classifier.predict(xx)
             X.extend(xx)
             dl, ol, hl, ll, cl, vl = ([], [], [], [], [], [])
         
         dl.append(date)
         ol.append(open)
         hl.append(high)
         ll.append(low)
         cl.append(close)
         vl.append(volume)
         
         old_code = code
         
     self.classifier.fit(X)
     self.classifier.save()
 def learn(self):
     old_code = ""
     dl, ol, hl, ll, cl, vl = ([], [], [], [], [], [])
     X = []
     yma = []
     ymi = []
     kabuka_generator = kf.g_get_kabuka(self.meigaras, self.startd, self.endd)
 
     for line in kabuka_generator:
         (code, date, open, high, low, close, volume) = line
         if code != old_code and old_code != "":
             if self.chart_prg == "gen_bollinger_field":
                 tpl = gen_pf_bollinger(dl, ol, hl, ll, cl, vl)
                 if len(tpl) == 4:
                     (d, xx, ma, mi) = tpl
                 debug = False
                 if debug:
                     ma_labels = self.ma_classifier.predict(xx)
                     mi_labels = self.mi_classifier.predict(xx)
             X.extend(xx)
             yma.extend(ma)
             ymi.extend(mi)
             dl, ol, hl, ll, cl, vl = ([], [], [], [], [], [])
         
         dl.append(date)
         ol.append(open)
         hl.append(high)
         ll.append(low)
         cl.append(close)
         vl.append(volume)
         
         old_code = code
         
     self.ma_classifier.fit(X, yma)
     self.ma_classifier.save()
     self.mi_classifier.fit(X, ymi)
     self.mi_classifier.save()