代码拉取完成,页面将自动刷新
同步操作将从 macroan/traderStock-gui 强制同步,此操作会覆盖自 Fork 仓库以来所做的任何修改,且无法恢复!!!
确定后同步将在后台操作,完成时将刷新页面,请耐心等待。
#coding=utf-8
from __future__ import division
import sys
#sys.path.append('E:\\traderStock-gui\kline.pyd')
import pandas as pd
import db
import volume
import ma
import macd
import kdj
import kline
import config
import log
import multiprocessing as mp
import public
g_meettotalCount = 0 #成功次数
g_meettotal = {} #每天的涨幅,成功次数
#重置统计变量
def reset_statistics_var():
global g_meettotalCount, g_meettotal
g_meettotalCount = 0
g_meettotal = {day:{'totalrate':0, 'successcount':0} for day in config.ZF_DAY}
#获得的成功率
def get_successrate(cycle, techniquedata, funcstr, funcdesc):
public.cls_progressbar()
reset_statistics_var()
cycle = cycle.lower()
d = db.DB.getInstance()
basics = d.get_basics()
pool = mp.Pool(config.SUCC_CPU_COUNT)
progress = 0
totalCount = len(basics.index)
for code in basics.index:
progress += 1
pool.apply_async(succ_handle, (cycle, techniquedata, code, progress, totalCount, funcstr), callback=succ_result)
pool.close()
pool.join()
succ_output(cycle, techniquedata, funcdesc)
#计算成功率
def succ_handle(cycle, techniquedata, code, progress, totalCount, funcstr):
ret = progress/totalCount*100
d = db.DB.getInstance()
tbname = code+'_'+cycle+config.TABLENAME_STR_ALL+config.DATA_SOURCE
df = d.get_df(tbname)
if df is None or df.shape[0] == 0:
return None, None, ret, code, techniquedata
func = getattr(eval(techniquedata), funcstr)
if func is None:
return None, None, ret, code, techniquedata
meettotalCount, meettotal = func(df)
return meettotalCount, meettotal, ret, code, techniquedata
def succ_result(ret):
print(ret)
global g_meettotalCount, g_meettotal
if ret[0] != None and ret[1] != None:
g_meettotalCount += ret[0]
meet_total = ret[1]
for day in config.ZF_DAY:
g_meettotal[day]['totalrate'] += meet_total[day]['totalrate']
g_meettotal[day]['successcount'] += meet_total[day]['successcount']
progress = ret[2]
code = ret[3]
techniquedata = ret[4]
print(techniquedata+'_successrate_progress===============:%s, %d%%'%(code, progress))
public.setprogressbar(progress)
def succ_output(cycle, techniquedata, funcdesc):
global g_meettotalCount, g_meettotal
if g_meettotalCount == 0:
return
result = {}
for day in config.ZF_DAY:
result[funcdesc+u'平均涨幅day'+str(day)] = pd.Series(g_meettotal[day]['totalrate']/g_meettotalCount)
result[funcdesc+u'成功率day'+str(day)] = pd.Series(float(g_meettotal[day]['successcount'])/float(g_meettotalCount)*100)
result[u'总次数'] = pd.Series(g_meettotalCount)
df = pd.DataFrame(result)
df = df.T
if cycle == 'd':
df.to_csv(u'./output/成功率/'+techniquedata+'/'+funcdesc+'d.csv', encoding='gbk')
else:
df.to_csv(u'./output/成功率/'+techniquedata+'/'+funcdesc+'w.csv', encoding='gbk')
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。