Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

optimizer.add_listed_param 好像name太长的话engine run那里就会中断,并且api没有报错 #77

Open
umruuu opened this issue Nov 15, 2022 · 3 comments

Comments

@umruuu
Copy link

umruuu commented Nov 15, 2022

optimizer.add_listed_param(name="stopProfitPercent", val_list=[0])
当有两个可变参数的时候,name太长engine.run_backtest()这里就会在第一次for循环中断,且没有报错,很难debug。
参数名改成spp就好了

@umruuu
Copy link
Author

umruuu commented Nov 15, 2022

    for param in params:
        cnt += 1
        print(f"{gpName} 正在回测{cnt}/{total}")
        name = param["name"]
        param_content = content.replace("$NAME$", name)
        if is_yaml:
            param_content = json.dumps(yaml.full_load(param_content))
        
        engine.configBacktest(param["start_time"], param["end_time"])
        time_range = (param["start_time"], param["end_time"])
        # 去掉多余的参数
        param.pop("start_time")
        param.pop("end_time")
        if self.cpp_stra_module is not None:
            param.pop("name")
            engine.setExternalCtaStrategy(name, self.cpp_stra_module, self.cpp_stra_type, param)
        else:
            straInfo = self.strategy_type(**param)
            engine.set_cta_strategy(straInfo,slippage=1)
        engine.commitBTConfig()

print(2)

        engine.run_backtest()# !!!!!!!!在这里中断了,没有任何提示,接下来就是summary.json找不到

print(1)

        self.__ayalyze_result__(name, time_range, param, capital, rf, period)

@wondertrader
Copy link
Owner

没遇到过,我试试看

@wondertrader
Copy link
Owner

这个问题,我怀疑和一些字符串长度的限制有关

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants