[Fix]修复缺失委托价格类型的错误

This commit is contained in:
vn.py 2017-11-01 21:15:28 +08:00
parent f38ec0aa33
commit 65d9f15052

View File

@ -229,22 +229,26 @@ class JsEngine(object):
params = req['params'] params = req['params']
s, e = params['security'].split('.') s, e = params['security'].split('.')
vor = VtOrderReq() contract = self.mainEngine.getContract(s)
vor.symbol = s
vor.exchange = EXCHANGE_MAP[e] if not contract:
vor.direction, vor.offset = ACTION_MAP[params['action']] vtOrderID = ''
vor.price = params['price'] error = [-1, u'委托失败,找不到合约%s' %params['security']]
vor.volume = params['size'] else:
vor = VtOrderReq()
contract = self.mainEngine.getContract(contract) vor.symbol = s
vor.exchange = EXCHANGE_MAP[e]
vtOrderID = self.mainEngine.sendOrder(vor, contract.gatewayName) vor.direction, vor.offset = ACTION_MAP[params['action']]
vor.price = float(params['price'])
error = [0, ''] 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.server.send_rsp(clientId, req, vtOrderID, error)
self.writeLog(u'发出响应:%s' %result) self.writeLog(u'发出响应:%s' %vtOrderID)
#---------------------------------------------------------------------- #----------------------------------------------------------------------
def onCancelOrder(self, clientId, req): def onCancelOrder(self, clientId, req):