gpt4 book ai didi

python - 使用 Python 在 QuickFix 中修改 session 设置

转载 作者:行者123 更新时间:2023-12-03 19:50:39 24 4
gpt4 key购买 nike

读取配置文件后:

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

是否可以动态修改特定 session 的设置?例如修改 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 之前修改配置文件中现有的一个函数被调用。

最佳答案

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

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

关于python - 使用 Python 在 QuickFix 中修改 session 设置,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37342106/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com