代码拉取完成,页面将自动刷新
同步操作将从 macroan/traderStock-gui 强制同步,此操作会覆盖自 Fork 仓库以来所做的任何修改,且无法恢复!!!
确定后同步将在后台操作,完成时将刷新页面,请耐心等待。
#coding=utf-8
from __future__ import division
import pandas as pd
import db
import utils
import volume
import ma
import macd
import kdj
import kline
import log
import multiprocessing as mp
import stock
import public
import config
#选股结果列表
result_list = []
def reset_resultlist():
global result_list
result_list = []
def xuangu(cycle, techniquedata, funcstr, funcdesc, opttype=1):
public.cls_progressbar()
reset_resultlist()
d = db.DB.getInstance()
basics = d.get_basics()
pool = mp.Pool(config.XUGU_CPU_COUNT)
progress = 0
totalCount = len(basics.index)
try:
for code in basics.index:
progress += 1
pool.apply_async(xuangu_handle, (cycle, techniquedata, code, progress, totalCount, funcstr, opttype), callback=xuangu_result)
pool.close()
pool.join()
except Exception, e:
print(e)
#xuangu_handle(cycle, techniquedata, '300602', progress, totalCount, funcstr, opttype)
xuangu_output(cycle, techniquedata, funcstr, funcdesc, opttype)
def xuangu_handle(cycle, techniquedata, code, progress, totalCount, funcstr, opttype):
d = db.DB.getInstance()
s = stock.Stock.getInstance()
ret = progress/totalCount*100
if opttype == 1:
tbname = code+'_'+cycle.lower()+config.TABLENAME_STR_RECENT+config.DATA_SOURCE
df = d.get_df(tbname)
else:
start = '2017-01-01'
df = s.get_stock_data(code, ty=cycle, start=start)
df = s.set_integrated_data(df)
if df is None or df.shape[0] == 0 or (not utils.xuangu_filter(code, df)):
return 0, ret, code, techniquedata
func = getattr(eval(techniquedata), funcstr)
if func is None:
return 0, ret, code, techniquedata
retcode = func(df, code)
return retcode, ret, code, techniquedata
def xuangu_result(ret):
global result_list
retcode = ret[0]
progress = ret[1]
code = ret[2]
techniquedata = ret[3]
if ret[0] != 0:
result_list.append(retcode)
print(techniquedata+'_xuangu_progress===============:%s, %d%%'%(code, progress))
public.setprogressbar(progress)
def xuangu_output(cycle, techniquedata, funcstr, funcdesc, opttype):
if len(result_list) == 0:
return
ret = {}
ret[funcstr] = pd.Series(result_list)
df = pd.DataFrame(ret)
if opttype == 1:
df.to_csv(u'./output/选股/'+techniquedata+'/'+funcdesc+cycle.lower()+'.csv', encoding='gbk', index=False)
else:
df.to_csv(u'./output/选股/'+techniquedata+u'/尾盘'+funcdesc+cycle.lower()+'.csv', encoding='gbk', index=False)
'''
ret = {}
ret = {u'代码':[], u'名字':[], u'主力流入':[], u'主力流出':[], u'主力净流入':[],
u'主力净流入/资金流入流出总和':[], u'散户流入':[],
u'散户流出':[], u'散户净流入':[], u'散户净流入/资金流入流出总和':[],
u'资金流入流出总和':[]}
s = stock.Stock.getInstance()
for code in result_list:
info = s.get_realtime_capital(code)
if info is None or len(info) == 0:
continue
ret[u'代码'].append(info[0])
ret[u'名字'].append(info[12])
ret[u'主力流入'].append(info[1])
ret[u'主力流出'].append(info[2])
ret[u'主力净流入'].append(info[3])
ret[u'主力净流入/资金流入流出总和'].append(info[4])
ret[u'散户流入'].append(info[5])
ret[u'散户流出'].append(info[6])
ret[u'散户净流入'].append(info[7])
ret[u'散户净流入/资金流入流出总和'].append(info[8])
ret[u'资金流入流出总和'].append(info[9])
df = pd.DataFrame(ret).T
#todaylist = []
#fivedaylist = []
#buycountlist = []
#sellcountlist = []
#for code in result_list:
#todaymoney, fivedaymoney, buy_count, sell_count = s.get_capital_info(code)
#todaylist.append(todaymoney)
#fivedaylist.append(fivedaymoney)
#buycountlist.append(buy_count)
#sellcountlist.append(sell_count)
#df[u'今天资金'] = pd.Series(todaylist)
#df[u'5日资金'] = pd.Series(fivedaylist)
#df[u'今天买盘次数'] = pd.Series(buycountlist)
#df[u'今天卖盘次数'] = pd.Series(sellcountlist)
if opttype == 1:
df.to_csv(u'./output/选股/'+techniquedata+'/'+funcdesc+cycle.lower()+'.csv', encoding='gbk')
else:
df.to_csv(u'./output/选股/'+techniquedata+u'/尾盘'+funcdesc+cycle.lower()+'.csv', encoding='gbk')
'''
def testxuangu():
s = stock.Stock.getInstance()
d = db.DB.getInstance()
basics = d.get_basics()
pool = mp.Pool(mp.cpu_count())
progress = 0
totalCount = len(basics.index)
try:
for code in basics.index:
progress += 1
df = s.get_stock_data(code, 'D')
if df is not None and df.shape[0] > 0:
df = df.sort_values('date', ascending=False)
df = s.set_integrated_data(df, type='R')
df = df[:60]
if df is None or df.shape[0] == 0 or utils.isnew(df):
continue
pool.apply_async(xuangu_handle, (df, 'macd', code, progress, totalCount, 'macd.macd_zeroup_first_gc'), callback=xuangu_result)
pool.close()
pool.join()
except Exception, e:
print(e)
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。