#!/usr/bin/env python # -*- coding: utf-8 -*- from grs import Stock from grs import TWSENo import sys sys.path.append('../') from Trade import Trade from KD import KD from MA import MA from DMI import DMI from MACD import MACD stock = Stock.createByCSV('2454', '../../data/2454_14MonData.csv') trade = Trade(stock) dmi = DMI(stock) macd = MACD(stock) print "MACD with adx >16:" trade.MACD_DMI_1(macd, dmi) trade.printTradeResult() kd = KD(stock) #print "Trade by perfect buy and perfect sell KD:" #trade.KD_PerfectBuyPerfectSell(kd) #trade.printTradeResult() #print "Trade by perfect buy and normal sell KD:" #trade.KD_PerfectBuyNormalSell(kd) #trade.printTradeResult() #print "Trade by normal buy and normal sell KD:" #trade.KD_NormalBuyNormalSell(kd) #trade.printTradeResult()
#!/usr/bin/env python # -*- coding: utf-8 -*- from grs import Stock import matplotlib.pyplot as plt import sys sys.path.append('../') from MA import MA stock = Stock.createByCSV('2330', '../../data/2330_14MonData.csv') ma = MA(stock) print "MA5=> len: " + str(len(ma.ma5)) print ma.ma5 print "MA10=> len: " + str(len(ma.ma10)) print ma.ma10 print "MA20=> len: " + str(len(ma.ma20)) print ma.ma20 print "MA5 diff MA10:" + str(len(ma.ma5diffma10)) ma.printMA5DiffMA10() #print "Buy point short term:" #ma.printBuyPoints_ST() #print "MA5 gradient=> len: "+str(len(ma.ma5_gradient)) #ma.printMA5_gradient() #plt.figure(1) #plt.subplot(211) #plt.plot(stock.price, 'r', ma.ma5, 'b', ma.ma10, 'yellow')