From 49d863a286c77dbb2b4f4b3e0044296cbd7c1fed Mon Sep 17 00:00:00 2001 From: nanoric Date: Wed, 17 Apr 2019 23:16:33 -0400 Subject: [PATCH] [Add] get_newest_bar_data in database.py [Add] get_newest_tick_data in database.py --- vnpy/trader/database/database.py | 27 ++++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/vnpy/trader/database/database.py b/vnpy/trader/database/database.py index ec765e8d..1b1728bb 100644 --- a/vnpy/trader/database/database.py +++ b/vnpy/trader/database/database.py @@ -1,7 +1,7 @@ from abc import ABC, abstractmethod from datetime import datetime from enum import Enum -from typing import Sequence, TYPE_CHECKING +from typing import Sequence, TYPE_CHECKING, Optional if TYPE_CHECKING: from vnpy.trader.constant import Interval, Exchange # noqa @@ -51,3 +51,28 @@ class BaseDatabaseManager(ABC): datas: Sequence["TickData"], ): pass + + @abstractmethod + def get_newest_bar_data( + self, + symbol: str, + exchange: "Exchange", + interval: "Interval" + ) -> Optional["BarData"]: + """ + If there is data in database, return the one with greatest datetime(newest one) + otherwise, return None + """ + pass + + @abstractmethod + def get_newest_tick_data( + self, + symbol: str, + exchange: "Exchange", + ) -> Optional["TickData"]: + """ + If there is data in database, return the one with greatest datetime(newest one) + otherwise, return None + """ + pass