From 4e30095ac37870e5f00617b9c89bab2da8dd622e Mon Sep 17 00:00:00 2001 From: vigarbuaa Date: Thu, 6 Jun 2019 23:33:17 +0800 Subject: [PATCH] modify send_order func to fill limit price order --- vnpy/gateway/alpaca/alpaca_gateway.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/vnpy/gateway/alpaca/alpaca_gateway.py b/vnpy/gateway/alpaca/alpaca_gateway.py index 3d938b44..aa58dc98 100644 --- a/vnpy/gateway/alpaca/alpaca_gateway.py +++ b/vnpy/gateway/alpaca/alpaca_gateway.py @@ -263,14 +263,17 @@ class AlpacaRestApi(RestClient): def send_order(self, req: OrderRequest): orderid = str(self.connect_time + self._new_order_id()) - data = { + raw_dict={ "symbol": req.symbol, "qty": int(req.volume), "side": DIRECTION_VT2ALPACA[req.direction], "type": ORDERTYPE_VT2ALPACA[req.type], - "time_in_force":'opg', - "limit_price": float(req.price) + "time_in_force":'day', } + if raw_dict['type'] == "limit": + raw_dict['limit_price'] = float(req.price) + + data = raw_dict order = req.create_order_data(orderid, self.gateway_name) self.add_request( "POST",