示例#1
0
 def singalOnBarclose(self):
     np_close=np.array(self.bar['close'],dtype=np.float) #TA-lib wants numpy arrays of "double" floats as inputs
     DIFF, DEA, MACD = ta.MACD(np_close, self.fastperiod, self.slowperiod, self.signalperiod)
     
     #DIFF与DEA交叉交易
     if qf.cross(DIFF[-3:],DEA[-3:]):self.SP_BK(self.askprice,self.offsetNum)
     if qf.cross(DEA[-3:],DIFF[-3:]):self.BP_SK(self.bidprice,self.offsetNum) 
示例#2
0
 def singalOnBarclose(self):
     ma1=ta.SMA(self.bar['close'].values.astype(np.float),self.ma1_p)[-3:]
     ma2=ta.SMA(self.bar['close'].values.astype(np.float),self.ma2_p)[-3:]
     print '\n singalOnBarclose:'
     print ma1
     print ma2
     if qf.cross(ma1,ma2):self.SP_BK(self.askprice,self.offsetNum)
     if qf.cross(ma2,ma1):self.BP_SK(self.bidprice,self.offsetNum)