AlgoTraderAlgoTrader Documentation

Appendix D. Example Strategy "IPO"

The strategy trades US equity IPO's (initial public offering). When a new stock is launched on the exchange for the first time the strategy tries to realize trading profits of the first trading day. New IPO's are announced on web pages like IPOScoop together with an indicative open price.

The IPO strategy is equipped with the following HTML5 custom widget which displays currently active IPO's and allows adding and removing IPO's while the strategy is running


Note

It might be necessary to fully reload the browser on first startup to show the custom widget using Ctrl + Shift + R.

Inside the custom widget the user can enter a new IPO to be traded by populating the following fields:

  • Symbol to be traded

  • SecurityFamily the symbol belongs to

  • Limit The maximum limit price of the initial order

  • Multiplier to be applied to the opening price for secondary orders (see below)

For each symbol entered, the strategy will place orders at a configurable time in the morning (e.g. 4:30am).

Note

Trading of IPO's usually starts within 2-3 hours after the official market open

Definitions:

  • Cash commitment = starting capital / number of symbols to be traded

  • Quantity per symbol = cash commitment / user-defined limit price

The strategy will place a limit-at-the-open order at user-defined limit price for the entry quantity specified above. Using a limit-at-the-open order will cause the order to participate in the opening auction of the IPO.

Immediately following the open of regular trading, the strategy will check to see if the entire cash commitment for the given symbol has been exhausted.

  1. If it has been exhausted, no further action will be taken

  2. If the cash commitment has not been exhausted and the stock opened above the LIMIT PRICE, the unfilled quantity will be cancelled, and no further action will be taken by the strategy.

  3. Otherwise, if the cash commitment for the name has NOT been exhausted a secondary limit order is placed as per below:

  • Remaining cash = Cash commitment - cash used on current position

  • Quantity per symbol = Remaining cash / opening price

  • Limit price = opening price * MULTIPLIER (e.g. 1.02)

If the secondary order is not filled by a configurable end time (e.g. 3:30pm), it will be cancelled by the system.

Immediately after executing any buy orders, the strategy will place a market-on-close order for the entire position.

The main artifacts needed for the Implementation of a new Strategy are described in chapter Chapter 5, Strategy Development.

The following list will give an overview of the specific artifacts implemented by the IPO Strategy (Note: Most of the functionality is documented via JavaDoc or Esper comments):

/src/main/java/ch/algotrader/strategy/ipo/IPOService.java

The strategy service class providing the main trading logic

/src/main/java/ch/algotrader/strategy/ipo/IPO.java

Java POJO class representing a single IPO

/src/main/resources/module-ipo.epl

Esper Module containing all statements for this strategy:

  • SEND_ATO_ORDERS: sends out at-the-open orders at the configured

  • SEND_LIMIT_ORDERS: triggers the secondary order service once the at-the-open order has been fully executed and the official open price (via GenericTickVO) has been disseminated. An Esper Join is used for this since either one of those events can arrive first

  • CLOSE_OPEN_ORDERS : cancels all orders at the configured time

  • DAILY_CLEAN_UP: unsubscribes all market data and resets the list of IPO's an initial capital

/src/main/resources/conf-ipo.properties

Contains default parameters used by the strategy

/src/main/resources/META-INF/esper-ipo.cfg.xml

Contains Esper variables for the strategy

/src/main/resources/META-INF/applicationContext-client-ipo.xml

Contains ipoConfigParams, ipoEngine & ipoService.

/src/main/resources/db/mysql/mysql-ipo.sql

Contains the MySql database records. Needs to be imported into the database before running the strategy with the MySql database.

/src/main/resources/html5

HTML5 and JavaScript files needed for the strategy custom web UI

To start the Strategy please see the explanations in chapter Chapter 4, Starting AlgoTrader.

To start the strategy in live trading mode on a development workstation please execute the following steps:

To start the strategy in live trading mode on a productive server please execute the following steps:

Copy docker compose file

Copy the following file to the server and make changes as needed:

https://gitlab.algotrader.ch/main/examples/blob/master/ipo/docker-compose.yml

Run docker compose

Invoke the following command inside the directory where the docker-compose.yml file is located:

docker-compose up -d