Static Order Book Imbalance (SOBI) Strategies

Byoungjoon Kim and Michael Kearns

Updated: September 26, 2002

Strategy Summary

The underlying idea behind this family of strategies is rather simple. Imagine visualizing the distribution of volume at different prices in the buy and sell order books, as can be done nicely with Island's GUI tool (go to the "Order Book Chart" on the right). If the "shape" of the buy and sell distributions away from the last price differ sharply, it might be an indication of upcoming price movement that can be profitably acted upon. In this family of strategies, we investigate this idea only very crudely and superficially, looking for large imbalances in one distribution compared to the other. We also only do this statically, as opposed to computing the movements of the distributions. Clearly, refinement of these basic ideas is a major avenue for further research.

To describe the SOBI strategy family more precisely, we need to introduce some terminology.

Terminology

lastPrice: The most recently updated market price
bi (i=1,2,3,4) : The volume-weighted average price of the top i*25% of the volume in the buy order book. Thus b1 is computed by taking the top 25% of the buy order volume, and computing the average price offered per share. Note that b4 is simply the volume-weighted average of the entire buy order book.
si (i=1,2,3,4) : The volume-weighted average price of the top i*25% of the volume in the sell order book.

Si: si - lastPrice
Bi: lastPrice - bi

Note that Si and Bi will always be positive numbers. They can be interpreted as a measure of the "distance" from the last price of the top i*25% of the respective order book.

The SOBI Strategies

1. Basic SOBI. The basic SOBI strategy perpetually computes Si and Bi and places buy or sell orders according to the following rules:

    If (Si - Bi > theta), place an order to buy x shares at (lastPrice-p);
    If (Bi - Si > theta), place an order to sell x shares at (lastPrice+p);

We refer to SOBI as a family of strategies because we leave the choices of i=1,2,3,4, theta, p, and x as parameters.

2. Hedging SOBI. Here we introduce a new parameter hp, the "hedge" parameter.

    If (Si - Bi > theta), place an order to buy x shares at (lastPrice-p);
                                    and also place an order to sell x shares at (lastPrice+hp);
    If (Bi - Si > theta), place an order to sell x shares at (lastPrice+p);
                                    and also place an order to buy x shares at (lastPrice-hp);

Running the SOBI Strategies

1. On gradient, copy the two binary executables pxs (Penn Exchange Simulator) and sobi (for the SOBI trading strategy described above) from the directory /home/bkim2/PAT/SOBI to your home directory.
2. Open two xterms.
3. Run pxs as a background job on one xterm first, dumping the output to a file (say "out.pxs"). The unix command would look like:  pxs -p port_number > out.pxs &
4. Run sobi as a background job on the other xterm, dumping the output to a file (say "out.sobi") : sobi -p port_number [-q quartile] [-t theta] [-r orderPrice] [-h hedgeOrderPrice] [-v orderVolume] > out.sobi &   

Notes:
1. to avoid port collision, users must use only their assigned port numbers!

2. 'quartile' determines which quartile value your strategy will use.  The possible values for this are 1(25%), 2(50%), 3(75%), 4(100%)
3. orderPrice and hedgeOrderPrice determine (hedge)order price. For example, if you write "-r 0.5",  the agent place buyOrder at (lastPrice - 0.5) and sellOrder at (lastPrice+0.5).
4. If you do not specify a parameter on the command line, default values are as follows.
                 quartile = 2; // 50%
                 theta = 0.07;
                 orderPrice = 0;
                 orderVolume = 333;
 

Some Handy Unix Commands

  • I suggest that people consider the Unix utility "gnuplot", which can be invoked from the command line on gradient, for plotting purposes. Within gnuplot, you can do "help plot" to learn about the various options. As one simple example, within gnuplot you can simply type plot "foo.dat" with lines to get a plot of the data points in the file foo.dat. Please see below, for a brief note on how to crate a postscript file for a plot.
  • It is very important that project members manage their own processes, and prevent runaway jobs on gradient. We expect you to be responsible for monitoring and ending your processes. Towards this goal, the unix command ps is essential. The command ps -aux | grep pxs might result in the following output:

    mkearns 9586 0.1 0.2 2552 2032 pts/81 S 08:13:55 0:01 ./pxs -p 9800
    mkearns 10272 0.1 0.1 976 744 pts/81 S 08:18:17 0:00 grep pxs

    This simply indicates that among all users, there are two jobs running involving the string "pxs". One of these is the ps command itself, but the other, number 9586, is a simulator job. This job can be terminated by the command kill -9 9586. You can learn more about ps via doing "man ps".

  • You will find the Unix utility grep very useful for extracting specific lines from files. Do "man grep".

    How to create a postcript file of a plot in gnuplot

  • Briefly, to write a plot of the data file "foo.dat" in postscript format to the file "foo.ps", the commands are

    set terminal postscript
    set output "foo.ps"
    plot "foo.dat" with lines
    set terminal x11
    set output

    Please, read below for more information.

  • In gnuplot, a terminal determines the "format" in which a plot will be "displayed." The default terminal is x11, which just opens a X window and displays the plot there.

    To make gnuplot to write the plot in "postscript" format, just execute the following command in the gnuplot interpreter

    set terminal postscript

    We also want gnuplot to write the plot to a file. To write to file "foo.ps", type

    set output "foo.ps"

    Finally, to plot the data file "foo.dat" as a line, type

    plot "foo.dat" with lines

    Note that when we execute this command, the plot will not be shown as an X window, since we have changed the terminal. So we'll not really see what we are plotting and the current X window will not refresh. The idea is that before we changed the terminal and output, we had plotted the data to the X windows already. The command will instead generate a file "foo.ps" that is a postscript version of the plot. You can then use an external postscript viewer like 'gv' (outside gnuplot!) to display and print the postscript file. When done plotting to the file, we want to get back to the default values for terminal and output in gnuplot. To do this, type

    set terminal x11
    set output

    This will set the terminal so that future plots will be shown in the screen and the output will be written to the X window terminal where gnuplot is running, as it was before we decided to plot to a postscript file. This is important since if the terminal or the output is not changed, gnuplot will keep writting future plots to the output file in the terminal format specified!

    One way to know the current setting of these options is by executing the command 'show'. For instance,

    show terminal
    show output

    displays information about the current settings of the terminal and output options, respectively. Similarly with other options.

    You can always learn more by using the help provided in gnuplot. For instance, typing

    help

    will display the main help menu. From there you can get additional help on different sub-topics. You can also go immediate to the help for a specific command, option, or keyword in gnuplot, by typing

    help [command | option | keyword]

    For example,

    help plot

    displays help on how the plot command works. Similarly, you can execute 'help set', 'help terminal', 'help output', 'help with', 'help lines', etc. You can also find more information, and even manuals on how to use gnuplot, by doing a web-search.