Ejemplo n.º 1
0
def get_power_status(code, tdx_df=None, dtype='d', start=None, end=None, filter='y',
                     dl=60, ptype='low'):
    opc, rac = 0, 0
    fib = 0
    # for ptype in ['low', 'high']:
    for ptype in ['low']:
        op, ra, st, daysData = pct.get_linear_model_status(
            code, df=tdx_df, dtype=dtype, start=start, end=end, dl=dl, filter=filter, ptype=ptype)
        # fib.append(str(daysData[0]))
        opc += op
        # print ra
        rac += ra
        if ptype == 'low':
            stl = st
            fibl = str(daysData[0])
        else:
            fib = str(daysData[0])
    # fibl = sep.join(fib)

    tdx_df, operation = getab.Get_BBANDS(tdx_df, dtype='d')
    # opc +=operation
    # if opc > 21:
    #     opc = 21
    # log.debug( "opc:%s op:%s"%(opc,operation))

    # df.loc[code,'ma5'] = daysData[1].ma5d[0]
    # print tdx_df[:1].ma5d[0],daysData[1].ma5d[0]

    tdx_df, opkdj = getab.Get_KDJ(tdx_df, dtype='d')
    tdx_df, opmacd = getab.Get_MACD_OP(tdx_df, dtype='d')
    tdx_df, oprsi = getab.Get_RSI(tdx_df, dtype='d')
    opma = getab.algoMultiDay(tdx_df)
    # df = getab.Get_BBANDS(df, dtype='d')
    #'volume', 'ratio', 'counts','ldate' -> 'ma','macd','rsi','kdj'
    return int(opc), (rac), int(fib), int(fibl), stl, int(operation), int(opkdj), int(opmacd), int(oprsi), int(opma)
Ejemplo n.º 2
0
def fibonacciCount(code, dl=60, start=None, days=0):
    fibl = []
    if not isinstance(code, list):
        codes = [code]
    else:
        codes = code
    for code in codes:
        df = tdd.get_tdx_append_now_df_api(code, dl=dl)
        for ptype in ['low', 'high']:
            if ptype == 'low':
                op, ra, st, daysData = pct.get_linear_model_status(code,
                                                                   df=df,
                                                                   filter='y',
                                                                   dl=dl,
                                                                   ptype=ptype,
                                                                   days=days)
                dd, boll = getab.Get_BBANDS(df, days=days)
            else:
                # df = tdd.get_tdx_append_now_df_api(code,dl=dl)
                op, ra, st, daysData = pct.get_linear_model_status(code,
                                                                   df=df,
                                                                   filter='y',
                                                                   dl=dl,
                                                                   ptype=ptype,
                                                                   days=days)
                dd, boll = getab.Get_BBANDS(df, dtype='d')
            fib = cct.getFibonacci(300, daysData[0])
            # log.debug('st:%s days:%s fib:%s'%(st,days,fib))
            # print "%s op:%s ra:%s days:%s fib:%s %s" % (code, op,
            # ra,days,fib, st)
            if not daysData[1].ma5d[0]:
                daysData[1].ma5d[0] = 0
            fibl.append([
                code, op, ra, [daysData[0],
                               int(daysData[1].ma5d[0])], fib, st
            ])
    return fibl