增加主引擎内的英文翻译,修复ctpGateway中onRspQryInvestorPosition的zerodivision问题
This commit is contained in:
parent
f0179c410d
commit
d9401ba055
@ -7,5 +7,5 @@
|
||||
"mongoLogging": true,
|
||||
|
||||
"darkStyle": true,
|
||||
"language": "English"
|
||||
"language": "english"
|
||||
}
|
@ -5,7 +5,7 @@ import os
|
||||
import traceback
|
||||
|
||||
# 默认设置
|
||||
from Chinese import text
|
||||
from chinese import text
|
||||
|
||||
# 获取目录上级路径
|
||||
path = os.path.abspath(os.path.join(os.path.dirname(__file__), '..', '..'))
|
||||
@ -16,8 +16,8 @@ SETTING_FILENAME = os.path.join(path, SETTING_FILENAME)
|
||||
try:
|
||||
f = file(SETTING_FILENAME)
|
||||
setting = json.load(f)
|
||||
if setting['language'] == 'English':
|
||||
from English import text
|
||||
if setting['language'] == 'english':
|
||||
from english import text
|
||||
f.close()
|
||||
except:
|
||||
traceback.print_exc()
|
||||
|
@ -5,7 +5,7 @@ import os
|
||||
import traceback
|
||||
|
||||
# 默认设置
|
||||
from Chinese import text
|
||||
from chinese import text
|
||||
|
||||
# 获取目录上级路径
|
||||
path = os.path.abspath(os.path.join(os.path.dirname(__file__), '..', '..'))
|
||||
@ -16,8 +16,8 @@ SETTING_FILENAME = os.path.join(path, SETTING_FILENAME)
|
||||
try:
|
||||
f = file(SETTING_FILENAME)
|
||||
setting = json.load(f)
|
||||
if setting['language'] == 'English':
|
||||
from English import text
|
||||
if setting['language'] == 'english':
|
||||
from english import text
|
||||
f.close()
|
||||
except:
|
||||
traceback.print_exc()
|
||||
|
@ -1,7 +1,7 @@
|
||||
{
|
||||
"brokerID": "9999",
|
||||
"tdAddress": "tcp://180.168.146.187:10000",
|
||||
"password": "simnow申请",
|
||||
"mdAddress": "tcp://180.168.212.228:41213",
|
||||
"userID": "simnow申请"
|
||||
"password": "19890624",
|
||||
"mdAddress": "tcp://180.168.146.187:10010",
|
||||
"userID": "000300"
|
||||
}
|
@ -710,7 +710,8 @@ class CtpTdApi(TdApi):
|
||||
pos.positionProfit += data['PositionProfit']
|
||||
|
||||
# 计算持仓均价
|
||||
pos.price = (cost + data['PositionCost']) / pos.position
|
||||
if pos.position:
|
||||
pos.price = (cost + data['PositionCost']) / pos.position
|
||||
|
||||
# 读取冻结
|
||||
if pos.direction is DIRECTION_LONG:
|
||||
|
@ -5,10 +5,10 @@ import os
|
||||
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__), '..', '..', '..'))
|
||||
SETTING_FILENAME = 'VT_setting.json'
|
||||
SETTING_FILENAME = os.path.join(path, SETTING_FILENAME)
|
||||
|
||||
@ -16,8 +16,8 @@ SETTING_FILENAME = os.path.join(path, SETTING_FILENAME)
|
||||
try:
|
||||
f = file(SETTING_FILENAME)
|
||||
setting = json.load(f)
|
||||
if setting['language'] == 'English':
|
||||
from English import text
|
||||
if setting['language'] == 'english':
|
||||
from english import text
|
||||
f.close()
|
||||
except:
|
||||
traceback.print_exc()
|
||||
|
@ -5,10 +5,10 @@ import os
|
||||
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__), '..', '..', '..'))
|
||||
SETTING_FILENAME = 'VT_setting.json'
|
||||
SETTING_FILENAME = os.path.join(path, SETTING_FILENAME)
|
||||
|
||||
@ -16,8 +16,8 @@ SETTING_FILENAME = os.path.join(path, SETTING_FILENAME)
|
||||
try:
|
||||
f = file(SETTING_FILENAME)
|
||||
setting = json.load(f)
|
||||
if setting['language'] == 'English':
|
||||
from English import text
|
||||
if setting['language'] == 'english':
|
||||
from english import text
|
||||
f.close()
|
||||
except:
|
||||
traceback.print_exc()
|
||||
|
@ -4,7 +4,7 @@ import json
|
||||
import os
|
||||
|
||||
# 默认设置
|
||||
from Chinese import text, constant
|
||||
from chinese import text, constant
|
||||
|
||||
# 获取目录上级路径
|
||||
path = os.path.abspath(os.path.join(os.path.dirname(__file__), '..'))
|
||||
@ -15,8 +15,8 @@ SETTING_FILENAME = os.path.join(path, SETTING_FILENAME)
|
||||
try:
|
||||
f = file(SETTING_FILENAME)
|
||||
setting = json.load(f)
|
||||
if setting['language'] == 'English':
|
||||
from English import text, constant
|
||||
if setting['language'] == 'english':
|
||||
from english import text, constant
|
||||
f.close()
|
||||
except:
|
||||
pass
|
||||
|
@ -123,4 +123,11 @@ TEST = u'测试'
|
||||
CONNECT = u'连接'
|
||||
|
||||
CPU_MEMORY_INFO = u'CPU使用率:{cpu}% 内存使用率:{memory}%'
|
||||
CONFIRM_EXIT = u'确认退出?'
|
||||
CONFIRM_EXIT = u'确认退出?'
|
||||
|
||||
GATEWAY_NOT_EXIST = u'接口不存在:{gateway}'
|
||||
DATABASE_CONNECTING_COMPLETED = u'MongoDB连接成功'
|
||||
DATABASE_CONNECTING_FAILED = u'MongoDB连接失败'
|
||||
DATA_INSERT_FAILED = u'数据插入失败,MongoDB没有连接'
|
||||
DATA_QUERY_FAILED = u'数据查询失败,MongoDB没有连接'
|
||||
DATA_UPDATE_FAILED = u'数据更新失败,MongoDB没有连接'
|
||||
|
@ -123,4 +123,11 @@ TEST = u'Test'
|
||||
CONNECT = u'Connect '
|
||||
|
||||
CPU_MEMORY_INFO = u'CPU Usage:{cpu}% Memory Usage:{memory}%'
|
||||
CONFIRM_EXIT = u'Confirm Exit?'
|
||||
CONFIRM_EXIT = u'Confirm Exit?'
|
||||
|
||||
GATEWAY_NOT_EXIST = u"Can't find the gateway:{gateway}"
|
||||
DATABASE_CONNECTING_COMPLETED = u'MongoDB is connected.'
|
||||
DATABASE_CONNECTING_FAILED = u'Failed to connect to MongoDB.'
|
||||
DATA_INSERT_FAILED = u'Data insert failed,please connect MongoDB first.'
|
||||
DATA_QUERY_FAILED = u'Data query failed, please connect MongoDB first.'
|
||||
DATA_UPDATE_FAILED = u'Data update failed, please connect MongoDB first.'
|
@ -5,7 +5,7 @@ import os
|
||||
import traceback
|
||||
|
||||
# 默认设置
|
||||
from Chinese import text
|
||||
from chinese import text
|
||||
|
||||
# 获取目录上级路径
|
||||
path = os.path.abspath(os.path.join(os.path.dirname(__file__), '..', '..'))
|
||||
@ -16,8 +16,8 @@ SETTING_FILENAME = os.path.join(path, SETTING_FILENAME)
|
||||
try:
|
||||
f = file(SETTING_FILENAME)
|
||||
setting = json.load(f)
|
||||
if setting['language'] == 'English':
|
||||
from English import text
|
||||
if setting['language'] == 'english':
|
||||
from english import text
|
||||
f.close()
|
||||
except:
|
||||
traceback.print_exc()
|
||||
|
@ -10,6 +10,7 @@ from pymongo.errors import ConnectionFailure
|
||||
from eventEngine import *
|
||||
from vtGateway import *
|
||||
from vtFunction import loadMongoSetting
|
||||
from language import text
|
||||
|
||||
from gateway import GATEWAY_DICT
|
||||
from ctaStrategy.ctaEngine import CtaEngine
|
||||
@ -75,7 +76,7 @@ class MainEngine(object):
|
||||
# 接口连接后自动执行数据库连接的任务
|
||||
self.dbConnect()
|
||||
else:
|
||||
self.writeLog(u'接口不存在:%s' %gatewayName)
|
||||
self.writeLog(text.GATEWAY_NOT_EXIST.format(gateway=gatewayName))
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
def subscribe(self, subscribeReq, gatewayName):
|
||||
@ -84,7 +85,7 @@ class MainEngine(object):
|
||||
gateway = self.gatewayDict[gatewayName]
|
||||
gateway.subscribe(subscribeReq)
|
||||
else:
|
||||
self.writeLog(u'接口不存在:%s' %gatewayName)
|
||||
self.writeLog(text.GATEWAY_NOT_EXIST.format(gateway=gatewayName))
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
def sendOrder(self, orderReq, gatewayName):
|
||||
@ -97,7 +98,7 @@ class MainEngine(object):
|
||||
gateway = self.gatewayDict[gatewayName]
|
||||
return gateway.sendOrder(orderReq)
|
||||
else:
|
||||
self.writeLog(u'接口不存在:%s' %gatewayName)
|
||||
self.writeLog(text.GATEWAY_NOT_EXIST.format(gateway=gatewayName))
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
def cancelOrder(self, cancelOrderReq, gatewayName):
|
||||
@ -106,7 +107,8 @@ class MainEngine(object):
|
||||
gateway = self.gatewayDict[gatewayName]
|
||||
gateway.cancelOrder(cancelOrderReq)
|
||||
else:
|
||||
self.writeLog(u'接口不存在:%s' %gatewayName)
|
||||
self.writeLog(text.GATEWAY_NOT_EXIST.format(gateway=gatewayName))
|
||||
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
def qryAccount(self, gatewayName):
|
||||
@ -115,7 +117,7 @@ class MainEngine(object):
|
||||
gateway = self.gatewayDict[gatewayName]
|
||||
gateway.qryAccount()
|
||||
else:
|
||||
self.writeLog(u'接口不存在:%s' %gatewayName)
|
||||
self.writeLog(text.GATEWAY_NOT_EXIST.format(gateway=gatewayName))
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
def qryPosition(self, gatewayName):
|
||||
@ -124,7 +126,7 @@ class MainEngine(object):
|
||||
gateway = self.gatewayDict[gatewayName]
|
||||
gateway.qryPosition()
|
||||
else:
|
||||
self.writeLog(u'接口不存在:%s' %gatewayName)
|
||||
self.writeLog(text.GATEWAY_NOT_EXIST.format(gateway=gatewayName))
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
def exit(self):
|
||||
@ -165,14 +167,14 @@ class MainEngine(object):
|
||||
# 调用server_info查询服务器状态,防止服务器异常并未连接成功
|
||||
self.dbClient.server_info()
|
||||
|
||||
self.writeLog(u'MongoDB连接成功')
|
||||
self.writeLog(text.DATABASE_CONNECTING_COMPLETED)
|
||||
|
||||
# 如果启动日志记录,则注册日志事件监听函数
|
||||
if logging:
|
||||
self.eventEngine.register(EVENT_LOG, self.dbLogging)
|
||||
|
||||
except ConnectionFailure:
|
||||
self.writeLog(u'MongoDB连接失败')
|
||||
self.writeLog(text.DATABASE_CONNECTING_FAILED)
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
def dbInsert(self, dbName, collectionName, d):
|
||||
@ -182,7 +184,7 @@ class MainEngine(object):
|
||||
collection = db[collectionName]
|
||||
collection.insert_one(d)
|
||||
else:
|
||||
self.writeLog(u'数据插入失败,MongoDB没有连接')
|
||||
self.writeLog(text.DATA_INSERT_FAILED)
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
def dbQuery(self, dbName, collectionName, d):
|
||||
@ -196,7 +198,7 @@ class MainEngine(object):
|
||||
else:
|
||||
return []
|
||||
else:
|
||||
self.writeLog(u'数据查询失败,MongoDB没有连接')
|
||||
self.writeLog(text.DATA_QUERY_FAILED)
|
||||
return []
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
@ -207,7 +209,7 @@ class MainEngine(object):
|
||||
collection = db[collectionName]
|
||||
collection.replace_one(flt, d, upsert)
|
||||
else:
|
||||
self.writeLog(u'数据更新失败,MongoDB没有连接')
|
||||
self.writeLog(text.DATA_UPDATE_FAILED)
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
def dbLogging(self, event):
|
||||
|
Loading…
Reference in New Issue
Block a user