ricequant / rqalpha

A extendable, replaceable Python algorithmic backtest && trading framework supporting multiple securities
http://rqalpha.io
Other
5.39k stars 1.62k forks source link

mod 运行错误 #78

Closed FallacyWalker closed 7 years ago

FallacyWalker commented 7 years ago

我照着文档上mod的例子,写了一个helloworld的例子,但是运行时报错:

run -f /DeepLink/LocalRqalpha20/rqalpha/rqalpha/examples/buy_and_hold.py -sc 100000

error:

2015-06-01 ERROR Traceback (most recent call last):
  File /DeepLink/LocalRqalpha20/rqalpha/rqalpha/examples/buy_and_hold.py, line 32 in handle_bar
    order_percent(context.s1, 1)
    --> context = Context({stocks = ['000001.XSHE'], s1 = '000001.XSHE', fired = False})
    --> bar_dict = BarMap(000001.XSHE)

AttributeError: 'RQInvalidArgument' object has no attribute 'with_traceback'
Traceback (most recent call last):
  File "/DeepLink/LocalRqalpha20/rqalpha/rqalpha/core/strategy.py", line 84, in handle_bar
    self._handle_bar(self._user_context, bar_dict)
    │                │                   └ BarMap(000001.XSHE)
    │                └ <rqalpha.core.strategy.Strategy object at 0x10a692a50>
    └ <rqalpha.core.strategy.Strategy object at 0x10a692a50>
  File "/DeepLink/LocalRqalpha20/rqalpha/rqalpha/examples/buy_and_hold.py", line 32, in handle_bar
    order_percent(context.s1, 1)
    │             └ Context({stocks = ['000001.XSHE'], s1 = '000001.XSHE', fired = False})
    └ <function order_percent at 0x105ea4398>
  File "/DeepLink/LocalRqalpha20/rqalpha/rqalpha/execution_context.py", line 106, in wrapper
    return func(*args, **kwargs)
           │     │       └ {}
           │     └ ('000001.XSHE', 1)
           └ <function order_percent at 0x105ea4488>
  File "/DeepLink/LocalRqalpha20/rqalpha/rqalpha/utils/arg_checker.py", line 378, in api_rule_check_wrapper
    raise e.with_traceback(tb)
          │                └ <traceback object at 0x10a5f09e0>
          └ RQInvalidArgument(u"function order_percent: invalid percent argument, expect a value < 1, got 1 (type: <type 'int'>)",)
AttributeError: 'RQInvalidArgument' object has no attribute 'with_traceback'
wh1100717 commented 7 years ago

@FallacyWalker 您更新到最新版(2.0.6)试一下?

lizhi2013 commented 7 years ago

好像还不行

hzliu commented 7 years ago

试试 develop 分支

hzliu commented 7 years ago

只是 fix 了 with_backtrace 在 python2.7 上出错的问题

wh1100717 commented 7 years ago

@FallacyWalker 2.0.8 已经解决了在Python 2.7下 报错 'RQInvalidArgument' object has no attribute 'with_traceback' 的问题