From 4da519bd2c70fe6daf53a78f5b049d8f287e2e7c Mon Sep 17 00:00:00 2001 From: "vn.py" Date: Tue, 16 Apr 2019 13:49:50 +0800 Subject: [PATCH] [Add]mongoengine into requirements.txt --- requirements.txt | 1 + vnpy/trader/database/database_mongo.py | 9 +++++++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/requirements.txt b/requirements.txt index ee935ce6..308b49c4 100644 --- a/requirements.txt +++ b/requirements.txt @@ -13,3 +13,4 @@ futu-api tigeropen ta-lib ibapi +mongoengine diff --git a/vnpy/trader/database/database_mongo.py b/vnpy/trader/database/database_mongo.py index ef5038e1..cdf68000 100644 --- a/vnpy/trader/database/database_mongo.py +++ b/vnpy/trader/database/database_mongo.py @@ -16,10 +16,12 @@ def init(_: Driver, settings: dict): username = settings["user"] password = settings["password"] authentication_source = settings["authentication_source"] + if not username: # if username == '' or None, skip username username = None password = None authentication_source = None + connect( db=database, host=host, @@ -28,6 +30,7 @@ def init(_: Driver, settings: dict): password=password, authentication_source=authentication_source, ) + return MongoManager() @@ -51,7 +54,8 @@ class DbBarData(Document): meta = { "indexes": [ - {"fields": ("datetime", "interval", "symbol", "exchange"), "unique": True} + {"fields": ("datetime", "interval", "symbol", + "exchange"), "unique": True} ] } @@ -141,7 +145,8 @@ class DbTickData(Document): ask_volume_4: float = FloatField() ask_volume_5: float = FloatField() - meta = {"indexes": [{"fields": ("datetime", "symbol", "exchange"), "unique": True}]} + meta = {"indexes": [ + {"fields": ("datetime", "symbol", "exchange"), "unique": True}]} @staticmethod def from_tick(tick: TickData):