[Fix]修复TradingWidget里sendOrder无法找到contract的bug
This commit is contained in:
parent
8652f7fb2e
commit
680c0dd535
@ -1,3 +1,3 @@
|
|||||||
# encoding: UTF-8
|
# encoding: UTF-8
|
||||||
|
|
||||||
from vnokex import OkexSpotApi , OkexFuturesApi , okex_all_symbol_pairs , CONTRACT_SYMBOL , SPOT_CURRENCY
|
from vnokex import OkexSpotApi, OkexFuturesApi, CONTRACT_SYMBOL, SPOT_CURRENCY
|
@ -14,13 +14,13 @@ api.connect(apiKey, secretKey, True)
|
|||||||
sleep(3)
|
sleep(3)
|
||||||
|
|
||||||
#api.login()
|
#api.login()
|
||||||
#api.subscribeSpotTicker("bch_btc")
|
api.subscribeSpotTicker("bch_btc")
|
||||||
#api.subscribeSpotDepth("bch_btc")
|
api.subscribeSpotDepth("bch_btc")
|
||||||
#api.subscribeSpotDepth5("bch_btc")
|
api.subscribeSpotDepth("bch_btc", 5)
|
||||||
#api.subscribeSpotDeals("bch_btc")
|
api.subscribeSpotDeals("bch_btc")
|
||||||
#api.subscribeSpotKlines("bch_btc","30min")
|
api.subscribeSpotKlines("bch_btc","30min")
|
||||||
|
|
||||||
api.spotTrade("etc_usdt","sell", "50" , "0.01")
|
#api.spotTrade("etc_usdt","sell", "50" , "0.01")
|
||||||
#api.spotCancelOrder("etc_btc","44274138")
|
#api.spotCancelOrder("etc_btc","44274138")
|
||||||
#api.spotUserInfo()
|
#api.spotUserInfo()
|
||||||
#api.spotOrderInfo("etc_btc", 44284731)
|
#api.spotOrderInfo("etc_btc", 44284731)
|
||||||
@ -30,9 +30,9 @@ api.spotTrade("etc_usdt","sell", "50" , "0.01")
|
|||||||
|
|
||||||
# sleep(3)
|
# sleep(3)
|
||||||
#api.subsribeFutureTicker("btc","this_week")
|
#api.subsribeFutureTicker("btc","this_week")
|
||||||
#api.subscribeFutureKline("btc","this_week","30min")
|
#api.subscribeFutureKline("btc","this_week", "30min")
|
||||||
#api.subscribeFutureDepth("btc","this_week")
|
#api.subscribeFutureDepth("btc","this_week")
|
||||||
#api.subscribeFutureDepth20("btc","this_week")
|
#api.subscribeFutureDepth("btc","this_week", 5)
|
||||||
#api.subscribeFutureTrades("btc","this_week")
|
#api.subscribeFutureTrades("btc","this_week")
|
||||||
#api.subscribeFutureIndex("btc")
|
#api.subscribeFutureIndex("btc")
|
||||||
#api.subscribeFutureForecast_price("btc")
|
#api.subscribeFutureForecast_price("btc")
|
||||||
@ -46,4 +46,6 @@ api.spotTrade("etc_usdt","sell", "50" , "0.01")
|
|||||||
|
|
||||||
'''
|
'''
|
||||||
合约账户信息、 持仓信息等,在登录后都会自动推送。。。官方文档这样写的,还没实际验证过
|
合约账户信息、 持仓信息等,在登录后都会自动推送。。。官方文档这样写的,还没实际验证过
|
||||||
'''
|
'''
|
||||||
|
|
||||||
|
input()
|
@ -245,7 +245,7 @@ class OkexSpotApi(OkexApi):
|
|||||||
|
|
||||||
#----------------------------------------------------------------------
|
#----------------------------------------------------------------------
|
||||||
def subscribeSpotKlines(self, symbol, period):
|
def subscribeSpotKlines(self, symbol, period):
|
||||||
channel = 'ok_sub_spot_%s_kline_%s' %symbol
|
channel = 'ok_sub_spot_%s_kline_%s' %(symbol, period)
|
||||||
self.sendDataRequest(channel)
|
self.sendDataRequest(channel)
|
||||||
|
|
||||||
#----------------------------------------------------------------------
|
#----------------------------------------------------------------------
|
||||||
@ -325,9 +325,11 @@ class OkexFuturesApi(OkexApi):
|
|||||||
self.sendDataRequest(channel)
|
self.sendDataRequest(channel)
|
||||||
|
|
||||||
#----------------------------------------------------------------------
|
#----------------------------------------------------------------------
|
||||||
def subscribeFuturesDepth(self, symbol, contractType):
|
def subscribeFuturesDepth(self, symbol, contractType, depth=0):
|
||||||
"""订阅期货深度"""
|
"""订阅期货深度"""
|
||||||
channel = 'ok_sub_future_%s_depth_%s_usd' %(symbol, contractType)
|
channel = 'ok_sub_futureusd_%s_depth_%s' %(symbol, contractType)
|
||||||
|
if depth:
|
||||||
|
channel = channel + '_' + str(depth)
|
||||||
self.sendDataRequest(channel)
|
self.sendDataRequest(channel)
|
||||||
|
|
||||||
#----------------------------------------------------------------------
|
#----------------------------------------------------------------------
|
||||||
|
@ -1026,6 +1026,7 @@ class TradingWidget(QtWidgets.QFrame):
|
|||||||
def sendOrder(self):
|
def sendOrder(self):
|
||||||
"""发单"""
|
"""发单"""
|
||||||
symbol = str(self.lineSymbol.text())
|
symbol = str(self.lineSymbol.text())
|
||||||
|
vtSymbol = symbol
|
||||||
exchange = unicode(self.comboExchange.currentText())
|
exchange = unicode(self.comboExchange.currentText())
|
||||||
currency = unicode(self.comboCurrency.currentText())
|
currency = unicode(self.comboCurrency.currentText())
|
||||||
productClass = unicode(self.comboProductClass.currentText())
|
productClass = unicode(self.comboProductClass.currentText())
|
||||||
@ -1046,7 +1047,7 @@ class TradingWidget(QtWidgets.QFrame):
|
|||||||
req = VtOrderReq()
|
req = VtOrderReq()
|
||||||
req.symbol = symbol
|
req.symbol = symbol
|
||||||
req.exchange = exchange
|
req.exchange = exchange
|
||||||
req.vtSymbol = contract.vtSymbol
|
vtSymbol = contract.vtSymbol
|
||||||
req.price = self.spinPrice.value()
|
req.price = self.spinPrice.value()
|
||||||
req.volume = self.spinVolume.value()
|
req.volume = self.spinVolume.value()
|
||||||
req.direction = unicode(self.comboDirection.currentText())
|
req.direction = unicode(self.comboDirection.currentText())
|
||||||
|
Loading…
Reference in New Issue
Block a user