• Version 1.7.1
Show / Hide Table of Contents

Exchanging Messages

Sending Messages

To send a message to a counterparty, use the Send(IMessage) method. The Handler sets all session-level fields automatically (e.g., SeqNum, SendingTimeEpoch).

Note

The session should be fully established before sending application-level messages.

Receiving Messages

To receive messages, subscribe to corresponding events of the Session class:

  • InboundApplicationMessage
  • InboundSessionMessage

Example

SessionSettings settings = new()
{
    AccessKey = ConfigurationManager.AppSettings["AccessKey"],
    FirmId = ConfigurationManager.AppSettings["FirmId"],
    LicenseStore = "../../../../../license",
    SecretKey = ConfigurationManager.AppSettings["SecretKey"],
    SessionId = ConfigurationManager.AppSettings["SessionId"],
    TradingSystemName = "Trading System",
    TradingSystemVendor = "OnixS",
    TradingSystemVersion = "1.1.0",
};

using Session session = new Session(settings, marketSegmentId);

session.InboundApplicationMessage += (sender, args) => Console.WriteLine("Received: " + args.Message);
session.InboundSessionMessage += (sender, args) => Console.WriteLine("Received: " + args.Message);

IEncoder encoder = session.CreateEncoder();

const int NewOrderSingleTemplateId = 514;
IMessage message = encoder.Wrap(NewOrderSingleTemplateId);

message.SetUnsignedLong(Tag.PartyDetailsListReqID, partyDetailsListReqID)
       .SetByte(Tag.Side, (byte)Side.Buy)
       .SetString(Tag.SenderID, "GFP")
       .SetString(Tag.ClOrdID, "OrderId")
       .SetUnsignedLong(Tag.OrderRequestID, 1u)
       .SetString(Tag.Location, "UK")
       .SetChar(Tag.OrdType, (char)OrderType.Limit)
       .SetByte(Tag.TimeInForce, (byte)TimeInForce.Day)
       .SetInteger(Tag.SecurityID, securityId)
       .SetUnsignedInteger(Tag.OrderQty, 1)
       .SetDecimal(Tag.Price, price)
       .SetByte(Tag.ManualOrderIndicator, (byte)ManualOrdInd.Automated)
       .SetChar(Tag.ExecutionMode, (char)ExecMode.Aggressive)
       .SetByte(Tag.ExecInst, (byte)ExecInst.AON);

In this article
Back to top Copyright © Onix Solutions.
Generated by DocFX