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

dummy.one_symbol_dummy函数执行出错 #166

Closed
Mjzs12138 opened this issue Sep 10, 2023 · 1 comment
Closed

dummy.one_symbol_dummy函数执行出错 #166

Mjzs12138 opened this issue Sep 10, 2023 · 1 comment

Comments

@Mjzs12138
Copy link

使用示例脚本run_dummy_backtest,执行该函数时,显示策略保存失败。

dummy = czsc.DummyBacktest(strategy=CzscStrategyExample2, read_bars=get_raw_bars,
signals_module_name='czsc.signals',
sdt='20200101', edt='20230301',
signals_path=os.path.join('results', 'dummy_backtest信号'),
results_path=os.path.join('results', 'dummy_backtest结果'))

定义需要回测的品种,这里可以自定义

symbols = get_symbols('A股主要指数')
dummy.one_symbol_dummy(symbols[0])

2023-09-10 19:53:26.297 | DEBUG | czsc.traders.dummy:one_symbol_dummy:98 - 399682.SZ 15分钟笔停顿 保存失败,原因:"['bid'] not found in axis"
2023-09-10 19:53:26.307 | DEBUG | czsc.traders.dummy:one_symbol_dummy:98 - 399682.SZ 15分钟笔停顿B 保存失败,原因:"['bid'] not found in axis"
2023-09-10 19:53:26.307 | INFO | czsc.traders.dummy:one_symbol_dummy:100 - 399682.SZ 回测完成,共 2 个持仓策略,耗时 2.48 秒

@zengbin93
Copy link
Member

问题出在 holds 数据中没有继续保存 bid 这个字段,这是为了节省内容。将在 0.9.29 版本修复。临时修复方式是,找到源码 czsc.traders.dummy:one_symbol_dummy,将93行注释掉。

dfh['n1b'] = (dfh['price'].shift(-1) / dfh['price'] - 1) * 10000
# dfh.drop(columns=['bid'], inplace=True)
dfh.fillna(0, inplace=True)

zengbin93 added a commit that referenced this issue Sep 11, 2023
zengbin93 added a commit that referenced this issue Sep 24, 2023
* 0.9.29 start coding

* 0.9.29 新增交易日历

* update

* 0.9.29 update

* update

* 0.9.29 delete signals merged

* 0.9.29 fix bug (#166)

* 0.9.29 更新 streamlit 页面

* 0.9.29 update

* 0.9.29 update

* 0.9.29 update

* 0.9.29 新增多空对冲组合分析函数

* 0.9.29 update

* 0.9.29 update

* 0.9.29 update

* 0.9.29 fix bar_window_ps_V230801

* 0.9.29 update

* 0.9.29 新增 RWC

* 0.9.29 新增开平仓优化方法

* 0.9.29 新增笔特征计算

* 0.9.29 新增 cxt_bi_trend_V230913 信号函数

* 0.9.29 update
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