From c998cf9e7a0aaecdc0caefd8db644fc27b44ddc0 Mon Sep 17 00:00:00 2001 From: "vn.py" Date: Tue, 17 Jul 2018 14:05:01 +0800 Subject: [PATCH] =?UTF-8?q?[Fix]=E4=BF=AE=E6=94=B9=E5=A7=94=E6=89=98?= =?UTF-8?q?=E6=95=B0=E9=87=8F=E4=B8=BAfloat=E5=AF=BC=E8=87=B4=E9=83=A8?= =?UTF-8?q?=E5=88=86=E6=8E=A5=E5=8F=A3=E5=A7=94=E6=89=98=E6=8A=A5=E9=94=99?= =?UTF-8?q?=E7=9A=84bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- vnpy/trader/uiBasicWidget.py | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/vnpy/trader/uiBasicWidget.py b/vnpy/trader/uiBasicWidget.py index 2446f017..d3e9dbab 100644 --- a/vnpy/trader/uiBasicWidget.py +++ b/vnpy/trader/uiBasicWidget.py @@ -1050,13 +1050,30 @@ class TradingWidget(QtWidgets.QFrame): gatewayName = contract.gatewayName exchange = contract.exchange # 保证有交易所代码 vtSymbol = contract.vtSymbol - + + # 获取价格 + priceText = self.linePrice.text() + if not priceText: + return + price = float(priceText) + + # 获取数量 + volumeText = self.lineVolume.text() + if not volumeText: + return + + if '.' in volumeText: + volume = float(volumeText) + else: + volume = int(volumeText) + + # 委托 req = VtOrderReq() req.symbol = symbol req.exchange = exchange req.vtSymbol = vtSymbol - req.price = float(self.linePrice.text()) - req.volume = float(self.lineVolume.text()) + req.price = price + req.volume = volume req.direction = unicode(self.comboDirection.currentText()) req.priceType = unicode(self.comboPriceType.currentText()) req.offset = unicode(self.comboOffset.currentText())