Binary options 101 - An Introduction to binary options
5 stars based on
SBE was one of the binary encodings looked at. Nowadays, a large proportion of trading decisions are made by algorithms, not humans in trading pits or traders clicking with a mouse. Message encoding must be up to the task, along with every other aspect of algorithmic applications. CME Group saw SBE as an opportunity to speed up both text representation in binary trading internal messages and the market data which it disseminates to the trading world.
Circumstances change in unforeseen ways, no matter the brilliance of planners. What should you do about a protocol that is wildly successful for exchanging financial information around the world and yet is not fit-for-purpose for new use cases? FIX Protocol was created by the non-profit organisation 20 years ago to exchange trading information between US stock brokers.
It became a standard in the industry as its usage text representation in binary trading to more asset classes, including futures and options, fixed-income and other instruments.
At the same time, it covered other facets of the business beyond order routing, including market data dissemination, securities reference data and post-trade processing. FIX was able to meet all these various scenarios because they were expansions of business semantics. The new challenge was high-performance trading - a technical challenge to deliver messages with latencies measured in microseconds and even nanoseconds.
To be clear, the FIX Protocol is an industry standard, not a software implementation. Implementations need to follow the standard to interoperate, and there are numerous open-source and text representation in binary trading implementations of FIX. However, the composition of a standard has text representation in binary trading strong influence on whether high performance is attainable.
Unfortunately, the original FIX protocol design created barriers that prevented achieving really low-latency performance. To see why Simple Binary Encoding is part of the solution to the low-latency challenge, let's first take a tour of the original FIX Protocol. The first significant characteristic of the original FIX Protocol is that it is all-in-one.
Text representation in binary trading specifies message encoding, rules for message exchange session establishment and check-pointing and business text representation in binary trading, such as how order and execution quantities are managed. In the terminology of the Open Systems Interconnection conceptual model OSIit is the application layer, the presentation text representation in binary trading and the session layer, all rolled up in one big ball of text representation in binary trading. The problem with a monolithic protocol is that there is no substitutability for a better solution offered at one layer.
Separation of layers is clearly desirable and technical standards recently created by the FIX Trading Community aim to do just that. SBE was created to replace the presentation layer, no more and no less. The application layer of FIX that is familiar to thousands of users is retained. It is a requirement for SBE to be able to express existing FIX messages but also to make it possible to optimise them for performance.
A performance session layer is also under development but this is a discussion for another day. The second aspect of the original protocol that one needs to understand is why its message encoding is no longer fit-for-purpose.
Text is acceptable for fields like an account identifier and the like, but numeric text representation in binary trading, timestamps and so forth cannot be processed directly by computers. To calculate a price or time difference, text must first be converted back into native binary types. Then, to put the data back in a response message, the computer must convert the binary types back to ASCII text. This is a waste of processing time, especially for time and calendar functions, and it has no place in a high-performance system.
It was designed for a high degree of optionality. For example, 'expiration date' is an optional field on an order message, because it is only required for derivatives, but not equities. FIX also has a concept of conditionally required fields. A stop price field is only required in an order message if the order type is stop or stop-limit, but is not required otherwise.
Moreover, field text representation in binary trading within a message is largely non-deterministic. Price and then quantity is as equally valid as quantity and then price. Since the message layout is non-deterministic, it is necessary to convey metadata to identify each field in the message. The field tag is small for each field, but the combination of field tags, field delimiters and a verbose message header result in a typical message size of hundreds of bytes. All these characteristics resist performance optimisation.
High variability defeats CPU optimisations such as branch prediction and memory pre-fetch. Additionally, high variability of message layout in memory and large message size tends text representation in binary trading cause cache misses that can stall a CPU.
The variability also makes the encoding unsuitable for hardware implementations such as FPGA. The benefit is that the sender and receiver do not need to translate data representations but rather can directly use data right off the wire.
The best kind of optimisation is elimination of unnecessary work. More importantly, the SBE format is numeric, so text representation in binary trading differences can be easily computed. In this example, the backing unsigned bit integer is a count of ticks in 20, days and 14 hours, 17 minutes and 22 seconds since the UNIX epoch. SBE integers are usually encoded little-endian on the wire, since that is conducive to Intel and compatible processors.
But to be impartial, SBE also allows big-endian byte order to be specified in a message schema. One consequence of optimising for machine readability rather than human readability is that humans eventually need to read a log of FIX messages for trouble shooting or auditing, so SBE messages must be translated for human consumption. However, visualisation does not impede trading performance since it is done after the fact or on demand.
The second difference between encodings is that SBE keeps most metadata out-of-band rather than sending it text representation in binary trading the wire with each message. A message structure is defined by a template that must be disseminated to a peer, so it knows how to interpret a message.
A message template contains a list of fields in the message along with each field's identifiers and data type. A message may contain nested structures, particularly repeating groups and arrays of blocks of fields. The benefit of a template is that it controls a deterministic message layout.
Fields always appear in the message in the same order. Also, character data can have text representation in binary trading defined length. However, it is possible for a designer to constrain usage to fixed-length fields and thus produce messages of fixed-length. Another potential benefit of deterministic field position is that an application that only needs to examine select fields, such as an order router, can count on direct access to those fields without having to crack the whole message.
Such deterministic message layout also lends itself to FPGA implementations. In-band transmission of a message contains a message header that identifies its template. This supports mixing of message types in a stream. Templates may be narrowly tuned to a specific use case. The old way of designing FIX messages was to overload a message text representation in binary trading with many potential uses while making the numerous alternatives into optional fields.
The SBE way is to design a template for each narrow scenario, such as an equity order template distinct from a futures order.
Each template results in a highly optimised message layout. Aside from predictability, messages and repeating groups may even be forced to align with cache lines to prevent expensive cache misses. You may be thinking that XML is not a good choice for low-latency applications, but remember that a message schema is delivered out-of-band, not at run-time of message exchange. Most implementations parse the XML only once and generate code for encoders and decoders or at least convert it to an intermediate binary representation.
A schema usually contains multiple message templates. It containsinstances and repeating groups, labelled with XML element. A field is a unit of semantic information, such as a price, quantity or trading symbol. A field has a datatype, and its metadata has a name and a numeric ID.
By using those traditional tags, business knowledge is retained, and firms interact using shared concepts. A repeating group is an array of field blocks. The number of entries in a repeating group is usually not known until run-time. For example, a market data message may contain multiple prices, corresponding to the number of levels in an order book. The number of levels is variable with the state of a market. On the text representation in binary trading, each repeating group has a tiny header text representation in binary trading gives the dimensions of the group, so a decoder can make sense of it.
A wire format for a datatype may be shared by multiple messages and text representation in binary trading expressed by reusable simple and composite types.
A simple type, denoted by XML element, is backed by one primitive datatype. It can be either a scalar or an array of scalars. A composite type is a combination of two or more simple types, like a struct in the C language. The most common usage is to encode an exact decimal as a pair of integers, representing mantissa and exponent.
Note that these are not two separate fields, but rather a small structure that backs a single field. Remember that it is a field that carries semantic information.
One feature of SBE is that fields and types can be set to constants in metadata. When constant, the value needs not to be sent on the wire since the constant value is known to both sender and receiver. In the composite encoding for a decimal, the exponent is sometimes set to a constant, so that only the mantissa needs to be transmitted on the wire. Also, the enumeration of code values is supported. For example, order and execution messages may share an enumeration for order type; it needs to be defined only once and then can be referenced in multiple message templates.
Any value sent on the wire that does not correspond to the set of valid values specified in the schema is invalid. A bitset is sent on the wire as a native integer type of size 8 to 64 bits.
A message encoder or decoder should stride just once through a message buffer. That is best practice. This access pattern takes advantage of memory pre-fetch in hardware. The system anticipates the next piece of memory to be accessed and fetches it ahead of a read or write operation. By not jumping back and forth in a buffer, cache misses are avoided. Another best practice is to build encoders and decoders as a flyweight pattern over message buffers.