roboquant avatar

Features

The 4 main objectives

Roboquant has 4 main objectives that determine most of its features: Fast, Flexible, Friendly and Free. All the features listed on this page can be directly linked to one of these 4 objectives.

Fast

Nowadays, there is so much more data available than ever before. It would be a lost opportunity not being able to use this data to develop smarter and better performing strategies. Roboquant can work seamlessly with these large data-sets.

The design principles that have been followed to ensure the best performance possible are:

  • Much of the builtin functionality uses multithreading and Kotlin coroutines to speedup processing. For example, the CSVFeed parses CSV files in parallel so directories with thousands of CSV files can be parsed in seconds. So modern multicore CPUs can be fully utilized.

  • Roboquant is designed NOT to be a financial ledger, and in general, algo-trading applications don’t require this. The native Java Double type provides enough precision for algo-trading purposes, and there is no need to use (a much slower and more memory-hungry) BigDecimal type. BTW, the area where roboquant uses high precise calculations is when dealing with order- and position-sizes.

  • Avoid (auto)boxing, so the JVM can access these variables directly. This means where possible use native types and not the wrapped ones. Read also this autoboxing article from Oracle.

  • Optimized paths for common use-cases, for example, trading in a single currency only.

  • Reuse objects to allow for faster referential equality comparisons. For example, the common use-case of accessing a Map with an Asset as key, benefits a lot from this.

  • The Feed API supports data that is kept in-memory as well as data that is stored on disk and only accessed when required. This allows for running back test where the test data doesn’t fit in memory or running back-tests on machines with limited memory. In fact, roboquant can be used on a JVM with only 100 MB of heap allocated.

    Additionally, there is feed support for file formats like Apache Avro™ to further reduce parsing overhead and easily share data sets

  • Avoid unnecessary copying of objects in order to limit memory allocations and garbage collection. The overall latency is kept to a minimum when processing new market data events and generating the corresponding orders. So it is feasible to create fast, low-latency (millisecond) trading strategies.

  • Optimized collections, so they can be accessed efficiently even if back tests grow in size. For example, open- and closed-orders are maintained in two separate collections, so access to open-orders remains fast even if the total number of generated orders in a back test grows to over 100.000.

  • Optimized and fine-tuned back-test engine so the engine itself will not become a bottleneck. See also the performance blog for more details about the actual performance of this engine.

Running the performance test yourself

You can easily run the performance test on your own hardware after you’ve cloned the roboquant GitHub repo. All it takes is a single command from the command line:

./mvnw compile exec:java -pl roboquant-perf

With all these measures in place, roboquant is very fast while still have the benefit of being able to use a high-level language.

The following table shows the order of magnitude that the different parts of the system have been optimized for:

Aspect Size Description

Assets

50k

the number of unique assets used in a run. For example, every stock or option-contract is a unique asset

Positions

5k

the number of open positions during a run

Orders

100k

the number of orders created during a run

Trades

100k

the number of trades generated during a run

Currencies

100

the number of different currencies used

Events

10M

the total number of events during a run

Actions

10B

the total number of actions (like candlesticks) used during a run

Exchanges

100

the number of exchanges defined

Flexible

Flexible means being able to trade at different markets in different parts of the world. This implies:

  • Support for trading assets in different currencies at the same time

  • Roboquant comes out of the box with ready to use currency converters

  • Correctly handles data from different time-zones

  • Trade traditional asset classes like stocks, options, futures and forex as well as cryptocurrencies

  • Support for simple trading strategies and advanced machine-learning based approaches

  • Support for simple and advanced order types

Flexible also means roboquant is fully modular and can be extended:

  • Integrate with 3rd party brokers and exchanges

  • Add new types of data feeds ranging from price feeds and fundamental data to unstructured data like images

  • Support for custom order types

Friendly

Developing trading algorithms requires a lot of different skills. You need to know, of course, a lot about trading itself. But also programming and even a bit of statistics comes in handy. Roboquant tries to cater for both experienced and less experienced users and make it as user-friendly as possible without sacrificing the other objectives.

Simple API

Below are two examples of the same simple breakout strategy. The first one is implemented using Python/backtrader and the second one is using Kotlin/roboquant:

class MySignal(bt.Indicator):
    lines = ('signal',)
    params = (('period', 10),)

    def __init__(self):
        self.lines.signal = self.data - bt.indicators.SMA(period=self.p.period)
val period = 10
val strategy = TaLibStrategy()
strategy.buy { it.high.last() > sma(it, period) }
strategy.sell { it.low.last() < sma(it, period) }

As you can see, the roboquant version is just as easy to develop.

Trading specific Domain Model

Rather than having a generic framework where you still have to code a lot to make it usable, roboquant approach is that of providing a trading-specific domain model.

For example, you can easily work with monetary amounts:

val wallet = 100.EUR + 20.USD + 1_000.JPY
wallet.convert(USD)

But also working with collections is easy:

val account = broker.account
val totalPNL = account.trades.sumOf { it.pnl }
val appleOrders = account.closedOrders.filter { it.asset.symbol == "AAPL" }
val biggestPosition = account.positions.maxBy { it.marketValue.value }

Interactive Development

Roboquant can be run inside a Jupyter Notebook which makes it easy to explore and experiment different ideas. Any code you developed in the notebook, you can at a later stage be used in a standalone application if you want to move to live trading.

A lot of effort went into designing an API that is easy to use from a Notebook and add features that make sense in the context of algo-trading:

  • Many charts out of the box that provide insights into the feeds and the results of a run. See aso charts examples

  • Graceful introduction of complexity. In other words: simple things should be simple, complex things should be possible

  • Many convenience methods to get results with minimal amount of coding

  • Sensible defaults for many arguments, so you don’t have to specify them all the time

Another example, if you want to plot a chart, you don’t first have to mangle data to make it consumable by the chart. In roboquant, the charts understand the key domain concepts like Account, Trades and Metrics and can plot these directly.

val account = broker.account
TradeChart(account.trades)

Once your code base grows too large for a notebook, the same code can be used in a traditional IDE.

Order Management

One of the hardest (and most overlooked) aspects of algorithmic trading is order management, especially when your goal is to come to a robust live trading environment. There are many things that potentially can go wrong and will cost you real money. It is a real endeavor to translate signals into actual orders and manage these outstanding orders.

Because of this, roboquant separates the generation of signals (Strategy) from the actual orders (Policy). This allows algo-traders to focus on the generation of signals and pick the order management that fits their risk profile and trading style. And if full control over position- and order-management is required, it is still available.

Batteries included

  • Over 150 technical indicators that are easy to use in your own strategies

  • Powerful charts when running back-tests in a Jupyter Notebook

  • Support for many back-testing approaches, like for walk-forwards and Monte Carlo

  • Pluggable metrics you can use to see how a strategy is performing

  • An advanced simulated broker for back-testing and live-testing that supports both basic and advanced order types

  • Integration with 3rd party brokers and data providers

Free

In order to build the best platform for algo-trading possible, we think it is important to make sure this platform is free for anyone to use, contribute and improve upon. That is why roboquant is developed under the permissive Apache 2.0 license and welcomes people to contribute.

But it doesn’t stop at the software. For real progress also data has to become freely available so performance of various strategies can be more easily compared. This is still very much work in progress, but for sure, on the agenda of roboquant.

Deep Learning Datasets

For inspiration, look at what quality training data did for the progress of AI in recent years. By having standardized sets of data that are known to be of good quality and representative, it became much easier to compare different approaches and continue to improve those that showed the best performance.

The same can hopefully also be achieved in the algo-trading world, so we can easily compare strategies and reproduce results.

Feature Comparison

The following table provides a short overview of how the features of roboquant stack up to some alternative algo-trading frameworks.

Of course, we are not completely objective, so we recommend trying them out for yourself and see which one suits you best.

Feature roboquant Backtrader Zipline Lean (QuantConnect)

Back Testing

Forward Testing

Paper Trading

Live Trading

Primary Language

Kotlin

Python

Python

C#

License

Apache

GPL

Apache

Apache

Active Development

Multi Currency

Crypto Exchanges

Advanced Order Types

Multi Region

Performance

high

low

low

mid

Code base

small

small

medium

large

Jupyter Notebook

Completely Free