[Mod]修改原链行接口为新的LBANK接口
This commit is contained in:
parent
20bae552d6
commit
325bc05947
@ -1,16 +1,16 @@
|
||||
# vn.lhang
|
||||
# vn.lbank
|
||||
|
||||
### 简介
|
||||
|
||||
链行的比特币交易接口,基于Rest API开发。
|
||||
LBank的比特币交易接口,基于Rest API开发。
|
||||
|
||||
### 特点
|
||||
vn.lhang的一些特点:
|
||||
该接口的一些特点:
|
||||
|
||||
1. 面向对象的API设计,接近CTP API的结构,对于国内用户而言更容易上手
|
||||
|
||||
2. 参考CTP API的设计,主动函数调用的结果通过异步(回调函数)的方式推送到程序中,适用于开发稳定可靠的实盘交易程序
|
||||
|
||||
### API版本
|
||||
日期:2017 - 02
|
||||
日期:2017 - 12
|
||||
来源:链行官方API交流群 325248096
|
3
vnpy/api/lbank/__init__.py
Normal file
3
vnpy/api/lbank/__init__.py
Normal file
@ -0,0 +1,3 @@
|
||||
# encoding: UTF-8
|
||||
|
||||
from vnlbank import LbankApi
|
@ -2,7 +2,7 @@
|
||||
|
||||
from time import time, sleep
|
||||
|
||||
from vnlhang import LhangApi
|
||||
from vnlbank import LbankApi
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
@ -10,7 +10,7 @@ if __name__ == '__main__':
|
||||
secretKey = ''
|
||||
|
||||
# 创建API对象并初始化
|
||||
api = LhangApi()
|
||||
api = LbankApi()
|
||||
api.DEBUG = True
|
||||
api.init(apiKey, secretKey, 2)
|
||||
|
@ -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_DEPTH = ('depth.do', 'get')
|
||||
@ -40,7 +40,7 @@ def signature(params, secretKey):
|
||||
|
||||
|
||||
########################################################################
|
||||
class LhangApi(object):
|
||||
class LbankApi(object):
|
||||
""""""
|
||||
DEBUG = True
|
||||
|
||||
@ -80,7 +80,7 @@ class LhangApi(object):
|
||||
# 读取方法和参数
|
||||
api, method = req['function']
|
||||
params = req['params']
|
||||
url = LHANG_API_ROOT + api
|
||||
url = API_ROOT + api
|
||||
|
||||
# 在参数中增加必须的字段
|
||||
params['api_key'] = self.apiKey
|
@ -1,3 +0,0 @@
|
||||
# encoding: UTF-8
|
||||
|
||||
from vnlhang import LhangApi
|
@ -164,7 +164,6 @@ class AnalysisManager(QtWidgets.QWidget):
|
||||
|
||||
for priceChange in priceChangeArray:
|
||||
for impvChange in impvChangeArray:
|
||||
print priceChange, impvChange
|
||||
portfolioPnl = 0
|
||||
portfolioDelta = 0
|
||||
portfolioGamma = 0
|
||||
|
@ -1,10 +1,10 @@
|
||||
# encoding: UTF-8
|
||||
|
||||
from vnpy.trader import vtConstant
|
||||
from lhangGateway import LhangGateway
|
||||
from lbankGateway import LbankGateway
|
||||
|
||||
gatewayClass = LhangGateway
|
||||
gatewayName = 'LHANG'
|
||||
gatewayDisplayName = u'链行'
|
||||
gatewayClass = lbankGateway
|
||||
gatewayName = 'LBANK'
|
||||
gatewayDisplayName = u'LBANK'
|
||||
gatewayType = vtConstant.GATEWAYTYPE_BTC
|
||||
gatewayQryEnabled = True
|
@ -10,7 +10,7 @@ import json
|
||||
from datetime import datetime
|
||||
from time import sleep
|
||||
|
||||
from vnpy.api.lhang import LhangApi
|
||||
from vnpy.api.lbank import LbankApi
|
||||
from vnpy.trader.vtGateway import *
|
||||
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"""
|
||||
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.filePath = getJsonPath(self.fileName, __file__)
|
||||
@ -150,13 +150,13 @@ class LhangGateway(VtGateway):
|
||||
|
||||
|
||||
########################################################################
|
||||
class LhangApi(LhangApi):
|
||||
class LbankApi(LbankApi):
|
||||
""""""
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
def __init__(self, gateway):
|
||||
"""Constructor"""
|
||||
super(LhangApi, self).__init__()
|
||||
super(LbankApi, self).__init__()
|
||||
|
||||
self.gateway = gateway
|
||||
self.gatewayName = gateway.gatewayName
|
Loading…
Reference in New Issue
Block a user