[Mod]修改原链行接口为新的LBANK接口

This commit is contained in:
vn.py 2017-12-01 22:20:05 +08:00
parent 20bae552d6
commit 325bc05947
9 changed files with 23 additions and 24 deletions

View File

@ -1,16 +1,16 @@
# vn.lhang # vn.lbank
### 简介 ### 简介
链行的比特币交易接口基于Rest API开发。 LBank的比特币交易接口基于Rest API开发。
### 特点 ### 特点
vn.lhang的一些特点: 该接口的一些特点:
1. 面向对象的API设计接近CTP API的结构对于国内用户而言更容易上手 1. 面向对象的API设计接近CTP API的结构对于国内用户而言更容易上手
2. 参考CTP API的设计主动函数调用的结果通过异步回调函数的方式推送到程序中适用于开发稳定可靠的实盘交易程序 2. 参考CTP API的设计主动函数调用的结果通过异步回调函数的方式推送到程序中适用于开发稳定可靠的实盘交易程序
### API版本 ### API版本
日期2017 - 02 日期2017 - 12
来源链行官方API交流群 325248096 来源链行官方API交流群 325248096

View File

@ -0,0 +1,3 @@
# encoding: UTF-8
from vnlbank import LbankApi

View File

@ -2,7 +2,7 @@
from time import time, sleep from time import time, sleep
from vnlhang import LhangApi from vnlbank import LbankApi
if __name__ == '__main__': if __name__ == '__main__':
@ -10,7 +10,7 @@ if __name__ == '__main__':
secretKey = '' secretKey = ''
# 创建API对象并初始化 # 创建API对象并初始化
api = LhangApi() api = LbankApi()
api.DEBUG = True api.DEBUG = True
api.init(apiKey, secretKey, 2) api.init(apiKey, secretKey, 2)

View File

@ -10,7 +10,7 @@ from time import sleep
LHANG_API_ROOT ="https://api.lhang.com/v1/" API_ROOT ="https://api.lbank.info/v1/"
FUNCTION_TICKER = ('ticker.do', 'get') FUNCTION_TICKER = ('ticker.do', 'get')
FUNCTION_DEPTH = ('depth.do', 'get') FUNCTION_DEPTH = ('depth.do', 'get')
@ -40,7 +40,7 @@ def signature(params, secretKey):
######################################################################## ########################################################################
class LhangApi(object): class LbankApi(object):
"""""" """"""
DEBUG = True DEBUG = True
@ -80,7 +80,7 @@ class LhangApi(object):
# 读取方法和参数 # 读取方法和参数
api, method = req['function'] api, method = req['function']
params = req['params'] params = req['params']
url = LHANG_API_ROOT + api url = API_ROOT + api
# 在参数中增加必须的字段 # 在参数中增加必须的字段
params['api_key'] = self.apiKey params['api_key'] = self.apiKey

View File

@ -1,3 +0,0 @@
# encoding: UTF-8
from vnlhang import LhangApi

View File

@ -164,7 +164,6 @@ class AnalysisManager(QtWidgets.QWidget):
for priceChange in priceChangeArray: for priceChange in priceChangeArray:
for impvChange in impvChangeArray: for impvChange in impvChangeArray:
print priceChange, impvChange
portfolioPnl = 0 portfolioPnl = 0
portfolioDelta = 0 portfolioDelta = 0
portfolioGamma = 0 portfolioGamma = 0

View File

@ -1,10 +1,10 @@
# encoding: UTF-8 # encoding: UTF-8
from vnpy.trader import vtConstant from vnpy.trader import vtConstant
from lhangGateway import LhangGateway from lbankGateway import LbankGateway
gatewayClass = LhangGateway gatewayClass = lbankGateway
gatewayName = 'LHANG' gatewayName = 'LBANK'
gatewayDisplayName = u'链行' gatewayDisplayName = u'LBANK'
gatewayType = vtConstant.GATEWAYTYPE_BTC gatewayType = vtConstant.GATEWAYTYPE_BTC
gatewayQryEnabled = True gatewayQryEnabled = True

View File

@ -10,7 +10,7 @@ import json
from datetime import datetime from datetime import datetime
from time import sleep from time import sleep
from vnpy.api.lhang import LhangApi from vnpy.api.lbank import LbankApi
from vnpy.trader.vtGateway import * from vnpy.trader.vtGateway import *
from vnpy.trader.vtFunction import getJsonPath from vnpy.trader.vtFunction import getJsonPath
@ -37,15 +37,15 @@ STATUS_MAP[-1] = STATUS_CANCELLED
######################################################################## ########################################################################
class LhangGateway(VtGateway): class LbankGateway(VtGateway):
"""链行接口""" """链行接口"""
#---------------------------------------------------------------------- #----------------------------------------------------------------------
def __init__(self, eventEngine, gatewayName='LHANG'): def __init__(self, eventEngine, gatewayName='LBANK'):
"""Constructor""" """Constructor"""
super(LhangGateway, self).__init__(eventEngine, gatewayName) super(LbankGateway, self).__init__(eventEngine, gatewayName)
self.api = LhangApi(self) self.api = LbankApi(self)
self.fileName = self.gatewayName + '_connect.json' self.fileName = self.gatewayName + '_connect.json'
self.filePath = getJsonPath(self.fileName, __file__) self.filePath = getJsonPath(self.fileName, __file__)
@ -150,13 +150,13 @@ class LhangGateway(VtGateway):
######################################################################## ########################################################################
class LhangApi(LhangApi): class LbankApi(LbankApi):
"""""" """"""
#---------------------------------------------------------------------- #----------------------------------------------------------------------
def __init__(self, gateway): def __init__(self, gateway):
"""Constructor""" """Constructor"""
super(LhangApi, self).__init__() super(LbankApi, self).__init__()
self.gateway = gateway self.gateway = gateway
self.gatewayName = gateway.gatewayName self.gatewayName = gateway.gatewayName