Modernize vnpy/trader/gateway
This commit is contained in:
parent
29eb606e1c
commit
314dece44b
@ -1,7 +1,8 @@
|
|||||||
# encoding: UTF-8
|
# encoding: UTF-8
|
||||||
|
|
||||||
|
from __future__ import absolute_import
|
||||||
from vnpy.trader import vtConstant
|
from vnpy.trader import vtConstant
|
||||||
from cshshlpGateway import CshshlpGateway
|
from .cshshlpGateway import CshshlpGateway
|
||||||
|
|
||||||
gatewayClass = CshshlpGateway
|
gatewayClass = CshshlpGateway
|
||||||
gatewayName = 'CSHSHLP'
|
gatewayName = 'CSHSHLP'
|
||||||
|
@ -1,7 +1,8 @@
|
|||||||
# encoding: UTF-8
|
# encoding: UTF-8
|
||||||
|
|
||||||
|
from __future__ import absolute_import
|
||||||
from vnpy.trader import vtConstant
|
from vnpy.trader import vtConstant
|
||||||
from ctpGateway import CtpGateway
|
from .ctpGateway import CtpGateway
|
||||||
|
|
||||||
gatewayClass = CtpGateway
|
gatewayClass = CtpGateway
|
||||||
gatewayName = 'CTP'
|
gatewayName = 'CTP'
|
||||||
|
@ -1,15 +1,16 @@
|
|||||||
# encoding: UTF-8
|
# encoding: UTF-8
|
||||||
|
|
||||||
|
from __future__ import absolute_import
|
||||||
import json
|
import json
|
||||||
import os
|
import os
|
||||||
import traceback
|
import traceback
|
||||||
|
|
||||||
# 默认设置
|
# 默认设置
|
||||||
from chinese import text
|
from .chinese import text
|
||||||
|
|
||||||
# 获取全局配置
|
# 获取全局配置
|
||||||
from vnpy.trader.vtGlobal import globalSetting
|
from vnpy.trader.vtGlobal import globalSetting
|
||||||
|
|
||||||
# 打开配置文件,读取语言配置
|
# 打开配置文件,读取语言配置
|
||||||
if globalSetting['language'] == 'english':
|
if globalSetting['language'] == 'english':
|
||||||
from english import text
|
from .english import text
|
||||||
|
@ -1,7 +1,8 @@
|
|||||||
# encoding: UTF-8
|
# encoding: UTF-8
|
||||||
|
|
||||||
|
from __future__ import absolute_import
|
||||||
from vnpy.trader import vtConstant
|
from vnpy.trader import vtConstant
|
||||||
from femasGateway import FemasGateway
|
from .femasGateway import FemasGateway
|
||||||
|
|
||||||
gatewayClass = FemasGateway
|
gatewayClass = FemasGateway
|
||||||
gatewayName = 'FEMAS'
|
gatewayName = 'FEMAS'
|
||||||
|
@ -5,6 +5,7 @@ vn.femas的gateway接入
|
|||||||
|
|
||||||
考虑到飞马只对接期货(目前只有中金所), vtSymbol直接使用symbol
|
考虑到飞马只对接期货(目前只有中金所), vtSymbol直接使用symbol
|
||||||
'''
|
'''
|
||||||
|
from __future__ import print_function
|
||||||
|
|
||||||
|
|
||||||
import os
|
import os
|
||||||
@ -599,10 +600,10 @@ class FemasTdApi(TdApi):
|
|||||||
# 如果登录成功,推送日志信息
|
# 如果登录成功,推送日志信息
|
||||||
if error['ErrorID'] == 0:
|
if error['ErrorID'] == 0:
|
||||||
for k, v in data.items():
|
for k, v in data.items():
|
||||||
print k, ':', v
|
print(k, ':', v)
|
||||||
if data['MaxOrderLocalID']:
|
if data['MaxOrderLocalID']:
|
||||||
self.localID = int(data['MaxOrderLocalID']) # 目前最大本地报单号
|
self.localID = int(data['MaxOrderLocalID']) # 目前最大本地报单号
|
||||||
print 'id now', self.localID
|
print('id now', self.localID)
|
||||||
|
|
||||||
self.loginStatus = True
|
self.loginStatus = True
|
||||||
self.gateway.mdConnected = True
|
self.gateway.mdConnected = True
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
# encoding: UTF-8
|
# encoding: UTF-8
|
||||||
|
|
||||||
|
from __future__ import absolute_import
|
||||||
from vnpy.trader import vtConstant
|
from vnpy.trader import vtConstant
|
||||||
from .futuGateway import FutuGateway
|
from .futuGateway import FutuGateway
|
||||||
|
|
||||||
|
@ -1,7 +1,8 @@
|
|||||||
# encoding: UTF-8
|
# encoding: UTF-8
|
||||||
|
|
||||||
|
from __future__ import absolute_import
|
||||||
from vnpy.trader import vtConstant
|
from vnpy.trader import vtConstant
|
||||||
from fxcmGateway import FxcmGateway
|
from .fxcmGateway import FxcmGateway
|
||||||
|
|
||||||
gatewayClass = FxcmGateway
|
gatewayClass = FxcmGateway
|
||||||
gatewayName = 'FXCM'
|
gatewayName = 'FXCM'
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
# encoding: UTF-8
|
# encoding: UTF-8
|
||||||
|
|
||||||
|
from __future__ import print_function
|
||||||
import os
|
import os
|
||||||
import json
|
import json
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
@ -434,22 +435,22 @@ class Api(FxcmApi):
|
|||||||
#----------------------------------------------------------------------
|
#----------------------------------------------------------------------
|
||||||
def onOpenTrade(self, data, reqid):
|
def onOpenTrade(self, data, reqid):
|
||||||
"""开仓回调"""
|
"""开仓回调"""
|
||||||
print data, reqid
|
print(data, reqid)
|
||||||
|
|
||||||
#----------------------------------------------------------------------
|
#----------------------------------------------------------------------
|
||||||
def onCloseTrade(self, data, reqid):
|
def onCloseTrade(self, data, reqid):
|
||||||
"""平仓回调"""
|
"""平仓回调"""
|
||||||
print data, reqid
|
print(data, reqid)
|
||||||
|
|
||||||
#----------------------------------------------------------------------
|
#----------------------------------------------------------------------
|
||||||
def onChangeOrder(self, data, reqid):
|
def onChangeOrder(self, data, reqid):
|
||||||
"""改单回调"""
|
"""改单回调"""
|
||||||
print data, reqid
|
print(data, reqid)
|
||||||
|
|
||||||
#----------------------------------------------------------------------
|
#----------------------------------------------------------------------
|
||||||
def onDeleteOrder(self, data, reqid):
|
def onDeleteOrder(self, data, reqid):
|
||||||
"""撤单回调"""
|
"""撤单回调"""
|
||||||
print data, reqid
|
print(data, reqid)
|
||||||
|
|
||||||
#----------------------------------------------------------------------
|
#----------------------------------------------------------------------
|
||||||
def onPriceUpdate(self, data):
|
def onPriceUpdate(self, data):
|
||||||
|
@ -1,7 +1,8 @@
|
|||||||
# encoding: UTF-8
|
# encoding: UTF-8
|
||||||
|
|
||||||
|
from __future__ import absolute_import
|
||||||
from vnpy.trader import vtConstant
|
from vnpy.trader import vtConstant
|
||||||
from huobiGateway import HuobiGateway
|
from .huobiGateway import HuobiGateway
|
||||||
|
|
||||||
gatewayClass = HuobiGateway
|
gatewayClass = HuobiGateway
|
||||||
gatewayName = 'HUOBI'
|
gatewayName = 'HUOBI'
|
||||||
|
@ -3,8 +3,8 @@
|
|||||||
'''
|
'''
|
||||||
vn.sec的gateway接入
|
vn.sec的gateway接入
|
||||||
'''
|
'''
|
||||||
|
from __future__ import print_function
|
||||||
|
|
||||||
import os
|
|
||||||
import json
|
import json
|
||||||
from datetime import datetime, timedelta
|
from datetime import datetime, timedelta
|
||||||
from copy import copy
|
from copy import copy
|
||||||
@ -12,7 +12,7 @@ from math import pow
|
|||||||
|
|
||||||
from vnpy.api.huobi import TradeApi, DataApi
|
from vnpy.api.huobi import TradeApi, DataApi
|
||||||
from vnpy.trader.vtGateway import *
|
from vnpy.trader.vtGateway import *
|
||||||
from vnpy.trader.vtFunction import getJsonPath, getTempPath
|
from vnpy.trader.vtFunction import getJsonPath
|
||||||
|
|
||||||
|
|
||||||
# 委托状态类型映射
|
# 委托状态类型映射
|
||||||
@ -29,11 +29,9 @@ statusMapReverse['canceled'] = STATUS_CANCELLED
|
|||||||
#----------------------------------------------------------------------
|
#----------------------------------------------------------------------
|
||||||
def print_dict(d):
|
def print_dict(d):
|
||||||
""""""
|
""""""
|
||||||
print '-' * 30
|
print('-' * 30)
|
||||||
l = d.keys()
|
for key in sorted(d):
|
||||||
l.sort()
|
print('%s:%s' % (key, d[key]))
|
||||||
for k in l:
|
|
||||||
print '%s:%s' %(k, d[k])
|
|
||||||
|
|
||||||
|
|
||||||
########################################################################
|
########################################################################
|
||||||
@ -60,7 +58,7 @@ class HuobiGateway(VtGateway):
|
|||||||
def connect(self):
|
def connect(self):
|
||||||
"""连接"""
|
"""连接"""
|
||||||
try:
|
try:
|
||||||
f = file(self.filePath)
|
f = open(self.filePath)
|
||||||
except IOError:
|
except IOError:
|
||||||
log = VtLogData()
|
log = VtLogData()
|
||||||
log.gatewayName = self.gatewayName
|
log.gatewayName = self.gatewayName
|
||||||
@ -294,7 +292,7 @@ class HuobiDataApi(DataApi):
|
|||||||
#----------------------------------------------------------------------
|
#----------------------------------------------------------------------
|
||||||
def onTradeDetail(self, data):
|
def onTradeDetail(self, data):
|
||||||
"""成交细节推送"""
|
"""成交细节推送"""
|
||||||
print data
|
print(data)
|
||||||
|
|
||||||
#----------------------------------------------------------------------
|
#----------------------------------------------------------------------
|
||||||
def onMarketDetail(self, data):
|
def onMarketDetail(self, data):
|
||||||
@ -322,7 +320,6 @@ class HuobiDataApi(DataApi):
|
|||||||
self.gateway.onTick(tick)
|
self.gateway.onTick(tick)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
########################################################################
|
########################################################################
|
||||||
class HuobiTradeApi(TradeApi):
|
class HuobiTradeApi(TradeApi):
|
||||||
"""交易API实现"""
|
"""交易API实现"""
|
||||||
@ -693,7 +690,7 @@ class HuobiTradeApi(TradeApi):
|
|||||||
#----------------------------------------------------------------------
|
#----------------------------------------------------------------------
|
||||||
def onGetMatchResult(self, data, reqid):
|
def onGetMatchResult(self, data, reqid):
|
||||||
"""查询单一成交回调"""
|
"""查询单一成交回调"""
|
||||||
print reqid, data
|
print(reqid, data)
|
||||||
|
|
||||||
#----------------------------------------------------------------------
|
#----------------------------------------------------------------------
|
||||||
def onPlaceOrder(self, data, reqid):
|
def onPlaceOrder(self, data, reqid):
|
||||||
@ -717,4 +714,4 @@ class HuobiTradeApi(TradeApi):
|
|||||||
#----------------------------------------------------------------------
|
#----------------------------------------------------------------------
|
||||||
def onBatchCancel(self, data, reqid):
|
def onBatchCancel(self, data, reqid):
|
||||||
"""批量撤单回调"""
|
"""批量撤单回调"""
|
||||||
print reqid, data
|
print(reqid, data)
|
||||||
|
@ -1,7 +1,8 @@
|
|||||||
# encoding: UTF-8
|
# encoding: UTF-8
|
||||||
|
|
||||||
|
from __future__ import absolute_import
|
||||||
from vnpy.trader import vtConstant
|
from vnpy.trader import vtConstant
|
||||||
from ibGateway import IbGateway
|
from .ibGateway import IbGateway
|
||||||
|
|
||||||
gatewayClass = IbGateway
|
gatewayClass = IbGateway
|
||||||
gatewayName = 'IB'
|
gatewayName = 'IB'
|
||||||
|
@ -10,6 +10,7 @@ Interactive Brokers的gateway接入,已经替换为vn.ib封装。
|
|||||||
4. 目前只支持股票和期货交易,ib api里期权合约的确定是基于Contract对象的多个字段,比较复杂暂时没做
|
4. 目前只支持股票和期货交易,ib api里期权合约的确定是基于Contract对象的多个字段,比较复杂暂时没做
|
||||||
5. 海外市场的交易规则和国内有很多细节上的不同,所以一些字段类型的映射可能不合理,如果发现问题欢迎指出
|
5. 海外市场的交易规则和国内有很多细节上的不同,所以一些字段类型的映射可能不合理,如果发现问题欢迎指出
|
||||||
'''
|
'''
|
||||||
|
from __future__ import print_function
|
||||||
|
|
||||||
import os
|
import os
|
||||||
import json
|
import json
|
||||||
@ -375,7 +376,7 @@ class IbWrapper(IbApi):
|
|||||||
newtick = copy(tick)
|
newtick = copy(tick)
|
||||||
self.gateway.onTick(newtick)
|
self.gateway.onTick(newtick)
|
||||||
else:
|
else:
|
||||||
print field
|
print(field)
|
||||||
|
|
||||||
#----------------------------------------------------------------------
|
#----------------------------------------------------------------------
|
||||||
def tickSize(self, tickerId, field, size):
|
def tickSize(self, tickerId, field, size):
|
||||||
@ -385,7 +386,7 @@ class IbWrapper(IbApi):
|
|||||||
key = tickFieldMap[field]
|
key = tickFieldMap[field]
|
||||||
tick.__setattr__(key, size)
|
tick.__setattr__(key, size)
|
||||||
else:
|
else:
|
||||||
print field
|
print(field)
|
||||||
|
|
||||||
#----------------------------------------------------------------------
|
#----------------------------------------------------------------------
|
||||||
def tickOptionComputation(self, tickerId, tickType, impliedVol, delta, optPrice, pvDividend, gamma, vega, theta, undPrice):
|
def tickOptionComputation(self, tickerId, tickType, impliedVol, delta, optPrice, pvDividend, gamma, vega, theta, undPrice):
|
||||||
|
@ -1,11 +1,12 @@
|
|||||||
# encoding: UTF-8
|
# encoding: UTF-8
|
||||||
|
|
||||||
|
from __future__ import absolute_import
|
||||||
import json
|
import json
|
||||||
import os
|
import os
|
||||||
import traceback
|
import traceback
|
||||||
|
|
||||||
# 默认设置
|
# 默认设置
|
||||||
from chinese import text
|
from .chinese import text
|
||||||
|
|
||||||
# 获取目录上级路径
|
# 获取目录上级路径
|
||||||
path = os.path.abspath(os.path.join(os.path.dirname(__file__), '..', '..', '..'))
|
path = os.path.abspath(os.path.join(os.path.dirname(__file__), '..', '..', '..'))
|
||||||
@ -14,10 +15,9 @@ SETTING_FILENAME = os.path.join(path, SETTING_FILENAME)
|
|||||||
|
|
||||||
# 打开配置文件,读取语言配置
|
# 打开配置文件,读取语言配置
|
||||||
try:
|
try:
|
||||||
f = file(SETTING_FILENAME)
|
with open(SETTING_FILENAME) as f:
|
||||||
setting = json.load(f)
|
setting = json.load(f)
|
||||||
if setting['language'] == 'english':
|
if setting['language'] == 'english':
|
||||||
from english import text
|
from .english import text
|
||||||
f.close()
|
except Exception:
|
||||||
except:
|
|
||||||
traceback.print_exc()
|
traceback.print_exc()
|
||||||
|
@ -1,7 +1,8 @@
|
|||||||
# encoding: UTF-8
|
# encoding: UTF-8
|
||||||
|
|
||||||
|
from __future__ import absolute_import
|
||||||
from vnpy.trader import vtConstant
|
from vnpy.trader import vtConstant
|
||||||
from ksgoldGateway import KsgoldGateway
|
from .ksgoldGateway import KsgoldGateway
|
||||||
|
|
||||||
gatewayClass = KsgoldGateway
|
gatewayClass = KsgoldGateway
|
||||||
gatewayName = 'KSGOLD'
|
gatewayName = 'KSGOLD'
|
||||||
|
@ -1,7 +1,8 @@
|
|||||||
# encoding: UTF-8
|
# encoding: UTF-8
|
||||||
|
|
||||||
|
from __future__ import absolute_import
|
||||||
from vnpy.trader import vtConstant
|
from vnpy.trader import vtConstant
|
||||||
from ksotpGateway import KsotpGateway
|
from .ksotpGateway import KsotpGateway
|
||||||
|
|
||||||
gatewayClass = KsotpGateway
|
gatewayClass = KsotpGateway
|
||||||
gatewayName = 'KSOTP'
|
gatewayName = 'KSOTP'
|
||||||
|
@ -1,7 +1,8 @@
|
|||||||
# encoding: UTF-8
|
# encoding: UTF-8
|
||||||
|
|
||||||
|
from __future__ import absolute_import
|
||||||
from vnpy.trader import vtConstant
|
from vnpy.trader import vtConstant
|
||||||
from lbankGateway import LbankGateway
|
from .lbankGateway import LbankGateway
|
||||||
|
|
||||||
gatewayClass = LbankGateway
|
gatewayClass = LbankGateway
|
||||||
gatewayName = 'LBANK'
|
gatewayName = 'LBANK'
|
||||||
|
@ -3,6 +3,7 @@
|
|||||||
'''
|
'''
|
||||||
vn.lhang的gateway接入
|
vn.lhang的gateway接入
|
||||||
'''
|
'''
|
||||||
|
from __future__ import print_function
|
||||||
|
|
||||||
|
|
||||||
import os
|
import os
|
||||||
@ -244,11 +245,11 @@ class LbankApi(LbankApi):
|
|||||||
# ----------------------------------------------------------------------
|
# ----------------------------------------------------------------------
|
||||||
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):
|
||||||
print data, reqID
|
print(data, reqID)
|
||||||
|
|
||||||
# ----------------------------------------------------------------------
|
# ----------------------------------------------------------------------
|
||||||
def onGetUserInfo(self, data, req, reqID):
|
def onGetUserInfo(self, data, req, reqID):
|
||||||
|
@ -1,7 +1,8 @@
|
|||||||
# encoding: UTF-8
|
# encoding: UTF-8
|
||||||
|
|
||||||
|
from __future__ import absolute_import
|
||||||
from vnpy.trader import vtConstant
|
from vnpy.trader import vtConstant
|
||||||
from ltsGateway import LtsGateway
|
from .ltsGateway import LtsGateway
|
||||||
|
|
||||||
gatewayClass = LtsGateway
|
gatewayClass = LtsGateway
|
||||||
gatewayName = 'LTS'
|
gatewayName = 'LTS'
|
||||||
|
@ -3,6 +3,7 @@
|
|||||||
'''
|
'''
|
||||||
vn.lts的gateway接入
|
vn.lts的gateway接入
|
||||||
'''
|
'''
|
||||||
|
from __future__ import print_function
|
||||||
|
|
||||||
import os
|
import os
|
||||||
import json
|
import json
|
||||||
@ -980,7 +981,7 @@ class LtsQryApi(QryApi):
|
|||||||
elif data['ProductClass'] == '8':
|
elif data['ProductClass'] == '8':
|
||||||
contract.productClass = PRODUCT_EQUITY
|
contract.productClass = PRODUCT_EQUITY
|
||||||
else:
|
else:
|
||||||
print data['ProductClass']
|
print(data['ProductClass'])
|
||||||
|
|
||||||
# 期权类型
|
# 期权类型
|
||||||
if data['InstrumentType'] == '1':
|
if data['InstrumentType'] == '1':
|
||||||
|
@ -1,7 +1,8 @@
|
|||||||
# encoding: UTF-8
|
# encoding: UTF-8
|
||||||
|
|
||||||
|
from __future__ import absolute_import
|
||||||
from vnpy.trader import vtConstant
|
from vnpy.trader import vtConstant
|
||||||
from oandaGateway import OandaGateway
|
from .oandaGateway import OandaGateway
|
||||||
|
|
||||||
gatewayClass = OandaGateway
|
gatewayClass = OandaGateway
|
||||||
gatewayName = 'OANDA'
|
gatewayName = 'OANDA'
|
||||||
|
@ -1,7 +1,8 @@
|
|||||||
# encoding: UTF-8
|
# encoding: UTF-8
|
||||||
|
|
||||||
|
from __future__ import absolute_import
|
||||||
from vnpy.trader import vtConstant
|
from vnpy.trader import vtConstant
|
||||||
from qdpGateway import QdpGateway
|
from .qdpGateway import QdpGateway
|
||||||
|
|
||||||
gatewayClass = QdpGateway
|
gatewayClass = QdpGateway
|
||||||
gatewayName = 'QDP'
|
gatewayName = 'QDP'
|
||||||
|
@ -1,7 +1,8 @@
|
|||||||
# encoding: UTF-8
|
# encoding: UTF-8
|
||||||
|
|
||||||
|
from __future__ import absolute_import
|
||||||
from vnpy.trader import vtConstant
|
from vnpy.trader import vtConstant
|
||||||
from secGateway import SecGateway
|
from .secGateway import SecGateway
|
||||||
|
|
||||||
gatewayClass = SecGateway
|
gatewayClass = SecGateway
|
||||||
gatewayName = 'SEC'
|
gatewayName = 'SEC'
|
||||||
|
@ -3,6 +3,7 @@
|
|||||||
'''
|
'''
|
||||||
vn.sec的gateway接入
|
vn.sec的gateway接入
|
||||||
'''
|
'''
|
||||||
|
from __future__ import print_function
|
||||||
|
|
||||||
import os
|
import os
|
||||||
import json
|
import json
|
||||||
@ -50,11 +51,11 @@ exchangeMapReverse = {v:k for k,v in exchangeMap.items()}
|
|||||||
#----------------------------------------------------------------------
|
#----------------------------------------------------------------------
|
||||||
def print_dict(d):
|
def print_dict(d):
|
||||||
""""""
|
""""""
|
||||||
print '-' * 30
|
print('-' * 30)
|
||||||
l = d.keys()
|
l = d.keys()
|
||||||
l.sort()
|
l.sort()
|
||||||
for k in l:
|
for k in l:
|
||||||
print '%s:%s' %(k, d[k])
|
print('%s:%s' %(k, d[k]))
|
||||||
|
|
||||||
|
|
||||||
########################################################################
|
########################################################################
|
||||||
|
@ -1,7 +1,8 @@
|
|||||||
# encoding: UTF-8
|
# encoding: UTF-8
|
||||||
|
|
||||||
|
from __future__ import absolute_import
|
||||||
from vnpy.trader import vtConstant
|
from vnpy.trader import vtConstant
|
||||||
from sgitGateway import SgitGateway
|
from .sgitGateway import SgitGateway
|
||||||
|
|
||||||
gatewayClass = SgitGateway
|
gatewayClass = SgitGateway
|
||||||
gatewayName = 'SGIT'
|
gatewayName = 'SGIT'
|
||||||
|
@ -1,7 +1,8 @@
|
|||||||
# encoding: UTF-8
|
# encoding: UTF-8
|
||||||
|
|
||||||
|
from __future__ import absolute_import
|
||||||
from vnpy.trader import vtConstant
|
from vnpy.trader import vtConstant
|
||||||
from shzdGateway import ShzdGateway
|
from .shzdGateway import ShzdGateway
|
||||||
|
|
||||||
gatewayClass = ShzdGateway
|
gatewayClass = ShzdGateway
|
||||||
gatewayName = 'SHZD'
|
gatewayName = 'SHZD'
|
||||||
|
@ -8,6 +8,7 @@ vn.shzd的gateway接入
|
|||||||
3. 持仓全部平光后,再次查询时会没有该合约的推送(和CTP不同),为了避免最后平仓
|
3. 持仓全部平光后,再次查询时会没有该合约的推送(和CTP不同),为了避免最后平仓
|
||||||
不更新的情况,使用缓存机制来处理
|
不更新的情况,使用缓存机制来处理
|
||||||
'''
|
'''
|
||||||
|
from __future__ import print_function
|
||||||
|
|
||||||
|
|
||||||
import os
|
import os
|
||||||
@ -721,9 +722,9 @@ class ShzdGatewayApi(ShzdApi):
|
|||||||
#----------------------------------------------------------------------
|
#----------------------------------------------------------------------
|
||||||
def printDict(d):
|
def printDict(d):
|
||||||
"""打印字典"""
|
"""打印字典"""
|
||||||
print '-' * 50
|
print('-' * 50)
|
||||||
l = d.keys()
|
l = d.keys()
|
||||||
l.sort()
|
l.sort()
|
||||||
for k in l:
|
for k in l:
|
||||||
print k, ':', d[k]
|
print(k, ':', d[k])
|
||||||
|
|
@ -570,7 +570,7 @@ class TkproDataApi(object):
|
|||||||
tick.lowerLimit = data['limit_down']
|
tick.lowerLimit = data['limit_down']
|
||||||
|
|
||||||
self.gateway.onTick(tick)
|
self.gateway.onTick(tick)
|
||||||
except Exception, e:
|
except Exception as e:
|
||||||
self.writeLog(u'行情更新失败,错误信息:%s' % str(e))
|
self.writeLog(u'行情更新失败,错误信息:%s' % str(e))
|
||||||
|
|
||||||
#----------------------------------------------------------------------
|
#----------------------------------------------------------------------
|
||||||
|
@ -1,7 +1,8 @@
|
|||||||
# encoding: UTF-8
|
# encoding: UTF-8
|
||||||
|
|
||||||
|
from __future__ import absolute_import
|
||||||
from vnpy.trader import vtConstant
|
from vnpy.trader import vtConstant
|
||||||
from windGateway import WindGateway
|
from .windGateway import WindGateway
|
||||||
|
|
||||||
gatewayClass = WindGateway
|
gatewayClass = WindGateway
|
||||||
gatewayName = 'WIND'
|
gatewayName = 'WIND'
|
||||||
|
@ -3,6 +3,7 @@
|
|||||||
'''
|
'''
|
||||||
Wind Python API的gateway接入
|
Wind Python API的gateway接入
|
||||||
'''
|
'''
|
||||||
|
from __future__ import print_function
|
||||||
|
|
||||||
from copy import copy
|
from copy import copy
|
||||||
|
|
||||||
@ -11,7 +12,7 @@ w = None
|
|||||||
try:
|
try:
|
||||||
from WindPy import w
|
from WindPy import w
|
||||||
except ImportError:
|
except ImportError:
|
||||||
print u'请先安装WindPy接口'
|
print(u'请先安装WindPy接口')
|
||||||
|
|
||||||
from vnpy.trader.vtGateway import *
|
from vnpy.trader.vtGateway import *
|
||||||
|
|
||||||
|
@ -1,7 +1,8 @@
|
|||||||
# encoding: UTF-8
|
# encoding: UTF-8
|
||||||
|
|
||||||
|
from __future__ import absolute_import
|
||||||
from vnpy.trader import vtConstant
|
from vnpy.trader import vtConstant
|
||||||
from xspeedGateway import XspeedGateway
|
from .xspeedGateway import XspeedGateway
|
||||||
|
|
||||||
gatewayClass = XspeedGateway
|
gatewayClass = XspeedGateway
|
||||||
gatewayName = 'XSPEED'
|
gatewayName = 'XSPEED'
|
||||||
|
@ -1,7 +1,8 @@
|
|||||||
# encoding: UTF-8
|
# encoding: UTF-8
|
||||||
|
|
||||||
|
from __future__ import absolute_import
|
||||||
from vnpy.trader import vtConstant
|
from vnpy.trader import vtConstant
|
||||||
from xtpGateway import XtpGateway
|
from .xtpGateway import XtpGateway
|
||||||
|
|
||||||
gatewayClass = XtpGateway
|
gatewayClass = XtpGateway
|
||||||
gatewayName = 'XTP'
|
gatewayName = 'XTP'
|
||||||
|
Loading…
Reference in New Issue
Block a user