[Add] send_orders and cancel_orders function
This commit is contained in:
parent
fb4d7c9c01
commit
4cdf809d41
@ -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):
|
||||
"""
|
||||
|
Loading…
Reference in New Issue
Block a user