Modernize vnpy/api/l*
This commit is contained in:
parent
92377715af
commit
e58a71c79b
@ -1,3 +1,4 @@
|
|||||||
# encoding: UTF-8
|
# encoding: UTF-8
|
||||||
|
|
||||||
from vnlbank import LbankApi
|
from __future__ import absolute_import
|
||||||
|
from .vnlbank import LbankApi
|
@ -1,8 +1,11 @@
|
|||||||
# encoding: utf-8
|
# encoding: utf-8
|
||||||
|
|
||||||
|
from __future__ import absolute_import
|
||||||
from time import time, sleep
|
from time import time, sleep
|
||||||
|
|
||||||
from vnlbank import LbankApi
|
from six.moves import input
|
||||||
|
|
||||||
|
from .vnlbank import LbankApi
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
@ -44,4 +47,4 @@ if __name__ == '__main__':
|
|||||||
#api.getOrdersInfoHistory('btc_cny', '0', '1', '100')
|
#api.getOrdersInfoHistory('btc_cny', '0', '1', '100')
|
||||||
|
|
||||||
# 阻塞
|
# 阻塞
|
||||||
raw_input()
|
input()
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
# encoding: utf-8
|
# encoding: utf-8
|
||||||
|
|
||||||
|
from __future__ import print_function
|
||||||
import urllib
|
import urllib
|
||||||
import hashlib
|
import hashlib
|
||||||
|
|
||||||
@ -120,7 +121,7 @@ class LbankApi(object):
|
|||||||
# 请求成功
|
# 请求成功
|
||||||
else:
|
else:
|
||||||
if self.DEBUG:
|
if self.DEBUG:
|
||||||
print callback.__name__
|
print(callback.__name__)
|
||||||
callback(data, req, reqID)
|
callback(data, req, reqID)
|
||||||
|
|
||||||
# 流控等待
|
# 流控等待
|
||||||
@ -149,7 +150,7 @@ class LbankApi(object):
|
|||||||
#----------------------------------------------------------------------
|
#----------------------------------------------------------------------
|
||||||
def onError(self, error, req, reqID):
|
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):
|
def onGetTicker(self, data, req, reqID):
|
||||||
"""查询行情回调"""
|
"""查询行情回调"""
|
||||||
print data, reqID
|
print(data, reqID)
|
||||||
|
|
||||||
# ----------------------------------------------------------------------
|
# ----------------------------------------------------------------------
|
||||||
def onGetDepth(self, data, req, reqID):
|
def onGetDepth(self, data, req, reqID):
|
||||||
"""查询深度回调"""
|
"""查询深度回调"""
|
||||||
print data, reqID
|
print(data, reqID)
|
||||||
|
|
||||||
# ----------------------------------------------------------------------
|
# ----------------------------------------------------------------------
|
||||||
def onGetTrades(self, data, req, reqID):
|
def onGetTrades(self, data, req, reqID):
|
||||||
"""查询历史成交"""
|
"""查询历史成交"""
|
||||||
print data, reqID
|
print(data, reqID)
|
||||||
|
|
||||||
# ----------------------------------------------------------------------
|
# ----------------------------------------------------------------------
|
||||||
def onGetKline(self, data, req, reqID):
|
def onGetKline(self, data, req, reqID):
|
||||||
"""查询K线回报"""
|
"""查询K线回报"""
|
||||||
print data, reqID
|
print(data, reqID)
|
||||||
|
|
||||||
###############################################
|
###############################################
|
||||||
# 交易接口
|
# 交易接口
|
||||||
@ -283,25 +284,25 @@ class LbankApi(object):
|
|||||||
# ----------------------------------------------------------------------
|
# ----------------------------------------------------------------------
|
||||||
def onGetUserInfo(self, data, req, reqID):
|
def onGetUserInfo(self, data, req, reqID):
|
||||||
"""查询账户信息"""
|
"""查询账户信息"""
|
||||||
print data, reqID
|
print(data, reqID)
|
||||||
|
|
||||||
# ----------------------------------------------------------------------
|
# ----------------------------------------------------------------------
|
||||||
def onCreateOrder(self, data, req, reqID):
|
def onCreateOrder(self, data, req, reqID):
|
||||||
"""委托回报"""
|
"""委托回报"""
|
||||||
print data, reqID
|
print(data, reqID)
|
||||||
|
|
||||||
# ----------------------------------------------------------------------
|
# ----------------------------------------------------------------------
|
||||||
def onCancelOrder(self, data, req, reqID):
|
def onCancelOrder(self, data, req, reqID):
|
||||||
"""撤单回报"""
|
"""撤单回报"""
|
||||||
print data, reqID
|
print(data, reqID)
|
||||||
|
|
||||||
# ----------------------------------------------------------------------
|
# ----------------------------------------------------------------------
|
||||||
def onGetOrdersInfo(self, data, req, reqID):
|
def onGetOrdersInfo(self, data, req, reqID):
|
||||||
"""查询委托回报"""
|
"""查询委托回报"""
|
||||||
print data, reqID
|
print(data, reqID)
|
||||||
|
|
||||||
# ----------------------------------------------------------------------
|
# ----------------------------------------------------------------------
|
||||||
def onGetOrdersInfoHistory(self, data, req, reqID):
|
def onGetOrdersInfoHistory(self, data, req, reqID):
|
||||||
"""撤单回报"""
|
"""撤单回报"""
|
||||||
print data, reqID
|
print(data, reqID)
|
||||||
|
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
# encoding: UTF-8
|
# encoding: UTF-8
|
||||||
|
|
||||||
from vnltsmd import MdApi
|
from __future__ import absolute_import
|
||||||
from vnltstd import TdApi
|
from .vnltsmd import MdApi
|
||||||
from vnltsqry import QryApi
|
from .vnltstd import TdApi
|
||||||
from lts_data_type import defineDict
|
from .vnltsqry import QryApi
|
||||||
|
from .lts_data_type import defineDict
|
@ -1,5 +1,6 @@
|
|||||||
# encoding: UTF-8
|
# encoding: UTF-8
|
||||||
|
|
||||||
|
from __future__ import print_function
|
||||||
__author__ = 'CHENXY'
|
__author__ = 'CHENXY'
|
||||||
|
|
||||||
# C++和python类型的映射字典
|
# C++和python类型的映射字典
|
||||||
@ -88,9 +89,9 @@ def main():
|
|||||||
fcpp.close()
|
fcpp.close()
|
||||||
fpy.close()
|
fpy.close()
|
||||||
|
|
||||||
print u'data_type.py生成过程完成'
|
print(u'data_type.py生成过程完成')
|
||||||
except:
|
except:
|
||||||
print u'data_type.py生成过程出错'
|
print(u'data_type.py生成过程出错')
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
# encoding: UTF-8
|
# encoding: UTF-8
|
||||||
|
|
||||||
|
from __future__ import print_function
|
||||||
__author__ = 'CHENXY'
|
__author__ = 'CHENXY'
|
||||||
|
|
||||||
# C++和python类型的映射字典
|
# C++和python类型的映射字典
|
||||||
@ -88,9 +89,9 @@ def main():
|
|||||||
fcpp.close()
|
fcpp.close()
|
||||||
fpy.close()
|
fpy.close()
|
||||||
|
|
||||||
print u'data_type.py生成过程完成'
|
print(u'data_type.py生成过程完成')
|
||||||
except:
|
except:
|
||||||
print u'data_type.py生成过程出错'
|
print(u'data_type.py生成过程出错')
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
# encoding: UTF-8
|
# encoding: UTF-8
|
||||||
|
|
||||||
# 内置模块
|
# 内置模块
|
||||||
|
from __future__ import print_function
|
||||||
import sys
|
import sys
|
||||||
from time import sleep
|
from time import sleep
|
||||||
|
|
||||||
@ -11,15 +12,15 @@ from vnltsmd import *
|
|||||||
def print_dict(d):
|
def print_dict(d):
|
||||||
"""按照键值打印一个字典"""
|
"""按照键值打印一个字典"""
|
||||||
for key,value in d.items():
|
for key,value in d.items():
|
||||||
print key + ':' + str(value)
|
print(key + ':' + str(value))
|
||||||
|
|
||||||
|
|
||||||
#----------------------------------------------------------------------
|
#----------------------------------------------------------------------
|
||||||
def simple_log(func):
|
def simple_log(func):
|
||||||
"""简单装饰器用于输出函数名"""
|
"""简单装饰器用于输出函数名"""
|
||||||
def wrapper(*args, **kw):
|
def wrapper(*args, **kw):
|
||||||
print ""
|
print("")
|
||||||
print str(func.__name__)
|
print(str(func.__name__))
|
||||||
return func(*args, **kw)
|
return func(*args, **kw)
|
||||||
return wrapper
|
return wrapper
|
||||||
|
|
||||||
@ -43,13 +44,13 @@ class TestMdApi(MdApi):
|
|||||||
@simple_log
|
@simple_log
|
||||||
def onFrontDisconnected(self, n):
|
def onFrontDisconnected(self, n):
|
||||||
"""服务器断开"""
|
"""服务器断开"""
|
||||||
print n
|
print(n)
|
||||||
|
|
||||||
#----------------------------------------------------------------------
|
#----------------------------------------------------------------------
|
||||||
@simple_log
|
@simple_log
|
||||||
def onHeartBeatWarning(self, n):
|
def onHeartBeatWarning(self, n):
|
||||||
"""心跳报警"""
|
"""心跳报警"""
|
||||||
print n
|
print(n)
|
||||||
|
|
||||||
#----------------------------------------------------------------------
|
#----------------------------------------------------------------------
|
||||||
@simple_log
|
@simple_log
|
||||||
@ -124,7 +125,7 @@ def main():
|
|||||||
|
|
||||||
#获取交易日,测试通过
|
#获取交易日,测试通过
|
||||||
day = api.getTradingDay()
|
day = api.getTradingDay()
|
||||||
print 'Trading Day is:' + str(day)
|
print('Trading Day is:' + str(day))
|
||||||
sleep(0.5)
|
sleep(0.5)
|
||||||
|
|
||||||
# 订阅合约,测试通过
|
# 订阅合约,测试通过
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
# encoding: UTF-8
|
# encoding: UTF-8
|
||||||
|
|
||||||
# 内置模块
|
# 内置模块
|
||||||
|
from __future__ import print_function
|
||||||
import sys
|
import sys
|
||||||
from time import sleep
|
from time import sleep
|
||||||
|
|
||||||
@ -12,15 +13,15 @@ from lts_data_type import defineDict
|
|||||||
def print_dict(d):
|
def print_dict(d):
|
||||||
"""按照键值打印一个字典"""
|
"""按照键值打印一个字典"""
|
||||||
for key,value in d.items():
|
for key,value in d.items():
|
||||||
print key + ':' + str(value)
|
print(key + ':' + str(value))
|
||||||
|
|
||||||
|
|
||||||
#----------------------------------------------------------------------
|
#----------------------------------------------------------------------
|
||||||
def simple_log(func):
|
def simple_log(func):
|
||||||
"""简单装饰器用于输出函数名"""
|
"""简单装饰器用于输出函数名"""
|
||||||
def wrapper(*args, **kw):
|
def wrapper(*args, **kw):
|
||||||
print ""
|
print("")
|
||||||
print str(func.__name__)
|
print(str(func.__name__))
|
||||||
return func(*args, **kw)
|
return func(*args, **kw)
|
||||||
return wrapper
|
return wrapper
|
||||||
|
|
||||||
@ -44,13 +45,13 @@ class TestQryApi(QryApi):
|
|||||||
@simple_log
|
@simple_log
|
||||||
def onFrontDisconnected(self, n):
|
def onFrontDisconnected(self, n):
|
||||||
"""服务器断开"""
|
"""服务器断开"""
|
||||||
print n
|
print(n)
|
||||||
|
|
||||||
#----------------------------------------------------------------------
|
#----------------------------------------------------------------------
|
||||||
@simple_log
|
@simple_log
|
||||||
def onHeartBeatWarning(self, n):
|
def onHeartBeatWarning(self, n):
|
||||||
"""心跳报警"""
|
"""心跳报警"""
|
||||||
print n
|
print(n)
|
||||||
|
|
||||||
#----------------------------------------------------------------------
|
#----------------------------------------------------------------------
|
||||||
@simple_log
|
@simple_log
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
# encoding: UTF-8
|
# encoding: UTF-8
|
||||||
|
|
||||||
# 内置模块
|
# 内置模块
|
||||||
|
from __future__ import print_function
|
||||||
import sys
|
import sys
|
||||||
from time import sleep
|
from time import sleep
|
||||||
|
|
||||||
@ -12,15 +13,15 @@ from lts_data_type import defineDict
|
|||||||
def print_dict(d):
|
def print_dict(d):
|
||||||
"""按照键值打印一个字典"""
|
"""按照键值打印一个字典"""
|
||||||
for key,value in d.items():
|
for key,value in d.items():
|
||||||
print key + ':' + str(value)
|
print(key + ':' + str(value))
|
||||||
|
|
||||||
|
|
||||||
#----------------------------------------------------------------------
|
#----------------------------------------------------------------------
|
||||||
def simple_log(func):
|
def simple_log(func):
|
||||||
"""简单装饰器用于输出函数名"""
|
"""简单装饰器用于输出函数名"""
|
||||||
def wrapper(*args, **kw):
|
def wrapper(*args, **kw):
|
||||||
print ""
|
print("")
|
||||||
print str(func.__name__)
|
print(str(func.__name__))
|
||||||
return func(*args, **kw)
|
return func(*args, **kw)
|
||||||
return wrapper
|
return wrapper
|
||||||
|
|
||||||
@ -44,13 +45,13 @@ class TestTdApi(TdApi):
|
|||||||
@simple_log
|
@simple_log
|
||||||
def onFrontDisconnected(self, n):
|
def onFrontDisconnected(self, n):
|
||||||
"""服务器断开"""
|
"""服务器断开"""
|
||||||
print n
|
print(n)
|
||||||
|
|
||||||
#----------------------------------------------------------------------
|
#----------------------------------------------------------------------
|
||||||
@simple_log
|
@simple_log
|
||||||
def onHeartBeatWarning(self, n):
|
def onHeartBeatWarning(self, n):
|
||||||
"""心跳报警"""
|
"""心跳报警"""
|
||||||
print n
|
print(n)
|
||||||
|
|
||||||
#----------------------------------------------------------------------
|
#----------------------------------------------------------------------
|
||||||
@simple_log
|
@simple_log
|
||||||
|
Loading…
Reference in New Issue
Block a user