def judgeSell(index): global lastK global lastD global lastJ #当前的K值 ck = lastK[-1] cd = lastD[-1] cj = lastJ[-1] #上一个的K值 lk = lastK[-2] ld = lastD[-2] lj = lastJ[-2] if cd > ck and ld < lk :#下穿 p1 = point.Point(1, lk) p2 = point.Point(2, ck) line1 = point.Line(p1, p2) p3 = point.Point(1, ld) p4 = point.Point(2, cd) line2 = point.Line(p3, p4) pointXY = point.GetCrossPoint(line1, line2) if pointXY.y > 70: return True # if ck > 80 and cd >70: # return True # if len(lastJ)>3 and cj > 100 and lj >100 and lastJ[-3]>100: # return True return False
def judgeBuy(symbol): global kdjDict KDJModelList = kdjDict.get(symbol, [KDJModel(50, 50, 50)]) if len(KDJModelList) < 3: return False thisModel = KDJModelList[-1] lastModel = KDJModelList[-2] K = thisModel.K D = thisModel.D J = thisModel.J lastK = lastModel.K lastD = lastModel.D lastJ = lastModel.J isBuy = False if K < D and lastK > lastD and D - K > 1 and lastK - lastD > 1: # 普通下穿 p1 = point.Point(1, lastK) p2 = point.Point(2, K) line1 = point.Line(p1, p2) p3 = point.Point(1, lastD) p4 = point.Point(2, D) line2 = point.Line(p3, p4) pointXY = point.GetCrossPoint(line1, line2) if pointXY.y < 60: isBuy = True if KDJModelList[-3].J < 0 and lastJ < 0 and J < 0: isBuy = True if K>55 and D>55 or abs(J-lastJ)<30: isBuy = False return isBuy
def judgeBuy(data,index): global lastK global lastD global lastJ global last100 isBuy = False Cn = data['close'] Ln = data['low'] Hn = data['high'] if Hn==Ln: return False RSV = (Cn-Ln)/(Hn-Ln)*100 K = 2.0/3*lastK[-1]+1.0/3*RSV D = 2.0/3*lastD[-1]+1.0/3*K J = 3*K-2*D if K<D and lastK[-1]>lastD[-1] and D-K>1 and lastK[-1]-lastD[-1]>1: #普通下穿 p1=point.Point(index-1,lastK[-1]) p2=point.Point(index,K) line1=point.Line(p1,p2) p3=point.Point(index-1,lastD[-1]) p4=point.Point(index,D) line2=point.Line(p3,p4) pointXY = point.GetCrossPoint(line1, line2) if pointXY.y < 60: isBuy = True if len(lastJ) >= 2: # J 连续为负数3个周期 if lastJ[-1] < 0 and lastJ[-2] < 0 and J < 0 : isBuy = True if K>55 and D>55 or abs(J-lastJ[-1])<30: isBuy = False if isBuy: if len(last100) > 1 and Cn >= last100[-1] : isBuy = False # if len(last100)>90 and Cn <= last100[0]: # isBuy = True lastK.append(K) lastJ.append(J) lastD.append(D) if len(lastK)>10: lastK = lastK[1:] lastD = lastD[1:] lastJ = lastJ[1:] last100.append(data['close']) last100.sort() if len(last100) >101: last100 = last100[1:] return isBuy