status_change = True time_s = time.time() top_all = pd.DataFrame() else: status_change = False if len(top_now) > 10 or cct.get_work_time(): # time_Rt = time.time() if len(top_all) == 0 and len(lastpTDX_DF) == 0: cct.get_terminal_Position(position=sys.argv[0]) top_all, lastpTDX_DF = tdd.get_append_lastp_to_df( top_now, lastpTDX_DF=None, dl=duration_date, end=end_date, ptype=ptype, filter=filter, power=ct.lastPower, lastp=False, resample=resample) log.debug("len:%s" % (len(top_all))) top_list = tdd.compute_jump_du_count(top_all, resample=resample) elif len(top_all) == 0 and len(lastpTDX_DF) > 0: top_all = top_now top_all = top_all.merge(lastpTDX_DF, left_index=True, right_index=True, how='left') log.info('Top-merge_now:%s' % (top_all[:1]))
log.info("top_now.buy[:30]>0:%s" % len(top_now[:30][top_now[:30]['buy'] > 0])) if len(top_now) > 10 or cct.get_work_time(): # if len(top_now) > 10 or len(top_now[:10][top_now[:10]['buy'] > 0]) > 3: # if len(top_now) > 10 and not top_now[:1].buy.values == 0: # top_now=top_now[top_now['percent']>=0] if 'trade' in top_now.columns: top_now['buy'] = (map(lambda x, y: y if int(x) == 0 else x, top_now['buy'].values, top_now['trade'].values)) # time_Rt = time.time() if len(top_all) == 0 and len(lastpTDX_DF) == 0: cct.get_terminal_Position(position=sys.argv[0]) time_Rt = time.time() top_all, lastpTDX_DF = tdd.get_append_lastp_to_df(top_now) elif len(top_all) == 0 and len(lastpTDX_DF) > 0: # time_Rt = time.time() top_all = tdd.get_append_lastp_to_df(top_now, lastpTDX_DF) else: if 'couts' in top_now.columns.values: if not 'couts' in top_all.columns.values: top_all['couts'] = 0 top_all['prev_p'] = 0 # for symbol in top_now.index: # # code = rl._symbol_to_code(symbol) # if symbol in top_all.index and top_now.loc[symbol, 'buy'] <> 0: # # top_now.loc[symbol, 'dff'] = round(((float(top_now.loc[symbol, 'buy']) - float(top_all.loc[symbol, 'lastp'])) / float(top_all.loc[symbol, 'lastp']) * 100), 1) # if 'couts' in top_now.columns.values: # top_all.loc[symbol, ct.columns_now] = top_now.loc[symbol, ct.columns_now]
len(top_now[:30][top_now[:30]['buy'] > 0])) if len(top_now) > 10 or cct.get_work_time(): # if len(top_now) > 10 or len(top_now[:10][top_now[:10]['buy'] > 0]) > 3: # if len(top_now) > 10 and not top_now[:1].buy.values == 0: # top_now=top_now[top_now['percent']>=0] if 'trade' in top_now.columns: top_now['buy'] = (map(lambda x, y: y if int(x) == 0 else x, top_now['buy'].values, top_now['trade'].values)) if len(top_all) == 0 and len(lastpTDX_DF) == 0: terminal_count = cct.get_terminal_Position( position=sys.argv[0]) print "term:%s" % (terminal_count), if terminal_count > 1: top_all, lastpTDX_DF = tdd.get_append_lastp_to_df( top_now, lastpTDX_DF=None, dl=duration_date) else: top_all, lastpTDX_DF = tdd.get_append_lastp_to_df( top_now, lastpTDX_DF=None, dl=duration_date, checknew=True) # time_Rt = time.time() # top_all,lastpTDX_DF = tdd.get_append_lastp_to_df(top_now,end=end_date,dl=duration_date) elif len(top_all) == 0 and len(lastpTDX_DF) > 0: # time_Rt = time.time() top_all = tdd.get_append_lastp_to_df(top_now, lastpTDX_DF) else: if 'couts' in top_now.columns.values: if not 'couts' in top_all.columns.values:
time_s = time.time() top_all = pd.DataFrame() else: status_change = False # print ("Buy>0:%s" % len(top_now[top_now['buy'] > 0])), if len(top_now) > 10 or cct.get_work_time(): time_Rt = time.time() if len(top_all) == 0 and len(lastpTDX_DF) == 0: cct.get_terminal_Position(position=sys.argv[0]) time_Rt = time.time() top_all, lastpTDX_DF = tdd.get_append_lastp_to_df( top_now, lastpTDX_DF=None, dl=duration_date, end=end_date, ptype=ptype, filter=filter, power=False, lastp=False, newdays=newdays) elif len(top_all) == 0 and len(lastpTDX_DF) > 0: time_Rt = time.time() top_all = top_now top_all = top_all.merge(lastpTDX_DF, left_index=True, right_index=True, how='left') top_all = top_all[top_all['llow'] > 0] else:
else: status_change = False # print ("Buy>0:%s" % len(top_now[top_now['buy'] > 0])), if len(top_now) > 0 or cct.get_work_time(): # time_Rt = time.time() if len(top_all) == 0 and len(lastpTDX_DF) == 0: cct.get_terminal_Position(position=sys.argv[0]) # time_Rt = time.time() print "term:%s" % (cct.get_terminal_Position(cmd='DurationDn.py')), # if cct.get_terminal_Position(cmd='DurationDn.py') > 1: # top_all, lastpTDX_DF = tdd.get_append_lastp_to_df( # top_now, lastpTDX_DF=None, dl=duration_date, end=end_date, ptype=ptype, filter=filter, power=ct.lastPower, lastp=lastp, newdays=newdays, resample=resample) # else: newdays = 0 top_all, lastpTDX_DF = tdd.get_append_lastp_to_df( top_now, lastpTDX_DF=None, dl=duration_date, end=end_date, ptype=ptype, filter=filter, power=ct.lastPower, lastp=lastp, newdays=newdays, checknew=True, resample=resample) # codelist = top_all.index.tolist() # log.info('toTDXlist:%s' % len(codelist)) # # tdxdata = tdd.get_tdx_all_day_LastDF(codelist,dt=duration_date,ptype=ptype) # # print "duration_date:%s ptype=%s filter:%s"%(duration_date, ptype,filter) # # tdxdata = tdd.get_tdx_exp_all_LastDF(codelist, dt=duration_date, end=end_date, ptype=ptype,filter=filter) # tdxdata = tdd.get_tdx_exp_all_LastDF_DL(codelist, dt=duration_date, end=end_date, ptype=ptype,filter=filter,power=power) # log.debug("TdxLastP: %s %s" % (len(tdxdata), tdxdata.columns.values)) # tdxdata.rename(columns={'low': 'llow'}, inplace=True) # tdxdata.rename(columns={'high': 'lhigh'}, inplace=True) # tdxdata.rename(columns={'close': 'lastp'}, inplace=True) # tdxdata.rename(columns={'vol': 'lvol'}, inplace=True) # if power: # tdxdata = tdxdata.loc[:, ['llow', 'lhigh', 'lastp', 'lvol', 'date','ra','op','fib','ldate']] # # print len(tdxdata[tdxdata.op >12]),
if time_d - time_s > delay_time: status_change = True time_s = time.time() top_all = pd.DataFrame() else: status_change = False if len(top_now) > 10 and len(top_now.columns) > 4: # top_now = top_now[top_now.trade >= top_now.high * 0.98] # if 'percent' in top_now.columns.values: # top_now = top_now[top_now['percent'] >= 0] if len(top_all) == 0 and len(lastpTDX_DF) == 0: cct.get_terminal_Position(position=sys.argv[0]) time_Rt = time.time() top_all, lastpTDX_DF = tdd.get_append_lastp_to_df( top_now, resample=resample) elif len(top_all) == 0 and len(lastpTDX_DF) > 0: time_Rt = time.time() top_all = tdd.get_append_lastp_to_df(top_now, lastpTDX_DF) # dd=dd.fillna(0) else: # for symbol in top_now.index: # if symbol in top_all.index: # count_n = top_now.loc[symbol, 'couts'] # count_a = top_all.loc[symbol, 'couts'] # top_now.loc[symbol, 'dff'] = count_n - count_a # if status_change: # # top_all.loc[symbol] = top_now.loc[symbol] # top_all.loc[symbol, ['name', 'percent', 'dff', 'couts', 'trade', 'high', 'open', 'low', 'ratio', 'volume', # 'prev_p']] = top_now.loc[symbol, ['name', 'percent', 'dff', 'couts', 'trade', 'high', 'open', 'low', 'ratio', 'volume', # 'prev_p']]