From 680c0dd5350f3c5a7dc6184faa0362a895c17b35 Mon Sep 17 00:00:00 2001 From: "vn.py" Date: Mon, 18 Dec 2017 09:37:31 +0800 Subject: [PATCH] =?UTF-8?q?[Fix]=E4=BF=AE=E5=A4=8DTradingWidget=E9=87=8Cse?= =?UTF-8?q?ndOrder=E6=97=A0=E6=B3=95=E6=89=BE=E5=88=B0contract=E7=9A=84bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- vnpy/api/okex/__init__.py | 2 +- vnpy/api/okex/test.py | 20 +++++++++++--------- vnpy/api/okex/vnokex.py | 8 +++++--- vnpy/trader/uiBasicWidget.py | 3 ++- 4 files changed, 19 insertions(+), 14 deletions(-) diff --git a/vnpy/api/okex/__init__.py b/vnpy/api/okex/__init__.py index ff9012b2..a55eb22f 100644 --- a/vnpy/api/okex/__init__.py +++ b/vnpy/api/okex/__init__.py @@ -1,3 +1,3 @@ # encoding: UTF-8 -from vnokex import OkexSpotApi , OkexFuturesApi , okex_all_symbol_pairs , CONTRACT_SYMBOL , SPOT_CURRENCY \ No newline at end of file +from vnokex import OkexSpotApi, OkexFuturesApi, CONTRACT_SYMBOL, SPOT_CURRENCY \ No newline at end of file diff --git a/vnpy/api/okex/test.py b/vnpy/api/okex/test.py index 80724a18..c85a365d 100644 --- a/vnpy/api/okex/test.py +++ b/vnpy/api/okex/test.py @@ -14,13 +14,13 @@ api.connect(apiKey, secretKey, True) sleep(3) #api.login() -#api.subscribeSpotTicker("bch_btc") -#api.subscribeSpotDepth("bch_btc") -#api.subscribeSpotDepth5("bch_btc") -#api.subscribeSpotDeals("bch_btc") -#api.subscribeSpotKlines("bch_btc","30min") +api.subscribeSpotTicker("bch_btc") +api.subscribeSpotDepth("bch_btc") +api.subscribeSpotDepth("bch_btc", 5) +api.subscribeSpotDeals("bch_btc") +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.spotUserInfo() #api.spotOrderInfo("etc_btc", 44284731) @@ -30,9 +30,9 @@ api.spotTrade("etc_usdt","sell", "50" , "0.01") # sleep(3) #api.subsribeFutureTicker("btc","this_week") -#api.subscribeFutureKline("btc","this_week","30min") +#api.subscribeFutureKline("btc","this_week", "30min") #api.subscribeFutureDepth("btc","this_week") -#api.subscribeFutureDepth20("btc","this_week") +#api.subscribeFutureDepth("btc","this_week", 5) #api.subscribeFutureTrades("btc","this_week") #api.subscribeFutureIndex("btc") #api.subscribeFutureForecast_price("btc") @@ -46,4 +46,6 @@ api.spotTrade("etc_usdt","sell", "50" , "0.01") ''' 合约账户信息、 持仓信息等,在登录后都会自动推送。。。官方文档这样写的,还没实际验证过 -''' \ No newline at end of file +''' + +input() \ No newline at end of file diff --git a/vnpy/api/okex/vnokex.py b/vnpy/api/okex/vnokex.py index f9c20ae1..cb565ecc 100644 --- a/vnpy/api/okex/vnokex.py +++ b/vnpy/api/okex/vnokex.py @@ -245,7 +245,7 @@ class OkexSpotApi(OkexApi): #---------------------------------------------------------------------- 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) #---------------------------------------------------------------------- @@ -325,9 +325,11 @@ class OkexFuturesApi(OkexApi): 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) #---------------------------------------------------------------------- diff --git a/vnpy/trader/uiBasicWidget.py b/vnpy/trader/uiBasicWidget.py index e1db5059..d43dba1b 100644 --- a/vnpy/trader/uiBasicWidget.py +++ b/vnpy/trader/uiBasicWidget.py @@ -1026,6 +1026,7 @@ class TradingWidget(QtWidgets.QFrame): def sendOrder(self): """发单""" symbol = str(self.lineSymbol.text()) + vtSymbol = symbol exchange = unicode(self.comboExchange.currentText()) currency = unicode(self.comboCurrency.currentText()) productClass = unicode(self.comboProductClass.currentText()) @@ -1046,7 +1047,7 @@ class TradingWidget(QtWidgets.QFrame): req = VtOrderReq() req.symbol = symbol req.exchange = exchange - req.vtSymbol = contract.vtSymbol + vtSymbol = contract.vtSymbol req.price = self.spinPrice.value() req.volume = self.spinVolume.value() req.direction = unicode(self.comboDirection.currentText())