实现配置文件优先从当前文件夹加载
This commit is contained in:
parent
065808a0b0
commit
a26cb7e09d
19
examples/CtaTrading/CTA_setting.json
Normal file
19
examples/CtaTrading/CTA_setting.json
Normal file
@ -0,0 +1,19 @@
|
||||
[
|
||||
{
|
||||
"name": "double ema",
|
||||
"className": "EmaDemoStrategy",
|
||||
"vtSymbol": "IF1706"
|
||||
},
|
||||
|
||||
{
|
||||
"name": "atr rsi",
|
||||
"className": "AtrRsiStrategy",
|
||||
"vtSymbol": "IC1706"
|
||||
},
|
||||
|
||||
{
|
||||
"name": "king keltner",
|
||||
"className": "KkStrategy",
|
||||
"vtSymbol": "IH1706"
|
||||
}
|
||||
]
|
7
examples/CtaTrading/CTP_connect.json
Normal file
7
examples/CtaTrading/CTP_connect.json
Normal file
@ -0,0 +1,7 @@
|
||||
{
|
||||
"brokerID": "9999",
|
||||
"mdAddress": "tcp://180.168.146.187:10011",
|
||||
"tdAddress": "tcp://180.168.146.187:10001",
|
||||
"userID": "simnow申请",
|
||||
"password": "simnow申请"
|
||||
}
|
7
examples/DataRecording/CTP_connect.json
Normal file
7
examples/DataRecording/CTP_connect.json
Normal file
@ -0,0 +1,7 @@
|
||||
{
|
||||
"brokerID": "9999",
|
||||
"mdAddress": "tcp://180.168.146.187:10011",
|
||||
"tdAddress": "tcp://180.168.146.187:10001",
|
||||
"userID": "simnow申请",
|
||||
"password": "simnow申请"
|
||||
}
|
18
examples/DataRecording/DR_setting.json
Normal file
18
examples/DataRecording/DR_setting.json
Normal file
@ -0,0 +1,18 @@
|
||||
{
|
||||
"working": true,
|
||||
|
||||
"tick":
|
||||
[
|
||||
],
|
||||
|
||||
"bar":
|
||||
[
|
||||
["BTC_CNY_SPOT", "OKCOIN"],
|
||||
["LTC_CNY_SPOT", "OKCOIN"],
|
||||
["ETH_CNY_SPOT", "OKCOIN"]
|
||||
],
|
||||
|
||||
"active":
|
||||
{
|
||||
}
|
||||
}
|
19
examples/VnTrader/CTA_setting.json
Normal file
19
examples/VnTrader/CTA_setting.json
Normal file
@ -0,0 +1,19 @@
|
||||
[
|
||||
{
|
||||
"name": "double ema",
|
||||
"className": "EmaDemoStrategy",
|
||||
"vtSymbol": "IF1706"
|
||||
},
|
||||
|
||||
{
|
||||
"name": "atr rsi",
|
||||
"className": "AtrRsiStrategy",
|
||||
"vtSymbol": "IC1706"
|
||||
},
|
||||
|
||||
{
|
||||
"name": "king keltner",
|
||||
"className": "KkStrategy",
|
||||
"vtSymbol": "IH1706"
|
||||
}
|
||||
]
|
7
examples/VnTrader/CTP_connect.json
Normal file
7
examples/VnTrader/CTP_connect.json
Normal file
@ -0,0 +1,7 @@
|
||||
{
|
||||
"brokerID": "9999",
|
||||
"mdAddress": "tcp://180.168.146.187:10011",
|
||||
"tdAddress": "tcp://180.168.146.187:10001",
|
||||
"userID": "000300",
|
||||
"password": "19890624"
|
||||
}
|
18
examples/VnTrader/DR_setting.json
Normal file
18
examples/VnTrader/DR_setting.json
Normal file
@ -0,0 +1,18 @@
|
||||
{
|
||||
"working": true,
|
||||
|
||||
"tick":
|
||||
[
|
||||
],
|
||||
|
||||
"bar":
|
||||
[
|
||||
["BTC_CNY_SPOT", "OKCOIN"],
|
||||
["LTC_CNY_SPOT", "OKCOIN"],
|
||||
["ETH_CNY_SPOT", "OKCOIN"]
|
||||
],
|
||||
|
||||
"active":
|
||||
{
|
||||
}
|
||||
}
|
7
examples/VnTrader/FEMAS_connect.json
Normal file
7
examples/VnTrader/FEMAS_connect.json
Normal file
@ -0,0 +1,7 @@
|
||||
{
|
||||
"brokerID": "0110",
|
||||
"tdAddress": "tcp://118.126.16.229:17111",
|
||||
"password": "飞马账户请自行联系期货公司申请",
|
||||
"mdAddress": "tcp://118.126.16.229:17101",
|
||||
"userID": "飞马账户请自行联系期货公司申请"
|
||||
}
|
7
examples/VnTrader/HUOBI_connect.json
Normal file
7
examples/VnTrader/HUOBI_connect.json
Normal file
@ -0,0 +1,7 @@
|
||||
{
|
||||
"accessKey": "火币网站申请",
|
||||
"secretKey": "火币网站申请",
|
||||
"interval": 0.5,
|
||||
"market": "cny",
|
||||
"debug": false
|
||||
}
|
6
examples/VnTrader/IB_connect.json
Normal file
6
examples/VnTrader/IB_connect.json
Normal file
@ -0,0 +1,6 @@
|
||||
{
|
||||
"host": "localhost",
|
||||
"port": 7497,
|
||||
"clientId": 888,
|
||||
"accountCode": "DU545254"
|
||||
}
|
5
examples/VnTrader/OANDA_connect.json
Normal file
5
examples/VnTrader/OANDA_connect.json
Normal file
@ -0,0 +1,5 @@
|
||||
{
|
||||
"token": "请在OANDA网站申请",
|
||||
"accountId": "请在OANDA网站申请",
|
||||
"settingName": "practice"
|
||||
}
|
7
examples/VnTrader/OKCOIN_connect.json
Normal file
7
examples/VnTrader/OKCOIN_connect.json
Normal file
@ -0,0 +1,7 @@
|
||||
{
|
||||
"host": "CNY",
|
||||
"apiKey": "OKCOIN网站申请",
|
||||
"secretKey": "OKCOIN网站申请",
|
||||
"trace": false,
|
||||
"leverage": 20
|
||||
}
|
9
examples/VnTrader/RM_setting.json
Normal file
9
examples/VnTrader/RM_setting.json
Normal file
@ -0,0 +1,9 @@
|
||||
{
|
||||
"orderFlowClear": 1,
|
||||
"orderCancelLimit": 10,
|
||||
"workingOrderLimit": 20,
|
||||
"tradeLimit": 1000,
|
||||
"orderSizeLimit": 100,
|
||||
"active": true,
|
||||
"orderFlowLimit": 50
|
||||
}
|
7
examples/VnTrader/SGIT_connect.json
Normal file
7
examples/VnTrader/SGIT_connect.json
Normal file
@ -0,0 +1,7 @@
|
||||
{
|
||||
"brokerID": "9999",
|
||||
"tdAddress": "tcp://140.206.81.6:37776",
|
||||
"password": "888888",
|
||||
"mdAddress": "tcp://140.206.81.6:37777",
|
||||
"userID": "0600035"
|
||||
}
|
8
examples/VnTrader/SHZD_connect.json
Normal file
8
examples/VnTrader/SHZD_connect.json
Normal file
@ -0,0 +1,8 @@
|
||||
{
|
||||
"frontAddress": "222.73.119.230",
|
||||
"frontPort": 7003,
|
||||
"marketAddress": "222.73.119.230",
|
||||
"marketPort": 9003,
|
||||
"userId": "demo000604",
|
||||
"userPwd": "888888"
|
||||
}
|
85
examples/VnTrader/ST_setting.json
Normal file
85
examples/VnTrader/ST_setting.json
Normal file
@ -0,0 +1,85 @@
|
||||
[
|
||||
{
|
||||
"name": "m.09-01",
|
||||
|
||||
"activeLeg":
|
||||
{
|
||||
"vtSymbol": "m1709",
|
||||
"ratio": 1,
|
||||
"multiplier": 1.0,
|
||||
"payup": 2
|
||||
},
|
||||
|
||||
"passiveLegs": [
|
||||
{
|
||||
"vtSymbol": "m1801",
|
||||
"ratio": -1,
|
||||
"multiplier": -1.0,
|
||||
"payup": 2
|
||||
}
|
||||
]
|
||||
},
|
||||
|
||||
{
|
||||
"name": "IF.07-09",
|
||||
|
||||
"activeLeg":
|
||||
{
|
||||
"vtSymbol": "IF1707",
|
||||
"ratio": 1,
|
||||
"multiplier": 1.0,
|
||||
"payup": 2
|
||||
},
|
||||
|
||||
"passiveLegs": [
|
||||
{
|
||||
"vtSymbol": "IF1709",
|
||||
"ratio": -1,
|
||||
"multiplier": -1.0,
|
||||
"payup": 2
|
||||
}
|
||||
]
|
||||
},
|
||||
|
||||
{
|
||||
"name": "IH.07-09",
|
||||
|
||||
"activeLeg":
|
||||
{
|
||||
"vtSymbol": "IH1707",
|
||||
"ratio": 1,
|
||||
"multiplier": 1.0,
|
||||
"payup": 2
|
||||
},
|
||||
|
||||
"passiveLegs": [
|
||||
{
|
||||
"vtSymbol": "IH1709",
|
||||
"ratio": -1,
|
||||
"multiplier": -1.0,
|
||||
"payup": 2
|
||||
}
|
||||
]
|
||||
},
|
||||
|
||||
{
|
||||
"name": "IC.07-09",
|
||||
|
||||
"activeLeg":
|
||||
{
|
||||
"vtSymbol": "IC1707",
|
||||
"ratio": 1,
|
||||
"multiplier": 1.0,
|
||||
"payup": 2
|
||||
},
|
||||
|
||||
"passiveLegs": [
|
||||
{
|
||||
"vtSymbol": "IC1709",
|
||||
"ratio": -1,
|
||||
"multiplier": -1.0,
|
||||
"payup": 2
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
6
examples/VnTrader/XSPEED_connect.json
Normal file
6
examples/VnTrader/XSPEED_connect.json
Normal file
@ -0,0 +1,6 @@
|
||||
{
|
||||
"tdAddress": "tcp://203.187.171.250:10910",
|
||||
"password": "请联系飞创申请",
|
||||
"mdAddress": "tcp://203.187.171.250:10915",
|
||||
"accountID": "请联系飞创申请"
|
||||
}
|
@ -12,11 +12,9 @@ from vnpy.trader.uiQt import qApp
|
||||
from vnpy.trader.uiMainWindow import MainWindow
|
||||
|
||||
# 加载底层接口
|
||||
# from vnpy.trader.gateway import (ctpGateway, femasGateway, xspeedGateway,
|
||||
# sgitGateway, oandaGateway, ibGateway,
|
||||
# shzdGateway, huobiGateway, okcoinGateway)
|
||||
|
||||
from vnpy.trader.gateway import ( huobiGateway, okcoinGateway)
|
||||
from vnpy.trader.gateway import (ctpGateway, femasGateway, xspeedGateway,
|
||||
sgitGateway, oandaGateway, ibGateway,
|
||||
shzdGateway, huobiGateway, okcoinGateway)
|
||||
|
||||
# 加载上层应用
|
||||
from vnpy.trader.app import (riskManager, ctaStrategy, spreadTrading)
|
||||
@ -32,13 +30,13 @@ def main():
|
||||
me = MainEngine(ee)
|
||||
|
||||
# 添加交易接口
|
||||
# me.addGateway(ctpGateway)
|
||||
# me.addGateway(femasGateway)
|
||||
# me.addGateway(xspeedGateway)
|
||||
# me.addGateway(sgitGateway)
|
||||
# me.addGateway(oandaGateway)
|
||||
# me.addGateway(ibGateway)
|
||||
# me.addGateway(shzdGateway)
|
||||
me.addGateway(ctpGateway)
|
||||
me.addGateway(femasGateway)
|
||||
me.addGateway(xspeedGateway)
|
||||
me.addGateway(sgitGateway)
|
||||
me.addGateway(oandaGateway)
|
||||
me.addGateway(ibGateway)
|
||||
me.addGateway(shzdGateway)
|
||||
me.addGateway(huobiGateway)
|
||||
me.addGateway(okcoinGateway)
|
||||
|
||||
|
@ -29,10 +29,10 @@ from vnpy.trader.vtEvent import *
|
||||
from vnpy.trader.vtConstant import *
|
||||
from vnpy.trader.vtObject import VtTickData, VtBarData
|
||||
from vnpy.trader.vtGateway import VtSubscribeReq, VtOrderReq, VtCancelOrderReq, VtLogData
|
||||
from vnpy.trader.vtFunction import todayDate
|
||||
from vnpy.trader.vtFunction import todayDate, getJsonPath
|
||||
|
||||
from vnpy.trader.app.ctaStrategy.ctaBase import *
|
||||
from vnpy.trader.app.ctaStrategy.strategy import STRATEGY_CLASS
|
||||
from .ctaBase import *
|
||||
from .strategy import STRATEGY_CLASS
|
||||
|
||||
|
||||
|
||||
@ -41,8 +41,7 @@ from vnpy.trader.app.ctaStrategy.strategy import STRATEGY_CLASS
|
||||
class CtaEngine(object):
|
||||
"""CTA策略引擎"""
|
||||
settingFileName = 'CTA_setting.json'
|
||||
path = os.path.abspath(os.path.dirname(__file__))
|
||||
settingFileName = os.path.join(path, settingFileName)
|
||||
settingfilePath = getJsonPath(settingFileName, __file__)
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
def __init__(self, mainEngine, eventEngine):
|
||||
@ -486,7 +485,7 @@ class CtaEngine(object):
|
||||
#----------------------------------------------------------------------
|
||||
def saveSetting(self):
|
||||
"""保存策略配置"""
|
||||
with open(self.settingFileName, 'w') as f:
|
||||
with open(self.settingfilePath, 'w') as f:
|
||||
l = []
|
||||
|
||||
for strategy in self.strategyDict.values():
|
||||
@ -501,7 +500,7 @@ class CtaEngine(object):
|
||||
#----------------------------------------------------------------------
|
||||
def loadSetting(self):
|
||||
"""读取策略配置"""
|
||||
with open(self.settingFileName) as f:
|
||||
with open(self.settingfilePath) as f:
|
||||
l = json.load(f)
|
||||
|
||||
for setting in l:
|
||||
|
@ -17,7 +17,7 @@ from threading import Thread
|
||||
|
||||
from vnpy.event import Event
|
||||
from vnpy.trader.vtEvent import *
|
||||
from vnpy.trader.vtFunction import todayDate
|
||||
from vnpy.trader.vtFunction import todayDate, getJsonPath
|
||||
from vnpy.trader.vtObject import VtSubscribeReq, VtLogData, VtBarData, VtTickData
|
||||
|
||||
from vnpy.trader.app.dataRecorder.drBase import *
|
||||
@ -28,9 +28,8 @@ from vnpy.trader.app.dataRecorder.language import text
|
||||
class DrEngine(object):
|
||||
"""数据记录引擎"""
|
||||
|
||||
settingFileName = 'DR_setting.csv'
|
||||
path = os.path.abspath(os.path.dirname(__file__))
|
||||
settingFileName = os.path.join(path, settingFileName)
|
||||
settingFileName = 'DR_setting.json'
|
||||
settingFilePath = getJsonPath(settingFileName, __file__)
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
def __init__(self, mainEngine, eventEngine):
|
||||
@ -66,49 +65,122 @@ class DrEngine(object):
|
||||
|
||||
# 注册事件监听
|
||||
self.registerEvent()
|
||||
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
def loadSetting(self):
|
||||
"""加载配置"""
|
||||
with open(self.settingFileName) as f:
|
||||
drSetting = csv.DictReader(f)
|
||||
|
||||
for d in drSetting:
|
||||
# 读取配置
|
||||
gatewayName = d['gateway']
|
||||
symbol = d['symbol']
|
||||
exchange = d['exchange']
|
||||
currency = d['currency']
|
||||
productClass = d['product']
|
||||
recordTick = d['tick']
|
||||
recordBar = d['bar']
|
||||
activeSymbol = d['active']
|
||||
|
||||
if exchange:
|
||||
vtSymbol = '.'.join([symbol, exchange])
|
||||
else:
|
||||
drSetting = json.load(f)
|
||||
|
||||
# 如果working设为False则不启动行情记录功能
|
||||
working = drSetting['working']
|
||||
if not working:
|
||||
return
|
||||
|
||||
if 'tick' in drSetting:
|
||||
l = drSetting['tick']
|
||||
|
||||
for setting in l:
|
||||
symbol = setting[0]
|
||||
vtSymbol = symbol
|
||||
|
||||
# 订阅行情
|
||||
req = VtSubscribeReq()
|
||||
req.symbol = symbol
|
||||
req.exchange = exchange
|
||||
req.currency = currency
|
||||
req.productClass = productClass
|
||||
self.mainEngine.subscribe(req, gatewayName)
|
||||
|
||||
# 设置需要记录的数据
|
||||
if recordTick:
|
||||
tick = VtTickData()
|
||||
self.tickDict[vtSymbol] = VtTickData()
|
||||
|
||||
if recordBar:
|
||||
self.barDict[vtSymbol] = VtBarData()
|
||||
|
||||
if activeSymbol:
|
||||
|
||||
req = VtSubscribeReq()
|
||||
req.symbol = setting[0]
|
||||
|
||||
# 针对LTS和IB接口,订阅行情需要交易所代码
|
||||
if len(setting)>=3:
|
||||
req.exchange = setting[2]
|
||||
vtSymbol = '.'.join([symbol, req.exchange])
|
||||
|
||||
# 针对IB接口,订阅行情需要货币和产品类型
|
||||
if len(setting)>=5:
|
||||
req.currency = setting[3]
|
||||
req.productClass = setting[4]
|
||||
|
||||
self.mainEngine.subscribe(req, setting[1])
|
||||
|
||||
tick = VtTickData() # 该tick实例可以用于缓存部分数据(目前未使用)
|
||||
self.tickDict[vtSymbol] = tick
|
||||
|
||||
if 'bar' in drSetting:
|
||||
l = drSetting['bar']
|
||||
|
||||
for setting in l:
|
||||
symbol = setting[0]
|
||||
vtSymbol = symbol
|
||||
|
||||
req = VtSubscribeReq()
|
||||
req.symbol = symbol
|
||||
|
||||
if len(setting)>=3:
|
||||
req.exchange = setting[2]
|
||||
vtSymbol = '.'.join([symbol, req.exchange])
|
||||
|
||||
if len(setting)>=5:
|
||||
req.currency = setting[3]
|
||||
req.productClass = setting[4]
|
||||
|
||||
self.mainEngine.subscribe(req, setting[1])
|
||||
|
||||
bar = VtBarData()
|
||||
self.barDict[vtSymbol] = bar
|
||||
|
||||
if 'active' in drSetting:
|
||||
d = drSetting['active']
|
||||
|
||||
# 注意这里的vtSymbol对于IB和LTS接口,应该后缀.交易所
|
||||
for activeSymbol, vtSymbol in d.items():
|
||||
self.activeSymbolDict[vtSymbol] = activeSymbol
|
||||
|
||||
# 启动数据插入线程
|
||||
self.start()
|
||||
|
||||
# 注册事件监听
|
||||
self.registerEvent()
|
||||
|
||||
|
||||
##----------------------------------------------------------------------
|
||||
#def loadCsvSetting(self):
|
||||
#"""加载CSV配置"""
|
||||
#with open(self.settingFileName) as f:
|
||||
#drSetting = csv.DictReader(f)
|
||||
|
||||
#for d in drSetting:
|
||||
## 读取配置
|
||||
#gatewayName = d['gateway']
|
||||
#symbol = d['symbol']
|
||||
#exchange = d['exchange']
|
||||
#currency = d['currency']
|
||||
#productClass = d['product']
|
||||
#recordTick = d['tick']
|
||||
#recordBar = d['bar']
|
||||
#activeSymbol = d['active']
|
||||
|
||||
#if exchange:
|
||||
#vtSymbol = '.'.join([symbol, exchange])
|
||||
#else:
|
||||
#vtSymbol = symbol
|
||||
|
||||
## 订阅行情
|
||||
#req = VtSubscribeReq()
|
||||
#req.symbol = symbol
|
||||
#req.exchange = exchange
|
||||
#req.currency = currency
|
||||
#req.productClass = productClass
|
||||
#self.mainEngine.subscribe(req, gatewayName)
|
||||
|
||||
## 设置需要记录的数据
|
||||
#if recordTick:
|
||||
#tick = VtTickData()
|
||||
#self.tickDict[vtSymbol] = VtTickData()
|
||||
|
||||
# 保存配置到缓存中
|
||||
#if recordBar:
|
||||
#self.barDict[vtSymbol] = VtBarData()
|
||||
|
||||
#if activeSymbol:
|
||||
#self.activeSymbolDict[vtSymbol] = activeSymbol
|
||||
|
||||
## 保存配置到缓存中
|
||||
self.settingDict[vtSymbol] = d
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
|
@ -15,14 +15,14 @@ from vnpy.event import Event
|
||||
from vnpy.trader.vtEvent import *
|
||||
from vnpy.trader.vtConstant import *
|
||||
from vnpy.trader.vtGateway import VtLogData
|
||||
from vnpy.trader.vtFunction import getJsonPath
|
||||
|
||||
|
||||
########################################################################
|
||||
class RmEngine(object):
|
||||
"""风控引擎"""
|
||||
settingFileName = 'RM_setting.json'
|
||||
path = os.path.abspath(os.path.dirname(__file__))
|
||||
settingFileName = os.path.join(path, settingFileName)
|
||||
settingFilePath = getJsonPath(settingFileName, __file__)
|
||||
|
||||
name = u'风控模块'
|
||||
|
||||
@ -64,7 +64,7 @@ class RmEngine(object):
|
||||
#----------------------------------------------------------------------
|
||||
def loadSetting(self):
|
||||
"""读取配置"""
|
||||
with open(self.settingFileName) as f:
|
||||
with open(self.settingFilePath) as f:
|
||||
d = json.load(f)
|
||||
|
||||
# 设置风控参数
|
||||
@ -84,7 +84,7 @@ class RmEngine(object):
|
||||
#----------------------------------------------------------------------
|
||||
def saveSetting(self):
|
||||
"""保存风控参数"""
|
||||
with open(self.settingFileName, 'w') as f:
|
||||
with open(self.settingFilePath, 'w') as f:
|
||||
# 保存风控参数
|
||||
d = {}
|
||||
|
||||
|
@ -8,7 +8,7 @@ from time import sleep
|
||||
from vnpy.api.cshshlp import CsHsHlp
|
||||
from vnpy.api.ctp import MdApi
|
||||
from vnpy.trader.vtGateway import *
|
||||
from vnpy.trader.vtFunction import getTempPath
|
||||
from vnpy.trader.vtFunction import getTempPath, getJsonPath
|
||||
|
||||
|
||||
# 接口常量
|
||||
@ -97,11 +97,10 @@ class CshshlpGateway(VtGateway):
|
||||
"""连接"""
|
||||
# 载入json文件
|
||||
fileName = self.gatewayName + '_connect.json'
|
||||
path = os.path.abspath(os.path.dirname(__file__))
|
||||
fileName = os.path.join(path, fileName)
|
||||
filePath = getJsonPath(fileName, __file__)
|
||||
|
||||
try:
|
||||
f = file(fileName)
|
||||
f = file(filePath)
|
||||
except IOError:
|
||||
log = VtLogData()
|
||||
log.gatewayName = self.gatewayName
|
||||
|
@ -15,9 +15,9 @@ from datetime import datetime
|
||||
|
||||
from vnpy.api.ctp import MdApi, TdApi, defineDict
|
||||
from vnpy.trader.vtGateway import *
|
||||
from vnpy.trader.vtFunction import getTempPath
|
||||
from vnpy.trader.gateway.ctpGateway.language import text
|
||||
from vnpy.trader.vtFunction import getJsonPath, getTempPath
|
||||
from vnpy.trader.vtConstant import GATEWAYTYPE_FUTURES
|
||||
from .language import text
|
||||
|
||||
|
||||
# 以下为一些VT类型和CTP类型的映射字典
|
||||
@ -97,11 +97,10 @@ class CtpGateway(VtGateway):
|
||||
"""连接"""
|
||||
# 载入json文件
|
||||
fileName = self.gatewayName + '_connect.json'
|
||||
path = os.path.abspath(os.path.dirname(__file__))
|
||||
fileName = os.path.join(path, fileName)
|
||||
filePath = getJsonPath(fileName, __file__)
|
||||
|
||||
try:
|
||||
f = file(fileName)
|
||||
f = file(filePath)
|
||||
except IOError:
|
||||
log = VtLogData()
|
||||
log.gatewayName = self.gatewayName
|
||||
|
@ -11,7 +11,7 @@ import os
|
||||
import json
|
||||
|
||||
from vnpy.api.femas import MdApi, TdApi, defineDict
|
||||
from vnpy.trader.vtFunction import getTempPath
|
||||
from vnpy.trader.vtFunction import getTempPath, getJsonPath
|
||||
from vnpy.trader.vtGateway import *
|
||||
|
||||
# 以下为一些VT类型和CTP类型的映射字典
|
||||
@ -77,11 +77,10 @@ class FemasGateway(VtGateway):
|
||||
"""连接"""
|
||||
# 载入json文件
|
||||
fileName = self.gatewayName + '_connect.json'
|
||||
path = os.path.abspath(os.path.dirname(__file__))
|
||||
fileName = os.path.join(path, fileName)
|
||||
filePath = getJsonPath(fileName, __file__)
|
||||
|
||||
try:
|
||||
f = file(fileName)
|
||||
f = file(filePath)
|
||||
except IOError:
|
||||
log = VtLogData()
|
||||
log.gatewayName = self.gatewayName
|
||||
|
@ -15,7 +15,7 @@ from threading import Thread
|
||||
|
||||
from vnpy.api.huobi import vnhuobi
|
||||
from vnpy.trader.vtGateway import *
|
||||
|
||||
from vnpy.trader.vtFunction import getJsonPath
|
||||
|
||||
SYMBOL_BTCCNY = 'BTCCNY'
|
||||
SYMBOL_LTCCNY = 'LTCCNY'
|
||||
@ -65,11 +65,10 @@ class HuobiGateway(VtGateway):
|
||||
"""连接"""
|
||||
# 载入json文件
|
||||
fileName = self.gatewayName + '_connect.json'
|
||||
path = os.path.abspath(os.path.dirname(__file__))
|
||||
fileName = os.path.join(path, fileName)
|
||||
filePath = getJsonPath(fileName, __file__)
|
||||
|
||||
try:
|
||||
f = file(fileName)
|
||||
f = file(filePath)
|
||||
except IOError:
|
||||
log = VtLogData()
|
||||
log.gatewayName = self.gatewayName
|
||||
|
@ -19,7 +19,9 @@ from copy import copy
|
||||
|
||||
from vnpy.api.ib import *
|
||||
from vnpy.trader.vtGateway import *
|
||||
from vnpy.trader.gateway.ibGateway.language import text
|
||||
from vnpy.trader.vtFunction import getJsonPath
|
||||
from .language import text
|
||||
|
||||
|
||||
|
||||
# 以下为一些VT类型和CTP类型的映射字典
|
||||
@ -142,11 +144,10 @@ class IbGateway(VtGateway):
|
||||
"""连接"""
|
||||
# 载入json文件
|
||||
fileName = self.gatewayName + '_connect.json'
|
||||
path = os.path.abspath(os.path.dirname(__file__))
|
||||
fileName = os.path.join(path, fileName)
|
||||
filePath = getJsonPath(fileName, __file__)
|
||||
|
||||
try:
|
||||
f = file(fileName)
|
||||
f = file(filePath)
|
||||
except IOError:
|
||||
log = VtLogData()
|
||||
log.gatewayName = self.gatewayName
|
||||
|
@ -13,6 +13,7 @@ import time
|
||||
|
||||
from vnpy.api.ksgold import TdApi, defineDict
|
||||
from vnpy.trader.vtGateway import *
|
||||
from vnpy.trader.vtFunction import getJsonPath
|
||||
|
||||
# 以下类型映射参考的是原生API里的Constant.h
|
||||
|
||||
@ -50,11 +51,10 @@ class KsgoldGateway(VtGateway):
|
||||
"""连接"""
|
||||
# 载入json文件
|
||||
fileName = self.gatewayName + '_connect.json'
|
||||
path = os.path.abspath(os.path.dirname(__file__))
|
||||
fileName = os.path.join(path, fileName)
|
||||
filePath = getJsonPath(fileName, __file__)
|
||||
|
||||
try:
|
||||
f = file(fileName)
|
||||
f = file(filePath)
|
||||
except IOError:
|
||||
log = VtLogData()
|
||||
log.gatewayName = self.gatewayName
|
||||
|
@ -9,7 +9,7 @@ import os
|
||||
import json
|
||||
|
||||
from vnpy.api.ksotp import MdApi, TdApi, defineDict
|
||||
from vnpy.trader.vtFunction import getTempPath
|
||||
from vnpy.trader.vtFunction import getTempPath, getJsonPath
|
||||
from vnpy.trader.vtGateway import *
|
||||
|
||||
# 以下为一些VT类型和CTP类型的映射字典
|
||||
@ -73,11 +73,10 @@ class KsotpGateway(VtGateway):
|
||||
"""连接"""
|
||||
# 载入json文件
|
||||
fileName = self.gatewayName + '_connect.json'
|
||||
path = os.path.abspath(os.path.dirname(__file__))
|
||||
fileName = os.path.join(path, fileName)
|
||||
filePath = getJsonPath(fileName, __file__)
|
||||
|
||||
try:
|
||||
f = file(fileName)
|
||||
f = file(filePath)
|
||||
except IOError:
|
||||
log = VtLogData()
|
||||
log.gatewayName = self.gatewayName
|
||||
|
@ -12,6 +12,7 @@ from time import sleep
|
||||
|
||||
from vnpy.api.lhang import LhangApi
|
||||
from vnpy.trader.vtGateway import *
|
||||
from vnpy.trader.vtFunction import getJsonPath
|
||||
|
||||
|
||||
SYMBOL_BTCCNY = 'BTCCNY'
|
||||
@ -51,11 +52,10 @@ class LhangGateway(VtGateway):
|
||||
"""连接"""
|
||||
# 载入json文件
|
||||
fileName = self.gatewayName + '_connect.json'
|
||||
path = os.path.abspath(os.path.dirname(__file__))
|
||||
fileName = os.path.join(path, fileName)
|
||||
filePath = getJsonPath(fileName, __file__)
|
||||
|
||||
try:
|
||||
f = file(fileName)
|
||||
f = file(filePath)
|
||||
except IOError:
|
||||
log = VtLogData()
|
||||
log.gatewayName = self.gatewayName
|
||||
|
@ -8,7 +8,7 @@ import os
|
||||
import json
|
||||
|
||||
from vnpy.api.lts import MdApi, QryApi, TdApi, defineDict
|
||||
from vnpy.trader.vtFunction import getTempPath
|
||||
from vnpy.trader.vtFunction import getTempPath, getJsonPath
|
||||
from vnpy.trader.vtGateway import *
|
||||
|
||||
|
||||
@ -74,11 +74,10 @@ class LtsGateway(VtGateway):
|
||||
"""连接"""
|
||||
# 载入json 文件
|
||||
fileName = self.gatewayName + '_connect.json'
|
||||
path = os.path.abspath(os.path.dirname(__file__))
|
||||
fileName = os.path.join(path, fileName)
|
||||
filePath = getJsonPath(fileName, __file__)
|
||||
|
||||
try:
|
||||
f = file(fileName)
|
||||
f = file(filePath)
|
||||
except IOError:
|
||||
log = VtLogData()
|
||||
log.gatewayName = self.gatewayName
|
||||
|
@ -26,6 +26,7 @@ import datetime
|
||||
|
||||
from vnpy.api.oanda import OandaApi
|
||||
from vnpy.trader.vtGateway import *
|
||||
from vnpy.trader.vtFunction import getJsonPath
|
||||
|
||||
# 价格类型映射
|
||||
priceTypeMap = {}
|
||||
@ -58,11 +59,10 @@ class OandaGateway(VtGateway):
|
||||
"""连接"""
|
||||
# 载入json文件
|
||||
fileName = self.gatewayName + '_connect.json'
|
||||
path = os.path.abspath(os.path.dirname(__file__))
|
||||
fileName = os.path.join(path, fileName)
|
||||
filePath = getJsonPath(fileName, __file__)
|
||||
|
||||
try:
|
||||
f = file(fileName)
|
||||
f = file(filePath)
|
||||
except IOError:
|
||||
log = VtLogData()
|
||||
log.gatewayName = self.gatewayName
|
||||
|
@ -20,6 +20,7 @@ from time import sleep
|
||||
|
||||
from vnpy.api.okcoin import vnokcoin
|
||||
from vnpy.trader.vtGateway import *
|
||||
from vnpy.trader.vtFunction import getJsonPath
|
||||
|
||||
# 价格类型映射
|
||||
priceTypeMap = {}
|
||||
@ -122,11 +123,10 @@ class OkcoinGateway(VtGateway):
|
||||
"""连接"""
|
||||
# 载入json文件
|
||||
fileName = self.gatewayName + '_connect.json'
|
||||
path = os.path.abspath(os.path.dirname(__file__))
|
||||
fileName = os.path.join(path, fileName)
|
||||
filePath = getJsonPath(fileName, __file__)
|
||||
|
||||
try:
|
||||
f = file(fileName)
|
||||
f = file(filePath)
|
||||
except IOError:
|
||||
log = VtLogData()
|
||||
log.gatewayName = self.gatewayName
|
||||
|
@ -15,6 +15,7 @@ from copy import copy
|
||||
|
||||
from vnpy.api.qdp import MdApi, TdApi, defineDict
|
||||
from vnpy.trader.vtGateway import *
|
||||
from vnpy.trader.vtFunction import getJsonPath
|
||||
|
||||
|
||||
# 以下为一些VT类型和QDP类型的映射字典
|
||||
@ -82,11 +83,10 @@ class QdpGateway(VtGateway):
|
||||
"""连接"""
|
||||
# 载入json文件
|
||||
fileName = self.gatewayName + '_connect.json'
|
||||
path = os.path.abspath(os.path.dirname(__file__))
|
||||
fileName = os.path.join(path, fileName)
|
||||
filePath = getJsonPath(fileName, __file__)
|
||||
|
||||
try:
|
||||
f = file(fileName)
|
||||
f = file(filePath)
|
||||
except IOError:
|
||||
log = VtLogData()
|
||||
log.gatewayName = self.gatewayName
|
||||
|
@ -14,7 +14,7 @@ from copy import copy
|
||||
from datetime import datetime
|
||||
|
||||
from vnpy.api.sgit import MdApi, TdApi, defineDict
|
||||
from vnpy.trader.vtFunction import getTempPath
|
||||
from vnpy.trader.vtFunction import getTempPath, getJsonPath
|
||||
from vnpy.trader.vtGateway import *
|
||||
|
||||
|
||||
@ -94,11 +94,10 @@ class SgitGateway(VtGateway):
|
||||
"""连接"""
|
||||
# 载入json文件
|
||||
fileName = self.gatewayName + '_connect.json'
|
||||
path = os.path.abspath(os.path.dirname(__file__))
|
||||
fileName = os.path.join(path, fileName)
|
||||
filePath = getJsonPath(fileName, __file__)
|
||||
|
||||
try:
|
||||
f = file(fileName)
|
||||
f = file(filePath)
|
||||
except IOError:
|
||||
log = VtLogData()
|
||||
log.gatewayName = self.gatewayName
|
||||
|
@ -17,6 +17,7 @@ from datetime import datetime
|
||||
|
||||
from vnpy.api.shzd import ShzdApi
|
||||
from vnpy.trader.vtGateway import *
|
||||
from vnpy.trader.vtFunction import getJsonPath
|
||||
|
||||
|
||||
# 以下为一些VT类型和SHZD类型的映射字典
|
||||
@ -34,10 +35,6 @@ directionMapReverse = {v: k for k, v in directionMap.items()}
|
||||
|
||||
# 交易所类型映射
|
||||
exchangeMap = {}
|
||||
#exchangeMap[EXCHANGE_CFFEX] = 'CFFEX'
|
||||
#exchangeMap[EXCHANGE_SHFE] = 'SHFE'
|
||||
#exchangeMap[EXCHANGE_CZCE] = 'CZCE'
|
||||
#exchangeMap[EXCHANGE_DCE] = 'DCE'
|
||||
exchangeMap[EXCHANGE_HKEX] = 'HKEX'
|
||||
exchangeMap[EXCHANGE_CME] = 'CME'
|
||||
exchangeMap[EXCHANGE_ICE] = 'ICE'
|
||||
@ -77,11 +74,10 @@ class ShzdGateway(VtGateway):
|
||||
"""连接"""
|
||||
# 载入json文件
|
||||
fileName = self.gatewayName + '_connect.json'
|
||||
path = os.path.abspath(os.path.dirname(__file__))
|
||||
fileName = os.path.join(path, fileName)
|
||||
filePath = getJsonPath(fileName, __file__)
|
||||
|
||||
try:
|
||||
f = file(fileName)
|
||||
f = file(filePath)
|
||||
except IOError:
|
||||
log = VtLogData()
|
||||
log.gatewayName = self.gatewayName
|
||||
|
@ -11,6 +11,8 @@ from copy import copy
|
||||
|
||||
from vnpy.api.xspeed import MdApi, TdApi, defineDict
|
||||
from vnpy.trader.vtGateway import *
|
||||
from vnpy.trader.vtFunction import getJsonPath
|
||||
|
||||
|
||||
# 以下为一些VT类型和XSPEED类型的映射字典
|
||||
# 价格类型映射
|
||||
@ -81,11 +83,10 @@ class XspeedGateway(VtGateway):
|
||||
"""连接"""
|
||||
# 载入json文件
|
||||
fileName = self.gatewayName + '_connect.json'
|
||||
path = os.path.abspath(os.path.dirname(__file__))
|
||||
fileName = os.path.join(path, fileName)
|
||||
filePath = getJsonPath(fileName, __file__)
|
||||
|
||||
try:
|
||||
f = file(fileName)
|
||||
f = file(filePath)
|
||||
except IOError:
|
||||
log = VtLogData()
|
||||
log.gatewayName = self.gatewayName
|
||||
|
Loading…
Reference in New Issue
Block a user