[Mod]connect dialog use chinese for setting key

This commit is contained in:
vn.py 2019-03-22 23:22:15 +08:00
parent e296a8098c
commit 4a309ac199
4 changed files with 49 additions and 45 deletions

View File

@ -67,12 +67,12 @@ class BitmexGateway(BaseGateway):
"""
default_setting = {
"key": "",
"secret": "",
"session_number": 3,
"server": ["REAL", "TESTNET"],
"proxy_host": "127.0.0.1",
"proxy_port": 1080,
"ID": "",
"Secret": "",
"会话数": 3,
"服务器": ["REAL", "TESTNET"],
"代理地址": "127.0.0.1",
"代理端口": 1080,
}
def __init__(self, event_engine):
@ -84,12 +84,12 @@ class BitmexGateway(BaseGateway):
def connect(self, setting: dict):
""""""
key = setting["key"]
secret = setting["secret"]
session_number = setting["session_number"]
server = setting["server"]
proxy_host = setting["proxy_host"]
proxy_port = setting["proxy_port"]
key = setting["ID"]
secret = setting["Secret"]
session_number = setting["会话数"]
server = setting["服务器"]
proxy_host = setting["代理地址"]
proxy_port = setting["代理端口"]
self.rest_api.connect(key, secret, session_number,
server, proxy_host, proxy_port)

View File

@ -125,13 +125,13 @@ class CtpGateway(BaseGateway):
"""
default_setting = {
"userid": "",
"password": "",
"brokerid": "",
"td_address": "",
"md_address": "",
"auth_code": "",
"product_info": ""
"用户名": "",
"密码": "",
"经纪商代码": 0,
"交易服务器": "",
"行情服务器": "",
"产品名称": "",
"授权编码": ""
}
def __init__(self, event_engine):
@ -143,13 +143,13 @@ class CtpGateway(BaseGateway):
def connect(self, setting: dict):
""""""
userid = setting["userid"]
password = setting["password"]
brokerid = setting["brokerid"]
td_address = setting["td_address"]
md_address = setting["md_address"]
auth_code = setting["auth_code"]
product_info = setting["product_info"]
userid = setting["用户名"]
password = setting["密码"]
brokerid = setting["经纪商代码"]
td_address = setting["交易服务器"]
md_address = setting["行情服务器"]
product_info = setting["产品名称"]
auth_code = setting["授权编码"]
if not td_address.startswith("tcp://"):
td_address = "tcp://" + td_address

View File

@ -79,11 +79,11 @@ class FutuGateway(BaseGateway):
""""""
default_setting = {
"password": "",
"host": "127.0.0.1",
"port": 11111,
"market": ["HK", "US"],
"env": [TrdEnv.REAL, TrdEnv.SIMULATE],
"密码": "",
"地址": "127.0.0.1",
"端口": 11111,
"市场": ["HK", "US"],
"环境": [TrdEnv.REAL, TrdEnv.SIMULATE],
}
def __init__(self, event_engine):
@ -112,11 +112,11 @@ class FutuGateway(BaseGateway):
def connect(self, setting: dict):
""""""
self.host = setting["host"]
self.port = setting["port"]
self.market = setting["market"]
self.password = setting["password"]
self.env = setting["env"]
self.host = setting["地址"]
self.port = setting["端口"]
self.market = setting["市场"]
self.password = setting["密码"]
self.env = setting["环境"]
self.connect_quote()
self.connect_trade()

View File

@ -110,7 +110,11 @@ ACCOUNTFIELD_IB2VT = {
class IbGateway(BaseGateway):
""""""
default_setting = {"host": "127.0.0.1", "port": 7497, "clientid": 1}
default_setting = {
"TWS地址": "127.0.0.1",
"TWS端口": 7497,
"客户号": 1
}
def __init__(self, event_engine):
""""""
@ -122,7 +126,11 @@ class IbGateway(BaseGateway):
"""
Start gateway connection.
"""
self.api.connect(setting)
host = setting["TWS地址"]
port = setting["TWS端口"]
clientid = setting["客户号"]
self.api.connect(host, port, clientid)
def close(self):
"""
@ -490,21 +498,17 @@ class IbApi(EWrapper):
for account_code in accountsList.split(","):
self.client.reqAccountUpdates(True, account_code)
def connect(self, setting: dict):
def connect(self, host: str, port: int, clientid: int):
"""
Connect to TWS.
"""
if self.status:
return
self.clientid = setting["clientid"]
self.client.connect(
setting["host"], setting["port"], setting["clientid"])
self.clientid = clientid
self.client.connect(host, port, clientid)
self.thread.start()
# n = self.client.reqCurrentTime()
self.client.reqCurrentTime()
def close(self):