我正在制作一个python应用程序,它将通过API向代理应用程序发送消息。在文档中,我知道消息应该是XML格式的:
<FIXML v="5.0" r="20080317" s="20080314">
<UserReq UserReqID="0" UserReqTyp="1" Username="1234" Password="1234"/>
</FIXML>。
In order to connect to the API, use the following registers:
HKEY_CURRENT_USER/Software/COMARCH S.A./NOL3/7/Settings:
• nca_pasync – port value for an asynchronous channel (default value: 24445),
• nca_psync – port value for a synchronous channel (default value: 24444),
• ncaset_pasync – flag informing whether the value in nca_pasync is active (1 - active, 0 -
inactive),
• ncaset_psync - a flag indicating whether the value in nca_psync is active (1 - active, 0 - inactive).发布于 2020-10-24 08:33:15
我已经想明白了。一般说来,你需要做每件事都很不幸。
import socket
import sys
HOST = '127.0.0.1' # Standard loopback interface address (localhost)
PORT = 24444 # nca_psync – port value for a synchronous channel (default value: 24444) you need to check your registery for correct value.
with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as sock:
sock.connect((HOST, PORT))
message = '<FIXML v="5.0" r="20080317" s="20080314"><UserReq UserReqID="0" UserReqTyp="1" Username="YOUR_LOGIN" Password="YOUR_PASS"/></FIXML>'
try:
# Send data
enc = message.encode()
sock.send(bytes([len(enc)]))
sock.send(message.encode())
finally:
sock.close()使用这段代码我就可以登录了。请记住,您必须先登录到您的代理和午餐nol3应用程序。
https://stackoverflow.com/questions/64296611
复制相似问题