【问题标题】:How to send FIXML message with python to broker?如何使用 python 向代理发送 FIXML 消息?
【发布时间】:2020-10-24 16:33:15
【问题描述】:

我正在制作一个 python 应用程序,它将通过 API 向代理应用程序发送消息。 我在文档信息中有消息应该是 XML 格式:

<FIXML v="5.0" r="20080317" s="20080314">
<UserReq UserReqID="0" UserReqTyp="1" Username="1234" Password="1234"/>
</FIXML>
  1. 你能告诉我如何用python语言发送它吗?
  2. 如何连接到那个 API,我有信息说:
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).

【问题讨论】:

  • 这通常取决于消息代理,因为不同的消息代理有不同的 API:stop.py 用于 ActiveMQ、Artemis 或 RabbitMQ,pika 用于 Rabbit MQ,mqlight 用于 IBM MQ 等。

标签: python xml api broker


【解决方案1】:

我想通了。一般来说,不幸的是,您需要手动完成所有操作。

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 应用程序。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-03-19
    • 1970-01-01
    • 2022-09-22
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多