def _doLogic(self, index): lastValue = self._analyseKLine.getDifByIndex( index - 1) - self._analyseKLine.getDeaByIndex(index - 1) value = self._analyseKLine.getDifByIndex( index) - self._analyseKLine.getDeaByIndex(index) ret = None if lastValue > 0 and value < 0: # 此处肯定为绿柱的起始点 dataFragment = self._analyseKLine.getDataFragmentByIndex(index) if dataFragment is None: raise IndexError fragmentIndex = self._analyseKLine.getDataFragments().index( dataFragment) if fragmentIndex >= 3: # 至少要有两组红柱,计算逻辑才能产生事件 dataFragment1 = self._analyseKLine.getDataFragments()[ fragmentIndex - 1] dataFragment2 = self._analyseKLine.getDataFragments()[ fragmentIndex - 3] # 1和3 为相邻两组红柱 from Stock.AnalyseKLine import StockPillar if dataFragment1.getStockPillar( ) == StockPillar.RED and dataFragment2.getStockPillar( ) == StockPillar.RED: # 此两组fragment一定为红柱否则整个K线是错误的 # print("间隔2个的红柱") if dataFragment1.getMax() < dataFragment2.getMax(): ret = Event() ret.setBIndex(index) ret.setEIndex(index) ret.setEventIndex(index) ret.setEventType(EventType.HIGH_TO_LOW) ret.setEventValue(value) return ret
def _doLogic(self, index): ret = None difIndex = self._analyseKLine.getDifByIndex(index) if self.__difNewHigh < difIndex: if index == self._index: ret = Event() ret.setBIndex(index) ret.setEIndex(index) ret.setEventIndex(index) ret.setEventType(EventType.NEW_HIGH_DIF) ret.setEventValue(difIndex) self.__difNewHigh = difIndex return ret
def _doLogic(self, index): lastValue = self._analyseKLine.getDifByIndex( index - 1) - self._analyseKLine.getDeaByIndex(index - 1) value = self._analyseKLine.getDifByIndex( index) - self._analyseKLine.getDeaByIndex(index) ret = None if lastValue > 0 and value < 0: ret = Event() ret.setBIndex(index) ret.setEIndex(index) ret.setEventIndex(index) ret.setEventType(EventType.DEAD_FORK) ret.setEventValue(value) return ret
def _doLogic(self): ret = None self.__calFragments() newHigh = 0 for fragment in self.__dataFragments: if fragment.getStockPillar() == StockPillar.RED: if fragment.getMax() > newHigh: ret = Event() ret.getEventType(EventType.NEW_HIGH_DIF) ret.setBIndex(fragment.getBIndex) ret.setEIndex(fragment.getEIndex()) ret.getEventValue(fragment.getMax()) ret.setEventIndex(self._currentIndex) break return ret
def _doLogic(self, index): ret = None # if self._index - self.__duration >= 0: highestIndex = self._index - self.__duration # math.ceil(self._index / 2) highestValue = self._analyseKLine.getHighByIndex(highestIndex) step = 1 isHighest = True while step <= self.__duration: if highestValue < self._analyseKLine.getHighByIndex( highestIndex - step) or highestValue < self._analyseKLine.getHighByIndex( highestIndex + step): isHighest = False break step += 1 if isHighest: ret = Event() ret.setBIndex(highestIndex - step) ret.setEIndex(highestIndex + step) ret.setEventIndex(highestIndex) ret.setEventType(self.__getHighEventType()) ret.setEventValue(highestValue) return ret