Skip to content

Commit

Permalink
Hotfix :code:`UnboundLocalError: local variable signature referenced …
Browse files Browse the repository at this point in the history
…before assignment`
  • Loading branch information
cedricporter committed Mar 17, 2017
1 parent 539cacf commit 5c3b80d
Show file tree
Hide file tree
Showing 5 changed files with 44 additions and 3 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
0.3.14
==================

- Hotfix :code:`UnboundLocalError: local variable 'signature' referenced before assignment`

0.3.13
==================

Expand Down
2 changes: 1 addition & 1 deletion rqalpha/VERSION.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.3.13
0.3.14
4 changes: 2 additions & 2 deletions rqalpha/utils/scheduler.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,8 @@ def run_monthly(func, tradingday=None, time_rule=None, **kwargs):
def _verify_function(name, func):
if not callable(func):
raise patch_user_exc(ValueError('scheduler.{}: func should be callable'.format(name)))
signature = signature(func)
if len(signature.parameters) != 2:
sig = signature(func)
if len(sig.parameters) != 2:
raise patch_user_exc(TypeError(
'scheduler.{}: func should take exactly 2 arguments (context, bar_dict)'.format(name)))

Expand Down
Binary file added tests/outs/test_s_scheduler.pkl
Binary file not shown.
36 changes: 36 additions & 0 deletions tests/test_s_scheduler.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
from rqalpha.api import *


def init(context):
scheduler.run_weekly(rebalance, 1, time_rule = market_open(0, 0))


def rebalance(context, bar_dict):
stock = "000001.XSHE"
if context.portfolio.positions[stock].quantity == 0:
order_target_percent(stock, 1)
else:
order_target_percent(stock, 0)


__config__ = {
"base": {
"strategy_type": "stock",
"start_date": "2008-07-01",
"end_date": "2017-01-01",
"frequency": "1d",
"matching_type": "current_bar",
"stock_starting_cash": 100000,
"benchmark": "000001.XSHE",
"slippage": 0.00123,
},
"extra": {
"log_level": "error",
},
"mod": {
"progress": {
"enabled": True,
"priority": 400,
},
},
}

0 comments on commit 5c3b80d

Please sign in to comment.