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