AlgoTraderAlgoTrader Documentation
The purpose of this Strategy is to demonstrate capabilities of AlgoTrader. Do not use it with a Live Trading Account and real Money! The strategy might lead to large losses. Even when modifying or extending the Strategy use caution before trading it Live.
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:
/src/main/java/ch/algotrader/strategy/delta/DeltaService.java
The strategy service class providing the all the logic.
/src/main/java/ch/algotrader/strategy/delta/DeltaConfig.java
Contains all strategy configuration items
/src/main/java/ch/algotrader/strategy/delta/DeltaSnapshotVO.java
A POJO class representing current state of security
/src/main/java/ch/algotrader/strategy/delta/DeltaEventVO.java
A POJO class representing the collection of DeltaSnapshotVO containting current state of entire portfolio
This POJO is transported to the UI via Generic Events
/src/main/resources/delta-default.properties
Contains parameters used by the strategy
/src/main/resources/META-INF/applicationContext-client-delta.xml
Contains the Spring Bean definitions for
deltaConfigParams
,
deltaConfig
,
deltaEngine
,
deltaService
/src/main/resources/META-INF/esper-delta.cfg.xml
Contains event-types definitions
/src/main/resources/db.mysql/mysql-data.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
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:
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
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.
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
invoke the Run Configuration for Futures reference data:
ReferenceDataStarter-futures-delta
invoke the Run Configuration for Options reference data:
ReferenceDataStarter-options-delta
invoke the Run Configuration:
EmbeddedStrategyStarter-delta
To start the strategy in live trading mode on a productive server please execute the following steps:
Copy the following file to the server and make changes as needed:
https://gitlab.algotrader.com/general/examples/blob/master/delta/docker-compose.yml
Invoke the following command inside the directory where the
docker-compose.yml
file is located:
docker-compose up -d
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