def get_hot_count(changepercent):
    allTop = pd.DataFrame()
    for market in ct.SINA_Market_KEY:
        df = rd.get_sina_Market_json(market, False)
        # count=len(df.index)
        # print df[:1]
        top = df[df['percent'] > changepercent]['code']
        topTen = df[df['percent'] > 9.9]['code']
        crashTen = df[df['percent'] < -9.8]['code']
        crash = df[df['percent'] < -changepercent]['code']
        # top=df[ df['changepercent'] <6]

        print (
            "%s topT: %s top>%s: %s " % (
                f_print(4, market), f_print(3, len(topTen)), changepercent, f_print(4, len(top)))),
        url = ct.DFCFW_FUND_FLOW_URL % ct.SINA_Market_KEY_TO_DFCFW[market]
        log.debug("ffurl:%s" % url)
        ff = ffu.get_dfcfw_fund_flow(url)
        if len(ff) > 0:
            zlr = float(ff['zlr'])
            zzb = float(ff['zzb'])
            # zt=str(ff['time'])
            print (u"crashT:%s crash<-%s:%s 流入: %0.1f亿 比: %0.1f%%" % (
                f_print(4, len(crashTen)), changepercent, f_print(4, len(crash)), zlr, zzb))
        else:
            print (u"crashT:%s crash<-%s:%s 流入: %0.1f亿 比: %0.1f%% %s" % (
                f_print(4, len(crashTen)), changepercent, f_print(4, len(crash))))

        allTop = allTop.append(df, ignore_index=True)

    df = allTop
    count = len(df.index)
    top = df[df['percent'] > changepercent]['code']
    topTen = df[df['percent'] > 9.9]['code']
    crashTen = df[df['percent'] < -9.8]['code']
    crash = df[df['percent'] < -changepercent]['code']
    print (
        u"\t\tA:%s topT:%s top>%s:%s" % (
            f_print(4, count), f_print(3, len(topTen)), changepercent, f_print(4, len(top)))),
    ff = ffu.get_dfcfw_fund_flow(ct.DFCFW_FUND_FLOW_ALL)
    if len(ff) > 0:
        zlr = float(ff['zlr'])
        zzb = float(ff['zzb'])
        zt = str(ff['time'])
        print (u"crashT:%s crash<-%s:%s 流入: %0.1f亿 占比: %0.1f%% %s" % (
            f_print(3, len(crashTen)), changepercent, f_print(4, (len(crash))), zlr, zzb, zt))
    else:
        print (u"crashT:%s crash<-%s:%s" % (f_print(3, len(crashTen)), changepercent, f_print(4, len(crash))))
    return allTop
def get_hot_countNew(changepercent,rzrq):
    allTop = pd.DataFrame()
    for market in ct.SINA_Market_KEY:
        df = rd.get_sina_Market_json(market, False)
        # count=len(df.index)
        log.info("market:%s" % df[:1])
        df = df.dropna()
        if 'percent' in df.columns.values:
            # and len(df[:20][df[:20]['percent']>0])>3:
            top = df[df['percent'] > changepercent]['code']
            topTen = df[df['percent'] > 9.9]['code']
            crashTen = df[df['percent'] < -9.8]['code']
            crash = df[df['percent'] < -changepercent]['code']
        else:
            log.info("market No Percent:%s" % df[:1])
            top = '0'
            topTen = '0'
            crashTen = '0'
            crash = '0'
        # top=df[ df['changepercent'] <6]

        print (
            "%s topT: %s top>%s: %s " % (
                f_print(4, market), f_print(3, len(topTen)), changepercent, f_print(4, len(top)))),
        # url = ct.DFCFW_FUND_FLOW_URL % ct.SINA_Market_KEY_TO_DFCFW[market]
        # log.debug("ffurl:%s" % url)
        print (u"crashT:%s crash<-%s:%s" % (f_print(4, len(crashTen)), changepercent, f_print(4, len(crash)))),
        ff = ffu.get_dfcfw_fund_flow(market)
        if len(ff) > 0:
            zlr = float(ff['zlr'])
            zzb = float(ff['zzb'])
            # zt=str(ff['time'])
            # modfprint=lambda x:f_print(4,x) if x>0 else "-%s"%(f_print(4,str(x).replace('-','')))
            # print modfprint(zlr)
            # print (u"流入: %s亿 比: %s%%" % (modfprint(zlr), modfprint(zzb))),
            print (u"流入: %s亿 比: %s%%" % (f_print(4, zlr), f_print(4, zzb))),
            print (u"%s %s%s"%( f_print(4,ff['close']),f_print(1,'!' if ff['open'] > ff['lastp'] else '?'),f_print(2,'!!' if ff['close'] > ff['lastp'] else '??')))
        allTop = allTop.append(df, ignore_index=True)

    df = allTop
    count = len(df.index)
    top = df[df['percent'] > changepercent]['code']
    topTen = df[df['percent'] > 9.9]['code']
    crashTen = df[df['percent'] < -9.8]['code']
    crash = df[df['percent'] < -changepercent]['code']
    print (
        u" \tA:%s topT:%s top>%s:%s" % (
            f_print(4, count), f_print(3, len(topTen)), changepercent, f_print(4, len(top)))),
    print (u"crashT:%s crash<-%s:%s" % (f_print(3, len(crashTen)), changepercent, f_print(4, len(crash)))),
    ff = ffu.get_dfcfw_fund_flow(ct.DFCFW_FUND_FLOW_ALL)
    if len(ff) > 0:
        zlr = float(ff['zlr'])
        zzb = float(ff['zzb'])
        zt = str(ff['time'])
        print (u"流入: %s亿 占比: %s%% %s" % (f_print(4, zlr), f_print(4, zzb), f_print(4, zt)))
    ff = ffu.get_dfcfw_fund_SHSZ()
    hgt = ffu.get_dfcfw_fund_HGT()
    log.debug("shzs:%s" % ff)
    log.debug("hgt:%s" % hgt)
    # if len(ff) > 0:
    #     print ("\tSH: %s u:%s vo: %s sz: %s u:%s vo: %s" % (
    #         f_print(4, ff['scent']), f_print(4, ff['sup']), f_print(5, ff['svol']), f_print(4, ff['zcent']),
    #         f_print(4, ff['zup']),
    #         f_print(5, ff['zvol']))),
    if len(ff) > 0:
        print (u"\tSh: %s Vr:  %s Sz: %s Vr: %s " % (
            f_print(4, ff['scent']), f_print(5, ff['svol']), f_print(4, ff['zcent']), f_print(5, ff['zvol']))),
    if len(hgt) > 0:
        print ("Hgt: %s Ggt: %s" % (hgt['hgt'], hgt['ggt']))    
    
    if len(rzrq) > 0:
        print (u"\t\t\t\t\t    Sh: %s sz:  %s All: %s diff: %s亿" % (
            f_print(5, rzrq['sh']), f_print(5, rzrq['sz']), f_print(4, rzrq['all']), f_print(5, rzrq['diff']))) 
    

        
        
    return allTop
示例#3
0
def get_hot_countNew(changepercent, rzrq, fibl=None, fibc=10):
    global fibcount
    if fibcount == 0 or fibcount >= fibc:
        if fibcount >= fibc:
            fibcount = 1
        else:
            fibcount += 1
        if fibl is not None:
            int = 0
            for f in fibl:
                code, op, ra, daysData, fib, st = f[0], f[1], f[2], f[3], f[
                    4], f[5]
                int += 1
                if int % 2 != 0:
                    print "%s op:%s ra:%s d:%s fib:%s m5:%s  %s" % (
                        code, f_print(3, op), f_print(
                            5, ra), f_print(2, daysData[0]), f_print(
                                3, fib), f_print(4, daysData[1]), st),
                else:
                    print "%s op:%s ra:%s d:%s fib:%s m5:%s " % (
                        st, f_print(3, op), f_print(
                            5, ra), f_print(2, daysData[0]), f_print(
                                3, fib), f_print(4, daysData[1]))

    else:
        fibcount += 1
    allTop = pd.DataFrame()
    indexKeys = ['sh', 'sz', 'cyb']
    ffindex = ffu.get_dfcfw_fund_flow('all')
    ffall = {}
    ffall['zlr'] = 0
    ffall['zzb'] = 0

    for market in indexKeys:
        # market = ct.SINA_Market_KEY()
        #        df = rd.get_sina_Market_json(market, False)
        df = sina_data.Sina().market(market)
        # count=len(df.index)
        log.info("market:%s" % df[:1])
        df = df.dropna()
        df = df[df.close > 0]
        if 'percent' not in df.columns:
            df['percent'] = map(lambda x, y: round((x - y) / y * 100, 1),
                                df.close.values, df.llastp.values)

        if 'percent' in df.columns.values:
            # and len(df[:20][df[:20]['percent']>0])>3:
            # if 'code' in df.columns:
            #     top = df[df['percent'] > changepercent]
            #     topTen = df[df['percent'] > 9.9]
            #     crashTen = df[df['percent'] < -9.8]
            #     crash = df[df['percent'] < -changepercent]
            # else:
            top = df[df['percent'] > changepercent]
            topTen = df[df['percent'] > 9.9]
            crashTen = df[df['percent'] < -9.8]
            crash = df[df['percent'] < -changepercent]
        else:
            log.info("market No Percent:%s" % df[:1])
            top = '0'
            topTen = '0'
            crashTen = '0'
            crash = '0'
        # top=df[ df['changepercent'] <6]

        print("%s topT: %s top>%s: %s " %
              (f_print(4, market), f_print(
                  3, len(topTen)), changepercent, f_print(4, len(top)))),
        # url = ct.DFCFW_FUND_FLOW_URL % ct.SINA_Market_KEY_TO_DFCFW[market]
        # log.debug("ffurl:%s" % url)
        print(u"crashT:%s crash<-%s:%s" % (f_print(
            4, len(crashTen)), changepercent, f_print(4, len(crash)))),
        ff = ffindex[market]
        if len(ff) > 0:
            zlr = float(ff['zlr'])
            zzb = float(ff['zzb'])
            ffall['zlr'] = ffall['zlr'] + zlr
            ffall['zzb'] = ffall['zzb'] + zzb
            # zt=str(ff['time'])
            # modfprint=lambda x:f_print(4,x) if x>0 else "-%s"%(f_print(4,str(x).replace('-','')))
            # print modfprint(zlr)
            # print (u"流入: %s亿 比: %s%%" % (modfprint(zlr), modfprint(zzb))),
            print(u"流入: %s亿 比: %s%%" % (f_print(4, zlr), f_print(4, zzb))),
            print(u"%s %s%s" %
                  (f_print(4, ff['close']),
                   f_print(1, '!' if ff['open'] > ff['lastp'] else '?'),
                   f_print(2, '!!' if ff['close'] > ff['lastp'] else '??')))
        allTop = allTop.append(df, ignore_index=True)
        allTop = allTop.drop_duplicates()
    df = allTop
    count = len(df.index)
    top = df[df['percent'] > changepercent]
    topTen = df[df['percent'] > 9.9]
    crashTen = df[df['percent'] < -9.8]
    crash = df[df['percent'] < -changepercent]
    print(u" \tA:%s topT:%s top>%s:%s" %
          (f_print(4, count), f_print(
              3, len(topTen)), changepercent, f_print(4, len(top)))),
    print(u"crashT:%s crash<-%s:%s" %
          (f_print(3, len(crashTen)), changepercent, f_print(4, len(crash)))),

    # ff = ffu.get_dfcfw_fund_flow(ct.DFCFW_FUND_FLOW_ALL)
    ffall['time'] = ff['time']
    ff = ffall
    zzb = 0
    if len(ff) > 0:
        zlr = round(float(ff['zlr']), 1)
        zzb = round(float(ff['zzb']) / 3, 1)
        zt = str(ff['time'])
        print(u"流入: %s亿 占比: %s%% %s" %
              (f_print(4, zlr), f_print(4, zzb), f_print(4, zt)))

    ff = ffu.get_dfcfw_fund_SHSZ()
    hgt = ffu.get_dfcfw_fund_HGT()
    szt = ffu.get_dfcfw_fund_HGT(url=ct.DFCFW_FUND_FLOW_SZT)
    log.debug("shzs:%s" % ff)
    log.debug("hgt:%s" % hgt)
    # if len(ff) > 0:
    #     print ("\tSH: %s u:%s vo: %s sz: %s u:%s vo: %s" % (
    #         f_print(4, ff['scent']), f_print(4, ff['sup']), f_print(5, ff['svol']), f_print(4, ff['zcent']),
    #         f_print(4, ff['zup']),
    #         f_print(5, ff['zvol']))),
    if len(ff) > 0:
        print(u"\t\tSh: %s Vr:%s Sz: %s Vr:%s " %
              (f_print(4, ff['scent']), f_print(5, ff['svol']),
               f_print(4, ff['zcent']), f_print(5, ff['zvol'])))
    else:
        print(u"\t\tSh: \t%s Vr:  \t%s Sz: \t%s Vr: \t%s ") % (0, 0, 0, 0)
    if len(hgt) > 0:
        print("\t\tHgt: %s Ggt: %s Sgt: %s Gst: %s" %
              (hgt['hgt'], hgt['ggt'], szt['hgt'], szt['ggt']))
    else:
        print("\t\tHgt: \t%s Ggt: \t%s Sgt: %s Gst: %s" % (0, 0, 0, 0))
    if len(rzrq) > 0:
        shpcent = round(
            (rzrq['shrz'] / rzrq['sh'] * 100), 1) if rzrq['sh'] > 0 else '?'
        szpcent = round(
            (rzrq['szrz'] / rzrq['sz'] * 100), 1) if rzrq['sz'] > 0 else '?'
        print(u"\tSh: %s rz:%s :%s%% sz: %s rz:%s :%s%% All: %s diff: %s亿" %
              (f_print(5, rzrq['sh']), f_print(4, rzrq['shrz']), shpcent,
               f_print(5, rzrq['sz']), f_print(4, rzrq['szrz']), szpcent,
               f_print(4, rzrq['all']), f_print(5, rzrq['dff'])))
    bigcount = rd.getconfigBigCount(count=None, write=True)
    # print bigcount

    cct.set_console(width,
                    height,
                    title=[
                        'B:%s-%s V:%s' %
                        (bigcount[0], bigcount[2], bigcount[1]),
                        'ZL: %s' % (zlr if len(ff) > 0 else 0),
                        'To:%s' % len(topTen),
                        'D:%s' % len(crash),
                        'Sh: %s ' % ff['scent'] if len(ff) > 0 else '?',
                        'Vr:%s%% ' % ff['svol'] if len(ff) > 0 else '?',
                        'MR: %s' % zzb,
                        'ZL: %s' % (zlr if len(ff) > 0 else '?')
                    ])

    return allTop