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

事件驱动型回测执行期货指数合约时报错 #58

Open
kevinhuangwl opened this issue Sep 15, 2018 · 0 comments
Open

事件驱动型回测执行期货指数合约时报错 #58

kevinhuangwl opened this issue Sep 15, 2018 · 0 comments

Comments

@kevinhuangwl
Copy link

报错信息:
Traceback (most recent call last):
File "/home/kevin/Documents/JAQS/test/test_backtest_eventdriven.py", line 207, in
test_backtest()
File "/home/kevin/Documents/JAQS/test/test_backtest_eventdriven.py", line 161, in test_backtest
do_analyze()
File "/home/kevin/Documents/JAQS/test/test_backtest_eventdriven.py", line 200, in do_analyze
ta.do_analyze(result_dir=result_dir_path, selected_sec=[])
File "/home/kevin/Documents/JAQS/jaqs/trade/analyze/analyze.py", line 1542, in do_analyze
self.process_trades()
File "/home/kevin/Documents/JAQS/jaqs/trade/analyze/analyze.py", line 548, in process_trades
self._trades = self._process_trades(self._trades)
File "/home/kevin/Documents/JAQS/jaqs/trade/analyze/analyze.py", line 543, in _process_trades
res = gp.apply(_apply,self.inst_map)
File "/home/kevin/Documents/anaconda3/envs/dl/lib/python3.6/site-packages/pandas/core/groupby.py", line 805, in apply
return self._python_apply_general(f)
File "/home/kevin/Documents/anaconda3/envs/dl/lib/python3.6/site-packages/pandas/core/groupby.py", line 809, in _python_apply_general
self.axis)
File "/home/kevin/Documents/anaconda3/envs/dl/lib/python3.6/site-packages/pandas/core/groupby.py", line 1969, in apply
res = f(group)
File "/home/kevin/Documents/anaconda3/envs/dl/lib/python3.6/site-packages/pandas/core/groupby.py", line 796, in f
return func(g, *args, **kwargs)
File "/home/kevin/Documents/JAQS/jaqs/trade/analyze/analyze.py", line 524, in _apply
mult = self.inst_map.get(symbol).get("multiplier")
AttributeError: 'NoneType' object has no attribute 'get'

重现步骤:
JAQS/test/test_backtest_eventdriven.py中把test_backtest()函数中的合约设置为指数合约rb.SHF(在instrument.csv中得知),具体代码如下:
props = {"symbol": "rb.SHF",
"start_date": 20170710,
"end_date": 20170730,
"bar_type": "1M", # '1d'
"init_balance": 2e4}
然后执行该测试用例,在策略部分运行正常,然后在do_analyze()函数运行时出现上述异常。

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

1 participant