an open source algorithmic trading framework written in Kotlin for anyone serious about algo-trading

Overview

Roboquant

roboquant Kotlin Automated Build APL v2 Binder GitHub issues GitHub last commit GitHub tag (latest by date)

Roboquant is an algorithmic trading platform that is fast and flexible while at the same time strives to be easy to use. It is fully open source and written in Kotlin. It can be used in Jupyter Notebooks as well as standalone applications. It is meant to be used by anyone serious about algo trading, from retail traders to proprietary trading firms.

You can find out more at roboquant.org roboquant Logo

Code sample

To demonstrate how easy it is to get started, the following code snippet shows all the key ingredients required to back-test a trading strategy:

val strategy = EMACrossover()
val metric = AccountSummary()
val roboquant =  Roboquant(strategy, metric)

val feed = CSVFeed("data/US")
roboquant.run(feed)

Features

Some key features of roboquant are:

  • Very fast back-testing, even on large volumes of data.
  • Easy to develop your own strategies and integrate with brokers and data feeds
  • Trade in multiple asset classes at the same time
  • Run anything from a technical indicator to complex deep learning based strategies
  • Easy to transition from back-testing to live trading
  • Trade on multi-markets with multi-currencies
  • Developed under open source with a permissive Apache license
  • Use Jupyter Notebooks with insightful charts if you prefer interactive development
  • Batteries included: over 200 technical indicators
  • Out of the box integration with Alpaca, Interactive Brokers, IEX Cloud, Yahoo Finance, Alpha Vantage, Binance and most other crypto exchanges

Installation

If you have already Docker installed, all it takes is a single command to have a fully functional Jupyter Lab environment available:

docker run --rm -p 8888:8888 roboquant/jupyter 

This also comes with several tutorials. And if you just want to try it without any installation, go toBinder, although it might be a bit slow to start the environment.

Jupyter Lab

See the installation guide for more ways to install and use roboquant, for example if you want to use it in a standalone application and want to include the libraries.

License

Roboquant is distributed under the Apache 2.0 License.

Disclaimer

Roboquant also comes with live trading and paper trading capabilities. Using this is at your own risk and there are NO guarantees about the correct functioning of the software.

Beta version

Roboquant is in its pre-1.0 release and bugs are fore sure still present. Also expect API's to change without notice. PR are more than welcome, see also the Contribution Guide document. If you're missing some features, just open an issue on GitHub.

See also the todo documentation for already identified backlog items if you look for something to work on.

Comments
  • Consider opening Order classes

    Consider opening Order classes

    Hi,

    It'd be useful if classes from the order hierarchy, in particular the BracketOrder were made open. We've been forced to duplicate a large part of the code so we could model an specific kind of order.

    TIA, Martin Paoletta

    opened by mpaoletta 9
  • Rounding problem on position sizes

    Rounding problem on position sizes

    Hi! We've been working on porting our (already on production) crypto Backtrader strategy to Roboquant very easily, and find the design decisions you made very sound. We did find a rounding issue on position sizes operating with crypto coins, the same issue we had to fix on Backtrader.

    Whenever we have more than one concurrent bracket order, when one of the limit orders (tp or sl) is executed, and the order quantity is substracted from the position size, the position can end up having a very small amount due to rounding errors using doubles. We managed to solve the issue rewriting part of the Position class (mostly the plus method), maintaining a read only double size so the change is encapsulated in the Position. We can fork your repo and create a PR if that's ok, or we can chat about that if you want.

    Thanks for creating Roboquant!

    Regards, Martin

    opened by mpaoletta 6
  • order execution using more sophisticated price matching

    order execution using more sophisticated price matching

    Hi, currently order execution is using the open price. This is something that is done on the execution method on the order, and while a refactor of the sim execution part would allow to change it somehow, it still needs the broker to send the whole candlestick in order to do something like backtrader does:

    https://www.backtrader.com/docu/order-creation-execution/order-creation-execution/

    It probably was a backtesting strategy choice, but it'd be great to allow for different strategies regarding this. This probably means having a proper OHLC data class instead of a map. Do you have any thoughts regarding this?

    Best regards and thanks again for this wonderful project, Martin

    opened by mpaoletta 4
  • Support bar time duration in Alpaca's historic feed

    Support bar time duration in Alpaca's historic feed

    Alpaca's getBars API hasbarTimePeriodDuration which enable us to retrieve different bar durations, such as 5m/15m etc. As for now this value is hardcodedto 1.

    opened by idanakav 4
  • com.google.gson.JsonIOException: Failed making field 'java.lang.Throwable#detailMessage' accessible;

    com.google.gson.JsonIOException: Failed making field 'java.lang.Throwable#detailMessage' accessible;

    I encounter this exception often with JDK17 when I try to get live data or get a lot of historic data. Exception in thread "DefaultDispatcher-worker-2" com.google.gson.JsonIOException: Failed making field 'java.lang.Throwable#detailMessage' accessible; either change its visibility or write a custom TypeAdapter for its declaring type at com.google.gson.internal.reflect.ReflectionHelper.makeAccessible(ReflectionHelper.java:22) at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory.getBoundFields(ReflectiveTypeAdapterFactory.java:158) at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory.create(ReflectiveTypeAdapterFactory.java:101) at com.google.gson.Gson.getAdapter(Gson.java:501) at com.google.gson.Gson.fromJson(Gson.java:990) at com.google.gson.Gson.fromJson(Gson.java:956) at com.google.gson.Gson.fromJson(Gson.java:905) at com.google.gson.Gson.fromJson(Gson.java:876) at com.oanda.v20.Context.execute(Context.java:303) at com.oanda.v20.pricing.PricingContext.get(PricingContext.java:179) at org.roboquant.oanda.OANDALiveFeed$subscribeOrderBook$3.invokeSuspend(OANDALiveFeed.kt:139) at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33) at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:106) at kotlinx.coroutines.scheduling.CoroutineScheduler.runSafely(CoroutineScheduler.kt:570) at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.executeTask(CoroutineScheduler.kt:750) at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.runWorker(CoroutineScheduler.kt:677) at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.run(CoroutineScheduler.kt:664) Suppressed: kotlinx.coroutines.DiagnosticCoroutineContextException: [StandaloneCoroutine{Cancelling}@4d705c18, Dispatchers.Default] Caused by: java.lang.reflect.InaccessibleObjectException: Unable to make field private java.lang.String java.lang.Throwable.detailMessage accessible: module java.base does not "opens java.lang" to unnamed module @51a9ad5e at java.base/java.lang.reflect.AccessibleObject.throwInaccessibleObjectException(AccessibleObject.java:387) at java.base/java.lang.reflect.AccessibleObject.checkCanSetAccessible(AccessibleObject.java:363) at java.base/java.lang.reflect.AccessibleObject.checkCanSetAccessible(AccessibleObject.java:311) at java.base/java.lang.reflect.Field.checkCanSetAccessible(Field.java:180) at java.base/java.lang.reflect.Field.setAccessible(Field.java:174) at com.google.gson.internal.reflect.ReflectionHelper.makeAccessible(ReflectionHelper.java:19) ... 16 more

    opened by johntheocs 3
  • Modelling Shorts

    Modelling Shorts

    Hi, We've stumbled on a limitation that we haven't been able to circunvent while backtesting shorts. We are currently using BracketOrders for our trades, but the problem happens on every order type. When the sim broker updates the account and makes a withdraw, it actually increases the account's cash amount when we are shorting (which is consistent with the sell operation), but it is not something that happens in a real exchange. Do you have a suggestion regarding using short on the sim broker? Our current idea would be to create a new simbroker handling this. We could also try to support this on current simbroker.

    Regards, Martin

    opened by mpaoletta 2
  • Better support classic notebook environments

    Better support classic notebook environments

    Right now classic and lab notebooks render different. Classic notebooks use iframes for embedding HTML output while lab notebooks directly insert the HTML snippet. This makes it important that the environment is detected/set correctly otherwise the output is not rendered correctly.

    Classic notebooks can also directly insert an HTML snippet, but somehow the echarts library doesn't load correctly when added it to the main HTML page. It only works in an iframe in a classic notebook.

    possible reasons:

    1. requirejs that is loaded in a classic notebook stops echarts from loading correctly
    2. the load script that is generated by kotlin kernel contains a bug
    opened by jbaron 1
  • Exceptions in ZonedPeriod conversions

    Exceptions in ZonedPeriod conversions

    Existing conversion methods in ZonedPeriod are assuming the underlying object will have specific units which is not true.

    Example: 5.minutes.toMinutes() //Method threw 'java.time.temporal.UnsupportedTemporalTypeException' exception.

    In that case the Duration object actually holds seconds. Instead, it will be better to use the existing conversion methods in the Java API itself.

    enhancement 
    opened by idanakav 1
  • Improve code documentation

    Improve code documentation

    Several places in the code base, documentation is missing or not complete. To see what is missing in a certain module, you can run:

    mvn dokka:dokka -P release -pl roboquant
    

    Before the 1.0 release, at least all key Classes and Interfaces in the core roboquant module should be well documented.

    documentation 
    opened by jbaron 1
  • Order tag is missing in new branch

    Order tag is missing in new branch

    Hi, we are currently upgrading to the new version and found out that the tag property was removed from . We were using it to map client order id from Binance and we generally use it when syncyng different order types. Is this being replaced with something different? We are reading in our fork, and would happily create a PR for this but weren't sure about the rationale behind this.

    opened by mpaoletta 1
  • Metric Chart based on live feed shows erratic results

    Metric Chart based on live feed shows erratic results

    When using time scale, the metric charts sometimes shows a wrong graph (one x value has multiple y values). When using the step scale all is fine. Can been seen using for example using Alpaca Live Feed provider during trading hours.

    There is a mistake either in the captured metric data or more likely the chart itself cannot deal with very small differences in time (currently passed as a string).

    bug 
    opened by jbaron 1
  • Grouping of actions in a single event in live feeds

    Grouping of actions in a single event in live feeds

    When subscribing to assets in live feeds, it is sometime desirable to group actions together is they arrive closely after each other. Otherwise every action would result in its own event.

    This could be implemented in the abstract base class LiveFeed by support a "queue" where actions are put before a timeout is triggered and send all of them in a single Event.

    enhancement 
    opened by jbaron 0
  • Implement full crypto broker functionality

    Implement full crypto broker functionality

    Right now the live-trading crypto broker are not fully implemented. Help would be welcome since limited exposure to crypto trading using Binance or other pure Crypto brokers.

    help wanted 
    opened by jbaron 0
  • [Feature request] Support for more data formats

    [Feature request] Support for more data formats

    Currently, AFAIK, roboquant only supports .csv local historical data.

    However, this is not great in terms of storage efficiency, and there are many alternatives (e.g pickle, feather, parquet...) with various combinations of compressions (e.g. zip, gzip...).

    Would it be possible to add native support for some of these other formats?

    (Personally I use zip-compressed pickle as the best compromise between size and read/write times)

    df.to_pickle('foo.pkl', compression='zip')
    
    pd.read_pickle('foo.pkl', compression='zip')
    
    enhancement 
    opened by mr-september 3
  • predefined set of CSVConfig

    predefined set of CSVConfig

    For common and often used CSV files formats, have a pre-defined CSVConfig file that makes it convenient to parse those files without having to manually configure the CSVConfig.

    enhancement 
    opened by jbaron 0
Releases(v0.9.8)
  • v0.9.8(Dec 4, 2022)

  • v0.9.6(Oct 10, 2022)

    This release contains:

    1. Fixed inconsistent naming for many of the classes and interfaces
    2. Several performance improvements, especially for back-testing with very large datasets
    3. Added many test cases to get > 95% coverage
    4. Walk-Forward Feed know scales to almost infinite timelines
    5. Removed several utility methods that nobody used
    6. Moved to a standard directory structure to be more compatible with Java/Kotlin tooling
    7. The default policy now has a much simpler and more robust implementation
    8. Upgraded the versions of dependent libraries
    Source code(tar.gz)
    Source code(zip)
  • v0.9.5(Sep 2, 2022)

    Main changes:

    1. Overall improved performance (especially when working with single currency strategies)
    2. Better charting solution for notebooks (using now ECharts-Java)
    3. Test coverage now over 93%
    4. Integration with polygon.io added (basic)
    5. Upgraded dependent libraries to their latest versions
    6. Refactored lifecycle & metrics APIs to be more concise
    Source code(tar.gz)
    Source code(zip)
  • 0.9.3(Jun 6, 2022)

    Changes:

    • Improved and more consistent APIs all around
    • many small bug fixes
    • better performance for large data sets
    • additional support for real brokers
    • extended unit tests
    Source code(tar.gz)
    Source code(zip)
  • 0.9.2(Apr 28, 2022)

    Major Changes

    • API getting stable, especially for the core roboquant module
    • Refactored position and order sizes to be precise without overhead (see the new Size class)
    • Renamed roboquant-core module to roboquant to be more inline with best practices
    • This is the first published artefact to Maven Central (so not a SNAPSHOT release), so it is easier to consume
    • Fixed Detekt code findings
    • Renamed some classes for more consistent naming convention
    • Added additional support for technical analysis (own module)
    • Restored some previously disabled functionality in 3rd party integrations
    Source code(tar.gz)
    Source code(zip)
  • v0.9.1(Mar 15, 2022)

    • Extensible order state solution that allows for more complex order types
    • prototype implementation of server side rendering of charts (requires locally installed nodejs)
    • many small bug fixes and performance improvements
    • added test cases to improve coverage
    Source code(tar.gz)
    Source code(zip)
  • v0.9.0(Mar 1, 2022)

    Changes:

    • Major change to how orders are handled, cleaner design
    • SimBroker logic is limited to sim package
    • Better implementation of handling of modify orders
    • Account object is immutable
    • Several performance improvements
    • Many smaller fixes
    Source code(tar.gz)
    Source code(zip)
  • v0.8.4(Jan 16, 2022)

  • v0.8.3(Oct 14, 2021)

    Release notes:

    • Put the foundation in place to support OANDA, both as a feed provider and as a broker.
    • Moved to asciidoc as the standard for documentation in roboquant
    • Added more flexible solution for precision when displaying values
    Source code(tar.gz)
    Source code(zip)
  • v0.8.2(Oct 6, 2021)

    Change log:

    • added support for Interactive Brokers
    • added correlation matrix chart type
    • renamed some API elements to be more consistent
    • improved exception handling in notebooks
    Source code(tar.gz)
    Source code(zip)
  • v0.8.1(Sep 26, 2021)

  • v0.8.0(Sep 16, 2021)

    This is the first public beta of roboquant. Still a lot of things to be added, tested and fixed, so don't use it yet for real trading decisions.

    Source code(tar.gz)
    Source code(zip)
Owner
Neural Layer
Data Driven by Design
Neural Layer
XliteKt is an open-source, and forever open-source Kotlin based OSRS Emulator for educational purposes.

xlitekt Introduction XliteKt is an open-source, and forever open-source Kotlin based OSRS Emulator for educational purposes. Currently built around th

Runetopic 6 Dec 16, 2022
Open-Source Forge 1.8.9 Hypixel Duels bot! Planned to support many modes and written in Kotlin.

This project has been moved to a new repository: [HumanDuck23/duck-dueller-v2](https://github.com/HumanDuck23/duck-dueller-v2) Duck Dueller Are you ti

null 2 Aug 29, 2022
LittleKt - An OpenGL game framework written in Kotlin

LittleKt - A 2D game framework written in Kotlin Currently in development. Littl

LittleKt 128 Dec 31, 2022
KotlinDL - High-level Deep Learning Framework written in Kotlin and inspired by Keras

Оригинальный репозиторий https://github.com/JetBrains/KotlinDL KotlinDL: High-le

Temur Yunusov 1 Feb 4, 2022
Open source Crypto Currency Tracker Android App made fully in Kotlin

CoinBit CoinBit is a beautiful CryptoCurrency app, completely open sourced and 100% in kotlin. It supports following features Track prices of over 300

Pranay Airan 50 Dec 5, 2022
Free and open source manga reader for Android.

Build Stable Weekly Preview Contribute Support Server Tachiyomi Tachiyomi is a free and open source manga reader for Android 5.0 and above. Features F

Tachiyomi 20.2k Dec 30, 2022
Free and open source Android app to manage qBittorrent remotely.

qBitController qBitController is a free and open source app for managing qBittorrent remotely. Please note that qBitController is in alpha version. Us

Bartu Özen 12 Dec 25, 2022
Bible Study App, by And Bible Open Source Project

Bible Study App by And Bible Open Source Project Powerful offline Bible Study tool for Android Promovideo See promovideo in Youtube Users Please see t

And Bible 437 Dec 23, 2022
An open source app which can be used to do basic surveys

SurveyApp This is an open source app which can be used to do basic surveys. It supports multiple question types. For demo please check the releases pa

Dhiraj Uchil 0 Dec 9, 2021
Android Open-Source Telematics App with Firebase© integration

Android Open-Source Telematics App with Firebase© integration Description This Telematics App is developed by Damoov and is distributed free of charge

null 0 Jan 14, 2022
OpenAbyss - Open source script for Powbot that crafts runes through the abyss

OpenAbyss Open source script for Powbot that crafts runes through the abyss Feat

null 3 Feb 9, 2022
An open-source Android app for locating your group's people privately using Facebook Login, Google Maps API and Firebase

An open-source Android app for locating your group's people privately using Facebook Login, Google Maps API and Firebase

Duong Tran Thanh 2 Feb 27, 2022
Kotatsu is a free and open source manga reader for Android platform

Kotatsu is a free and open source manga reader for Android platform. Supports a lot of online catalogues on different languages with filters and search, offline reading from local storage, favourites, bookmarks, new chapters notifications and more features.

null 7 Dec 19, 2022
XCore is a Open-Source , simple and lightweight API & Template for Android Apps.

XCore XCore is a Open-Source , simple and lightweight API & Template for Android Apps. Support XCore is compatible with Android Studio & Sketchware Pr

TherionRO 3 Dec 2, 2022
Akka-in-action-kotlin - Accompanying source code for Akka in Action by Kotlin

Akka実践バイブル Kotlin版サンプルコード ( Accompanying source code for Akka in Action by Kotli

nrs 7 Jul 26, 2022
Jetpack Compose for Desktop and Web, a modern UI framework for Kotlin that makes building performant and beautiful user interfaces easy and enjoyable.

Jetpack Compose for Desktop and Web, a modern UI framework for Kotlin that makes building performant and beautiful user interfaces easy and enjoyable.

JetBrains 10k Jan 7, 2023
A Modern Kotlin-Ktor RESTful API example. Connects to a PostgreSQL database and uses Exposed framework for database operations.

kotlin-ktor-rest-api A Modern Kotlin-Ktor RESTful API example. Connects to a PostgreSQL database and uses Exposed framework for database operations. F

Selim Atasoy 32 Dec 20, 2022
A simple MVI framework for Kotlin Multiplatform and Android

Orbit Multiplatform Get in touch What is Orbit Orbit is a Redux/MVI-like library - but without the baggage. It's so simple we think of it as MVVM+. Si

null 521 Jan 1, 2023