Modernize recent changes
This commit is contained in:
parent
30be00063c
commit
6b85efa3d9
@ -1,5 +1,6 @@
|
||||
# encoding: UTF-8
|
||||
|
||||
from __future__ import print_function
|
||||
import hashlib
|
||||
import hmac
|
||||
import json
|
||||
@ -14,6 +15,8 @@ from copy import copy
|
||||
from urllib import urlencode
|
||||
from threading import Thread
|
||||
|
||||
from six.moves import input
|
||||
|
||||
import requests
|
||||
import websocket
|
||||
|
||||
@ -138,14 +141,14 @@ class BitmexRestApi(object):
|
||||
#----------------------------------------------------------------------
|
||||
def onError(self, code, error):
|
||||
"""错误回调"""
|
||||
print 'on error'
|
||||
print code, error
|
||||
print('on error')
|
||||
print(code, error)
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
def onData(self, data, reqid):
|
||||
"""通用回调"""
|
||||
print 'on data'
|
||||
print data, reqid
|
||||
print('on data')
|
||||
print(data, reqid)
|
||||
|
||||
|
||||
########################################################################
|
||||
@ -203,21 +206,21 @@ class BitmexWebsocketApi(object):
|
||||
#----------------------------------------------------------------------
|
||||
def onConnect(self):
|
||||
"""连接回调"""
|
||||
print 'connected'
|
||||
print('connected')
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
def onData(self, data):
|
||||
"""数据回调"""
|
||||
print '-' * 30
|
||||
print('-' * 30)
|
||||
l = data.keys()
|
||||
l.sort()
|
||||
for k in l:
|
||||
print k, data[k]
|
||||
print(k, data[k])
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
def onError(self, msg):
|
||||
"""错误回调"""
|
||||
print msg
|
||||
print(msg)
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
def sendReq(self, req):
|
||||
@ -265,8 +268,6 @@ if __name__ == '__main__':
|
||||
|
||||
#req = {"op": "subscribe", "args": ['order', 'execution', 'position', 'margin']}
|
||||
#req = {"op": "subscribe", "args": ['instrument']}
|
||||
#ws.sendReq(req)
|
||||
|
||||
raw_input()
|
||||
|
||||
|
||||
#ws.sendReq(req)
|
||||
|
||||
input()
|
||||
|
@ -12,6 +12,7 @@ from vnpy.trader.uiQt import QtWidgets
|
||||
from .algoTemplate import AlgoTemplate
|
||||
from .uiAlgoWidget import AlgoWidget, QtWidgets
|
||||
|
||||
from six import text_type
|
||||
|
||||
|
||||
STATUS_FINISHED = set([STATUS_ALLTRADED, STATUS_CANCELLED, STATUS_REJECTED])
|
||||
@ -30,9 +31,9 @@ class DmaAlgo(AlgoTemplate):
|
||||
|
||||
# 参数,强制类型转换,保证从CSV加载的配置正确
|
||||
self.vtSymbol = str(setting['vtSymbol']) # 合约代码
|
||||
self.direction = unicode(setting['direction']) # 买卖
|
||||
self.offset = unicode(setting['offset']) # 开平
|
||||
self.priceType = unicode(setting['priceType']) # 价格类型
|
||||
self.direction = text_type(setting['direction']) # 买卖
|
||||
self.offset = text_type(setting['offset']) # 开平
|
||||
self.priceType = text_type(setting['priceType']) # 价格类型
|
||||
self.price = float(setting['price']) # 价格
|
||||
self.totalVolume = float(setting['totalVolume']) # 数量
|
||||
|
||||
@ -178,12 +179,12 @@ class DmaWidget(AlgoWidget):
|
||||
setting = OrderedDict()
|
||||
setting['templateName'] = DmaAlgo.templateName
|
||||
setting['vtSymbol'] = str(self.lineSymbol.text())
|
||||
setting['direction'] = unicode(self.comboDirection.currentText())
|
||||
setting['direction'] = text_type(self.comboDirection.currentText())
|
||||
setting['price'] = float(self.spinPrice.value())
|
||||
setting['totalVolume'] = float(self.spinVolume.value())
|
||||
setting['priceType'] = unicode(self.comboPriceType.currentText())
|
||||
setting['offset'] = unicode(self.comboOffset.currentText())
|
||||
setting['priceType'] = text_type(self.comboPriceType.currentText())
|
||||
setting['offset'] = text_type(self.comboOffset.currentText())
|
||||
|
||||
return setting
|
||||
|
||||
|
||||
|
||||
|
@ -10,6 +10,7 @@ from vnpy.trader.uiQt import QtWidgets
|
||||
from .algoTemplate import AlgoTemplate
|
||||
from .uiAlgoWidget import AlgoWidget, QtWidgets
|
||||
|
||||
from six import text_type
|
||||
|
||||
|
||||
########################################################################
|
||||
@ -25,10 +26,10 @@ class StopAlgo(AlgoTemplate):
|
||||
|
||||
# 参数,强制类型转换,保证从CSV加载的配置正确
|
||||
self.vtSymbol = str(setting['vtSymbol']) # 合约代码
|
||||
self.direction = unicode(setting['direction']) # 买卖
|
||||
self.direction = text_type(setting['direction']) # 买卖
|
||||
self.stopPrice = float(setting['stopPrice']) # 触发价格
|
||||
self.totalVolume = float(setting['totalVolume']) # 数量
|
||||
self.offset = unicode(setting['offset']) # 开平
|
||||
self.offset = text_type(setting['offset']) # 开平
|
||||
self.priceAdd = float(setting['priceAdd']) # 下单时的超价
|
||||
|
||||
self.vtOrderID = '' # 委托号
|
||||
@ -195,12 +196,12 @@ class StopWidget(AlgoWidget):
|
||||
setting = OrderedDict()
|
||||
setting['templateName'] = StopAlgo.templateName
|
||||
setting['vtSymbol'] = str(self.lineSymbol.text())
|
||||
setting['direction'] = unicode(self.comboDirection.currentText())
|
||||
setting['direction'] = text_type(self.comboDirection.currentText())
|
||||
setting['stopPrice'] = float(self.spinPrice.value())
|
||||
setting['totalVolume'] = float(self.spinVolume.value())
|
||||
setting['offset'] = unicode(self.comboOffset.currentText())
|
||||
setting['offset'] = text_type(self.comboOffset.currentText())
|
||||
setting['priceAdd'] = float(self.spinPriceAdd.value())
|
||||
|
||||
return setting
|
||||
|
||||
|
||||
|
||||
|
@ -3,6 +3,7 @@
|
||||
'''
|
||||
vnpy.api.bitmex的gateway接入
|
||||
'''
|
||||
from __future__ import print_function
|
||||
|
||||
import os
|
||||
import json
|
||||
@ -528,9 +529,9 @@ class WebsocketApi(BitmexWebsocketApi):
|
||||
#----------------------------------------------------------------------
|
||||
def printDict(d):
|
||||
""""""
|
||||
print '-' * 30
|
||||
print('-' * 30)
|
||||
l = d.keys()
|
||||
l.sort()
|
||||
for k in l:
|
||||
print k, d[k]
|
||||
print(k, d[k])
|
||||
|
Loading…
Reference in New Issue
Block a user