diff --git a/vnpy/trader/database/database_mongo.py b/vnpy/trader/database/database_mongo.py index f1e7c4a9..19292e66 100644 --- a/vnpy/trader/database/database_mongo.py +++ b/vnpy/trader/database/database_mongo.py @@ -55,7 +55,7 @@ class DbBarData(Document): meta = { "indexes": [ { - "fields": ("datetime", "interval", "symbol", "exchange"), + "fields": ("symbol", "exchange", "interval", "datetime"), "unique": True, } ] @@ -150,7 +150,7 @@ class DbTickData(Document): meta = { "indexes": [ { - "fields": ("datetime", "symbol", "exchange"), + "fields": ("symbol", "exchange", "datetime"), "unique": True, } ], diff --git a/vnpy/trader/database/database_sql.py b/vnpy/trader/database/database_sql.py index 41e54856..b2a39460 100644 --- a/vnpy/trader/database/database_sql.py +++ b/vnpy/trader/database/database_sql.py @@ -82,7 +82,7 @@ def init_models(db: Database, driver: Driver): class Meta: database = db - indexes = ((("datetime", "interval", "symbol", "exchange"), True),) + indexes = ((("symbol", "exchange", "interval", "datetime"), True),) @staticmethod def from_bar(bar: BarData): @@ -195,7 +195,7 @@ def init_models(db: Database, driver: Driver): class Meta: database = db - indexes = ((("datetime", "symbol", "exchange"), True),) + indexes = ((("symbol", "exchange", "datetime"), True),) @staticmethod def from_tick(tick: TickData):