Esempio n. 1
0
def run_policy():
    p = live_policy_runner.LivePolicySwitch()
    s = boll_pramid.Strategy_Boll_Pre(data_interface.TdxData())
    if agl.is_function(s.setParams):
        s.setParams()
    p.Regist(s)

    while 1:
        agl.tic()
        p.Run()
        agl.toc()
        time.sleep(3)
        if stock.IsShouPan():
            break
Esempio n. 2
0
def main(args):
    agl.tic()
    BackTestPolicy.Test()
    agl.toc()
    print("end")
Esempio n. 3
0
#测试策略, 为了并行计算, 需要使用这种格式的函数定义		    
def Run(codes='', task_id=0):
    from pypublish import publish
    #设置策略参数
    def setParams(s):
	if 0: s = Strategy_Boll
	s.setParams(trade_num = 300, 
                    pl=publish.Publish()
                    )
    if codes == '':
	codes = ['300033']
    #现在的5分钟线在2017-5-15之后才有
    backtest_policy.test_strategy(codes, BollFenCangKline, setParams, day_num=20, mode=myenum.hisdat_mode, 
                                  start_day='2016-10-20', end_day='2017-10-1'
                                  )    

  
def calcYinKui(price, chengben):
    return (price - chengben)/chengben
if __name__ == "__main__":
    is_multi = 0
    #is_multi = 1
    if not is_multi:
	Run()
    else:
	codes = stock.DataSources.getCodes()
	cpu_num = 5
	#codes = stock.get_codes(myenum.randn, cpu_num*1)
	backtest_policy.MultiProcessRun(cpu_num, codes, Run, __file__)
    agl.toc()