def set_duration_console(du_date): if cct.isMac(): cct.set_console(width, height) else: cct.set_console(width, height, title=str(du_date))
if __name__ == "__main__": # print get_linear_model_status('600671', filter='y', dl=10, ptype='low') # print get_linear_model_status('600671', filter='y', dl=10, ptype='high') # print get_linear_model_status('600671', filter='y', start='20160329', ptype='low') # print get_linear_model_status('600671', filter='y', start='20160329', ptype='high') # print get_linear_model_status('999999', filter='y', dl=30, ptype='high') # print get_linear_model_status('999999', filter='y', dl=30, ptype='low') # print powerCompute_df(['300134','002171'], dtype='d',end=None, dl=10, filter='y') # # print powerCompute_df(['601198', '002791', '000503'], dtype='d', end=None, dl=30, filter='y') # print get_linear_model_status('999999', filter='y', dl=34, ptype='low', days=1) # print pct.get_linear_model_status('601519', filter='y', dl=34, ptype='low', days=1) # sys.exit() import re if cct.isMac(): cct.set_console(80, 19) else: cct.set_console(80, 19) parser = parseArgmain() parser.print_help() if cct.get_os_system().find('win') >= 0: import win_unicode_console win_unicode_console.disable() while 1: try: # log.setLevel(LoggerFactory.INFO) # log.setLevel(LoggerFactory.DEBUG) code = raw_input("code:") args = parser.parse_args(code.split()) # if not code.lower() == 'q' and not code.lower() == 'quit' and not code.lower() == 'exit' and not code == 'q' and not code == 'e' and not str(args.code) == 'None' and (args.wencai == 'y' or re.match('[a-zA-Z]+',code) is not None or re.match('[ \u4e00 -\u9fa5]+',code) == None ): # if not cct.get_os_system() == 'mac':
# elif percent_status == 'y' and cct.get_now_time_int() > 935 and ptype == 'high' : elif ptype == 'low': # top_dif = top_dif[top_dif.percent >= 0] top_temp = stf.filterPowerCount(top_dif,ct.PowerCount) top_end = top_dif[-5:].copy() top_temp = pct.powerCompute_df(top_temp, dl=ct.PowerCountdl, talib=True, newdays=newdays) top_end = pct.powerCompute_df(top_end, dl=ct.PowerCountdl, talib=True, newdays=newdays) else: # top_dif = top_dif[top_dif.percent >= 0] top_end = top_dif[:5].copy() top_temp = top_dif[-ct.PowerCount:].copy() top_temp = pct.powerCompute_df(top_temp, dl=ct.PowerCountdl, talib=True, newdays=newdays) top_end = pct.powerCompute_df(top_end, dl=ct.PowerCountdl, talib=True, newdays=newdays) cct.set_console(width, height, title=[du_date, 'dT:%s' % cct.get_time_to_date(time_s), 'G:%s' % goldstock, 'zxg: %s' % (blkname+'-'+market_blk)]) top_all = tdd.get_powerdf_to_all(top_all, top_temp) top_all = tdd.get_powerdf_to_all(top_all, top_end) top_temp = stf.getBollFilter(df=top_temp, boll=ct.bollFilter, duration=ct.PowerCountdl,resample=resample) print("N:%s K:%s %s G:%s" % ( now_count, len(top_all[top_all['buy'] > 0]), len(top_now[top_now['volume'] <= 0]), goldstock)), print "Rt:%0.1f dT:%s N:%s T:%s %s%%" % (float(time.time() - time_Rt), cct.get_time_to_date(time_s), cct.get_now_time(), len(top_temp), round(len(top_temp) / float(ct.PowerCount) * 100, 1)) # top_end = stf.getBollFilter(df=top_end, boll=ct.bollFilter,duration=ct.PowerCountdl) if 'op' in top_temp.columns: if cct.get_now_time_int() > ct.checkfilter_end_timeDu and (int(duration_date) > int(ct.duration_date_sort) or int(duration_date) < ct.duration_diff): top_temp = top_temp.sort_values(by=eval(market_sort_value), ascending=market_sort_value_key) else:
log = LoggerFactory.log args = docopt(cct.sina_doc, version='sina_cxdn') # print args,args['-d'] if args['-d'] == 'debug': log_level = LoggerFactory.DEBUG elif args['-d'] == 'info': log_level = LoggerFactory.INFO else: log_level = LoggerFactory.ERROR # log_level = LoggerFactory.DEBUG if args['-d'] else LoggerFactory.ERROR log.setLevel(log_level) # width, height = 132, 18 if cct.isMac(): width, height = 160, 16 cct.set_console(width, height) else: width, height = 160, 20 cct.set_console(width, height) # cct.set_console(width, height) # log.setLevel(LoggerFactory.DEBUG) status = False vol = ct.json_countVol type = ct.json_countType top_all = pd.DataFrame() code_a = {} success = 0 time_s = time.time() # delay_time = 3600 delay_time = cct.get_delay_time()
from docopt import docopt log = LoggerFactory.log args = docopt(cct.sina_doc, version='SinaMarket') if args['-d'] == 'debug': log_level = LoggerFactory.DEBUG elif args['-d'] == 'info': log_level = LoggerFactory.INFO else: log_level = LoggerFactory.ERROR log.setLevel(log_level) if cct.isMac(): width, height = 176, 22 cct.set_console(width, height) else: width, height = 176, 22 cct.set_console(width, height) # cct.terminal_positionKey_triton # cct.set_console(width, height) # if cct.isMac(): # cct.set_console(108, 16) # else: # cct.set_console(100, 16) status = False vol = ct.json_countVol type = ct.json_countType cut_num = 1000000 success = 0
if __name__ == "__main__": # import matplotlib # # matplotlib.use('WXAgg') # # plt.interactive(True) # matplotlib.use('QT5Agg') status = get_linear_model_histogramDouble('601198') # plt.show() # print status # get_tdx_and_now_data('002399') # sys.exit(0) # args=main(cct.cct_raw_input('input').split()) # print (args.d) # sys.exit() if cct.isMac(): cct.set_console(80, 16) else: cct.set_console(80, 16) num_input = '' parser = parseArgmain() if len(sys.argv) == 2: num_input = sys.argv[1] args = parser.parse_args(num_input.split()) elif len(sys.argv) > 2: num_input = sys.argv[1] args = parser.parse_args(sys.argv[1:]) else: parser.print_help() while 1: try: if not len(num_input) == 6:
def get_hot_countNew(changepercent, rzrq, fibl=None, fibc=10): global fibcount INDEX_LIST_TDX = {'999999': 'sh', '399001': 'sz', '399006': 'cyb'} # {v: k for k, v in m.items()} # >>> zip(m.values(), m.keys()) # mi = dict(zip(m.values(), m.keys())) 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] # cumin_index[INDEX_LIST_TDX[code]]=cumin 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') ffindex = ffu.get_dfcfw_fund_flow2020('all') ffall = {} topTen_all = 0 crashTen_all = 0 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] # dropcode = [ x for x in topTen.index.tolist() if x not in top_Ten_Dropcxg] # if len(dropcode) >0: # topT_l = tdd.get_tdx_exp_all_LastDF_DL(dropcode, dt=ct.duration_date_l,newdays=10,showRunTime=False) # if isinstance(topT_l, pd.DataFrame): # top_Ten_Dropcxg.extend(topT_l.index.tolist()) 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' topTen_all += len(topTen) crashTen_all += len(crashTen) # top=df[ df['changepercent'] <6] # print("\033[1;31;40m您输入的帐号或密码错误!\033[0m") 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)))), # print(u"-5:%s" % # (f_print(4, len(crash[crash < -5])))), 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(6, zlr, 32), f_print(4, zzb, 32))), if 'close' in ff.keys(): if ff['close'] == 0: _percent = 0 else: _percent = round( (ff['close'] - ff['lastp']) * 100 / ff['close'], 2) else: _percent = 0 ff['close'] = 0.0 ff['open'] = 0.0 ff['lastp'] = 0.0 # print (u" %s"%(f_print(2,cumin_index[market],31))), print( u"%s %s%% %s%s" % (f_print(7, ff['close']), f_print(4, _percent, 31), f_print(1, '!' if ff['open'] > ff['lastp'] else '?'), f_print(2, '!!' if ff['close'] > ff['lastp'] else '??', 32))) allTop = allTop.append(df.reset_index(), ignore_index=True) allTop = allTop.drop_duplicates() df = allTop df = tdd.get_single_df_lastp_to_df(df.set_index('code'), resample='d') count = len(df.index) top = df[df['percent'] > changepercent] topTen = df[df['percent'] >= 9.9] if 'max5' in df.columns: top_Max = (df[(df.close >= df.hmax) & (df.close >= df.max5)]) # top_low = len(df[df.low < df.min5]) top_min = (df[(df.close <= df.lmin) & (df.close <= df.min5)]) cct.GlobalValues().setkey('top_max', top_Max) cct.GlobalValues().setkey('top_min', top_min) else: top_Max = [] top_low = 0 top_min = [] # topTen = str(len(topTen)) +'('+str(len(top_Ten_Dropcxg))+')' +'(H:'+str(len(top_Max))+')' topTen = str(topTen_all) + '(' + str(len(topTen)) + ')' + \ '(H:' + str(len(top_Max)) + ')' # print "top_Ten_Dropcxg:%s",top_Ten_Dropcxg # crashTen = df[df['percent'] < -9.8] crashTen = str(crashTen_all) + '(L:' + str(len(top_min)) + ')' crash = df[df['percent'] < -changepercent] print(u"AL:%s topT:%s top>%s:%s" % (f_print(4, count), f_print( 3, (topTen), 31), changepercent, f_print(4, len(top), 31))), print( u"crashT:%s crash<-%s:%s" % (f_print(3, (crashTen), 32), changepercent, f_print(4, len(crash), 31))), print(u"-5:%s" % (f_print(4, len(crash[crash.percent < -5]), 32))), # 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, 31), f_print(4, zzb, 31), 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) hgt = ffu.get_dfcfw_fund_HGSZ2021('bei') szt = ffu.get_dfcfw_fund_HGSZ2021('nan') log.debug("shzs:%s hgt:%s" % (ff, 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']))), bigcount = rd.getconfigBigCount(count=None, write=True) if len(ff) > 0: print(u"\tSh: %s Vr:%s Sz: %s Vr:%s " % (f_print(4, ff['scent']), f_print(5, ff['svol'], 31), f_print(4, ff['zcent']), f_print(5, ff['zvol'], 31))), print(u'B:%s-%s V:%s' % (bigcount[0], bigcount[2], f_print(4, bigcount[1]))) else: print(u"\tSh: \t%s Vr: \t%s Sz: \t%s Vr: \t%s ") % (0, 0, 0, 0), print(u'B:%s-%s V:%s' % (bigcount[0], bigcount[2], f_print(4, bigcount[1]))) if len(hgt) > 0: print("\tSgt: %s Gst: %s Hgt: %s Ggt: %s SSVol:%s" % (hgt['ggt'], szt['ggt'], hgt['hgt'], szt['hgt'], f_print(10, ff['allvol'], 31))) else: print("\t%s Sgt: %s Gst: %s \tHgt: \t%s Ggt: " % (0, 0, 0, 0)) if len(rzrq) > 0: if 'shrz' not in rzrq.keys() and 'szrz' not in rzrq.keys(): rzrq['shrz'] = 0 rzrq['szrz'] = 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'], 31), f_print(5, rzrq['dff'], 31))) # print "bigcount:",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 '?') ], closeTerminal=True) log.debug("set_console:bigcount[0]%s bigcount[2]:%s" % (bigcount[0], bigcount[2])) return allTop
args = docopt(cct.sina_doc, version='sina_cxdn') # print args,args['-d'] if args['-d'] == 'debug': log_level = LoggerFactory.DEBUG elif args['-d'] == 'info': log_level = LoggerFactory.INFO else: log_level = LoggerFactory.ERROR # log_level = LoggerFactory.DEBUG if args['-d'] else LoggerFactory.ERROR log.setLevel(log_level) # log.setLevel(LoggerFactory.DEBUG) # print len(sys.argv) if cct.isMac(): width, height = 108, 15 cct.set_console(width, height) else: width, height = 108, 15 cct.set_console(width, height) if len(sys.argv) == 2: status = True num_input = sys.argv[1] # print num_input elif (len(sys.argv) > 2): pass else: status = False num_input = '' status = False