New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

对run_file, run_code函数进行for循环情况 #158

Closed
joey-chan opened this Issue Jun 15, 2017 · 8 comments

Comments

Projects
None yet
5 participants
@joey-chan

joey-chan commented Jun 15, 2017

提 ISSUE 须知

请先阅读文档 rqalpha文档

如果仍有问题的话请在 issue列表 中寻找是否有相关问题的解决方案

如果没有的话 麻烦开一个issue 描述以下问题:

1. RQAlpha的版本

2.2.7

2. Python的版本

2.7

3. 是Windows/Linux/MacOS or others?

win10

4. 您出现问题对应的源码/或者能复现问题的简易代码 以及对应的配置

run_file_demo

from rqalpha import run_file
import time
import gc

config = {
  "base": {
    "start_date": "2014-01-01",
    "end_date": "2016-01-01",
    "securities": ['stock'],
    "stock_starting_cash": 100000,
    "benchmark": "000300.XSHG"
  },
  "extra": {
    "log_level": "verbose",
  },
  "mod": {
    "sys_analyser": {
      "enabled": True,
      "plot": False
    }
  }
}

strategy_file_path = "./MACD.py"
for i in range(10):
    print i
    run_file(strategy_file_path, config)

5. 您出现的错误堆栈日志信息

跑到第七次(不同电脑,次数不一)的时候出来以下错误

Error in sys.excepthook:
Traceback (most recent call last):
  File "D:\Anaconda\lib\site-packages\better_exceptions\__init__.py", line 343, in excepthook
    formatted = format_exception(exc, value, tb)
  File "D:\Anaconda\lib\site-packages\rqalpha\utils\logger.py", line 35, in format_exception
    formatted, colored_source = better_exceptions.format_traceback(tb)
  File "D:\Anaconda\lib\site-packages\better_exceptions\__init__.py", line 307, in format_traceback
    formatted, colored = format_traceback_frame(tb)
  File "D:\Anaconda\lib\site-packages\better_exceptions\__init__.py", line 267, in format_traceback_frame
    filename, lineno, function, source, color_source, relevant_values = get_traceback_information(tb)
  File "D:\Anaconda\lib\site-packages\better_exceptions\__init__.py", line 260, in get_traceback_information
    relevant_values = get_relevant_values(source, tb.tb_frame, tree)
  File "D:\Anaconda\lib\site-packages\better_exceptions\__init__.py", line 169, in get_relevant_values
    values.append((text, col, format_value(val)))
  File "D:\Anaconda\lib\site-packages\better_exceptions\__init__.py", line 154, in format_value
    v = repr(v)
  File "D:\Anaconda\lib\site-packages\bcolz\ctable.py", line 1427, in __repr__
    nbytes, cbytes, cratio = self._get_stats()
  File "D:\Anaconda\lib\site-packages\bcolz\ctable.py", line 1414, in _get_stats
    column = cols[name]
  File "D:\Anaconda\lib\site-packages\bcolz\ctable.py", line 84, in __getitem__
    return self._cols[name]
KeyError: 'close'

Original exception was:
Traceback (most recent call last):
  File "D:/Joe/Documents/ģ��ʵ��/rqalpha-strategy/nTask.py", line 28, in <module>
    run_file(strategy_file_path, config)
  File "D:\Anaconda\lib\site-packages\rqalpha\__init__.py", line 93, in run_file
    return main.run(config)
  File "D:\Anaconda\lib\site-packages\rqalpha\main.py", line 316, in run
    code = _exception_handler(user_exc)
  File "D:\Anaconda\lib\site-packages\rqalpha\main.py", line 322, in _exception_handler
    better_exceptions.excepthook(e.error.exc_type, e.error.exc_val, e.error.exc_tb)
  File "D:\Anaconda\lib\site-packages\better_exceptions\__init__.py", line 343, in excepthook
    formatted = format_exception(exc, value, tb)
  File "D:\Anaconda\lib\site-packages\rqalpha\utils\logger.py", line 35, in format_exception
    formatted, colored_source = better_exceptions.format_traceback(tb)
  File "D:\Anaconda\lib\site-packages\better_exceptions\__init__.py", line 307, in format_traceback
    formatted, colored = format_traceback_frame(tb)
  File "D:\Anaconda\lib\site-packages\better_exceptions\__init__.py", line 267, in format_traceback_frame
    filename, lineno, function, source, color_source, relevant_values = get_traceback_information(tb)
  File "D:\Anaconda\lib\site-packages\better_exceptions\__init__.py", line 260, in get_traceback_information
    relevant_values = get_relevant_values(source, tb.tb_frame, tree)
  File "D:\Anaconda\lib\site-packages\better_exceptions\__init__.py", line 169, in get_relevant_values
    values.append((text, col, format_value(val)))
  File "D:\Anaconda\lib\site-packages\better_exceptions\__init__.py", line 154, in format_value
    v = repr(v)
  File "D:\Anaconda\lib\site-packages\bcolz\ctable.py", line 1427, in __repr__
    nbytes, cbytes, cratio = self._get_stats()
  File "D:\Anaconda\lib\site-packages\bcolz\ctable.py", line 1414, in _get_stats
    column = cols[name]
  File "D:\Anaconda\lib\site-packages\bcolz\ctable.py", line 84, in __getitem__
    return self._cols[name]
KeyError: 'close'
@wh1100717

This comment has been minimized.

Member

wh1100717 commented Jun 16, 2017

@hzliu 看上去像是 bcolz 访问的问题?

@wh1100717

This comment has been minimized.

Member

wh1100717 commented Jun 24, 2017

#164 @cedricporter same issue?

@cedricporter

This comment has been minimized.

Member

cedricporter commented Jun 24, 2017

not the same

@LunaFire1989

This comment has been minimized.

LunaFire1989 commented Jun 24, 2017

相同的情况在Windows10平台出现 在Mac平台不会出现 报错的时候系统会提示内存不足 我看了一下windows的资源管理器 内存会持续暴涨 直到出现该错误 @wh1100717

@wh1100717

This comment has been minimized.

Member

wh1100717 commented Jul 4, 2017

@joey-chan @LunaFire1989 我们已经发现并正在解决该问题。这源自于为了提升回测速度,我们使用了lu_cache而导致在多次连续回测中引起的内存泄漏。

我们会尽快解决该问题

@cedricporter

This comment has been minimized.

Member

cedricporter commented Jul 4, 2017

fix by bcbda2b

@joey-chan

This comment has been minimized.

joey-chan commented Jul 4, 2017

@cedricporter .utils.py2中没有这个clear_all_cached_functions()函数,要自己写吗

@cedricporter

This comment has been minimized.

Member

cedricporter commented Jul 4, 2017

In branch develop.

@wh1100717 wh1100717 added the fixed label Jul 5, 2017

@wh1100717 wh1100717 closed this Jul 10, 2017

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment