Merge pull request #895 from cclauss/modernize-vnpy_api_xspeed

Modernize vnpy/api/xspeed
This commit is contained in:
vn.py 2018-05-30 09:36:24 +08:00 committed by GitHub
commit ab7398c4f5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
9 changed files with 56 additions and 47 deletions

View File

@ -1,5 +1,6 @@
# encoding: UTF-8
from vnxspeedmd import MdApi
from vnxspeedtd import TdApi
from xspeed_data_type import defineDict
from __future__ import absolute_import
from .vnxspeedmd import MdApi
from .vnxspeedtd import TdApi
from .xspeed_data_type import defineDict

View File

@ -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__':

View File

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

View File

@ -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]

View File

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

View File

@ -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__':

View File

@ -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')

View File

@ -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

View File

@ -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)
#----------------------------------------------------------------------