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.
The Strategy is a simple example without Esper that trades the EUR.USD FX Market and is based on two exponential moving averages.
The Strategy sends a BUY order when shorter moving average (e.g. 10-days) crosses above the longer moving average (e.g. 20-days) and it sends a SELL order when shorter moving average crosses below the longer moving average.
The main artifacts needed for the Implementation of a new Strategy are described in Chapter 4, Strategy Development.
The strategy uses the TA4J library which provides over 100 technical indicator that are computed on a continuous basis.
The EMA Strategy consist of one single Java class only:
/src/main/java/ch/algotrader/strategy/ema/EMAService.java
The strategy service class providing onStart
and onBar
method containing the trading
logic
To start the Strategy please see the explanations in Chapter 3, Starting AlgoTrader.
To setup the strategy for back testing and live trading on a development workstation please execute the following steps:
Perform a Git clone from the command line:
git clone https://gitlab.algotrader.ch/general/examples.git
Import the projects ema
into Eclipse via File /
Import / Maven / Existing Maven Projects:
download file:
eurusd-1min-20111218-20130121.zip
and unpack to:
ema/files/bardata/eurusd-1min-20111218-20130121/EURUSD.csv
You can also import this bar data csv file into InfluxDB through the historical data manager (see Section 10.4, “Historical Data Manager” Historical Data Import) and run simulations based on the Influx data.
launch the Eclipse Run Configuration:
SimulationStarter-simulate-ema
To start the strategy in live trading mode on a development workstation please execute the following steps:
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:
/ema/src/main/resources/db/mysql/mysql-data.sql
invoke the Eclipse Run Configuration:
EmbeddedStarter-ema
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.ch/general/examples/blob/master/ema/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