使用Python在QuickFix中修改会话设置

时间:2016-05-20 08:47:41

标签: python quickfix

阅读配置文件后:

f = "excfg.cfg"
settings = fix.SessionSettings(f)

是否可以动态修改特定会话的设置?例如,修改TargetCompIDSocketAcceptPort

我正在寻找替代方案:

dictionary = settings.get()
id1 = fix.SessionID(dictionary.getString(fix.BEGINSTRING),
                    dictionary.getString(fix.SENDERCOMPID), "EX1")

dictionary.setInt(fix.SOCKET_ACCEPT_PORT, 7001)
settings.set(id1, dictionary)

在我调用SessionID函数之前,我没有创建新的SocketAcceptor/SocketInitiator,而是从配置文件中修改现有的if(!localStorage.token || !localStorage.token.next){ location.path("/signin"); }

1 个答案:

答案 0 :(得分:2)

您无需执行settings.set,因为settings.get返回的字典包含对会话设置的引用(而不是副本):

import quickfix as fix

# print the current port 
settings = fix.SessionSettings('/opt/robotfx/etc/fxgo-config/config.txt', True)
session_settings = settings.get(fix.SessionID('FIX.4.4','SENDER','TARGET'))  
print('current port=', session_settings.getString('SocketConnectPort'))

# updates the port value, get the session settings again and print the current port
session_settings.setString('SocketConnectPort', '1234')
session_settings = settings.get(fix.SessionID('FIX.4.4','SENDER','TARGET'))  
print('current port=', session_settings.getString('SocketConnectPort'))

输出:

current port=31337
current port=1234