From 65d9f150522de4ba0dd25d69e1a875c517e55299 Mon Sep 17 00:00:00 2001 From: "vn.py" Date: Wed, 1 Nov 2017 21:15:28 +0800 Subject: [PATCH] =?UTF-8?q?[Fix]=E4=BF=AE=E5=A4=8D=E7=BC=BA=E5=A4=B1?= =?UTF-8?q?=E5=A7=94=E6=89=98=E4=BB=B7=E6=A0=BC=E7=B1=BB=E5=9E=8B=E7=9A=84?= =?UTF-8?q?=E9=94=99=E8=AF=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- vnpy/trader/app/jaqsService/jsEngine.py | 30 ++++++++++++++----------- 1 file changed, 17 insertions(+), 13 deletions(-) diff --git a/vnpy/trader/app/jaqsService/jsEngine.py b/vnpy/trader/app/jaqsService/jsEngine.py index 20718381..bacab694 100644 --- a/vnpy/trader/app/jaqsService/jsEngine.py +++ b/vnpy/trader/app/jaqsService/jsEngine.py @@ -229,22 +229,26 @@ class JsEngine(object): params = req['params'] s, e = params['security'].split('.') - vor = VtOrderReq() - vor.symbol = s - vor.exchange = EXCHANGE_MAP[e] - vor.direction, vor.offset = ACTION_MAP[params['action']] - vor.price = params['price'] - vor.volume = params['size'] - - contract = self.mainEngine.getContract(contract) - - vtOrderID = self.mainEngine.sendOrder(vor, contract.gatewayName) - - error = [0, ''] + contract = self.mainEngine.getContract(s) + + if not contract: + vtOrderID = '' + error = [-1, u'委托失败,找不到合约%s' %params['security']] + else: + vor = VtOrderReq() + vor.symbol = s + vor.exchange = EXCHANGE_MAP[e] + vor.direction, vor.offset = ACTION_MAP[params['action']] + vor.price = float(params['price']) + vor.volume = int(params['size']) + vor.priceType = PRICETYPE_LIMITPRICE + + vtOrderID = self.mainEngine.sendOrder(vor, contract.gatewayName) + error = [0, ''] self.server.send_rsp(clientId, req, vtOrderID, error) - self.writeLog(u'发出响应:%s' %result) + self.writeLog(u'发出响应:%s' %vtOrderID) #---------------------------------------------------------------------- def onCancelOrder(self, clientId, req):