FIX API
General information
The B2CONNECT FIX server provides all the functionality necessary for real-time trading and receiving up-to-date market information via the Financial Information eXchange protocol.
In this document, you can find a detailed description of the B2CONNECT FIX API, including the information about how to connect to a demo FIX server.
Note
The B2CONNECT FIX API is based on the version 4.4 of the Financial Information eXchange protocol.
It’s assumed that the reader of this document is already familiar with the FIX protocol. To learn more about the protocol specification, see the FIX Trading Community website.
If your trading engine is powered by Go, take a minute to learn about SimpleFix Go. This open-source library is provided by the B2CONNECT team to help you quickly integrate FIX messaging into your environment. The library is entirely written in Go and supports any FIX API version.
Supported message types
The following message types can be assigned to the <35> MsgType
field of a Standard header:
0
— Heartbeat (Client ↔ B2CONNECT)1
— Test Request (Client ↔ B2CONNECT)2
— Resend Request (Client ↔ B2CONNECT)3
— Reject (Client ← B2CONNECT)4
— Sequence Reset (Client ↔ B2CONNECT)5
— Logout (Client ↔ B2CONNECT)8
— Execution Report (Client ← B2CONNECT)9
— Order Cancel Reject (Client ← B2CONNECT)A
— Logon (Client → B2CONNECT)D
— New Order Single (Client → B2CONNECT)F
— Order Cancel Request (Client → B2CONNECT)V
— Market Data Request (Client → B2CONNECT)W
— Market Data — Snapshot/Full Refresh (Client ← B2CONNECT)Y
— Market Data Request Reject (Client ← B2CONNECT)
Standard header
All FIX messages must start with a Standard header.
The Standard header includes the following fields:
Tag |
Name |
Required |
Datatype |
Description |
---|---|---|---|---|
8 |
BeginString |
Y |
String |
Marks the beginning of a new message and indicates the FIX version ( Always the first field in a message. |
9 |
BodyLength |
Y |
int |
The message length, in bytes. Always the second field in a message. |
35 |
MsgType |
Y |
String |
The message type. Always the third field in a message. See Supported message types for a list of supported values. |
34 |
MsgSeqNum |
Y |
int |
The message sequence number. This value is incremented by 1 for each consecutive message. |
49 |
SenderCompID |
Y |
String |
The B2CONNECT-supplied identifier of a client sending requests to the FIX server. |
52 |
SendingTime |
Y |
Timestamp |
The date and time when a message was sent, in UTC time with milliseconds precision: |
56 |
TargetCompID |
Y |
String |
The B2CONNECT-supplied identifier of a server receiving client messages. |
Standard trailer
Along with a Standard Header, all FIX messages must also contain a Standard trailer.
The Standard trailer includes the following fields:
Tag |
Name |
Required |
Datatype |
Description |
---|---|---|---|---|
10 |
CheckSum |
Y |
int |
A three-digit simple checksum indicating the end of a message. Always the last field in a message. |
Session messages
The messages listed in this section are used to maintain any live FIX session with the B2CONNECT FIX server, including both quoting and trading sessions.
Heartbeat
This message is sent back and forth between the FIX server and the client to check the connection status and in response to Test Request messages.
The Heartbeat message includes the following fields:
Tag |
Name |
Required |
Datatype |
Description |
---|---|---|---|---|
Y |
|
|||
112 |
TestReqID |
N |
String |
The identifier of a Test Request in response to which this Heartbeat message is sent. |
Y |
Test Request
This message is sent back and forth between the FIX server and the client in response to Heartbeat messages as a means of connectivity check.
The Test Request message includes the following fields:
Tag |
Name |
Required |
Datatype |
Description |
---|---|---|---|---|
Y |
|
|||
112 |
TestReqID |
N |
String |
The identifier of this Test Request in response to which a Heartbeat message will be sent. |
Y |
Resend Request
This message is sent by the client or FIX server to initiate the retransmission of messages, which may be required upon detecting a gap in the sequence numbers or losing a particular message.
The Resend Request message includes the following fields:
Tag |
Name |
Required |
Datatype |
Description |
---|---|---|---|---|
Y |
|
|||
7 |
BeginSeqNo |
Y |
int |
The number of the first message in a sequence to resend. |
16 |
EndSeqNo |
Y |
int |
The number of the last message in a sequence to resend:
|
Y |
Reject
This message is sent by the FIX server upon receiving a malformed message from the client.
The possible reason for rejection is specified in the <373> SessionRejectReason
field.
Note
This message is unrelated to a trade-level rejection (Order Cancel Reject) issued when a FIX server is unable to place a requested order.
The Reject message includes the following fields:
Tag |
Name |
Required |
Datatype |
Description |
---|---|---|---|---|
Y |
|
|||
45 |
RefSeqNum |
Y |
int |
The sequence number of a rejected message ( |
371 |
RefTagID |
N |
int |
The tag number of a field that caused message rejection. |
372 |
RefMsgType |
N |
int |
The type of a rejected message ( |
373 |
SessionRejectReason |
N |
int |
The reason why a message is rejected. See Possible reasons for a list of possible values. |
58 |
Text |
N |
String |
The detailed information about the rejection reason. |
Y |
Possible reasons
When the FIX server sends a Reject notification informing the client that a session-level request has been rejected, the <373> SessionRejectReason
field can be set to one of the following values specifying the reason for message rejection:
0
— an invalid tag number1
— a required tag is missing2
— a tag isn’t defined for this message type3
— a tag is undefined4
— a tag has no value assigned5
— an assigned value is incorrect (out of range) for this tag6
— an incorrect value data format7
— an issue related to decryption9
— an issue related toCompID
10
— an accuracy issue related to<52> SendingTime
11
— an invalid<35> MsgType
12
— an XML validation error13
— the same tag appears more than once14
— a tag is specified not in the required order15
— a wrong order of repeating group fields17
— a non-“Data” value includes a field delimiter (an SOH character)99
— other (unspecified) reason
Sequence Reset
This message is sent by the client or FIX server to indicate to the recipient the sequence number of the next message from the sender, immediately following the Sequence Reset message. This may be necessary to recover from a disconnect, in case if some messages were lost or their resending is not desirable.
The Sequence Reset message includes the following fields:
Tag |
Name |
Required |
Datatype |
Description |
---|---|---|---|---|
Y |
|
|||
123 |
GapFillFlag |
N |
Boolean |
Indicates that this message replaces missing messages that won’t be resent:
|
36 |
NewSeqNo |
Y |
int |
The new sequence number. |
Y |
Logon
This message is sent by the client to initiate a FIX session.
The Logon message includes the following fields:
Tag |
Name |
Required |
Datatype |
Description |
---|---|---|---|---|
Y |
|
|||
98 |
EncryptMethod |
Y |
int |
The message encryption method. This value must always be |
108 |
HeartBtInt |
Y |
int |
The heartbeat interval, in seconds. Indicates how often the FIX server sends messages to the client as part of a connection health check. The maximum value is 60. |
141 |
ResetSeqNumFlag |
Y |
Boolean |
Indicates whether both parties of a FIX session should reset the currently used sequence numbers. It’s recommended to set the flag to Y for Quoting sessions. |
553 |
Username |
N |
String |
The client username. It should be specified if provided as part of the FIX credentials. |
554 |
Password |
Y |
String |
The client password, as provided by B2CONNECT. |
Y |
Logout
This message is sent by the client or FIX server to terminate a session.
When terminated, the possible reason is specified in the <58> Text
field.
The Logout message includes the following fields:
Tag |
Name |
Required |
Datatype |
Description |
---|---|---|---|---|
Y |
|
|||
58 |
Text |
N |
String |
The detailed information about the reason for logging out. |
Y |
Demo mode
The B2CONNECT FIX server supports a Demo mode that allows clients to establish a test connection and simulate quoting and trading sessions. Contact your account manager to obtain a set of settings and credentials.
Quoting
After connecting to the FIX server and establishing a live quoting session, the client can send a Market Data Request to subscribe to quote updates streamed by B2CONNECT.
Note
To subscribe to multiple symbols, the client should send a separate Market Data Request for each symbol.
Upon successful subscription to a selected symbol, the FIX server starts streaming market data updates by sending Market Data — Snapshot/Full Refresh messages each time the market data is updated. The quote updates are streamed continuously for the entire duration of a FIX session.
If a subscription request can’t be executed for some reason (for example, when a requested symbol isn’t found), the FIX server responds with a Market Data Request Reject message providing detailed information about an error.
To terminate a specific subscription and stop receiving the updates, the client can send a Market Data Request with the <263> SubscriptionRequestType
set to 2
(standing for “Unsubscribe”).
Upon sending a Logout request, the current session is closed and subscriptions to all ticker symbols are terminated.
Market Data Request
This message is sent by the client to start receiving up-to-date quoting data for a specified ticker symbol.
The Market Data Request message includes the following fields:
Tag |
Name |
Required |
Value Type |
Description |
---|---|---|---|---|
Y |
|
|||
262 |
MDReqID |
Y |
String |
The identifier of a market data request. This value must be unique for the duration of each session. If |
263 |
SubscriptionRequestType |
Y |
int |
The type of response expected from the FIX server:
|
264 |
MarketDepth |
Y |
int |
The market depth for an order book snapshot:
|
265 |
MDUpdateType |
Y |
int |
This value must always be |
267 |
NoMDEntryTypes |
Y |
int |
The number of |
→ 269 |
MDEntryType |
Y |
int |
The side of a quote:
|
146 |
NoRelatedSym |
Y |
int |
The number of ticker symbols included in a subscription. This value must always be To subscribe to multiple symbols, the client should send a separate Market Data Request for each symbol. |
→ 55 |
Instrument |
Y |
String |
The ticker symbol to subscribe to (such as |
Y |
Market Data Request Reject
This message is sent by the FIX server to reject a Market Data Request with invalid values.
The Market Data Request Reject message includes the following fields:
Tag |
Name |
Required |
Value Type |
Description |
---|---|---|---|---|
Y |
|
|||
262 |
MDReqID |
Y |
String |
The identifier of a rejected Market Data Request. |
281 |
MDReqRejReason |
N |
int |
The reason why a request is rejected. See Possible reasons for a list of supported values. |
58 |
Text |
N |
String |
The detailed information about the rejection reason. |
Y |
Possible reasons
The <281> MDReqRejReason
field can be set to one of the following values specifying the reason for request rejection:
0
— the specified symbol isn’t recognized1
— a duplicate<262> MDReqID
2
— insufficient bandwidth3
— insufficient permissions4
— the specified<263> SubscriptionRequestType
isn’t supported5
— the specified<264> MarketDepth
isn’t supported6
— the specified<265> MDUpdateType
isn’t supported8
— the specified<269> MDEntryType
isn’t supported
Market Data — Snapshot/Full Refresh
Such messages are continuously sent by the FIX server after the client subscribes to a ticker symbol. A new message is sent with each market data update.
The Market Data — Snapshot/Full Refresh message includes the following fields:
Tag |
Name |
Required |
Value Type |
Description |
---|---|---|---|---|
Y |
|
|||
262 |
MDReqID |
Y |
String |
The identifier of an originating Market Data Request. |
55 |
Instrument |
Y |
String |
The ticker symbol that’s being quoted (such as |
268 |
NoMDEntries |
Y |
int |
The number of market data entries (bids or asks) listed in a request. |
→ 269 |
MDEntryType |
Y |
int |
The side of a quote:
|
→ 270 |
MDEntryPx |
Y |
Price |
The price for a market data entry. |
→ 271 |
MDEntrySize |
Y |
Qty |
The tradable volume of a market data entry. |
→ 299 |
QuoteEntryID |
N |
String |
The unique identifier of a quote. |
Y |
Trading
Place an order
After establishing a trading session with the FIX server, the client can place a new order by sending a New Order Single message.
In response to this, the FIX server sends back an Execution Report with the <150> ExecType
field set to A
, indicating that the order is placed successfully.
If the order can’t be placed (for example, due to lack of credit funds or other issues), the report is sent with <150> ExecType
set to 8
.
After placing the order, the FIX server sends a separate report with <150> ExecType
set to F
each the order status changes:
If the order is executed partially,
<39> OrdStatus
is set to1
.When the order is fully filled,
<39> OrdStatus
is set to2
.
Cancel an order
To cancel an open order, the client can send an Order Cancel Request.
If the order is canceled (either explicitly by a trader, or automatically due to timeout), the Execution Report is sent with <150> ExecType
set to 4
.
In this case, the <14> CumQty
field indicates the amount that has already been filled by the time the order was canceled, and <151> LeavesQty
indicates the unfilled amount.
If an order can’t be canceled for any reason, the FIX server sends back an Order Cancel Reject message indicating why the order cancellation failed.
New Order Single
This message is sent by the client to place a new order with specified parameters.
The New Order Single message includes the following fields:
Tag |
Name |
Required |
Value Type |
Description |
---|---|---|---|---|
Y |
|
|||
1 |
Account |
N |
String |
The client-defined account name. |
11 |
ClOrdID |
Y |
String |
The client-provided identifier of an order. This value must be unique across all previous trading sessions. |
55 |
Instrument |
Y |
String |
The ticker symbol (such as |
54 |
Side |
Y |
int |
The order side:
|
38 |
OrderQty |
Y |
Qty |
The order amount. |
40 |
OrdType |
Y |
Char |
The order type:
|
44 |
Price |
C |
Price |
The order price. This field is required for limit orders. |
58 |
Text |
N |
String |
The additional comments about an order. |
59 |
TimeInForce |
Y |
Char |
The time-in-force option applied to an order:
|
60 |
TransactTime |
Y |
Timestamp |
The date and time when an order was created, in UTC time with milliseconds precision: |
21 |
HandlInst |
Y |
int |
This field is ignored. Execution is always treated as if the supplied value was |
Y |
Order Cancel Request
This message is sent by the client to cancel an open order in its entire remaining amount.
This request is assigned a unique <11> ClOrdID
and is treated as a separate order.
Upon successful cancellation of the order, an Execution Report is sent with the <39> OrdStatus
field set to 4
.
In this case, the <14> CumQty
field indicates the amount that has already been filled by the time the order was canceled.
If the order can’t be canceled for some reason, the FIX server sends back an Order Cancel Reject message indicating why the order cancellation failed.
The Order Cancel Request message includes the following fields:
Tag |
Name |
Required |
Value Type |
Description |
---|---|---|---|---|
Y |
|
|||
41 |
OrigClOrdID |
Y |
String |
The |
11 |
ClOrdID |
Y |
String |
The client-provided unique identifier of the Order Cancel Request. |
Y |
Order Cancel Reject
This message is sent by the FIX server upon receiving an Order Cancel Request that can’t be fulfilled.
The Order Cancel Reject message includes the following fields:
Tag |
Name |
Required |
Value Type |
Description |
---|---|---|---|---|
Y |
|
|||
37 |
OrderID |
Y |
String |
The unique identifier assigned to an order by the FIX server. This value is |
41 |
OrigClOrdID |
Y |
String |
The |
11 |
ClOrdID |
Y |
String |
The client-provided unique identifier of the Order Cancel Request. |
39 |
OrdStatus |
Y |
Char |
The current order status by the moment of message generation:
|
102 |
CxlRejReason |
Y |
int |
The reason why a cancellation request is rejected:
|
434 |
CxlRejResponseTo |
Y |
int |
The type of a request that’s rejected. This value must always be |
60 |
TransactTime |
Y |
Timestamp |
The date and time of the last transaction made as part of order processing, in UTC time with milliseconds precision: |
Y |
Execution Report
This message is sent by the FIX server upon successfully placing or cancelling an order, or any change to the order status (such as a complete or partial execution). Among other data, the report indicates:
the current order status at the moment of report creation (
<39> OrdStatus
)the most recent change in the order status, which is being reported (
<150> ExecType
)
The Execution Report message includes the following fields:
Tag |
Name |
Required |
Value Type |
Description |
---|---|---|---|---|
Y |
|
|||
11 |
ClOrdID |
Y |
String |
The unique identifier assigned to an order by the client as part of a New Order Single request. |
37 |
OrderID |
Y |
String |
The unique identifier assigned to an order by the FIX server. |
17 |
ExecID |
Y |
String |
The unique identifier assigned by the FIX server to an individual execution. An empty string, if |
39 |
OrdStatus |
Y |
String |
The current order status by the moment of message generation:
|
150 |
ExecType |
Y |
String |
The type of a received report:
|
55 |
Instrument |
Y |
String |
The ticker symbol of an instrument listed in the original order request, such as |
54 |
Side |
Y |
int |
The order side:
|
38 |
OrderQtyData |
Y |
Qty |
The order amount, as indicated in the initial order. |
40 |
OrdType |
Y |
int |
The order type:
|
44 |
Price |
N |
Price |
The order bid or ask price. This field is included in the execution report for limit orders only. |
59 |
TimeInForce |
Y |
Char |
The time-in-force option applied to an order:
|
31 |
LastPx |
N |
Price |
For reports signaling a trade execution ( |
32 |
LastQty |
N |
Qty |
For reports signaling a trade execution ( |
151 |
LeavesQty |
Y |
Qty |
For reports signaling a trade execution ( |
14 |
CumQty |
Y |
Qty |
The total order amount filled so far, including the amount filled most recently. |
6 |
AvgPx |
Y |
Price |
The average price calculated based on all order parts filled so far, taking into account the most recent execution. This value is 0 for orders that are still awaiting execution ( |
64 |
SettlDate |
N |
Date |
For reports signaling a trade execution ( |
75 |
TradeDate |
N |
Date |
For reports signaling a trade execution ( |
103 |
OrdRejReason |
N |
int |
For reports signaling an order rejection ( |
58 |
Text |
N |
String |
For canceled ( |
60 |
TransactTime |
C |
Timestamp |
The date and time of the most recent change in the order status, in UTC time with milliseconds precision: This field is omitted for orders that are still awaiting execution ( |
Y |