Esempio n. 1
0
 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 self.chart_prg == "gen_pnf_field":
                 tpl = gen_pf_pnf(dl, ol, hl, ll, cl, vl)
             if self.chart_prg == "gen_ichimoku_field":
                 tpl = gen_pf_ichimoku(dl, hl, ll, cl)
                 
                 
             if len(tpl) > 0:
                 (d, sz, X, yma, ymi) = tpl
             else:
                 old_code = code
                 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], sz[i], yma[i], ymi[i]])
             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 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()