AlgoTraderAlgoTrader Documentation

Appendix H. Example Strategy "Delta Hedge"

Delta hedging is an options strategy that aims to reduce or hedge, the risk associated with price movements in the underlying asset. The approach uses Futures to offset the risk to an entire portfolio of holdings. The investor tries to reach a delta neutral state and not have a directional bias on the hedge.

Since delta hedging attempts to neutralize or reduce the extent of the move in an option's price relative to the asset's price, it requires a constant rebalancing of the hedge.

The Strategy tracks all position changes and calculates deltas for each position every 10 seconds. Every 30 seconds it calculates portfolio average deltas and adjusted market values.

Depending on the results - strategy hedges positions using Futures until it reaches a delta neutral state.

The following list will give an overview of the specific artifacts implemented by the Delta Strategy. Most of the functionality is documented via comments:

The Delta strategy is equipped with an HTML5 custom widget that displays current metrics like Delta, Adjusted Market Value, etc.


To setup the strategy for live trading on a development workstation please execute the following steps:

Download the Example Strategies

If you have used the Section 2.1, “Windows Installer” to setup AlgoTrader, this project is already setup in the AlgoTrader IntelliJ IDEA and you can skip this step.

Download the Examples project zip file and unpack it in a directory of your choosing: https://www.algotrader.com/downloads/latest-examples

Note

user name and password will be provided when signing up for an AlgoTrader license

If you need an older AlgoTrader version, login to our maven repository (https://repo.algotrader.com/nexus) and click on Browse on the left and select code-general.

Then select the AlgoTrader version you want and download:

Import the project delta into your IDE.

Initialize the database

load the db-samples script into the MySQL database: /algotrader-conf/src/main/resources/db-samples/mysql/mysql-data.sql

load the strategy specific script into the MySQL database: /delta/src/main/resources/db.mysql/mysql-data.sql

Download Reference Data

invoke the Run Configuration for Futures reference data: ReferenceDataStarter-futures-delta

invoke the Run Configuration for Options reference data: ReferenceDataStarter-options-delta

Start the Strategy

invoke the Run Configuration: EmbeddedStrategyStarter-delta

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.com/general/examples/blob/master/delta/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

Note

Prior to starting the strategy for the very first time please start the AlgoTrader server by itself by executing the following command inside /bootstrap/launch. this will load the MySQL sample data

docker-compose up -d mysql ibgateway algotrader