Example #1
0
def stocklist():
  stock_list = twseno.twseno().allstockno
  re_st = {}
  for i in stock_list:
    re_st.update({i: stock_list[i].decode('utf-8')})
  re = {'stocklist': re_st, 'n': len(stock_list)}
  re.update({'last_update': twseno.twseno().last_update})
  return json.dumps(re, ensure_ascii = False)
Example #2
0
def searchstock(q):
  q = q.encode('utf-8').replace(' ','')
  if q:
    rq = twseno.twseno().search(q)
    re_se ={}
    for i in rq:
      re_se.update({i: rq[i].decode('utf-8')})
    re = {'result': re_se, 'n': len(rq)}
    return json.dumps(re, ensure_ascii = False)
  else:
    re = {'ERRORREPORT': "No keyword."}
    return json.dumps(re, ensure_ascii = False)
Example #3
0
            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 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:
Example #4
0
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