From 6f9167303710a6a501da0153b95566836701a7c0 Mon Sep 17 00:00:00 2001 From: cclauss Date: Tue, 29 May 2018 13:21:14 +0200 Subject: [PATCH] Modernize vnpy/api/shzd --- vnpy/api/shzd/__init__.py | 3 ++- vnpy/api/shzd/test/test.py | 17 +++++++++-------- 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/vnpy/api/shzd/__init__.py b/vnpy/api/shzd/__init__.py index 7a5e03d5..f76a6d69 100644 --- a/vnpy/api/shzd/__init__.py +++ b/vnpy/api/shzd/__init__.py @@ -1,3 +1,4 @@ # encoding: UTF-8 -from vnshzd import ShzdApi \ No newline at end of file +from __future__ import absolute_import +from .vnshzd import ShzdApi \ No newline at end of file diff --git a/vnpy/api/shzd/test/test.py b/vnpy/api/shzd/test/test.py index 13bb2c5f..a958d450 100644 --- a/vnpy/api/shzd/test/test.py +++ b/vnpy/api/shzd/test/test.py @@ -1,5 +1,6 @@ # encoding: UTF-8 +from __future__ import print_function from time import sleep from vnshzd import * @@ -10,7 +11,7 @@ def printDict(d): l = d.keys() l.sort() for key in l: - print '%s:%s' %(key, d[key]) + print('%s:%s' %(key, d[key])) ######################################################################## @@ -26,19 +27,19 @@ class TestApi(ShzdApi): #---------------------------------------------------------------------- def onReceiveErrorInfo(self, errcode, errmsg): """""" - print '-' * 50 - print 'errorcode %s, error msg %s' %(errcode, errmsg) + print('-' * 50) + print('errorcode %s, error msg %s' %(errcode, errmsg)) #---------------------------------------------------------------------- def onReceiveMarketInfo(self, data): """""" - print '-' * 50 + print('-' * 50) printDict(data) #---------------------------------------------------------------------- def onReceiveTradeInfo(self, data): """""" - print '-' * 50 + print('-' * 50) printDict(data) if __name__ == '__main__': @@ -49,8 +50,8 @@ if __name__ == '__main__': api.initShZdServer() # 注册前置机地址 - print api.registerFront('222.73.119.230', 7003) - print api.registerMarket('222.73.119.230', 9003) + print(api.registerFront('222.73.119.230', 7003)) + print(api.registerMarket('222.73.119.230', 9003)) # 登录 sleep(1) @@ -68,7 +69,7 @@ if __name__ == '__main__': data['201'] = '+' #data['307'] = "CME,6J1609" data['307'] = 'ICE,WBS1611' - print data + print(data) api.shzdSendInfoToMarket(data) # # 查询合约