Closed Quant2017 closed 7 years ago
麻烦给一下完整的报错信息,以及 rqalpha 版本、python 版本、操作系统等信息,谢谢。
rqalpha_user@rqalpha-VirtualBox:~$ uname -a
Linux rqalpha-VirtualBox 4.8.0-42-generic #45~16.04.1-Ubuntu SMP Thu Mar 9 14:10:58 UTC 2017 x86_64 x86_64 x86_64 GNU/Linux
rqalpha_user@rqalpha-VirtualBox:~$ source activate py3
(py3) rqalpha_user@rqalpha-VirtualBox:~$ python -V
Python 3.5.3 :: Continuum Analytics, Inc.
(py3) rqalpha_user@rqalpha-VirtualBox:~$ rqalpha version
Current Version: (3, 0, 1)
(py3) rqalpha_user@rqalpha-VirtualBox:~$ cd examples/
(py3) rqalpha_user@rqalpha-VirtualBox:~/examples$ ls
buy_and_hold.py IF_macd.py __pycache__ subscribe_event.py
data_source __init__.py QueryRsp.con technical_analysis
DialogRsp.con macd.py rsi.py test_pt.py
extend_api pair_trading.py run_code_demo.py TradingDay.con
golden_cross.py Private.con run_file_demo.py turtle.py
IF1706_20161108.csv Public.con run_func_demo.py
(py3) rqalpha_user@rqalpha-VirtualBox:~/examples$ python run_code_demo.py
[2017-06-26 21:03:24.480968] DEBUG: system_log:
{'base': {'accounts': {'STOCK': 100000.0},
'benchmark': '000300.XSHG',
'data_bundle_path': '/home/rqalpha_user/.rqalpha/bundle',
'end_date': datetime.date(2016, 12, 1),
'frequency': '1d',
'margin_multiplier': 1,
'persist': False,
'persist_mode': PERSIST_MODE.REAL_TIME,
'resume_mode': False,
'run_type': RUN_TYPE.BACKTEST,
'source_code': None,
'start_date': datetime.date(2016, 6, 1),
'strategy_file': 'strategy.py'},
'extra': {'context_vars': None,
'enable_profiler': False,
'force_run_init_when_pt_resume': False,
'is_hold': False,
'locale': 'zh_Hans_CN',
'log_level': 'verbose',
'user_log_disabled': False,
'user_system_log_disabled': False},
'mod': {'ctp': {'enabled': True},
'shipane': {'enabled': False},
'sys_accounts': {'enabled': True},
'sys_analyser': {'enabled': True, 'plot': False},
'sys_funcat': {'enabled': True},
'sys_progress': {'enabled': True},
'sys_risk': {'enabled': True},
'sys_simulation': {'enabled': True},
'sys_stock_realtime': {'enabled': False},
'vnpy': {'enabled': False}},
'validator': {'cash_return_by_stock_delisted': False, 'close_amount': True},
'version': '0.1.6',
'whitelist': ['base', 'extra', 'validator', 'mod']}
[2017-06-26 21:03:24.481442] DEBUG: system_log: 载入 Mod rqalpha.mod.rqalpha_mod_sys_progress
[2017-06-26 21:03:24.482538] DEBUG: system_log: 载入 Mod rqalpha.mod.rqalpha_mod_sys_simulation
[2017-06-26 21:03:24.490595] DEBUG: system_log: 载入 Mod rqalpha.mod.rqalpha_mod_sys_risk
[2017-06-26 21:03:24.493989] DEBUG: system_log: 载入 Mod rqalpha.mod.rqalpha_mod_sys_accounts
[2017-06-26 21:03:24.500203] DEBUG: system_log: 载入 Mod rqalpha.mod.rqalpha_mod_sys_analyser
[2017-06-26 21:03:24.502382] DEBUG: system_log: 载入 Mod rqalpha.mod.rqalpha_mod_sys_funcat
[2017-06-26 21:03:24.503433] DEBUG: system_log: 载入 Mod rqalpha_mod_ctp
Traceback (most recent call last):
File "TraderApi.pyx", line 605, in ctp._TraderApi.TraderSpi_OnFrontConnected (ctp/TraderApi.cpp:14978)
File "/home/rqalpha_user/anaconda3/envs/py3/lib/python3.5/site-packages/rqalpha_mod_ctp/ctp/api.py", line 199, in OnFrontConnected
self.login()
└ <rqalpha_mod_ctp.ctp.api.CtpTdApi object at 0x7fe87e09df30>
File "/home/rqalpha_user/anaconda3/envs/py3/lib/python3.5/site-packages/rqalpha_mod_ctp/ctp/api.py", line 349, in login
Password=str2bytes(self.password),
│ └ <rqalpha_mod_ctp.ctp.api.CtpTdApi object at 0x7fe87e09df30>
└ <function str2bytes at 0x7fe87ff4a488>
TypeError: expected bytes, NoneType found
Traceback (most recent call last):
File "/home/rqalpha_user/anaconda3/envs/py3/lib/python3.5/site-packages/rqalpha/main.py", line 195, in run
mod_handler.start_up()
└ <rqalpha.mod.ModHandler object at 0x7fe88033de48>
File "/home/rqalpha_user/anaconda3/envs/py3/lib/python3.5/site-packages/rqalpha/mod/__init__.py", line 68, in start_up
self._mod_dict[mod_name].start_up(self._env, mod_config)
│ │ │ └ {'enabled': True,
'event': {'address': 'tcp://180.168.212.228:41213', 'all_day': False, 'enabled': True},
'login': {'broker_id...
│ │ └ <rqalpha.mod.ModHandler object at 0x7fe88033de48>
│ └ 'ctp'
└ <rqalpha.mod.ModHandler object at 0x7fe88033de48>
File "/home/rqalpha_user/anaconda3/envs/py3/lib/python3.5/site-packages/rqalpha_mod_ctp/mod.py", line 39, in start_up
self._init_trade_gateway()
└ <rqalpha_mod_ctp.mod.CtpMod object at 0x7fe87ff7e470>
File "/home/rqalpha_user/anaconda3/envs/py3/lib/python3.5/site-packages/rqalpha_mod_ctp/mod.py", line 65, in _init_trade_gateway
self._trade_gateway.connect(user_id, password, broker_id, trade_frontend_uri)
│ │ │ │ └ 'tcp://180.168.146.187:10000'
│ │ │ └ '9999'
│ │ └ None
│ └ None
└ <rqalpha_mod_ctp.mod.CtpMod object at 0x7fe87ff7e470>
File "/home/rqalpha_user/anaconda3/envs/py3/lib/python3.5/site-packages/rqalpha_mod_ctp/ctp/trade_gateway.py", line 56, in connect
self.td_api.connect()
└ <rqalpha_mod_ctp.ctp.trade_gateway.TradeGateway object at 0x7fe87eb679e8>
File "/home/rqalpha_user/anaconda3/envs/py3/lib/python3.5/site-packages/rqalpha_mod_ctp/ctp/api.py", line 326, in connect
self.login()
└ <rqalpha_mod_ctp.ctp.api.CtpTdApi object at 0x7fe87e09df30>
File "/home/rqalpha_user/anaconda3/envs/py3/lib/python3.5/site-packages/rqalpha_mod_ctp/ctp/api.py", line 349, in login
Password=str2bytes(self.password),
│ └ <rqalpha_mod_ctp.ctp.api.CtpTdApi object at 0x7fe87e09df30>
└ <function str2bytes at 0x7fe87ff4a488>
TypeError: expected bytes, NoneType found
2017-06-26 ERROR expected bytes, NoneType found
[2017-06-26 21:03:25.664501] ERROR: system_log: 策略运行产生异常
Traceback (most recent call last):
File "/home/rqalpha_user/anaconda3/envs/py3/lib/python3.5/site-packages/rqalpha/main.py", line 195, in run
mod_handler.start_up()
File "/home/rqalpha_user/anaconda3/envs/py3/lib/python3.5/site-packages/rqalpha/mod/__init__.py", line 68, in start_up
self._mod_dict[mod_name].start_up(self._env, mod_config)
File "/home/rqalpha_user/anaconda3/envs/py3/lib/python3.5/site-packages/rqalpha_mod_ctp/mod.py", line 39, in start_up
self._init_trade_gateway()
File "/home/rqalpha_user/anaconda3/envs/py3/lib/python3.5/site-packages/rqalpha_mod_ctp/mod.py", line 65, in _init_trade_gateway
self._trade_gateway.connect(user_id, password, broker_id, trade_frontend_uri)
File "/home/rqalpha_user/anaconda3/envs/py3/lib/python3.5/site-packages/rqalpha_mod_ctp/ctp/trade_gateway.py", line 56, in connect
self.td_api.connect()
File "/home/rqalpha_user/anaconda3/envs/py3/lib/python3.5/site-packages/rqalpha_mod_ctp/ctp/api.py", line 326, in connect
self.login()
File "/home/rqalpha_user/anaconda3/envs/py3/lib/python3.5/site-packages/rqalpha_mod_ctp/ctp/api.py", line 349, in login
Password=str2bytes(self.password),
TypeError: expected bytes, NoneType found
(py3) rqalpha_user@rqalpha-VirtualBox:~/examples$
请检查您配置项中 password 的设置,该项设置为 None 就会报以上错误。
1、启用 ctp(0.2.0)模块
2 运行 example 中 run_code_demo.py 结果提示:ERROR expected bytes, NoneType found