adl® iceberg example - Career Account Web Pages

advertisement
ADL® ICEBERG EXAMPLE
By Leo Murphy, University Program Manager, Trading Technologies International
An ICEBERG order parses the total order size into pieces and proceeds to enter the pieces successively as
each piece is filled. ADL® does not have a library block that in and of itself will place successive orders in
the market. It does however have the tools to create a strategy that will perform such a task.
An order can be considered a discrete event message. As an algorithm’s parameters are met ADL creates
a discrete event message in the form of an order that is distributed throughout the rest of the algorithm
in the form a single pulse. While an order may result in multiple discrete event messages, once the order
is filled it (the order) no longer exists.
Example 1: My algorithm says I would like to join the current bid to buy 1 ES Dec12 future. My algorithm
is a strategy on how to manage a single order in the market. Once that order is complete (“filled”) the
algorithm no longer has an order for the market. Even though there is no order you’ll notice that my
algorithm will continue to run. We see this both in the lower left hand corner of the ADL canvas (“Status:
Running”) and the fact that the bid price continues to update. The difference is that there is no order to
enter. It has been filled.
Image 1
What I need to do is replace my single order (The left side of Image 1) with an algorithm that will enter
successive orders upon the completion of each order.
Example 2: I would like to buy up to 100 CL Dec12 futures but I would like to work the order in
increments of 1 (“1 lots”) and I would like to try to buy them on the bid side of the market.
Like our original example we’re going to need and Instrument Block (CL Dec12), an Instrument Field
Block (Bid Price) and an Order Block. Whatever order we enter we want to work it on the market’s bid.
The “qty” port of the Order Block will need to be connected to some combination of ADL Library blocks
that will enter successive orders into the market. The question is ‘How?”.
Things to note:
1
1. Our orders will always be a quantity of 1.
2. We will stop sending orders when we have a total of 100 buys.
This means that we need something to keep count of our fills and enter an order each time ADL sends a
discrete message that an order is filled.
Keeping Count of our Fills: We will use the “Value Accumulator Block” to keep a running tally of our fills.
1. Select the Value Accumulator Block from the ‘Discrete Blocks’ in the ADL Toolbox. Connect it to
the “Fills” port in the Order Block. (Image 2, #1) The Value Accumulator Block keeps track of any
selected message that comes into it.
2. Double click on the Value Accumulator Block to get the ‘Edit Value Accumulator Block’ (Image 2,
#2). The block will show that the Accumulate Formula is ‘Not Defined’. By clicking on the ‘Not
Defined’ link we will get and ‘Edit Formula’ block (Image 2, #3).
3. The ‘Edit Formula’ block lets us define how and what we want to accumulate. We could put a
formula in here or just pull information straight from the connected port. In this case we will do
the latter and count each fill quantity as we receive it from the order block. We can do this by
dragging the blue ‘Message Info’ on to the green formula canvas. This will open up a ‘Select
Message Field’ block where we can choose ‘Fill Qty’ from the drop down window (Image 2, #4).
2
Image 2
Entering Successive ‘Clip Size’ Orders of 1 Until We Buy 100 Lots: With our filled orders accounted for
we now need to devise a way to enter successive 1-lot orders until we have bought a total of 100
futures.
In the ADL Toolbox, under ‘Misc Blocks’, we find the ‘Math Block’. The ‘Math Block’ provides us with
mathematical functions for analyzing data. If we double click on the block an ‘Edit Math Block’ window
opens (Image 3). From the available functions we choose the ‘Min’ function. Our strategy here is that as
we receive discrete messages for each fill the ‘Min’ function will send messages to bid for 1 lot while
monitoring the total number of fills to limit the total number of buys to 100.
Image 3
When we activate the ‘Min’ block we get two input ports for values. Every time the block receives a
discrete message (each new fill) it will compare the numeric values in the two ports and generate a
discrete message with the lesser value to the ‘qty’ input port in the order block.
Our algorithm would look something like Image 4. After each fill the accumulated fills will be added to
the ‘Clip Size’ (1). If this number is not greater than 100 it will generate a discrete message to the ‘Order
3
Block’. Image 4 shows that we have zero fills. This message is sent and the quantity is added to the ‘Clip
Size’ (1) giving us a total of 1. The lesser of the two values (1, 100) is then sent as a discrete message to
the Order Block and a working bid to buy 1 is enetered.
Image 4
The dotted yellow line is an ‘Order-Fill-Feedback’ loop meaning that the discrete messages from Order
Blocks fills are ultimately being fed directly into the Order Block.
A Quick Note on the ADL Order Block: Whenever we connect a Fill Accumulator (or a Value Accumulator
that is linked to the Order Block Fills port) to the Order Block Qty input port, we create an Order-FillFeedback loop. In some cases this creates an undesirable result. In our case however this is what we
want. Since the Order Block has an inputted quantity that is comprised of accumulated fills the Order
Block will subtract those accumulated fills from the inputted quantity and work the resulting number.
Think of it this way:
Working Order1 = Order Block Inputted Quantity2 – Accumulated Fills3
Working Order = (Clip Size + Accumulated Fills) – Accumulated Fills
1 How much we are actually trying to buy. Our “Clip Size”. This can be seen in the “wrk qty” port on the upper right
hand side of the Order Block.
4
Working Order = Clip Size
Image 5 shows us our algorithm after we have 64 fills. The accumulated fills are added to our ‘Clip Size’
(1) to generate a discrete message to the Order Block of 65 (‘Order Block Inputted Quantity’). This,
however is not the working quantity given the ‘Order-Fill-Feedback’ loop. The Order Block notes the loop
and subtracts the accumulated fills from the discrete message of 65 to arrive at a working quantity of 1
as seen in the ‘wrk qty’ port of the Order Block.
Image 5
When the total number of fills is 100 the working order is zero and the algorithm no longer sends any
orders.
Summary: This is only one way of using the ADL toolbox to create an algorithm that sends successive
orders to a market. As you experiment more you’ll find the ADL toolbox to be very practical.
2 This is the inputted quantity sent from the ‘Min’ block that is comprised of our “Clip Size” plus the accumulated
fills. It enters the Order Block at the ‘qty’ port.
3 The accumulated fills comes from the Fill Accumulator or a Value Accumulator that is linked to the Order Block
Fills port
5
Note: This example is for education use only and in no way represents a trade recommendation. This
document is for information purposes only and it should not be regarded as an offer to sell or as a
solicitation of an offer to buy the securities or other instruments mentioned in it. No part of this
document may be reproduced in any manner without the written permission of Trading Technologies.
We do not represent that this information is accurate or complete and it should not be relied upon as
such. The sole purpose of this paper is to demonstrate the functionality of Trading Technologies
software.
6
Download