Trade Capture Report (AE) message is a post-trade message which is sent by the broker or exchange to report the trades for participant.
How to Request Trade Capture Report?
A client may use Trade Capture Report Request (AD) to subscribe for trade capture reports based upon selection criteria provided on the trade capture report request.
The server will respond with a Trade Capture Report Request Ack (AR) to indicate, via the TradeRequestStatus
(750) and TradeRequestResult
(749
) fields, whether the request is successful or not. Sometimes if the Trade Capture Report Request message is rejected due to some validations, a Reject
message can be generated as the response.
Trade Capture Report Request (AD) Message Structure
Tag | Field Name | Req | Description |
568 | TradeRequestID | Y | Request unique identifier |
569 | TradeRequestType | Y | Type of request
- 0: All Trades
- 1: Trades Matching Specified Criteria If none of the criteria below are specified, this will return all trades.
|
150 | ExecType | N | Request for all trades of a specific execution type |
| <Instrument> block | N | Request for all trades for the list of instruments |
| =>Symbol | | Symbol name |
| => SecurityId | | Security Id |
| =>…… | | |
You need to remember that these are standard fields for Trade Capture Report Request (AD) message, the list of supported fields may vary between various FIX formats.
Also, always follow the Rules of engagement document provided by the broker before implementing FIX messages.
Trade Capture Report Request Ack (AC) Message
It is acknowledged message to Trade Capture Report Request (AD)
Tag | FieldName | Req | Description |
568 | TradeRequestID | Y | Identifier of the request being acknowledged |
569 | TradeRequestType | Y | Identifier of the request being acknowledged |
750 | TradeRequestStatus | Y | Whether the request is accepted or rejected
0: Accepted
1: Rejected |
749 | TradeRequestResult | Y | Reason the request is rejected.
0: Successful
9: Not Authorized
100: Cannot Match Selection Criteria 200: Request Limit for Day Reached |
Trade Capture Report
It is a response message to TradeCapture
Report Request (AD) which reports trades between counterparties.
Message Structure
Tag | Field Name | Req | Description |
568 | TradeRequestID | Y | Request unique identifier |
571 | TradeReportID | Y | Unique Id of response message |
17 | ExecId | Y | Identifier of the trade |
48 | SecurityId | N | Instrument Id |
55 | Symbol | N | Symbol name |
32 | LastQty | Y | Traded Quantity |
31 | LastPx | Y | Traded Price |
75 | TradeDate | Y | Traded date |
60 | TransactTime | Y | Transaction time of a trade |
Implementation
TradeCaptureReportRequest (AD)
TradeCaptureReportRequest request = new TradeCaptureReportRequest();
string requestId = DateTime.UtcNow.ToString("yyyyMMddHHmmssfff");
request.TradeRequestID = new TradeRequestID(requestId);
request.TradeRequestType = new TradeRequestType
(TradeRequestType.MATCHED_TRADES_MATCHING_CRITERIA_PROVIDED_ON_REQUEST);
request.NoDates = new NoDates(2);
var noDatesGroup = new TradeCaptureReportRequest.NoDatesGroup();
noDatesGroup.TransactTime = new TransactTime(start);
request.AddGroup(noDatesGroup);
noDatesGroup = new TradeCaptureReportRequest.NoDatesGroup();
noDatesGroup.TransactTime = new TransactTime(end);
request.AddGroup(noDatesGroup);
<br>Session.SendToTarget(request, sessionId);
TradeCaptureReportRequest Ack (AC)
public void OnMessage(TradeCaptureReportRequestAck ackReport, SessionID session)
{
if (ackReport.TradeRequestStatus.getValue() == TradeRequestStatus.REJECTED)
{
if (OnReject != null)
Console.WriteLine("TradeReportRequest Rejected");
}
else if (ackReport.TradeRequestStatus.getValue() == TradeRequestStatus.ACCEPTED)
{
Console.WriteLine("TradeReportRequestStatus Accepted");
}
else if (ackReport.TradeRequestStatus.getValue() == TradeRequestStatus.COMPLETED)
{
Console.WriteLine("TradeReportRequestStatus COMPLETED");
}
}
TradeCaptureReport (AE)
public override void OnMessage(TradeCaptureReport ackReport, SessionID session)
{
TradeReport tradeReport = new TradeReport
{
Id = ackReport.ExecID.getValue(),
LastQty = ackReport.LastQty.getValue(),
TransactTime = ackReport.IsSetTransactTime() ?
ackReport.TransactTime.getValue() : DateTime.UtcNow,
LastPrice = ackReport.LastPx.getValue(),
InstrumentId = Convert.ToInt32(ackReport.SecurityID.getValue())
};
NoSides noSides = ackReport.NoSides;
tradeReport.Symbol = _symbolMap[tradeReport.InstrumentId];
var group = new TradeCaptureReport.NoSidesGroup();
group = (TradeCaptureReport.NoSidesGroup)ackReport.GetGroup(1, group);
if (group.IsSetSide())
{
switch (group.Side.getValue())
{
case Side.BUY:
tradeReport.Side = BuySellType.Buy;
break;
case Side.SELL:
tradeReport.Side = BuySellType.Sell;
break;
}
}
tradeReport.OrderId = group.OrderID.getValue();
tradeReport.ClientOrderId = group.ClOrdID.getValue();
}
You can download the code from Github here.