[Fix]修改委托数量为float导致部分接口委托报错的bug
This commit is contained in:
parent
988d432846
commit
c998cf9e7a
@ -1051,12 +1051,29 @@ class TradingWidget(QtWidgets.QFrame):
|
|||||||
exchange = contract.exchange # 保证有交易所代码
|
exchange = contract.exchange # 保证有交易所代码
|
||||||
vtSymbol = contract.vtSymbol
|
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 = VtOrderReq()
|
||||||
req.symbol = symbol
|
req.symbol = symbol
|
||||||
req.exchange = exchange
|
req.exchange = exchange
|
||||||
req.vtSymbol = vtSymbol
|
req.vtSymbol = vtSymbol
|
||||||
req.price = float(self.linePrice.text())
|
req.price = price
|
||||||
req.volume = float(self.lineVolume.text())
|
req.volume = volume
|
||||||
req.direction = unicode(self.comboDirection.currentText())
|
req.direction = unicode(self.comboDirection.currentText())
|
||||||
req.priceType = unicode(self.comboPriceType.currentText())
|
req.priceType = unicode(self.comboPriceType.currentText())
|
||||||
req.offset = unicode(self.comboOffset.currentText())
|
req.offset = unicode(self.comboOffset.currentText())
|
||||||
|
Loading…
Reference in New Issue
Block a user