示例#1
0
 def _judge_enter_proc(self, datei):
     datei -= 1
     (open, high, low, close, volume) = self._get_prices(datei, 1)
     price = (high+low+close)/3
     msg = ""
     boxsize = kf.get_lboxsize(price)
     ret = (NO_ENTER, msg)
     if high-low > boxsize:
         return ret
     
     if len(self.enter_prices) > 0:
         if price + boxsize >= self.enter_prices[-1] and price - boxsize <= self.enter_prices[-1]:
             return ret
     
     
     direction = 0
     
     #ichimoku
     tmp_direction = self._judge_ichimoku_points(datei)
     if tmp_direction != 0:
         msg = f.joinstr("Ichimoku", msg)
     direction += tmp_direction
     
     #bollinger
     tmp_direction = self._judge_bollinger_points(datei)
     if tmp_direction != 0:
         msg = f.joinstr("Bollinger", msg)
     direction += tmp_direction
     
     #base lines
     tmp_direction = self._judge_base_points(datei)
     if tmp_direction != 0:
         msg = f.joinstr("Base lines", msg)
     direction += tmp_direction
     
     #dow lines
     tmp_direction = self._judge_dow_points(datei)
     if tmp_direction != 0:
         msg = f.joinstr("Dow", msg)
     direction += tmp_direction
     
     #trend lines
     tmp_direction = self._judge_trend_points(datei)
     if tmp_direction != 0:
         msg = f.joinstr("Trend lines", msg)
     direction += tmp_direction
     
     if abs(direction) > self.min_action_score:
         if direction > 0:
             return (YES_ENTER_BUY, msg)
         elif direction < 0:
             return (YES_ENTER_SELL, msg)
     return ret
示例#2
0
 def _judge_passed(self, datei):
     (open, high, low, close, volume) = self._get_prices(datei, 1)
     price = (high+low+close)/3
     boxsize = kf.get_lboxsize(price)
     if high-low > boxsize:
         return 0
     
     (normal_lines, base_lines, dow_lines, trend_lines) = self.lines
     (tenkan, kijun, chikou, senko1, senko2, avg, bollp2, bollm2) = self._normal_lines2tuple(datei)
     
     direction = 0
     points = [tenkan, kijun, chikou, senko1, senko2, avg, bollp2, bollm2]
     
     last_pm = self._get_last_pm(datei)
     
     for i in range(len(points)):
         (touched, dir) = self._touched(datei, points[i], last_pm)
         if touched:
             return 1
         
     if base_lines.has_key(datei):
         base = base_lines[datei]
         for i in range(len(base)):
             (passed, dir) = self._passed_to(datei, base[i], last_pm)
             if passed:
                 return 1
 
     if dow_lines.has_key(datei):
         dow = dow_lines[datei]
         for i in range(len(dow)):
             (passed, dir) = self._passed_to(datei, dow[i], last_pm)
             if passed:
                 return 1
 
     if trend_lines.has_key(datei):
         trend = trend_lines[datei]
         for i in range(len(trend)):
             (passed, dir) = self._passed_to(datei, trend[i], last_pm)
             if passed:
                 return 1
         
     return 0