最近发现quantaxis的1分钟数据7万条数据耗时0:00:00.001997
+
但是vnpy的database_manager.load_bar_data,提取7万条数据要10秒钟,所以想着手改造一下,
+
但是我发现quantaxis用的是pymongo的collection.insert_many()方法存数据,collection.find()方法读取数据,在vnpy的数据库源代码却找不到相关的方法,所以想问下各位大佬vnpy的MongoDB连接是不是基于pymongo写的?有没有可能优化后达到quantaxis的提取速度?
+
def load_bar_data(
self,
symbol: str,
exchange: Exchange,
interval: Interval,
start: datetime,
end: datetime,
collection_name: str = None,
) -> Sequence[BarData]:
if collection_name is None:
s = DbBarData.objects(
symbol=symbol,
exchange=exchange.value,
interval=interval.value,
datetime__gte=start,
datetime__lte=end,
)
else:
with switch_collection(DbBarData, collection_name):
s = DbBarData.objects(
symbol=symbol,
exchange=exchange.value,
interval=interval.value,
datetime__gte=start,
datetime__lte=end,
)
data = [db_bar.to_bar() for db_bar in s]
return data
vnpy代码上面没有pymongo的影子。