diff --git a/vnpy/api/xspeed/__init__.py b/vnpy/api/xspeed/__init__.py index 697e5c75..0c4659fc 100644 --- a/vnpy/api/xspeed/__init__.py +++ b/vnpy/api/xspeed/__init__.py @@ -1,5 +1,6 @@ # encoding: UTF-8 -from vnxspeedmd import MdApi -from vnxspeedtd import TdApi -from xspeed_data_type import defineDict \ No newline at end of file +from __future__ import absolute_import +from .vnxspeedmd import MdApi +from .vnxspeedtd import TdApi +from .xspeed_data_type import defineDict \ No newline at end of file diff --git a/vnpy/api/xspeed/pyscript/generate_data_type.py b/vnpy/api/xspeed/pyscript/generate_data_type.py index df43f654..4595939d 100644 --- a/vnpy/api/xspeed/pyscript/generate_data_type.py +++ b/vnpy/api/xspeed/pyscript/generate_data_type.py @@ -1,5 +1,6 @@ # encoding: UTF-8 +from __future__ import print_function __author__ = 'CHENXY' # C++和python类型的映射字典 @@ -48,7 +49,7 @@ def process_typedef(line): else: keyword = content[-1] keyword = keyword.replace(';\n', '') - print content, keyword + print(content, keyword) if '[' in keyword: i = keyword.index('[') @@ -97,15 +98,15 @@ def main(): py_line = process_line(line) if py_line: fpy.write(py_line.decode('gbk').encode('utf-8')) - print n + print(n) fcpp.close() fpy.close() - print u'data_type.py生成过程完成' - except Exception, e: - print u'data_type.py生成过程出错' - print e + print(u'data_type.py生成过程完成') + except Exception as e: + print(u'data_type.py生成过程出错') + print(e) if __name__ == '__main__': diff --git a/vnpy/api/xspeed/pyscript/generate_md_functions.py b/vnpy/api/xspeed/pyscript/generate_md_functions.py index 9b380665..fb28de80 100644 --- a/vnpy/api/xspeed/pyscript/generate_md_functions.py +++ b/vnpy/api/xspeed/pyscript/generate_md_functions.py @@ -1,5 +1,6 @@ # encoding: UTF-8 +from __future__ import print_function __author__ = 'CHENXY' from string import join @@ -224,7 +225,7 @@ def processFunction(line): fcArgsTypeList.append(content[1]) # 参数类型列表 fcArgsValueList.append(content[3]) # 参数数据列表 - print fcArgsTypeList + print(fcArgsTypeList) if len(fcArgsTypeList)>0 and fcArgsTypeList[0] in structDict: createFunction(fcName, fcArgsTypeList, fcArgsValueList) @@ -286,10 +287,10 @@ define_count = 1 for line in fcpp: if " virtual void On" in line: - print 'callback' + print('callback') processCallBack(line) elif " virtual int" in line: - print 'function' + print('function') processFunction(line) fcpp.close() diff --git a/vnpy/api/xspeed/pyscript/generate_struct.py b/vnpy/api/xspeed/pyscript/generate_struct.py index ad0ff1c5..5f5a35fd 100644 --- a/vnpy/api/xspeed/pyscript/generate_struct.py +++ b/vnpy/api/xspeed/pyscript/generate_struct.py @@ -1,5 +1,6 @@ # encoding: UTF-8 +from __future__ import print_function __author__ = 'CHENXY' from xspeed_data_type import * @@ -47,10 +48,10 @@ def main(): n = line.index('//') line = line[:n] - print no, ':', line + print(no, ':', line) content = line.split('\t') - print content + print(content) typedef = content[1] type_ = typedefDict[typedef] diff --git a/vnpy/api/xspeed/pyscript/generate_td_functions.py b/vnpy/api/xspeed/pyscript/generate_td_functions.py index 52530211..a5dbe885 100644 --- a/vnpy/api/xspeed/pyscript/generate_td_functions.py +++ b/vnpy/api/xspeed/pyscript/generate_td_functions.py @@ -1,5 +1,6 @@ # encoding: UTF-8 +from __future__ import print_function __author__ = 'CHENXY' from string import join @@ -33,7 +34,7 @@ def processCallBack(line): cbArgsTypeList.append(content[0]) # 参数类型列表 cbArgsValueList.append(content[1]) # 参数数据列表 else: - print content + print(content) cbArgsTypeList.append(content[1]) # 参数类型列表 cbArgsValueList.append(content[2]+content[3]) # 参数数据列表 @@ -230,8 +231,8 @@ def processFunction(line): fcArgsTypeList.append(content[1]) # 参数类型列表 fcArgsValueList.append(content[3]) # 参数数据列表 - print line - print fcArgsTypeList + print(line) + print(fcArgsTypeList) if len(fcArgsTypeList)>0 and fcArgsTypeList[0] in structDict: createFunction(fcName, fcArgsTypeList, fcArgsValueList) @@ -263,7 +264,7 @@ def createFunction(fcName, fcArgsTypeList, fcArgsValueList): elif value == 'short': line = '\tgetShort(req, "' + key + '", &myreq.' + key + ');\n' elif value == 'float': - print line + print(line) line = '\tgetDouble(req, "' + key + '", &myreq.' + key + ');\n' ffunction.write(line) @@ -294,10 +295,10 @@ define_count = 1 for line in fcpp: if " virtual void On" in line: - print 'callback' + print('callback') processCallBack(line) elif " virtual int" in line: - print 'function' + print('function') processFunction(line) fcpp.close() diff --git a/vnpy/api/xspeed/pyscript/old/generate_data_type.py b/vnpy/api/xspeed/pyscript/old/generate_data_type.py index 477d5288..e833bad2 100644 --- a/vnpy/api/xspeed/pyscript/old/generate_data_type.py +++ b/vnpy/api/xspeed/pyscript/old/generate_data_type.py @@ -1,5 +1,6 @@ # encoding: UTF-8 +from __future__ import print_function __author__ = 'CHENXY' # C++和python类型的映射字典 @@ -48,7 +49,7 @@ def process_typedef(line): else: keyword = content[-1] keyword = keyword.replace(';\n', '') - print content, keyword + print(content, keyword) if '[' in keyword: i = keyword.index('[') @@ -91,15 +92,15 @@ def main(): py_line = process_line(line) if py_line: fpy.write(py_line.decode('gbk').encode('utf-8')) - print n + print(n) fcpp.close() fpy.close() - print u'data_type.py生成过程完成' - except Exception, e: - print u'data_type.py生成过程出错' - print e + print(u'data_type.py生成过程完成') + except Exception as e: + print(u'data_type.py生成过程出错') + print(e) if __name__ == '__main__': diff --git a/vnpy/api/xspeed/pyscript/old/generate_struct.py b/vnpy/api/xspeed/pyscript/old/generate_struct.py index df86652b..60f9662b 100644 --- a/vnpy/api/xspeed/pyscript/old/generate_struct.py +++ b/vnpy/api/xspeed/pyscript/old/generate_struct.py @@ -1,5 +1,6 @@ # encoding: UTF-8 +from __future__ import print_function __author__ = 'CHENXY' from ksgold_data_type import * @@ -47,7 +48,7 @@ def main(): n = line.index('//') line = line[:n] - print no, ':', line + print(no, ':', line) content = line.split('\t') diff --git a/vnpy/api/xspeed/test/xspeedmdtest.py b/vnpy/api/xspeed/test/xspeedmdtest.py index 44484002..08a6eb51 100644 --- a/vnpy/api/xspeed/test/xspeedmdtest.py +++ b/vnpy/api/xspeed/test/xspeedmdtest.py @@ -1,5 +1,6 @@ # encoding: UTF-8 +from __future__ import print_function import sys from time import sleep import datetime @@ -13,7 +14,7 @@ from vnxspeedmd import * def print_dict(d): """按照键值打印一个字典""" for key,value in d.items(): - print key + ':' + str(value) + print(key + ':' + str(value)) def parseDateTime(date,time,milli): @@ -32,8 +33,8 @@ def parseDateTime(date,time,milli): def simple_log(func): """简单装饰器用于输出函数名""" def wrapper(*args, **kw): - print "" - print str(func.__name__) + print("") + print(str(func.__name__)) return func(*args, **kw) return wrapper @@ -57,7 +58,7 @@ class TestMdApi(MdApi): @simple_log def onFrontDisconnected(self, n): """服务器断开""" - print n + print(n) #---------------------------------------------------------------------- @simple_log diff --git a/vnpy/api/xspeed/test/xspeedtdtest.py b/vnpy/api/xspeed/test/xspeedtdtest.py index 6dcedd32..9b69a2c7 100644 --- a/vnpy/api/xspeed/test/xspeedtdtest.py +++ b/vnpy/api/xspeed/test/xspeedtdtest.py @@ -1,5 +1,6 @@ # encoding: UTF-8 +from __future__ import print_function import sys from time import sleep @@ -12,15 +13,15 @@ from vnxspeedtd import * def print_dict(d): """按照键值打印一个字典""" for key,value in d.items(): - print key + ':' + str(value) + print(key + ':' + str(value)) #---------------------------------------------------------------------- def simple_log(func): """简单装饰器用于输出函数名""" def wrapper(*args, **kw): - print "" - print str(func.__name__) + print("") + print(str(func.__name__)) return func(*args, **kw) return wrapper @@ -43,7 +44,7 @@ class TestTdApi(TdApi): @simple_log def onFrontDisconnected(self, n): """服务器断开""" - print n + print(n) #---------------------------------------------------------------------- @simple_log @@ -82,7 +83,7 @@ class TestTdApi(TdApi): """查询持仓""" print_dict(data) print_dict(error) - print last + print(last) #---------------------------------------------------------------------- @simple_log @@ -90,7 +91,7 @@ class TestTdApi(TdApi): """查询持仓""" print_dict(data) print_dict(error) - print last + print(last) #---------------------------------------------------------------------- @simple_log @@ -105,7 +106,7 @@ class TestTdApi(TdApi): """查询持仓""" print_dict(data) print_dict(error) - print last + print(last) #---------------------------------------------------------------------- @simple_log @@ -113,7 +114,7 @@ class TestTdApi(TdApi): """查询持仓""" print_dict(data) print_dict(error) - print last + print(last) #---------------------------------------------------------------------- @simple_log @@ -145,7 +146,7 @@ class TestTdApi(TdApi): """查询持仓""" print_dict(data) print_dict(error) - print last + print(last) #---------------------------------------------------------------------- @simple_log @@ -153,7 +154,7 @@ class TestTdApi(TdApi): """查询持仓""" print_dict(data) print_dict(error) - print last + print(last) #---------------------------------------------------------------------- @simple_log @@ -161,7 +162,7 @@ class TestTdApi(TdApi): """查询持仓""" print_dict(data) print_dict(error) - print last + print(last) #---------------------------------------------------------------------- @simple_log @@ -188,7 +189,7 @@ class TestTdApi(TdApi): """查询持仓""" print_dict(data) print_dict(error) - print last + print(last) #---------------------------------------------------------------------- @simple_log @@ -203,7 +204,7 @@ class TestTdApi(TdApi): """查询持仓""" print_dict(data) print_dict(error) - print last + print(last) #---------------------------------------------------------------------- @simple_log @@ -217,7 +218,7 @@ class TestTdApi(TdApi): """查询持仓""" print_dict(data) print_dict(error) - print last + print(last) #---------------------------------------------------------------------- @simple_log @@ -225,7 +226,7 @@ class TestTdApi(TdApi): """查询持仓""" print_dict(data) print_dict(error) - print last + print(last) #---------------------------------------------------------------------- @simple_log @@ -233,7 +234,7 @@ class TestTdApi(TdApi): """查询持仓""" print_dict(data) print_dict(error) - print last + print(last) #----------------------------------------------------------------------