diff --git a/vnpy/gateway/bitmex/bitmex_gateway.py b/vnpy/gateway/bitmex/bitmex_gateway.py index 678f09c9..9127c64a 100644 --- a/vnpy/gateway/bitmex/bitmex_gateway.py +++ b/vnpy/gateway/bitmex/bitmex_gateway.py @@ -34,6 +34,7 @@ from vnpy.trader.object import ( OrderRequest, CancelRequest, SubscribeRequest, + HistoryRequest ) REST_HOST = "https://www.bitmex.com/api/v1" @@ -124,6 +125,10 @@ class BitmexGateway(BaseGateway): """""" pass + def query_history(self, req: HistoryRequest): + """""" + return self.rest_api.query_history(req) + def close(self): """""" self.rest_api.stop() @@ -279,6 +284,10 @@ class BitmexRestApi(RestClient): on_error=self.on_cancel_order_error, ) + def query_history(self, req: HistoryRequest): + """""" + pass + def on_send_order_failed(self, status_code: str, request: Request): """ Callback when sending order failed on server. @@ -615,6 +624,7 @@ class BitmexWebsocketApi(WebsocketClient): size=d["lotSize"], stop_supported=True, net_position=True, + bar_history=True, gateway_name=self.gateway_name, ) diff --git a/vnpy/trader/engine.py b/vnpy/trader/engine.py index 12e3c3d3..96246487 100644 --- a/vnpy/trader/engine.py +++ b/vnpy/trader/engine.py @@ -22,7 +22,13 @@ from .event import ( EVENT_LOG ) from .gateway import BaseGateway -from .object import CancelRequest, LogData, OrderRequest, SubscribeRequest +from .object import ( + CancelRequest, + LogData, + OrderRequest, + SubscribeRequest, + HistoryRequest +) from .setting import SETTINGS from .utility import get_folder_path @@ -174,6 +180,16 @@ class MainEngine: if gateway: gateway.cancel_order(req) + def query_history(self, req: HistoryRequest, gateway_name: str): + """ + Send cancel order request to a specific gateway. + """ + gateway = self.get_gateway(gateway_name) + if gateway: + return gateway.query_history(req) + else: + return None + def close(self): """ Make sure every gateway and app is closed properly before diff --git a/vnpy/trader/gateway.py b/vnpy/trader/gateway.py index 0583f125..ac2cd704 100644 --- a/vnpy/trader/gateway.py +++ b/vnpy/trader/gateway.py @@ -224,18 +224,12 @@ class BaseGateway(ABC): """ pass - def query_bar_history(self, req: HistoryRequest): + def query_history(self, req: HistoryRequest): """ Query bar history data. """ pass - def query_tick_history(self, req: HistoryRequest): - """ - Query tick history data. - """ - pass - def get_default_setting(self): """ Return default setting dict.