Installation

Two approaches

There are two different ways to install and use roboquant:

jupyter lab

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.


idea

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.

Run Jupyter Notebook

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:

  1. Jupyter Classic: Binder

  2. Jupyter Lab: Binder

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 docker.io/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 has two additional features:

  1. it disposes of the container as soon as you stop the container (the --rm option)

  2. it uses a fixed token, so you don’t have to look at the output to find out the token to use.

docker run --rm -p 8888:8888 -e JUPYTER_TOKEN="my-secret" docker.io/roboquant/jupyter

If you don’t have Docker yet installed on your computer, check out Docker get started and download Docker Desktop from there. If you are running Linux, then your distribution likely already has Docker or Podman included.

AWS SageMaker

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).

Install the roboquant libraries

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: Maven Central

  • snapshot release: Sonatype Nexus (Snapshots)

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

Maven

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 a Maven Archetype:

mvn archetype:generate                          \
-DarchetypeGroupId=org.roboquant                \
-DarchetypeArtifactId=roboquant-quickstart      \
-DarchetypeVersion=1.0               \
-DgroupId=org.mydomain                          \
-DartifactId=myapp                              \
-Dversion=0.1-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.

Gradle

Include the following line in your build.gradle script:

implementation group: 'org.roboquant', name: 'roboquant', version: 'VERSION'

Building from source

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
    submodule1
        src/main/kotlin
        src/test/kotlin
    submodule2
        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 assuming you already have this installed, building the libraries locally is as easy as:

mvn install

The build and install is tested using 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.

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 maven git openjdk-17-jre-headless
git clone https://github.com/neurallayer/roboquant.git
cd roboquant
mvn install

When the mvn 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).

Interactive Brokers

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.