Quality Money Management : Process Engineering and Best Practices for Systematic Trading and Investment

(Michael S) #1

207


Developers can create instances of instruments and collections of instruments or, more
appropriately, portfolios of instruments, to build the business logic layer in a manner that
is logically and structurally equivalent to reality. An instrument class will allow develop-
ers to connect to electronic exchanges via APIs. (In the class definitions, a singleton may
in fact perform the asynchronous connection to a gateway server.)
Asynchronous messages are sent and received to and from a computer ’ s queue in sep-
arate processes. An application using asynchronous communication can send a message
to a queue and immediately go on to other tasks without waiting for a reply. In synchro-
nous communication, on the other hand, the sender of a message must wait an indetermi-
nate amount of time for a response from the receiver before continuing. Sockets manage
both synchronous and asynchronous communications of messages. As you can imagine,
synchronous sockets, which make use of multithreading, are generally not preferable in
trading applications, which use networks heavily for price updates and order routing.
Rather, asynchronous sockets that do not suspend processing while waiting for network
operations are a better choice.
While message queues can provide temporary storage of data when the destination
program is busy or disconnected, real-time trading systems generally have little or no use
for old data and so message expirations are essential. Because message-oriented mid-
dleware (and business logic tiers are often message-oriented middleware) is stateless, in
many cases if a server is not connected, the middleware will be unaware unless there is
some process that monitors the state of the connection periodically.
Multithreading allows a program to perform multiple blocks of code concurrently, or
in parallel, and developers can use them to, for example, communicate asynchronously
over a network or with a database, perform time-consuming calculations, or to distinguish
between operations with different priorities. High priority threads can be used to manage
real-time data feeds and calculations while low priority ones can be used to perform less
critical tasks. In general, however, while multithreading is advantageous, fewer threads


TABLE 22-1


Nouns Description


Symbol The ticker symbol or CUSIP (unique identifier) of the instrument.


Bid The highest bid price.


Ask The lowest ask price.


Last Trade Price The price at which the last trade was executed.


Last Trade Qty The quantity of the last trade.


Bid Qty The volume on the bid price in the exchange order book.


Ask Qty The volume on the ask price in the exchange order book.


Expiration The date of the expiration of the instrument, if any.


Verbs Description


Enter Order Sends an order to the exchange.


Cancel Order(s) Sends a request to the exchange to cancel an order or orders.


22.1. PROGRAMMING CONSIDERATIONS


A simple abstracted instrument class may look like the following:
Free download pdf