Modernize vnpy/api/l*

This commit is contained in:
cclauss 2018-05-17 08:49:28 +02:00
parent 92377715af
commit e58a71c79b
9 changed files with 49 additions and 38 deletions

View File

@ -1,3 +1,4 @@
# encoding: UTF-8
from vnlbank import LbankApi
from __future__ import absolute_import
from .vnlbank import LbankApi

View File

@ -1,8 +1,11 @@
# encoding: utf-8
from __future__ import absolute_import
from time import time, sleep
from vnlbank import LbankApi
from six.moves import input
from .vnlbank import LbankApi
if __name__ == '__main__':
@ -44,4 +47,4 @@ if __name__ == '__main__':
#api.getOrdersInfoHistory('btc_cny', '0', '1', '100')
# 阻塞
raw_input()
input()

View File

@ -1,5 +1,6 @@
# encoding: utf-8
from __future__ import print_function
import urllib
import hashlib
@ -120,7 +121,7 @@ class LbankApi(object):
# 请求成功
else:
if self.DEBUG:
print callback.__name__
print(callback.__name__)
callback(data, req, reqID)
# 流控等待
@ -149,7 +150,7 @@ class LbankApi(object):
#----------------------------------------------------------------------
def onError(self, error, req, reqID):
"""错误推送"""
print error, req, reqID
print(error, req, reqID)
###############################################
# 行情接口
@ -203,22 +204,22 @@ class LbankApi(object):
#----------------------------------------------------------------------
def onGetTicker(self, data, req, reqID):
"""查询行情回调"""
print data, reqID
print(data, reqID)
# ----------------------------------------------------------------------
def onGetDepth(self, data, req, reqID):
"""查询深度回调"""
print data, reqID
print(data, reqID)
# ----------------------------------------------------------------------
def onGetTrades(self, data, req, reqID):
"""查询历史成交"""
print data, reqID
print(data, reqID)
# ----------------------------------------------------------------------
def onGetKline(self, data, req, reqID):
"""查询K线回报"""
print data, reqID
print(data, reqID)
###############################################
# 交易接口
@ -283,25 +284,25 @@ class LbankApi(object):
# ----------------------------------------------------------------------
def onGetUserInfo(self, data, req, reqID):
"""查询账户信息"""
print data, reqID
print(data, reqID)
# ----------------------------------------------------------------------
def onCreateOrder(self, data, req, reqID):
"""委托回报"""
print data, reqID
print(data, reqID)
# ----------------------------------------------------------------------
def onCancelOrder(self, data, req, reqID):
"""撤单回报"""
print data, reqID
print(data, reqID)
# ----------------------------------------------------------------------
def onGetOrdersInfo(self, data, req, reqID):
"""查询委托回报"""
print data, reqID
print(data, reqID)
# ----------------------------------------------------------------------
def onGetOrdersInfoHistory(self, data, req, reqID):
"""撤单回报"""
print data, reqID
print(data, reqID)

View File

@ -1,6 +1,7 @@
# encoding: UTF-8
from vnltsmd import MdApi
from vnltstd import TdApi
from vnltsqry import QryApi
from lts_data_type import defineDict
from __future__ import absolute_import
from .vnltsmd import MdApi
from .vnltstd import TdApi
from .vnltsqry import QryApi
from .lts_data_type import defineDict

View File

@ -1,5 +1,6 @@
# encoding: UTF-8
from __future__ import print_function
__author__ = 'CHENXY'
# C++和python类型的映射字典
@ -88,9 +89,9 @@ def main():
fcpp.close()
fpy.close()
print u'data_type.py生成过程完成'
print(u'data_type.py生成过程完成')
except:
print u'data_type.py生成过程出错'
print(u'data_type.py生成过程出错')
if __name__ == '__main__':

View File

@ -1,5 +1,6 @@
# encoding: UTF-8
from __future__ import print_function
__author__ = 'CHENXY'
# C++和python类型的映射字典
@ -88,9 +89,9 @@ def main():
fcpp.close()
fpy.close()
print u'data_type.py生成过程完成'
print(u'data_type.py生成过程完成')
except:
print u'data_type.py生成过程出错'
print(u'data_type.py生成过程出错')
if __name__ == '__main__':

View File

@ -1,6 +1,7 @@
# encoding: UTF-8
# 内置模块
from __future__ import print_function
import sys
from time import sleep
@ -11,15 +12,15 @@ from vnltsmd 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,13 +44,13 @@ class TestMdApi(MdApi):
@simple_log
def onFrontDisconnected(self, n):
"""服务器断开"""
print n
print(n)
#----------------------------------------------------------------------
@simple_log
def onHeartBeatWarning(self, n):
"""心跳报警"""
print n
print(n)
#----------------------------------------------------------------------
@simple_log
@ -124,7 +125,7 @@ def main():
#获取交易日,测试通过
day = api.getTradingDay()
print 'Trading Day is:' + str(day)
print('Trading Day is:' + str(day))
sleep(0.5)
# 订阅合约,测试通过

View File

@ -1,6 +1,7 @@
# encoding: UTF-8
# 内置模块
from __future__ import print_function
import sys
from time import sleep
@ -12,15 +13,15 @@ from lts_data_type import defineDict
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
@ -44,13 +45,13 @@ class TestQryApi(QryApi):
@simple_log
def onFrontDisconnected(self, n):
"""服务器断开"""
print n
print(n)
#----------------------------------------------------------------------
@simple_log
def onHeartBeatWarning(self, n):
"""心跳报警"""
print n
print(n)
#----------------------------------------------------------------------
@simple_log

View File

@ -1,6 +1,7 @@
# encoding: UTF-8
# 内置模块
from __future__ import print_function
import sys
from time import sleep
@ -12,15 +13,15 @@ from lts_data_type import defineDict
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
@ -44,13 +45,13 @@ class TestTdApi(TdApi):
@simple_log
def onFrontDisconnected(self, n):
"""服务器断开"""
print n
print(n)
#----------------------------------------------------------------------
@simple_log
def onHeartBeatWarning(self, n):
"""心跳报警"""
print n
print(n)
#----------------------------------------------------------------------
@simple_log