vn.py量化社区
By Traders, For Traders.
Member
avatar
加入于:
帖子: 3
声望: 0

报错信息如下:
Exception in thread Thread-167:
Traceback (most recent call last):
File "/Users/kuskyfei/venv/vnpy37/lib/python3.7/site-packages/mongoengine/queryset/transform.py", line 236, in update
fields = _doc_cls._lookup_field(parts)
File "/Users/kuskyfei/venv/vnpy37/lib/python3.7/site-packages/mongoengine/base/document.py", line 1032, in _lookup_field
raise LookUpError('Cannot resolve field "%s"' % field_name)
mongoengine.errors.LookUpError: Cannot resolve field "date"

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/Users/kuskyfei/.pyenv/versions/3.7.3/lib/python3.7/threading.py", line 917, in _bootstrap_inner
self.run()
File "/Users/kuskyfei/.pyenv/versions/3.7.3/lib/python3.7/threading.py", line 865, in run
self._target(*self._args, self._kwargs)
File "/Users/kuskyfei/Downloads/vnpy-2.0.7/vnpy/app/data_recorder/engine.py", line 69, in run
database_manager.save_tick_data([data])
File "/Users/kuskyfei/Downloads/vnpy-2.0.7/vnpy/trader/database/database_mongo.py", line 322, in save_tick_data
).update_one(upsert=True,
updates)
File "/Users/kuskyfei/venv/vnpy37/lib/python3.7/site-packages/mongoengine/queryset/base.py", line 593, in update_one
update)
File "/Users/kuskyfei/venv/vnpy37/lib/python3.7/site-packages/mongoengine/queryset/base.py", line 517, in update
update = transform.update(queryset._document,
update)
File "/Users/kuskyfei/venv/vnpy37/lib/python3.7/site-packages/mongoengine/queryset/transform.py", line 238, in update
raise InvalidQueryError(e)
mongoengine.errors.InvalidQueryError: Cannot resolve field "date"

一点点跟了断点进去,发现在 vnpy/app/data_recorder/engine.py中 65行( task_type, data = task),如下:

def run(self):
""""""
while self.active:
try:
task = self.queue.get(timeout=1)
task_type, data = task

            if task_type == "tick":
                database_manager.save_tick_data([data])
            elif task_type == "bar":
                database_manager.save_bar_data([data])

        except Empty:
            continue


data的属性字段中有个date和time,在进行mongo存储的时候报错~~~

求解~~~

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

进一步打印信息,在文件中database_mongo.py断点跟进,并且打印了信息,代码如下在313行:
for d in datas:
updates = self.to_update_param(d)
updates.pop("setgateway_name")
updates.pop("set
vt_symbol")
print(updates)
(
DbTickData.objects(
symbol=d.symbol, exchange=d.exchange.value, datetime=d.datetime
).update_one(upsert=True, **updates)
)

我打印了updates,信息如下:
{'setsymbol': 'LTCUSD', 'setexchange': 'BITFINEX', 'setdatetime': datetime.datetime(2019, 10, 17, 16, 55, 49, 206792), 'setname': 'LTCUSD', 'setvolume': 58245.03932339, 'setopen_interest': 0, 'setlast_price': 53.494, 'setlast_volume': 0, 'setlimit_up': 0, 'setlimit_down': 0, 'setopen_price': 54.99, 'sethigh_price': 55.152, 'setlow_price': 51.269, 'setpre_close': 0, 'setbid_price_1': 53.465, 'setbid_price_2': 53.462, 'setbid_price_3': 53.461, 'setbid_price_4': 53.449, 'setbid_price_5': 53.422, 'setask_price_1': 53.48, 'setask_price_2': 53.49, 'setask_price_3': 53.492, 'setask_price_4': 53.499, 'setask_price_5': 53.5, 'setbid_volume_1': 60.0, 'setbid_volume_2': 15.0, 'setbid_volume_3': 60.0, 'setbid_volume_4': 3.73893048, 'setbid_volume_5': 320.18926899, 'setask_volume_1': 10.0, 'setask_volume_2': 37.75928193, 'setask_volume_3': 60.0, 'setask_volume_4': 1.87971876, 'setask_volume_5': 0.00060068, 'setdate': '20191017', 'settime': '16:55:49.206792'}

报错是在
DbTickData.objects(
symbol=d.symbol, exchange=d.exchange.value, datetime=d.datetime
).update_one(upsert=True, **updates)

update_one的时候,进行字段查询的时候,无法转换date': '20191017'

Administrator
avatar
加入于:
帖子: 1868
声望: 85

这个应该是bug了,请在Github开issue吧,我们来处理下

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

用Python的交易员 wrote:

这个应该是bug了,请在Github开issue吧,我们来处理下
好的

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