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())