diff --git a/vnpy/trader/gateway.py b/vnpy/trader/gateway.py index ac2cd704..b7af2f59 100644 --- a/vnpy/trader/gateway.py +++ b/vnpy/trader/gateway.py @@ -3,7 +3,7 @@ """ from abc import ABC, abstractmethod -from typing import Any +from typing import Any, Sequence from copy import copy from vnpy.event import Event, EventEngine @@ -210,6 +210,29 @@ class BaseGateway(ABC): """ pass + def send_orders(self, reqs: Sequence[OrderRequest]): + """ + Send a batch of orders to server. + Use a for loop of send_order function by default. + Reimplement this function if batch order supported on server. + """ + vt_orderids = [] + + for req in reqs: + vt_orderid = self.send_order(req) + vt_orderids.append(vt_orderid) + + return vt_orderids + + def cancel_orders(self, reqs: Sequence[CancelRequest]): + """ + Cancel a batch of orders to server. + Use a for loop of cancel_order function by default. + Reimplement this function if batch cancel supported on server. + """ + for req in reqs: + self.cancel_order(req) + @abstractmethod def query_account(self): """