{"action":"closed","issue":{"url":"https://api.github.com/repos/ricequant/rqalpha/issues/375","repository_url":"https://api.github.com/repos/ricequant/rqalpha","labels_url":"https://api.github.com/repos/ricequant/rqalpha/issues/375/labels{/name}","comments_url":"https://api.github.com/repos/ricequant/rqalpha/issues/375/comments","events_url":"https://api.github.com/repos/ricequant/rqalpha/issues/375/events","html_url":"https://github.com/ricequant/rqalpha/issues/375","id":360714660,"node_id":"MDU6SXNzdWUzNjA3MTQ2NjA=","number":375,"title":"'NoneType' object is not callable when \"before trading\" undefined and force_run_init_when_pt_resume enabled.","user":{"login":"BurdenBear","id":5682650,"node_id":"MDQ6VXNlcjU2ODI2NTA=","avatar_url":"https://avatars2.githubusercontent.com/u/5682650?v=4","gravatar_id":"","url":"https://api.github.com/users/BurdenBear","html_url":"https://github.com/BurdenBear","followers_url":"https://api.github.com/users/BurdenBear/followers","following_url":"https://api.github.com/users/BurdenBear/following{/other_user}","gists_url":"https://api.github.com/users/BurdenBear/gists{/gist_id}","starred_url":"https://api.github.com/users/BurdenBear/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/BurdenBear/subscriptions","organizations_url":"https://api.github.com/users/BurdenBear/orgs","repos_url":"https://api.github.com/users/BurdenBear/repos","events_url":"https://api.github.com/users/BurdenBear/events{/privacy}","received_events_url":"https://api.github.com/users/BurdenBear/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":2,"created_at":"2018-09-17T03:42:24Z","updated_at":"2018-09-26T11:03:42Z","closed_at":"2018-09-26T11:03:42Z","author_association":"NONE","body":"## 1. RQAlpha的版本\r\n3.1.2\r\n## 2. Python的版本\r\n3.6.6\r\n## 3. 是Windows/Linux/MacOS or others?\r\nwindow10\r\n## 4. 出现问题对应的源码/或者能复现问题的简易代码 以及对应的配置\r\n```\r\n{'base': {'accounts': {'STOCK': 10000000.0},\r\n          'benchmark': None,\r\n          'data_bundle_path': 'C:\\\\Users\\\\Morri/.rqalpha\\\\bundle',\r\n          'end_date': datetime.date(2050, 1, 1),\r\n          'frequency': '1m',\r\n          'init_positions': [],\r\n          'margin_multiplier': 1,\r\n          'persist': True,\r\n          'persist_mode': PERSIST_MODE.REAL_TIME,\r\n          'resume_mode': True,\r\n          'round_price': False,\r\n          'run_type': RUN_TYPE.PAPER_TRADING,\r\n          'source_code': None,\r\n          'start_date': datetime.date(2018, 9, 17),\r\n          'strategy_file': 'strategy.py'},\r\n 'extra': {'context_vars': None,\r\n           'enable_profiler': False,\r\n           'force_run_init_when_pt_resume': True,\r\n           'is_hold': False,\r\n           'locale': 'cn',\r\n           'log_level': 'verbose',\r\n           'logger': (),\r\n           'user_log_disabled': False,\r\n           'user_system_log_disabled': False},\r\n 'mod': {'fxdayu_source': {'enabled': True,\r\n                           'mongo_url': 'mongodb://192.168.0.101:27017,192.168.0.102:27017',\r\n                           'persist_path': './persist',\r\n                           'quantos_token': '',\r\n                           'quantos_user': '',\r\n                           'redis_url': 'redis://192.168.0.102:6379',\r\n                           'source': 'quantos'},\r\n         'shipane_wrapper': {'enabled': False},\r\n         'sys_accounts': {'cash_return_by_stock_delisted': True,\r\n                          'dividend_reinvestment': False,\r\n                          'enabled': True},\r\n         'sys_analyser': {'enabled': True},\r\n         'sys_booking': {'enabled': False},\r\n         'sys_funcat': {'enabled': False},\r\n         'sys_incremental': {'enabled': False},\r\n         'sys_progress': {'enabled': True, 'show': False},\r\n         'sys_risk': {'enabled': True, 'validate_stock_position': True},\r\n         'sys_simulation': {'enabled': True, 'signal': True},\r\n         'sys_stock_realtime': {'enabled': False},\r\n         'trading_monitor': {'enabled': False}},\r\n 'validator': {'cash_return_by_stock_delisted': False, 'close_amount': True},\r\n 'version': '0.1.6',\r\n 'whitelist': ['base', 'extra', 'validator', 'mod']}\r\n```\r\nmainly: \r\n```\r\nbase:\r\n    ...\r\n    run_type: p\r\n    resume_mode: true\r\n    ...\r\nextra:\r\n    ...\r\n    force_run_init_when_pt_resume: true\r\n    ...\r\n```\r\nand there is no **before_trading** defined in strategy, which, AFAK,  is unneccessary.  \r\n\r\n## 5. 出现的错误堆栈日志信息\r\n```\r\n[2018-09-17 11:23:30.446124] DEBUG: basic_system_log:\r\n{'base': {'accounts': {'STOCK': 10000000.0},\r\n          'benchmark': None,\r\n          'data_bundle_path': 'C:\\\\Users\\\\Morri/.rqalpha\\\\bundle',\r\n          'end_date': datetime.date(2050, 1, 1),\r\n          'frequency': '1m',\r\n          'init_positions': [],\r\n          'margin_multiplier': 1,\r\n          'persist': True,\r\n          'persist_mode': PERSIST_MODE.REAL_TIME,\r\n          'resume_mode': True,\r\n          'round_price': False,\r\n          'run_type': RUN_TYPE.PAPER_TRADING,\r\n          'source_code': None,\r\n          'start_date': datetime.date(2018, 9, 17),\r\n          'strategy_file': 'strategy.py'},\r\n 'extra': {'context_vars': None,\r\n           'enable_profiler': False,\r\n           'force_run_init_when_pt_resume': True,\r\n           'is_hold': False,\r\n           'locale': 'cn',\r\n           'log_level': 'verbose',\r\n           'logger': (),\r\n           'user_log_disabled': False,\r\n           'user_system_log_disabled': False},\r\n 'mod': {'fxdayu_source': {'enabled': True,\r\n                           'mongo_url': 'mongodb://192.168.0.101:27017,192.168.0.102:27017',\r\n                           'persist_path': './persist',\r\n                           'quantos_token': '',\r\n                           'quantos_user': '',\r\n                           'redis_url': 'redis://192.168.0.102:6379',\r\n                           'source': 'quantos'},\r\n         'shipane_wrapper': {'enabled': False},\r\n         'sys_accounts': {'cash_return_by_stock_delisted': True,\r\n                          'dividend_reinvestment': False,\r\n                          'enabled': True},\r\n         'sys_analyser': {'enabled': True},\r\n         'sys_booking': {'enabled': False},\r\n         'sys_funcat': {'enabled': False},\r\n         'sys_incremental': {'enabled': False},\r\n         'sys_progress': {'enabled': True, 'show': False},\r\n         'sys_risk': {'enabled': True, 'validate_stock_position': True},\r\n         'sys_simulation': {'enabled': True, 'signal': True},\r\n         'sys_stock_realtime': {'enabled': False},\r\n         'trading_monitor': {'enabled': False}},\r\n 'validator': {'cash_return_by_stock_delisted': False, 'close_amount': True},\r\n 'version': '0.1.6',\r\n 'whitelist': ['base', 'extra', 'validator', 'mod']}\r\n[2018-09-17 11:23:30.449127] DEBUG: system_log: 载入 Mod rqalpha.mod.rqalpha_mod_sys_accounts\r\n[2018-09-17 11:23:30.457114] DEBUG: system_log: 载入 Mod rqalpha.mod.rqalpha_mod_sys_simulation\r\n[2018-09-17 11:23:30.466113] DEBUG: system_log: 载入 Mod rqalpha.mod.rqalpha_mod_sys_progress\r\n[2018-09-17 11:23:30.468119] DEBUG: system_log: 载入 Mod rqalpha.mod.rqalpha_mod_sys_risk\r\n[2018-09-17 11:23:30.474114] DEBUG: system_log: 载入 Mod rqalpha.mod.rqalpha_mod_sys_analyser\r\n[2018-09-17 11:23:30.477116] DEBUG: system_log: 载入 Mod rqalpha_mod_fxdayu_source\r\n[2018-09-17 11:23:30.505113] DEBUG: basic_system_log: mod start_up [START] sys_accounts\r\n[2018-09-17 11:23:30.506114] DEBUG: basic_system_log: mod start_up [END]   sys_accounts\r\n[2018-09-17 11:23:30.507112] DEBUG: basic_system_log: mod start_up [START] sys_simulation\r\n[2018-09-17 11:23:30.508111] DEBUG: basic_system_log: mod start_up [END]   sys_simulation\r\n[2018-09-17 11:23:30.509112] DEBUG: basic_system_log: mod start_up [START] sys_progress\r\n[2018-09-17 11:23:30.510114] DEBUG: basic_system_log: mod start_up [END]   sys_progress\r\n[2018-09-17 11:23:30.511119] DEBUG: basic_system_log: mod start_up [START] sys_risk\r\n[2018-09-17 11:23:30.512112] DEBUG: basic_system_log: mod start_up [END]   sys_risk\r\n[2018-09-17 11:23:30.512112] DEBUG: basic_system_log: mod start_up [START] sys_analyser\r\n[2018-09-17 11:23:30.513122] DEBUG: basic_system_log: mod start_up [END]   sys_analyser\r\n[2018-09-17 11:23:30.514116] DEBUG: basic_system_log: mod start_up [START] fxdayu_source\r\n2018-09-17 11:23:33.947127 WARN [Warning] When you use this version of RealtimeTradeMod, history_bars can only get data from yesterday.\r\n[2018-09-17 11:23:33.948112] DEBUG: basic_system_log: mod start_up [END]   fxdayu_source\r\n[2018-09-17 11:23:33.970148] DEBUG: system_log: restore core with state = b'{\"scheduler\": {\"py/b64\": \"eyJ0b2RheSI6ICIyMDE4LTA5LTE3IiwgImxhc3RfbWludXRlIjogNjgwfQ==\\\\n\"}}'\r\n[2018-09-17 11:23:33.971148] DEBUG: system_log: restore user_context with state = b'\\x80\\x03}q\\x00(X\\x02\\x00\\x00\\x00s1q\\x01C\\x15\\x80\\x03X\\x0b\\x00\\x00\\x00000001.XSHEq\\x00.q\\x02X\\x06\\x00\\x00\\x00PERIODq\\x03C\\x05\\x80\\x03KP.q\\x04X\\x11\\x00\\x00\\x00stoplossmultiplerq\\x05C\\x0c\\x80\\x03G?\\xef\\n=p\\xa3\\xd7\\n.q\\x06X\\x12\\x00\\x00\\x00takepofitmultiplerq\\x07C\\x05\\x80\\x03K\\x04.q\\x08u.'\r\n[2018-09-17 11:23:33.972160] DEBUG: system_log: restore context.s1 <class 'str'>\r\n[2018-09-17 11:23:33.973159] DEBUG: system_log: restore context.PERIOD <class 'int'>\r\n[2018-09-17 11:23:33.974143] DEBUG: system_log: restore context.stoplossmultipler <class 'float'>\r\n[2018-09-17 11:23:33.974143] DEBUG: system_log: restore context.takepofitmultipler <class 'int'>\r\n[2018-09-17 11:23:33.975148] DEBUG: system_log: restore global_vars with state = b'\\x80\\x03}q\\x00.'\r\n[2018-09-17 11:23:33.976132] DEBUG: system_log: restore universe with state = b'[]'\r\n[2018-09-17 11:23:33.976132] DEBUG: system_log: restore event_source with state = b'{\"before_trading_fire_date\": {\"__date__\": true, \"as_str\": \"20180917\"}, \"after_trading_fire_date\": {\"__date__\": true, \"as_str\": \"20000101\"}, \"settlement_fire_date\": {\"__date__\": true, \"as_str\": \"20000101\"}}'\r\n[2018-09-17 11:23:33.979116] DEBUG: system_log: restore portfolio with state = b'{\"accounts\": {\"STOCK\": {\"backward_trade_set\": [], \"dividend_receivable\": {}, \"frozen_cash\": 0, \"positions\": {}, \"total_cash\": 10000000.0, \"transaction_cost\": 0}}, \"last_unit_net_value\": 1, \"start_date\": {\"py/object\": \"datetime.date\", \"__reduce__\": [{\"py/type\": \"datetime.date\"}, [\"B+IJEQ==\"]]}, \"static_unit_net_value\": 1.0, \"units\": 10000000.0}'\r\n[2018-09-17 11:23:33.982135] DEBUG: system_log: restore executor with state = b'{\"last_before_trading\": {\"__date__\": true, \"as_str\": \"20180917\"}}'\r\n[2018-09-17 11:23:33.984116] DEBUG: system_log: real_dt 2018-09-17 11:23:33.984116, dt 2018-09-17 11:23:33.984116, event EVENT.BEFORE_TRADING\r\n[2018-09-17 11:23:33.985133] DEBUG: system_log: real_dt 2018-09-17 11:23:33.985133, dt 2018-09-17 11:23:33.984116, event EVENT.BAR\r\nTraceback (most recent call last):\r\n  File \"d:\\anaconda3\\envs\\rqalpha\\lib\\site-packages\\rqalpha\\core\\strategy.py\", line 80, in before_trading\r\n    self._before_trading(self._user_context)\r\nTypeError: 'NoneType' object is not callable\r\n2018-09-17 11:23:33.985133 ERROR 'NoneType' object is not callable\r\n[2018-09-17 11:23:33.989114] DEBUG: basic_system_log: mod tear_down [START] fxdayu_source\r\n[2018-09-17 11:23:33.991173] DEBUG: basic_system_log: mod tear_down [END]   fxdayu_source\r\n[2018-09-17 11:23:33.998151] DEBUG: basic_system_log: mod tear_down [START] sys_analyser\r\n[2018-09-17 11:23:33.999128] DEBUG: basic_system_log: mod tear_down [END]   sys_analyser\r\n[2018-09-17 11:23:34.000114] DEBUG: basic_system_log: mod tear_down [START] sys_risk\r\n[2018-09-17 11:23:34.001138] DEBUG: basic_system_log: mod tear_down [END]   sys_risk\r\n[2018-09-17 11:23:34.002114] DEBUG: basic_system_log: mod tear_down [START] sys_progress\r\n[2018-09-17 11:23:34.003115] DEBUG: basic_system_log: mod tear_down [END]   sys_progress\r\n[2018-09-17 11:23:34.003115] DEBUG: basic_system_log: mod tear_down [START] sys_simulation\r\n[2018-09-17 11:23:34.004115] DEBUG: basic_system_log: mod tear_down [END]   sys_simulation\r\n[2018-09-17 11:23:34.004115] DEBUG: basic_system_log: mod tear_down [START] sys_accounts\r\n[2018-09-17 11:23:34.005131] DEBUG: basic_system_log: mod tear_down [END]   sys_accounts\r\n```"}}
{"actor":{"display_login":"BurdenBear"}}