def timetest(no): """ To list the stock at lest 19 days info. """ a = goristock(no) while len(a.raw_data) > 19: if a.MAO(3, 6)[1] == '↑'.decode('utf-8') and ( a.MAO(3, 6)[0][1][-1] < 0 or (a.MAO(3, 6)[0][1][-1] < 1 and a.MAO(3, 6)[0][1][-1] > 0 and a.MAO(3, 6)[0][1][-2] < 0 and a.MAO(3, 6)[0][0] == 3)) and a.VOLMAX3: print 'buy-: ' + oop(a) elif a.MAO(3, 6)[1] == '↓'.decode('utf-8') and a.MAO( 3, 6)[0][1][-1] > 0 and a.MAO(3, 6)[0][0] <= 3: print 'sell: ' + oop(a) else: print '----: ' + oop(a) a.goback()
def stock_j(self): try: stock = goristock.goristock(self.stock_no) re = { 'stock_name': stock.stock_name, ## OU 'stock_no': stock.stock_no, ## OU 'stock_date': stock.data_date[-1], ## OU 'stock_price': stock.raw_data[-1], ## OU 'stock_range': stock.stock_range[-1], ## OU 'stock_range_per': stock.range_per, 'stock_vol': stock.stock_vol[-1]/1000, 'stock_open': stock.stock_open[-1], 'stock_h': stock.stock_h[-1], 'stock_l': stock.stock_l[-1], 'RABC': stock.RABC } except: re = {'ERRORREPORT': "Can't fetch stock data."} return json.dumps(re, ensure_ascii = False)
def timetest(no): """ To list the stock at lest 19 days info. """ a = goristock(no) while len(a.raw_data) > 19: if ( a.MAO(3, 6)[1] == "↑".decode("utf-8") and ( a.MAO(3, 6)[0][1][-1] < 0 or ( a.MAO(3, 6)[0][1][-1] < 1 and a.MAO(3, 6)[0][1][-1] > 0 and a.MAO(3, 6)[0][1][-2] < 0 and a.MAO(3, 6)[0][0] == 3 ) ) and a.VOLMAX3 ): print "buy-: " + oop(a) elif a.MAO(3, 6)[1] == "↓".decode("utf-8") and a.MAO(3, 6)[0][1][-1] > 0 and a.MAO(3, 6)[0][0] <= 3: print "sell: " + oop(a) else: print "----: " + oop(a) a.goback()
print '----: ' + oop(a) a.goback() def overall(goback=0, case=1): """ To run all over the stock and to find who match the 'case' 'goback' is back to what days ago. 0 is the last day. """ from twseno import twseno for i in twseno().allstock: #timetest(i) try: if case == 1: try: a = goristock(i) if goback: a.goback(goback) if a.MAO(3, 6)[1] == '↑'.decode('utf-8') and ( a.MAO(3, 6)[0][1][-1] < 0 or (a.MAO(3, 6)[0][1][-1] < 1 and a.MAO(3, 6)[0][1][-1] > 0 and a.MAO(3, 6)[0][1][-2] < 0 and a.MAO( 3, 6)[0][0] == 3)) and a.VOLMAX3 and a.stock_vol[ -1] > 1000 * 1000 and a.raw_data[-1] > 10: #print a.Cmd_display print 'buy-: ' + oop(a) elif a.MAO(3, 6)[1] == '↓'.decode('utf-8') and a.MAO( 3, 6)[0][1][-1] > 0 and a.MAO(3, 6)[0][0] <= 3: print 'sell: ' + oop(a)
def overall(goback=0, case=1): """ To run all over the stock and to find who match the 'case' 'goback' is back to what days ago. 0 is the last day. """ from twseno import twseno for i in twseno().allstock: # timetest(i) try: if case == 1: try: a = goristock(i) if goback: a.goback(goback) if ( a.MAO(3, 6)[1] == "↑".decode("utf-8") and ( a.MAO(3, 6)[0][1][-1] < 0 or ( a.MAO(3, 6)[0][1][-1] < 1 and a.MAO(3, 6)[0][1][-1] > 0 and a.MAO(3, 6)[0][1][-2] < 0 and a.MAO(3, 6)[0][0] == 3 ) ) and a.VOLMAX3 and a.stock_vol[-1] > 1000 * 1000 and a.raw_data[-1] > 10 ): # print a.Cmd_display print "buy-: " + oop(a) elif a.MAO(3, 6)[1] == "↓".decode("utf-8") and a.MAO(3, 6)[0][1][-1] > 0 and a.MAO(3, 6)[0][0] <= 3: print "sell: " + oop(a) except KeyboardInterrupt: print "::KeyboardInterrupt" break except IndexError: print i elif case == 2: try: a = goristock(i) if goback: a.goback(goback) if ( a.MAO(3, 6)[1] == "↑".decode("utf-8") and ( a.MAO(3, 6)[0][1][-1] < 0 or ( a.MAO(3, 6)[0][1][-1] < 1 and a.MAO(3, 6)[0][1][-1] > 0 and a.MAO(3, 6)[0][1][-2] < 0 and a.MAO(3, 6)[0][0] == 3 ) ) and a.stock_vol[-1] >= 1000 * 1000 and a.raw_data[-1] > 10 and (sum(a.stock_vol[-45:]) / 45) <= 1000 * 1000 ): # print a.Cmd_display print "buy-: " + oop(a) except KeyboardInterrupt: print "::KeyboardInterrupt" break except IndexError: print i elif case == 3: try: a = goristock(i) if goback: a.goback(goback) if a.MA(3) > a.raw_data[-1] and a.MA(6) <= a.raw_data[-1] and a.MA(6) > a.MA(18): # print a.Cmd_display print "buy-: " + oop(a) except KeyboardInterrupt: print "::KeyboardInterrupt" break except IndexError: print i except KeyboardInterrupt: print "KeyboardInterrupt" break