This series looks at building a near full-scale application in q and, in the process, tries to answer questions on the amount of code a q application requires, and how that code can be organised so that it is both comprehensible and straightforward to change. The target application is a participation strategy and some of its associated testing framework.
Participation is one of basic execution strategies: trading in line line with the market. At its simplest, every trade seen in the market is responded to by sending an order to take a proportionate quantity from the opposite side (far side) of the order book, i.e. the ask side if the strategy is buying. The strategy is not a "completing" strategy: it does to aim to finish the full order quantity assigned to it, as it simply reacts to the volume traded in the market. Despite this simplicity, the participation strategy can be viewed as the foundation for many other strategies. Algorithms that have fixed quantity schedules, such as VWAP, can also be expressed as constant or variable rate participation strategies. For one reason why this may be a good thing, see this chart.
The average price achieved by the strategy would be poor if all the strategy did was take from the order book. Consequently participation strategies operate on both the far and the near side of the book, aiming to achieve an average price nearer to the volume weighted average trade price, VWAP. Below is a summary of the basic near and far execution tactics. In the text
qty refers to the upstream order quantity;
leaves are the quantities filled and remaining;
maxtake are strategy parameters. From 2009-02-18:
minqty was renamed
minsize to avoid confusion with the equivalent FIX field.
|What is the primary signal for action?||Trades||Quotes|
|What types of order are used downstream?||IOC with limit price||Day orders with limit price|
|How is the quantity for the order calculated?|
|What are the minimum constraints on order quantity?|
|What are the maximum constraints on order quantity?|
|Which other signals can prompt action?||Quotes can prompt an order if the execution has been reduced by a maximum constraint, i.e. an increase in the far qty could cause another IOC to be sent||n/a|
|What happens when ||Reduce |
From 2009-02-05: Place all the remaining quantity on the book
If the design (and the coding) is right, then other tactics can be added without rewriting code: for example, consider adding a third tactic ("deep") that, with a hint about the duration of the order, uses the barrier diffusion model for longer term order placement.
In keeping with the limitations in this series, the participation strategy will neglect essential features such as spread constraints, start and end times, and auction participation.
Upstream orders are sent to the strategy and are executed within specification until
leaves equals zero. There is no status change on completion: if the upstream order is amended to have more
qty then the order can be processed again. This can be useful as it allows us to run the strategy with tranches of the original order size.
Execution is delegated to the tactics in equal allocations, each allocation being a multiple of the
minsize. As the tactics work through their allocation, further allocations are made on a "just-in-time" basis. The farside tactic has priority once the last allocation is being made; if the nearside tactic is still executing whilst the farside tactic has stopped, then all the remaining quantity is reallocated to the farside tactic.
This model of the strategy acting as the allocator, and the tactics executing their allocated quantities, means that the tactics will need their own values for
leaves and the strategy parameters.
|Benchmark figures are reset.|
|The effective |
|The effective |
Orders that are explicitly cancelled have their
qty amended down to the current value of
filled and all downstream orders are cancelled.