Ejemplo n.º 1
0
 def _get_xy(self, code, starti, endi, dates):
     ysl = []
     xsl = []
     labelsl = []
     
     (indexes, dates, open, high, low, close, volume) = self.data[code]
     dl = indexes.keys()
     dl.sort()
     x = dl[starti:endi+1]
     x = df.strl2datel(x)
     
     
     normal_lines = self.normal_lines[code]
     if self.base_lines.has_key(code):
         base_lines = self.base_lines[code]
     if self.trend_lines.has_key(code):
         trend_lines = self.trend_lines[code]
     pnf_joints = self.pnf_joints[code]
     pnf_indexes = self.pnf_indexes[code]
     
     for k in normal_lines.keys():
         ysl.append(normal_lines[k][starti:endi+1])
         labelsl.append(k)
         xsl.append(x)
         
         
     pnf_starti = -1
     pnf_endi = -1
     j=0
     for i in pnf_indexes:
         if i >= starti and pnf_starti < 0:
             pnf_starti = j
         if i > endi and pnf_endi < 0:
             pnf_endi = j-1
             break
         if i < 0:
             pnf_endi = j-1
             break
         j += 1
     
     
     ysl.append(pnf_joints[pnf_starti:pnf_endi])
     pnf_indexes = pnf_indexes[pnf_starti:pnf_endi]
     pnf_dates = self._indexl2datel(pnf_indexes, dl)
     xsl.append(pnf_dates)
     labelsl.append("pnf")
     
     ysl.append(close[starti:endi+1])
     xsl.append(x)
     labelsl.append("close")
     
     return xsl, ysl, labelsl
Ejemplo n.º 2
0
 def _indexl2datel(self, indexl, datel):
     datestrl = []
     for i in indexl:
         datestrl.append(datel[i])
         
     return df.strl2datel(datestrl)