def policyrun(): commonlib.msg('policyrun running', True) if (len(commonlib.bvpolicyarray) == 0): t_policypool = getpool() if (len(t_policypool) > 0): t_policypool = commonlib.arraysplit( t_policypool, (len(t_policypool) // int(commonlib.cfgvalue('bigvolumeprocesses')) + 1)) t_threshold = float(commonlib.cfgvalue('bigvolumethreshold')) t_threshold = t_threshold if (t_threshold != 0) else 0.01 for t_el0 in t_policypool: commonlib.bvpolicyarray.append([t_el0, t_threshold]) if (len(commonlib.bvpolicyarray) > 0): t_prcs = int(commonlib.cfgvalue('processes')) t_bvpolicymsg = (commonlib.multiprcs(t_prcs, commonlib.getbigvolumeprcs, commonlib.bvpolicyarray) ) #price,time,code,lastend, if (len(t_bvpolicymsg) > 0): socketlib.bvrunmsg(t_bvpolicymsg) #price,time,code,lastend, commonlib.bvpolicyarray = bvpolicypoolupdate( t_bvpolicymsg) #price,time,code,lastend, #print(commonlib.bvmsg) commonlib.msg('policyrun run', True, True) return (0)
def analyzebigvolume(): commonlib.msg('analyzebigvolume running', True) t_winlimit = float(commonlib.cfgvalue('winlimit')) t_loselimit = float(commonlib.cfgvalue('loselimit')) t_opt = 'select lastdaydate from \'lastdaydate\' where recod=1;' t_dailydate = int(sqlite3lib.optrecod(sqlite3lib.bigvolumedb, t_opt)[0][0]) t_opt = 'select * from \'bigvolume\' where analyzed=0 order by bigvolumedate;' t_codegroup = sqlite3lib.optrecod(sqlite3lib.bigvolumedb, t_opt) for t_el0 in t_codegroup: if (len(t_el0) > 0): t_bvdate = int(t_el0[0]) if (t_dailydate > t_bvdate): t_str = '' t_a0 = t_el0[1].split('\n') if (len(t_a0) > 0): for t_el1 in t_a0: t_a1 = t_el1.split(',') if (len(t_a1) >= 4): #price,time,code,lastend, t_str += countbvdata(t_a1, t_bvdate, t_winlimit, t_loselimit) + '\n' t_opt = 'replace into \'bigvolume\'(bigvolumedate,bigvolumedata,analyzed) values({0},\'{1}\',1);'.format( t_el0[0], t_str) sqlite3lib.optrecod(sqlite3lib.bigvolumedb, t_opt) commonlib.msg('analyzebigvolume run', True) return (0)
def getpool(v_poolvolume=0): commonlib.msg('policyrun running', True) t_pool = v_poolvolume if (v_poolvolume != 0) else int( commonlib.cfgvalue('pool')) t_opt = 'select * from \'lastdaydata\' order by meanincome;' t_array = sqlite3lib.optrecod( sqlite3lib.bigvolumedb, t_opt) #code,volume,lastend,bvcount,win,lose,meanincome, t_i = len(t_array) t_policypool = [] if (t_i > 0): t_pool = (t_pool if (t_i >= t_pool) else t_i) t_threshold = float(commonlib.cfgvalue('bigvolumethreshold')) t_policyprice = float(commonlib.cfgvalue('policyprice')) t_threshold = t_threshold if (t_threshold != 0) else 0.01 for t_el0 in t_array: if (float(t_el0[2]) < t_policyprice): t_weight = (int(t_el0[4]) / (t_el0[5] if (t_el0[5] > 0) else 0.382) ) + t_el0[6] * 382 #win/lose+meanincome*382 t_policypool.append( [ t_el0[0], t_el0[1], t_el0[2], t_threshold, t_weight, 0.0, 0, 0 ] ) #code,volume,lastend,threshold,weight,price,volume,successflag, t_policypool.sort(key=lambda t_policypool: t_policypool[4], reverse=True) t_policypool = t_policypool[0:t_pool] else: commonlib.msg('get empty pool', True) return (t_policypool)
def getdaily(): commonlib.msg('getdaily running', True) t_lastdaydata = [] t_prcs = int(commonlib.cfgvalue('processes')) t_codegroup = commonlib.arraysplit(commonlib.codelist(True), 256) t_codegroup = commonlib.arraysplit( t_codegroup, (len(t_codegroup) // int(commonlib.cfgvalue('dailyprocesses')) + 1)) t_paras = [] for t_el0 in t_codegroup: t_paras.append((t_el0, )) t_lastdaydata = commonlib.multiprcs(t_prcs, commonlib.getdailyprcs, t_paras) commonlib.msg('getdaily run', True) return (t_lastdaydata)
def getbigvolume(v_webdate): commonlib.msg('getbigvolume running', True) t_prcs = int(commonlib.cfgvalue('processes')) t_threshold = float(commonlib.cfgvalue('bigvolumethreshold')) t_threshold = t_threshold if (t_threshold != 0) else 0.01 t_opt = 'select * from \'lastdaydata\';' t_codegroup = sqlite3lib.optrecod(sqlite3lib.bigvolumedb, t_opt) t_codegroup = commonlib.arraysplit( t_codegroup, (len(t_codegroup) // int(commonlib.cfgvalue('bigvolumeprocesses')) + 1)) t_paras = [] for t_el0 in t_codegroup: t_paras.append([t_el0, t_threshold]) t_bigvolume = commonlib.multiprcs(t_prcs, commonlib.getbigvolumeprcs, t_paras) savebigvolume(t_bigvolume, v_webdate) commonlib.msg('getbigvolume run', True) return (0)