From fddcb454811ab6b2e423fba4203f23d38d0ca5f2 Mon Sep 17 00:00:00 2001 From: cclauss Date: Sun, 5 Aug 2018 17:13:40 +0200 Subject: [PATCH] print() is a function in Python 3 --- vnpy/api/bigone/vnbigone.py | 15 ++++++------- vnpy/api/bithumb/vnbithumb.py | 3 ++- vnpy/api/fcoin/vnfcoin.py | 22 ++++++++++--------- vnpy/trader/app/algoTrading/testRpc.py | 14 +++++++----- .../gateway/bigoneGateway/bigoneGateway.py | 5 +++-- .../gateway/fcoinGateway/fcoinGateway.py | 5 +++-- 6 files changed, 35 insertions(+), 29 deletions(-) diff --git a/vnpy/api/bigone/vnbigone.py b/vnpy/api/bigone/vnbigone.py index 8a8bb8ab..0e4bfd29 100644 --- a/vnpy/api/bigone/vnbigone.py +++ b/vnpy/api/bigone/vnbigone.py @@ -1,5 +1,6 @@ # encoding: UTF-8 +from __future__ import print_function import hashlib import hmac import json @@ -17,7 +18,7 @@ from threading import Thread import requests from jwt import PyJWS - +from six.moves import input REST_HOST = 'https://big.one/api/v2/' @@ -121,14 +122,14 @@ class BigoneRestApi(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) @@ -150,6 +151,4 @@ if __name__ == '__main__': rest.addReq('GET', '/viewer/orders', rest.onData) - raw_input() - - \ No newline at end of file + input() diff --git a/vnpy/api/bithumb/vnbithumb.py b/vnpy/api/bithumb/vnbithumb.py index 286202b0..981a2f51 100644 --- a/vnpy/api/bithumb/vnbithumb.py +++ b/vnpy/api/bithumb/vnbithumb.py @@ -7,6 +7,7 @@ from multiprocessing.dummy import Pool from time import time import requests +from six.moves import input from queue import Queue, Empty REST_HOST = 'https://api.bithumb.com' @@ -162,4 +163,4 @@ if __name__ == '__main__': rest.addReq('POST', '/public/ticker/BTC', onBtcTick) rest.addReq('POST', '/info/account', onAccountInfo, postdict={'currency': 'BTC'}) - raw_input() + input() diff --git a/vnpy/api/fcoin/vnfcoin.py b/vnpy/api/fcoin/vnfcoin.py index 84b24651..9d29b0e7 100644 --- a/vnpy/api/fcoin/vnfcoin.py +++ b/vnpy/api/fcoin/vnfcoin.py @@ -1,5 +1,6 @@ # encoding: UTF-8 +from __future__ import print_function import hashlib import hmac import json @@ -17,6 +18,7 @@ from threading import Thread import requests import websocket +from six.moves import input REST_HOST = 'https://api.fcoin.com/v2' @@ -146,14 +148,14 @@ class FcoinRestApi(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) ######################################################################## @@ -211,21 +213,21 @@ class FcoinWebsocketApi(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): @@ -287,6 +289,6 @@ if __name__ == '__main__': #ws.sendReq(req) - raw_input() + input() + - \ No newline at end of file diff --git a/vnpy/trader/app/algoTrading/testRpc.py b/vnpy/trader/app/algoTrading/testRpc.py index dc517935..feb7cf6e 100644 --- a/vnpy/trader/app/algoTrading/testRpc.py +++ b/vnpy/trader/app/algoTrading/testRpc.py @@ -1,7 +1,9 @@ # encoding: UTF-8 +from __future__ import print_function from time import sleep +from six.moves import input from vnpy.rpc import RpcClient from vnpy.trader.vtConstant import OFFSET_OPEN, DIRECTION_LONG @@ -18,7 +20,7 @@ class TestClient(RpcClient): #---------------------------------------------------------------------- def callback(self, topic, data): """回调函数实现""" - print('client received topic:', topic, ', data:', data) + print(('client received topic:', topic, ', data:', data)) if __name__ == '__main__': @@ -27,8 +29,8 @@ if __name__ == '__main__': tc = TestClient(reqAddress, subAddress) tc.subscribeTopic('') - tc.start() - + tc.start() + setting = { 'templateName': u'BestLimit 最优限价', 'vtSymbol': 'rb1810.SHFE', @@ -37,10 +39,10 @@ if __name__ == '__main__': 'offset': OFFSET_OPEN } algoName = tc.addAlgo(setting) - print u'启动算法,实例名', algoName + print(u'启动算法,实例名', algoName) sleep(5) tc.stopAlgo(algoName) - print u'停止算法' + print(u'停止算法') - raw_input() \ No newline at end of file + input() diff --git a/vnpy/trader/gateway/bigoneGateway/bigoneGateway.py b/vnpy/trader/gateway/bigoneGateway/bigoneGateway.py index dad9d2e6..1c60ecaa 100644 --- a/vnpy/trader/gateway/bigoneGateway/bigoneGateway.py +++ b/vnpy/trader/gateway/bigoneGateway/bigoneGateway.py @@ -3,6 +3,7 @@ ''' vnpy.api.bigone的gateway接入 ''' +from __future__ import print_function import os import json @@ -503,9 +504,9 @@ class RestApi(BigoneRestApi): #---------------------------------------------------------------------- def printDict(d): """""" - print '-' * 30 + print('-' * 30) l = d.keys() l.sort() for k in l: - print k, d[k] + print(k, d[k]) \ No newline at end of file diff --git a/vnpy/trader/gateway/fcoinGateway/fcoinGateway.py b/vnpy/trader/gateway/fcoinGateway/fcoinGateway.py index e64f1b5d..8c9a054d 100644 --- a/vnpy/trader/gateway/fcoinGateway/fcoinGateway.py +++ b/vnpy/trader/gateway/fcoinGateway/fcoinGateway.py @@ -3,6 +3,7 @@ ''' vnpy.api.fcoin的gateway接入 ''' +from __future__ import print_function import os import json @@ -573,9 +574,9 @@ class WebsocketApi(FcoinWebsocketApi): #---------------------------------------------------------------------- def printDict(d): """""" - print '-' * 30 + print('-' * 30) l = d.keys() l.sort() for k in l: - print k, d[k] + print(k, d[k]) \ No newline at end of file