AlgoTraderAlgoTrader Documentation
As a first step one needs to make sure that the appropriate AlgoTrader license key is
properly configured. The license key was provided in the Email after signing up for the
AlgoTrader free 30-day trial or when purchasing an AlgoTrader license. The license key
needs to be configured inside the file
/algotrader-conf/src/main/resources/conf.properties
as follows.
Now AlgoTrader can be started through various Eclipse Run Configurations which are available to launch the various operation modes of AlgoTrader. To access the available Eclipse Run Configurations follow screen shots below. For more information on Eclipse Run Configurations, please see https://wiki.eclipse.org/FAQ_What_is_a_launch_configuration.
Select the downward facing black arrow next to the green run symbol
Select the Run Configuration in the list on the left. The right hand side will show the project the Run Configuration will start in as well as the Main Java class
To run AlgoTrader in Simulation Mode and perform a back test of a strategy the
class ch.algotrader.starter.SimulationStarter
has to be
invoked. This will run the strategy using the embedded in-memory database h2.
In Eclipse Run Configurations named
SimulationStarter-simulate-xxx
are provided which contain the
following items:
Project: strategy project
Main Class:
ch.algotrader.starter.SimulationStarter
simulateWithCurrentParams
-Dsimulation=true -DstrategyName=XXX -DdataSource.0.dataSetType=TICK -DdataSource.dataSetName=yyy -Dspring.profiles.active=simulation,embeddedDataSource
To run the strategy in simulation mode a dependency to
algotrader-core
has to be added to the maven dependencies
of the trading strategy. Alternatively one can create a separate maven module
containing dependencies to the strategy project as well as
algotrader-core
.
To run AlgoTrader in Live Trading Mode the corresponding Adapter (e.g. local broker client, Fix session, VPN Connection, etc.) needs to be up and running.
If using InteractiveBrokers the Trader Workstation or the IB Gateway have to be running with the following configurations under API/Settings:
Enable ActiveX and Socket Clients
Read-Only Mode: false
Socket Port: 4001
Trusted IP Addresses: 127.0.0.1
When running AlgoTrader in Live Trading Mode the AlgoTrader Server and the Strategies can either be run in separate JVMs (distributed mode) or the entire system can be run within one single JVM (embedded mode).
Before starting AlgoTrader check the database table
strategy
. The column AUTO_ACTIVATE
should be set to true for records corresponding to the AlgoTrader Server and the
trading strategy one wants to trade.
In Embedded Mode both the AlgoTrader Server and the Strategy run within the same JVM.
Only one Strategy can be run at once in Embedded Mode
In Eclipse Run Configurations named
EmbeddedStrategyStarter-xxx
are provided which contain
the following items:
Project: strategy project
Main Class:
ch.algotrader.starter.EmbeddedStrategyStarter
-DstrategyName=TEST -Dmisc.embedded=true -Dspring.profiles.active=live,<dataSource>,<marketDataProfile>,<brokerProfile>,embeddedBroker,html5
dataSource
: the hibernate
datasource to use, either:
pooledDataSource
,
singleDataSource
marketDataProfile
: the
SpringProfile corresponding to the market data interface in
use (e.g. iBMarketData
or
bBMarketData
)
tradingProfile
: the SpringProfile
corresponding to the adapter in use (e.g.
iBNative
or
iBFix
)
To run the strategy in embedded mode a dependency to
algotrader-core
has to be added to the maven
dependencies of the trading strategy. Alternatively one can create a
separate maven module containing dependencies to the strategy project as
well as algotrader-core
.
In Distributed Mode the AlgoTrader Server and the Strategy / Strategies run in separate JVMs and have to be started separately.
To Start the AlgoTrader Server in distributed mode the Eclipse launch
configurations ServerStarterXX
is provided which contain the
following items:
Project: algotrader-core
Main Class:
ch.algotrader.starter.ServerStarter
-Dspring.profiles.active=live,<dataSource>,<marketDataProfile>,<brokerProfile>,embeddedBroker,html5
dataSource
: the hibernate
datasource to use, either:
pooledDataSource
,
singleDataSource
marketDataProfile
: the
SpringProfile corresponding to the market data interface in
use (e.g. iBMarketData
or
bBMarketData
)
tradingProfile
: the SpringProfile
corresponding to the adapter in use (e.g.
iBNative
or
iBFix
)
To start a Strategy Eclipse Run Configurations
StrategyStarter-xxx
are provided which contain the
following items:
Project: strategy project
Main Class:
ch.algotrader.starter.StrategyStarter
-DstrategyName=TEST -Dspring.profiles.active=live
AlgoTrader uses Docker for server environment installations. When using Docker,
various components of the system as well as their configurations are managed trough
docker-compose.yml
files. As a first step when using The
AlgoTrader Docker server environment is to configure the AlgoTrader license key
within the docker-compose.yml
file by replacing the
...
with the license key that was provided in the Email after
signing up for the AlgoTrader free 30-day trial or when purchasing an AlgoTrader
license
xyz: image: xyz command: -d environment: - VM_ARGUMENTS=-Dkeygen.id=... algotrader: image: docker.algotrader.ch/algotrader/algotrader container_name: algotrader environment: - VM_ARGUMENTS=-Dkeygen.id=...
In Embedded Mode both the AlgoTrader Server and the Strategy run within the same JVM.
Only one Strategy can be run at once in Embedded Mode
To run the system in embedded mode create a
docker-compose.yml
file similar to the
following:
xyz: image: xyz command: -e environment: - VM_ARGUMENTS=-Dkeygen.id=... links: - mysql - ibgateway - influxdb ports: - 9090:9090 - 61614:61614 environment: STRATEGY_NAME: XYZ ibgateway: image: docker.algotrader.ch/interactivebrokers/ibgateway environment: TWS_USERNAME: pmdemo TWS_PASSWORD: demouser volumes: - /var/lib/tws mysql: image: mysql:5.7.22 environment: MYSQL_ROOT_PASSWORD: password MYSQL_DATABASE: algotrader ports: - 3306:3306 volumes: - /var/lib/mysql influxdb: image: influxdb:1.5.2 ports: - 8086:8086 volumes: - /var/lib/influxdb
Please replace xyz
/ XYZ
with the name
of the trading strategy. Please refer to Chapter 4, Strategy Development
on how to create a new trading strategy.
To start the system in embedded mode please run the following command from the
directory where the docker-compose.yml
file is
located:
docker-compose up -d
This will create the following docker containers: strategy (xyz), ibgateway & mysql
For further details please see Section 2.2.3, “Docker Compose”
In Distributed Mode the AlgoTrader Server and the Strategy / Strategies run in separate JVMs and have to be started separately.
To run the system in distributed mode create a
docker-compose.yml
file similar to the
following:
xyz: image: xyz command: -d environment: - VM_ARGUMENTS=-Dkeygen.id=... links: - algotrader environment: STRATEGY_NAME: XYZ algotrader: image: docker.algotrader.ch/algotrader/algotrader container_name: algotrader environment: - VM_ARGUMENTS=-Dkeygen.id=... links: - mysql - ibgateway - influxdb ports: - 9090:9090 - 61614:61614 ibgateway: image: docker.algotrader.ch/interactivebrokers/ibgateway container_name: ibgateway environment: TWS_USERNAME: pmdemo TWS_PASSWORD: demouser volumes: - /var/lib/tws mysql: image: mysql:5.7.22 container_name: mysql environment: MYSQL_ROOT_PASSWORD: password MYSQL_DATABASE: algotrader ports: - 3306:3306 volumes: - /var/lib/mysql influxdb: image: influxdb:1.5.2 ports: - 8086:8086 volumes: - /var/lib/influxdb
Please replace xyz
/ XYZ
with the name
of the trading strategy.
To start the system in distributed mode please run the following command from
the directory where the docker-compose.yml
file is
located:
docker-compose up -d
This will create the following docker containers: strategy (xyz), algotrader, ibgateway & mysql
For further details please see Section 2.2.3, “Docker Compose”