
Interactively in a Jupyter Notebook. If you want to be up and running quickly, this is the easiest approach. Additionally, you get many charts out-of-the-box that help you to understand how the strategy is performing.
There are two ways to install and use roboquant:
Interactively in a Jupyter Notebook. If you want to be up and running quickly, this is the easiest approach. Additionally, you get many charts out-of-the-box that help you to understand how the strategy is performing.
As a library in your standalone Kotlin or Java application. If you plan to develop large and complex trading strategies, this is a good approach since you’ll have the full power of an IDE like IntelliJ IDEA at your disposal.
If you don’t want to install anything on your local machine, you can try any of the included notebooks right now by clicking on one of the two following badges:
However, if you have already Docker installed on your local machine, all it takes is a single command to have a fully functional Jupyter Notebook environment with roboquant available that is ready to use.
docker run -p 8888:8888 roboquant/jupyter
By default, this will start a new Jupyter-Lab environment. The installation comes with several how-to notebooks included that demonstrate how to develop and run your own strategies.
The following startup command shows some useful additional options that you can use:
dispose of the container as soon as you stop the container (the --rm
option)
use a predefined token, so you don’t have to look in the output to find out the token to use
map your local working directory to the work directory in the docker container
starts a classic notebook rather than a Jupyter Lab environment
docker run \
--rm \
-p 8888:8888 \
-e JUPYTER_TOKEN="my-secret" \
-e DOCKER_STACKS_JUPYTER_CMD=notebook \
-v "${PWD}":/home/jovyan/work \
roboquant/jupyter
If you don’t have Docker yet installed on your computer, check out Docker get started and download Docker Personal from there. If you are running Linux, then your distribution likely already has Docker or Podman included.
The AWS SageMaker notebook instances don’t have Kotlin support enabled by default. But there is an easy way to add it the first time an instance is created. You can add a lifecycle
script that will be run when the environment is created and in our case adds the Kotlin kernel.
When creating a new notebook instance from the SageMaker menu, open the additional configuration
option and select create new lifecycle configuration
from the lifecycle configuration dropdown. Then add the following snippet to the Start notebook
tab.
#!/bin/bash
set -eux
# This script installs the Kotlin kernel before starting the notebook
sudo -u ec2-user -i <<'EOF'
source /home/ec2-user/anaconda3/bin/activate JupyterSystemEnv
pip install kotlin-jupyter-kernel
source /home/ec2-user/anaconda3/bin/deactivate
EOF
This has been tested with the platform identifier set to "Amazon Linux 2/Jupyter Lab 3" and "Give users root access to the notebook" enabled (default).
Just add roboquant
as a dependency to your build tool, like Maven or Gradle. Regular versions of the Roboquant modules are published to Maven Central and snapshots are published to OSS Sonatype (https://s01.oss.sonatype.org/content/repositories/snapshots).
The latest available versions:
regular release:
snapshot release:
The following modules are available for inclusion in your application:
roboquant
: the core module of the platform
roboquant-crypto
: support for many of today’s popular crypto exchanges
roboquant-extra
: integrations with 3rd party brokers and market data providers
roboquant-ibkr
: integration with Interactive Brokers
roboquant-ta
: over 150 technical analysis indicators and strategies
roboquant-jupyter
additional Jupyter Notebook functionality like charting
Add the following snippet to your pom.xml file in the dependencies section:
<dependency>
<groupId>org.roboquant</groupId>
<artifactId>roboquant</artifactId>
<version>VERSION</version>
</dependency>
or if you want to create your own new algo-trading project, you can run the Maven Archetype that is available for roboquant:
mvn archetype:generate \
-DarchetypeGroupId=org.roboquant \
-DarchetypeArtifactId=roboquant-quickstart \
-DarchetypeVersion=1.2.0 \
-DgroupId=org.mydomain \
-DartifactId=myapp \
-Dversion=1.0-SNAPSHOT
This will result in a fully functional Kotlin Maven project with a small sample strategy, that is ready to be imported an IDE like IntelliJ IDEA.
Include the following line in your build.gradle script:
implementation group: 'org.roboquant', name: 'roboquant', version: 'VERSION'
First start with cloning the roboquant GitHub repository to your local disk. The quickest way to be up and running is then to install IntelliJ IDEA (either the free community edition or the paid Ultimate version) and open the directory you just cloned. IntelliJ IDEA will recognize it as Kotlin/Maven project, and you can build it and run test directly from the IDE.
Roboquant uses a directory setup that is similar to most other Kotlin projects:
root roboquant src/main/kotlin src/test/kotlin roboquant-extra src/main/kotlin src/test/kotlin ...
All source code is written in Kotlin, so there are no Java or other language source files. Roboquant uses Maven for the build process and includes a Maven wrapper (mvnw) to ensure optimal compatability between environments. Building the libraries locally is as easy as running a single command:
./mvnw install
The build and install is tested using the JDK 17 runtime, however the generated libraries are targeted against JDK 11 in order to provide better compatibility for projects that still use older versions of the JDK. JDK versions before 11 are not supported.
The following script shows how to get everything build based on a clean Ubuntu 22.04 installation (like the one you can select when starting an AWS EC2 instance)
sudo apt update -y
sudo apt install -y git openjdk-17-jre-headless
git clone https://github.com/neurallayer/roboquant.git
cd roboquant
./mvnw install
When the ./wvnw install
process has successfully finished, you should see something like this:
[INFO] roboquant parent ................................... SUCCESS [ 1.618 s]
[INFO] roboquant .......................................... SUCCESS [ 6.768 s]
[INFO] roboquant ta ....................................... SUCCESS [ 3.868 s]
[INFO] roboquant jupyter .................................. SUCCESS [ 2.503 s]
[INFO] roboquant extra .................................... SUCCESS [ 2.838 s]
[INFO] roboquant crypto ................................... SUCCESS [ 3.213 s]
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
If you plan to make regular changes and updates to the roboquant source code, checkout the Maven Daemon project that provides faster builds. Additionally, you can set the Kotlin incremental compiler property to true (in the main pom.xml ).
|
Unfortunately we are not allowed to redistribute the Interactive Brokers Java client, so you’ll have to download the TwsApi.jar file yourself. You can download the stable version 10.19
from here: https://interactivebrokers.github.io and within the downloaded archive file you’ll find the required TwsApi.jar
.
Then install the jar file in your local Maven repository on your machine using the following command:
mvn install:install-file -Dfile=TwsApi.jar -DgroupId=com.interactivebrokers -DartifactId=tws-api -Dversion=10.19 -Dpackaging=jar
If this artefact cannot be found in your local Maven repository during a build, the module roboquant-ibkr
will automatically be skipped. So if you don’t require integration with Interactive Brokers for your trading, you can skip this step altogether.