Trading protocols

To have two entities communicate with each other, they need to talk the same language. In networking, we use a protocol. In trading, this protocol is used for any venue. Some venues can have numerous protocols. Even if they are different, the steps that these protocols go through to establish a connection and start trading are similar:

  1. They start by initiating a logon describing who the trading initiator is, who the recipient is, and how the communication remains alive.
  1. Then, they inquire about what they expect from the different entities, for example, trading or subscribing price updates.
  2. After, that they receive orders and price updates.
  3. Then, they maintain communication by sending heartbeats.
  4. Finally, they close communication.

 The protocol we will be using in this chapter is called the Financial Information eXchange (FIX) protocol. It was created in 1992 for international real-time exchanges to handle securities between Fidelity Investments and Salomon Brothers. It expanded to foreign exchange (FX), fixed income (FI), derivatives, and clearing. This protocol is a string-based protocol, which means humans can read it. It is platform-independent, is an open protocol, and has many versions. The most widely used versions are versions 4.2, 4.4, 5, and 1. There are two types of messages:

  • The administrative messages, which do not carry any financial data
  • The application messages, which are used to get price updates and orders

The content of these messages is like a Python dictionary: it is a list of key-value pairs. The keys are predefined tags; every tag is a number that corresponds to a specific feature. Associated with these tags are the values, which can be numerical or string values. Let's take a look at an example:

  • Let's say that the tag corresponding to the price of an order has the value 44 if we want to send an order with a price of $1.23. Therefore, in the order message, we will have 44=1.23.
  • All the pairs are character-1 separated. This means that if we add the quantity (tag 38) of 100,000 to our prior example to create an order, we will have 44=1.23|38=100000. The| symbol represents the character-1.
  • All the messages start with a prefix, that is, 8=FIX.X.Y. This prefix indicates the fix version numbers. X and Y represent the numbers of the version.
  • They all terminate when 10=nn corresponds to the checksum.
  • The checksum is the sum of all the binary values in the message. It helps us identify transmission problems.

The following is an example of an FIX message:

8=FIX.4.2|9=76|35=A|34=1|49=DONALD|52=20160617-23:11:55.884|56=VENUE1|98=0|108=30|141=Y|10=134

The preceding FIX message has the following mandatory fields:

  • A tag of 8, which is associated with the value 4.2. This corresponds to the FIX version number.
  • A version number lower than FIX4.4: 8(BeginString), 9(BodyLength),  and 35(MsgType).
  • A version number higher than FIX4.4: 8(BeginString), 9(BodyLength), 35(MsgType), 49(SnderCompID),  and 56(TargetCompID).
  • The message type is defined by the tag 35.
  • The body length tag, 9, corresponds to the character count starting at tag 35 all the way to tag 10.
  • The 10 field is the checksum. The value is calculated by summing up the decimal value of the ASCII representation of all the bytes up to, but not including, the checksum field (which is the last field), and returns the value modulo 256.
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.144.93.73