There are two ways to use roboquant:
-
Interactively in a Jupyter notebook. If you want to get up and running quickly, and want to experiment with many strategies, this is the best approach. Additionally, you get many charts out-of-the-box.
-
As a library in your own Kotlin or Java application. If you plan to develop large and complex trading strategies, this is the good approach since you have the full power of an IDE like IntelliJ IDEA at your disposal.
If you have already Docker installed, it only takes a single command to have a fully functional Jupyter Lab environment available:
docker run -p 8888:8888 roboquant/jupyter
This will pull the latest image from DockerHub and run it on your local machine. The image comes with several notebooks included that demonstrate how to develop and run your own strategies.
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 included.
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 included.
If you don’t want to install anything locally, you can:
-
Try some same notebooks right now in your browser by clicking:
-
Go to JetBrains Datalore and create an account there. It supports Kotlin Notebooks and has a free tier available if you just want to try it out.
Just add roboquant
as a dependency to your build tool, like Maven or Gradle.
Maven
<dependency>
<groupId>org.roboquant</groupId>
<artifactId>roboquant</artifactId>
<version>VERSION</version>
</dependency>
Gradle
implementation group: 'org.roboquant', name: 'roboquant', version: 'VERSION'
Next to roboquant
, the following additional artefacts are available for inclusion in your application:
-
roboquant-crypto Adds support for many of today’s most popular crypto exchanges
-
roboquant-extra Adds out-of-the-box integrations with third party brokers and market data providers.
-
roboquant-ta Adds support for technical analysis indicators and strategies
-
roboquant-jupyter Adds support for running roboquant inside Jupyter Notebooks
-
roboquant-ibkr Adds support for Interactive Brokers
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 a 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 wrapper for the build process, so building and installing the roboquant libraries locally, is as easy as:
./mvnw clean install
The build and install is tested using JDK 17 runtime.
Tip
|
If you plan to make many changes and updates to the source code, checkout the Maven Daemon project that provides faster builds. It is an almost 100% drop-in replacement of the regular maven and is much faster. |
If you want to deploy a regular release or snapshot, use the -P release
option. This will include the required plugins and also generate source- and documentation-jar files. Additionally, it will also build and deploy the roboquant-ibkr
module, so you’ll need the locally installed IBKR Java client library.
./mvnw clean deploy -P release
Of course, this requires the having the right credentials for deploying to the Maven Central repo. Also note that autoReleaseAfterClose
of the nexus-staging-maven-plugin
is set to false, meaning that if the deployment was sucessfull, you still need to (manually) release the software from staging to production.
If you don’t require integration with Interactive Brokers for your trading, you can skip this step.
Unfortunately, it is 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 the 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
After this step, you can compile and install the modules including the roboquant-ibkr
module
./mvnw install -P ibkr
Warning
|
If the artefact cannot be found in your local Maven repository during a build, the ibkr profile with the module roboquant-ibkr will be skipped.
|
There is a special doc
profile to generate documentation and see if there is something missing. You can run the following command to find missing documentation:
./mvnw dokka:dokka -P doc | grep WARNING
Please note the release
profile has its own dokka task to generate a javadoc jar file.
To run the built-in performance tests, you can use the following maven commands:
./mvnw install
./mvnw exec:java -pl roboquant-perf
The output should look something like this:
_______ | $ $ | roboquant | o | version: 2.0.0 |_[___]_| build: 2023-09-17T09:09:45Z ___ ___|_|___ ___ os: Mac OS X 13.5 ()___) ()___) home: /Users/john/.roboquant / / | | \ \ jvm: OpenJDK 64-Bit Server VM 19.0.2 (___) |_________| (___) kotlin: 1.9.10 | | __/___\__ | | memory: 4096MB /_\ |_________| /_\ cpu cores: 8 // \\ ||| ||| // \\ \\ // ||| ||| \\ // ()__) ()__) /// \\\ __///_ _\\\__ |______| |______| CANDLES ASSETS EVENTS RUNS FEED FULL SEQUENTIAL PARALLEL TRADES CANDLES/S ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 1M 10 1000 100 4ms 10ms 101ms 23ms 1K 43M 5M 50 1000 100 1ms 7ms 136ms 18ms 5K 277M 10M 50 2000 100 3ms 11ms 263ms 34ms 10K 294M 50M 100 5000 100 5ms 55ms 987ms 130ms 50K 384M 100M 200 5000 100 9ms 109ms 1593ms 245ms 100K 408M 500M 500 10000 100 37ms 445ms 8994ms 1614ms 500K 309M 1000M 500 20000 100 73ms 883ms 19120ms 3325ms 1000K 300M
Note
|
The main purpose is to test the performance and stability of the back-test engine itself, not any specific feed, strategy or metric. So the overhead of those components is kept to a minimum, while still running full back tests. |
On a high-end server machine (c7g metal instance on AWS), you can expect even higher performance. In a best case scenario, the engine can process over 1.2 billion candle-sticks per second:
_______ | $ $ | roboquant | o | version: 2.0.0 |_[___]_| build: 2023-09-17T12:03:17Z ___ ___|_|___ ___ os: Linux 5.19.0-1025-aws ()___) ()___) home: /home/ubuntu/.roboquant / / | | \ \ jvm: Java HotSpot(TM) 64-Bit Server VM 20.0.2 (___) |_________| (___) kotlin: 1.9.10 | | __/___\__ | | memory: 30208MB /_\ |_________| /_\ cpu cores: 64 // \\ ||| ||| // \\ \\ // ||| ||| \\ // ()__) ()__) /// \\\ __///_ _\\\__ |______| |______| CANDLES ASSETS EVENTS RUNS FEED FULL SEQUENTIAL PARALLEL TRADES CANDLES/S ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 1M 10 1000 100 5ms 22ms 140ms 10ms 1K 100M 5M 50 1000 100 2ms 13ms 276ms 12ms 5K 416M 10M 50 2000 100 5ms 25ms 565ms 15ms 10K 666M 50M 100 5000 100 6ms 106ms 2369ms 47ms 50K 1063M 100M 200 5000 100 11ms 191ms 3988ms 83ms 100K 1204M 500M 500 10000 100 53ms 755ms 21449ms 458ms 500K 1091M 1000M 500 20000 100 130ms 1686ms 42971ms 958ms 1000K 1043M