Financial exchanges can be seen as big computer clusters that are accessed through specialized APIs. There are usually a few different ways to access an exchange. The connectivity can be direct or indirect, and there are usually different APIs for the different services. Direct connectivity is the fastest way to interact with the exchange and pretty much implies that you are a member of the exchange or that you are working closely with an exchange member. If you cannot afford or do not want to bother with direct connectivity then you access the exchange indirectly: your system will connect to a broker’s system that is connected to the exchange. Such a broker access may bundle up the different services into one API (e.g. using the FIX protocol). Direct connectivity usually has different APIs for different services. Typically there might be a trading API, a price feed API and a clearing API. Orders and quotes are entered and updated on the trading API. This API may or not receives confirmations of these trading commands, but will normally at least report own trade activity. Overall market activity is reported through the price feed API: it reports trading and quoting activity of other participants. Trades are reported as “last price”, quoting activity usually comes in multiple levels of details. For example, level 1 reports best order and quote activity, while level 2 reports all order and quoting activity. The clearing API tells you what happens “after” trades happen. For simple financial products like stocks, it is mostly just confirming your trading activity, but with more complex products like options, the clearing API will report exercise activity where the options are converted to stock or to cash.
In time critical trading activities like algorithmic trading or market making, the specifications of the trading API are not only what can be sent to or received from the exchange, but how much and how quickly these communications can be made. Trading commands usually have a very short validity lifetime: they become out of date with new information. All APIs have physical limitation that will cause them to block or queue-up when used with too much data or too high a rate of data. Therefore, delays will happen if too much trading activity is attempted through a trading API, and these delays may make you lose money. Some trading APIs provide extensive details on how much trading activity they allow. They may document the throttling algorithm used within them. For example, they may specify that no more than N trading commands be sent by given period of time. Other trading API may simply block when overused, or worse they may silently queue up trading commands without any form of indication. A way to avoid having the trading API queue-up always limit your trading activity. Yet that is not so simple because although you may decide when to enter an order into the market, the decision to update or cancel that order is often triggered by new information provided by others. Therefore too much new information will either cause you to try to overuse the capacity of the trading API, or leave you with “stale” orders that will be picked up by others (and bring you loss). For this type of issue, some APIs allow “mass cancelations” commands that allow all orders and quotes to be held as soon as possible, while using a minimal amount of API bandwidth. Note however that not all trading APIs offer mass cancelation options, and that the mass cancelation command may itself be subject to delays because of previously entered commands, or may have higher priority access to the exchange but then cause trouble with previously entered but not yet processed commands.
All original content copyright James Litsios, 2013.
No comments:
Post a Comment