Exemplo n.º 1
0
def Run(codes, task_id=0):
    #agl.LOG('sdf中')
    #codes = ['300033']
    def fnSample(code, dtype='5'):
        import warp_pytdx as tdx
        if dtype == '5':
            df = tdx.getFive(code)
            df = df.sort_index()
            return df
        if dtype == 'd':
            df = tdx.getHisdat(code)
            df = df.sort_index()
            return df

    def setParams(s):
        if 0: s = Strategy_Boll
        s.setParams(pl=publish.Publish(), )

    backtest_policy.test_strategy(
        codes,
        Strategy_Boll_Pre,
        setParams,
        start_day='2018-11-1',
        end_day='',
        #start_day='2017-12-2', end_day='2017-12-13',
        mode=BackTestPolicy.enum.hisdat_mode
        | BackTestPolicy.enum.hisdat_five_mode,
        datasource_mode=DataSources.datafrom.custom,
        datasource_fn=fnSample)
Exemplo n.º 2
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'
                                  )    
Exemplo n.º 3
0
def Run(codes, task_id=0):
    #agl.LOG('sdf中')
    #codes = ['300033']
    def setParams(s):
        if 0: s = Strategy_Boll
        s.setParams(pl=publish.Publish(), )

    backtest_policy.test_strategy(
        codes,
        Strategy_Boll_Pre,
        setParams,
        start_day='2018-2-7',
        end_day='2018-3-16',
        #start_day='2017-7-26', end_day='2017-12-13'
        mode=BackTestPolicy.enum.tick_mode)
Exemplo n.º 4
0
def Run(codes, task_id=0):
    #agl.LOG('sdf中')
    #codes = ['300033']
    def setParams(s):
        if 0: s = Strategy_Boll
        s.setParams(pl=publish.Publish(), )

    #fenshi数据源2017-8-1/2017-9-20
    backtest_policy.test_strategy(codes,
                                  Strategy_Boll_Pre,
                                  setParams,
                                  day_num=50,
                                  start_day='2017-8-1',
                                  end_day='2017-9-20'
                                  #start_day='2017-7-26', end_day='2017-12-13'
                                  )
Exemplo n.º 5
0
def Run(codes, task_id=0):
    #agl.LOG('sdf中')
    #codes = ['300033']
    def setParams(s):
        if 0: s = Strategy_Boll
        s.setParams(pl=publish.Publish(), )

    backtest_policy.test_strategy(
        codes,
        Strategy_Boll_Pre,
        setParams,
        #start_day='2017-8-26', end_day='2018-6-2',
        #start_day='2017-12-2', end_day='2017-12-13',
        mode=BackTestPolicy.enum.hisdat_mode
        | BackTestPolicy.enum.hisdat_five_mode,
        #mode=BackTestPolicy.enum.hisdat_mode,
        datasource_mode=stock.DataSources.datafrom.online)
Exemplo n.º 6
0
def Run(codes='', task_id=0):
    from pypublish import publish
    def fnSample(code, dtype=''):
        import tushare as ts
        df = ts.get_hist_data(code)[['high','low','open','close','volume']]
        df.columns = list('hlocv')
        df = df.sort_index()
        return df

    #设置策略参数
    def setParams(s):
        if 0: s = Strategy_Boll
        s.setParams(trade_num = 300, 
                    pl=publish.Publish(explicit=True),
                    )
    backtest_policy.test_strategy(codes, BollFenCangKline, setParams, mode=myenum.hisdat_mode, 
                                  start_day='2017-4-10', end_day='2018-9-15',
                                  datasource_mode=DataSources.datafrom.custom,
                                  datasource_fn=fnSample
                                  )    
Exemplo n.º 7
0
def main(args):
    #agl.LOG('sdf中')
    codes = ['300033']
    backtest_policy.test_strategy(codes, Strategy_Boll_Pre)