vn.py官网
Veighna量化社区 | 你的开源社区量化交易平台
Member
avatar
加入于:
帖子: 1
声望: 0

首次启动程序后,运行正常,

在同一个回测框架下更改回测时间段后,会出现如下报错

Can't get attribute 'dtype' on <module 'numpy' from 'C:\vnstudio\lib\site-packages\numpy\init.py'>

numpy版本,为最新。

提前感谢各位大神。

求各位大神指点,vnpy版本:2.8.1

Member
avatar
加入于:
帖子: 2875
声望: 200

请贴一下报错信息截图

Member
avatar
加入于:
帖子: 6
声望: 0

我也遇到了此问题,策略中使用了numpy就会出现,使用遗传算法优化时,刚开始会正常运作,跑满cpu,过一会(应该是结束时)就会出现这个错误,无法出结果

Exception in thread Thread-21:
multiprocessing.pool.RemoteTraceback:
"""
Traceback (most recent call last):
File "C:\vnstudio\lib\multiprocessing\pool.py", line 121, in worker
result = (True, func(args, **kwds))
File "C:\vnstudio\lib\multiprocessing\pool.py", line 44, in mapstar
return list(map(
args))
File "C:\vnstudio\lib\site-packages\vnpy\trader\optimize.py", line 229, in ga_evaluate
cache[tp] = result
File "<string>", line 2, in setitem
File "C:\vnstudio\lib\multiprocessing\managers.py", line 811, in _callmethod
raise convert_to_error(kind, result)

multiprocessing.managers.RemoteError:

Traceback (most recent call last):
File "C:\vnstudio\lib\multiprocessing\managers.py", line 234, in serve_client
request = recv()
File "C:\vnstudio\lib\multiprocessing\connection.py", line 251, in recv
return _ForkingPickler.loads(buf.getbuffer())

AttributeError: Can't get attribute 'dtype' on <module 'numpy' from 'C:\vnstudio\lib\site-packages\numpy\init.py'>

"""

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
File "C:\vnstudio\lib\threading.py", line 917, in _bootstrap_inner
self.run()
File "C:\vnstudio\lib\threading.py", line 865, in run
self._target(*self._args, **self._kwargs)
File "C:\vnstudio\lib\site-packages\vnpy_ctabacktester\engine.py", line 308, in run_optimization
output=False
File "C:\vnstudio\lib\site-packages\vnpy_ctastrategy\backtesting.py", line 559, in run_ga_optimization
output=self.output
File "C:\vnstudio\lib\site-packages\vnpy\trader\optimize.py", line 201, in run_ga_optimization
verbose=False
File "C:\vnstudio\lib\site-packages\deap\algorithms.py", line 301, in eaMuPlusLambda
fitnesses = toolbox.map(toolbox.evaluate, invalid_ind)
File "C:\vnstudio\lib\multiprocessing\pool.py", line 290, in map
return self._map_async(func, iterable, mapstar, chunksize).get()
File "C:\vnstudio\lib\multiprocessing\pool.py", line 683, in get
raise self._value

multiprocessing.managers.RemoteError:

Traceback (most recent call last):
File "C:\vnstudio\lib\multiprocessing\managers.py", line 234, in serve_client
request = recv()
File "C:\vnstudio\lib\multiprocessing\connection.py", line 251, in recv
return _ForkingPickler.loads(buf.getbuffer())

AttributeError: Can't get attribute 'dtype' on <module 'numpy' from 'C:\vnstudio\lib\site-packages\numpy\init.py'>

Member
avatar
加入于:
帖子: 271
声望: 29

请参考https://gitee.com/vnpy/vnpy/blob/master/examples/vn_trader/run.py 脚本,尝试使用python run.py启动vntrader,然后再试一下遗传算法优化是否还会报这个错。

Member
avatar
加入于:
帖子: 6
声望: 0

郭易燔 wrote:

请参考https://gitee.com/vnpy/vnpy/blob/master/examples/vn_trader/run.py 脚本,尝试使用python run.py启动vntrader,然后再试一下遗传算法优化是否还会报这个错。

这样启动,可以使用,无报错

© 2015-2022 上海韦纳软件科技有限公司
备案服务号:沪ICP备18006526号-3

沪公网安备 31011502017034号

【用户协议】
【隐私政策】
【免责条款】