ricequant / rqalpha-mod-tushare

Make Tushare compatible with RQAlpha
Apache License 2.0
185 stars 32 forks source link

策略运行产生异常(最简单的样例 buy_and_hold.py) #3

Closed fswzb closed 7 years ago

fswzb commented 7 years ago

C:\Python35\python.exe C:/www/huice/rqalpha/rqalpha run -f C:\www\huice\rqalpha\rqalpha\examples\golden_cross.py --stock-starting-cash 100000 -s 2015-01-01 -e 2016-08-09 -mc tushare1.enable True 0000-00-00 ERROR dict must be set to a dictionary, not a 'set' [2017-04-08 23:21:58.630125] ERROR: system_log: 策略运行产生异常 Traceback (most recent call last): File "C:/www/huice/rqalpha/rqalpha\main.py", line 190, in run mod_handler.set_env(env) File "C:\www\huice\rqalpha\rqalpha\mod__init.py", line 57, in set_env mod_config = RqAttrDict(copy.deepcopy(getattr(mod_module, "config", {}))) File "C:\www\huice\rqalpha\rqalpha\utils__init.py", line 50, in init self.dict = d if d is not None else dict() TypeError: dict must be set to a dictionary, not a 'set' Traceback (most recent call last): File "C:\Python35\lib\runpy.py", line 170, in _run_module_as_main "main", mod_spec) File "C:\Python35\lib\runpy.py", line 85, in _run_code exec(code, run_globals) �� �� {'entry_point': <function entry_point at 0x01172660>, 'spec': ModuleSpec(name='main__', loader=<_frozen_importlib_external... �� <code object at 0x0116C750, file "C:/www/huice/rqalpha/rqalpha__main.py", line 17> File "C:/www/huice/rqalpha/rqalpha\main.py", line 327, in entry_point() �� <function entry_point at 0x01172660> File "C:/www/huice/rqalpha/rqalpha\main__.py", line 68, in entry_point cli(obj={}) �� <click.core.Group object at 0x05697CD0> File "C:\Python35\lib\site-packages\click\core.py", line 722, in call return self.main(args, kwargs) �� �� �� {'obj': {'VERBOSE': 0}} �� �� () �� <click.core.Group object at 0x05697CD0> File "C:\Python35\lib\site-packages\click\core.py", line 697, in main rv = self.invoke(ctx) �� �� <click.core.Context object at 0x056A39B0> �� <click.core.Group object at 0x05697CD0> File "C:\Python35\lib\site-packages\click\core.py", line 1066, in invoke return _process_result(sub_ctx.command.invoke(sub_ctx)) �� �� �� <click.core.Context object at 0x056BCF10> �� �� <click.core.Context object at 0x056BCF10> �� <function MultiCommand.invoke.._process_result at 0x056A7390> File "C:\Python35\lib\site-packages\click\core.py", line 895, in invoke return ctx.invoke(self.callback, ctx.params) �� �� �� <click.core.Context object at 0x056BCF10> �� �� <click.core.Command object at 0x056A3330> �� <click.core.Context object at 0x056BCF10> File "C:\Python35\lib\site-packages\click\core.py", line 535, in invoke return callback(args, **kwargs) �� �� �� {'baseend_date': Timestamp('2016-08-09 00:00:00'), 'basesecurities': None, 'basestrategy_file': 'C:\www\huice\rqalpha\... �� �� () �� <function run at 0x056A7540> File "C:/www/huice/rqalpha/rqalpha__main.py", line 120, in run main.run(parse_config(kwargs, config_path)) �� �� �� �� None �� �� �� {'modtushare1enable': True, 'basesecurities': None, 'basestrategy_file': 'C:\www\huice\rqalpha\rqalpha\examples\go... �� �� <function parse_config at 0x0569FC00> �� <module 'main' from 'C:/www/huice/rqalpha/rqalpha\main.py'> File "C:/www/huice/rqalpha/rqalpha\main.py", line 321, in run mod_handler.tear_down(code, user_exc) �� �� �� CustomException(dict must be set to a dictionary, not a 'set',) �� �� EXIT_CODE.EXIT_INTERNAL_ERROR �� <rqalpha.mod.ModHandler object at 0x05AFCD90> File "C:\www\huice\rqalpha\rqalpha\mod\init.py", line 72, in tear_down ret = self._mod_dict[mod_name].tear_down(*args) �� �� �� (EXIT_CODE.EXIT_INTERNAL_ERROR, CustomException(dict__ must be set to a dictionary, not a 'set',)) �� �� 'tushare1' �� <rqalpha.mod.ModHandler object at 0x05AFCD90> KeyError: 'tushare1'

Process finished with exit code 1

fswzb commented 7 years ago

更新rqalpha-develop,上面的错误没有了,运行样例rsi出现下面错误:

C:\Python35\python.exe C:/www/rqalpha-develop/rqalpha run -f C:\www\rqalpha-develop\rqalpha\examples\rsi.py -s 2017-01-01 -e 2017-04-01 --stock-starting-cash 100000 -mc tushare1.enable True 2017-01-03 ERROR Traceback (most recent call last): File C:\www\rqalpha-develop\rqalpha\examples\rsi.py, line 38 in handle_bar rsi_data = talib.RSI(prices, timeperiod=context.TIME_PERIOD)[-1] --> bar_dict = BarMap() --> context = Context({s3 = '000068.XSHE', ORDER_PERCENT = 0.3, HIGH_RSI = 85, s1 = '000001.XSHE', s2 = '601988.XSHG', LOW_RSI = 30, TIME_PERIOD = 14, stocks = ['000001.XSHE' ... --> stock = '000001.XSHE' --> prices = array([[ 9.42], [ 9.4 ], [ 9.25], [ 9.25], [ 9.2 ], [ 9.11], [ 9.16], [ 9.14], [ 9.08], [ 9.12], ...

Exception: real has wrong dimensions Traceback (most recent call last): File "C:\www\rqalpha-develop\rqalpha\core\strategy.py", line 84, in handle_bar self._handle_bar(self._user_context, bar_dict) �� �� �� BarMap() �� �� <rqalpha.core.strategy.Strategy object at 0x14D1F7B0> �� <rqalpha.core.strategy.Strategy object at 0x14D1F7B0> File "C:\www\rqalpha-develop\rqalpha\examples\rsi.py", line 38, in handle_bar rsi_data = talib.RSI(prices, timeperiod=context.TIME_PERIOD)[-1] �� �� �� Context({s3 = '000068.XSHE', ORDER_PERCENT = 0.3, HIGH_RSI = 85, s1 = '000001.XSHE', s2 = '601988.XSHG', LOW_RSI = 30, TIME_PERI... �� �� array([[ 9.42], [ 9.4 ], [ 9.25], [ 9.25], [ 9.2 ], [ 9.11], [ 9.16], [ 9.14], ... �� <module 'talib' from 'C:\Python35\lib\site-packages\talib\init.py'> File "talib/func.pyx", line 9649, in talib.func.RSI (talib\func.c:101770) Exception: real has wrong dimensions

Process finished with exit code 0

fswzb commented 7 years ago

buy_and_hold运行没有出错了