[bug fix] 支持多个CTP账号同时连接
This commit is contained in:
parent
7f372c88df
commit
4b0bdc4e9f
@ -177,9 +177,9 @@ class CtpGateway(BaseGateway):
|
||||
# }
|
||||
exchanges = list(EXCHANGE_CTP2VT.values())
|
||||
|
||||
def __init__(self, event_engine):
|
||||
def __init__(self, event_engine, gateway_name="CTP"):
|
||||
"""Constructor"""
|
||||
super().__init__(event_engine, "CTP")
|
||||
super().__init__(event_engine, gateway_name)
|
||||
|
||||
self.td_api = None
|
||||
self.md_api = None
|
||||
|
@ -72,9 +72,14 @@ class MainEngine:
|
||||
"""
|
||||
Add gateway.
|
||||
"""
|
||||
if gateway_name:
|
||||
# 使用指定的gateway_name, 可以区分相同接口不同账号的gateway同时接入
|
||||
gateway = gateway_class(self.event_engine, gateway_name=gateway_name)
|
||||
else:
|
||||
# 缺省使用了接口自己定义的gateway_name
|
||||
gateway = gateway_class(self.event_engine)
|
||||
if gateway_name is None:
|
||||
gateway_name = gateway.gateway_name
|
||||
|
||||
self.gateways[gateway_name] = gateway
|
||||
|
||||
# Add gateway supported exchanges into engine
|
||||
|
Loading…
Reference in New Issue
Block a user