NautilusTrader is an open-source, high-performance, production-grade algorithmic trading platform, providing quantitative traders with the ability to backtest portfolios of automated trading strategies on historical data with an event-driven engine, and also deploy those same strategies live.
NautilusTrader is AI/ML first, designed to deploy models for algorithmic trading strategies developed using the Python ecosystem - within a highly performant and robust Python native environment.
The platform aims to be universal, with any REST/FIX/WebSocket API able to be integrated via modular adapters. Thus the platform can handle high-frequency trading operations for any asset classes including FX, Equities, Futures, Options, CFDs, Crypto and Betting - across multiple venues simultaneously.
- Fast: C-level speed and type safety provided through Cython. Asynchronous networking utilizing uvloop.
- Reliable: Redis backed performant state persistence for live implementations.
- Flexible: Any FIX, REST or WebSocket API can be integrated into the platform.
- Backtesting: Multiple instruments and strategies simultaneously with historical quote tick, trade tick, bar and order book data.
- Multi-venue: Multiple venue capabilities facilitate market making and statistical arbitrage strategies.
- AI Agent Training: Backtest engine fast enough to be used to train AI trading agents (RL/ES).
One of the key value propositions of NautilusTrader is that it addresses the challenge of keeping the research/backtest environment consistent with the production live trading environment.
Normally research and backtesting may be conducted in Python (or other suitable language), with trading strategies traditionally then needing to be reimplemented in C++/C#/Java or other statically typed language(s). The reasoning here is to enjoy the performance a compiled language can offer, along with the tooling and support which has made these languages historically more suitable for large enterprise systems.
The value of NautilusTrader here is that this re-implementation step is circumvented, as the platform was designed from the ground up to hold its own in terms of performance and quality.
Python has simply caught up in performance (via Cython offering C-level speed) and general tooling, making it a suitable language for building a large system such as this. The benefit being that a Python native environment can be offered, suitable for professional quantitative traders and hedge funds.
Python was originally created decades ago as a simple scripting language with a clean straight forward syntax. It has since evolved into a fully fledged general purpose object-oriented programming language. Not only that, Python has become the de facto lingua franca of data science, machine learning, and artificial intelligence.
The language out of the box is not without its drawbacks however, especially in the context of implementing large systems. Cython has addressed a lot of these issues, offering all the advantages of a statically typed language, embedded into Pythons rich ecosystem of software libraries and developer/user communities.
Cython is a compiled programming language that aims to be a superset of the Python programming language, designed to give C-like performance with code that is written mostly in Python with optional additional C-inspired syntax.
The project heavily utilizes Cython to provide static type safety and increased performance for Python through C extension modules. The vast majority of the production Python code is actually written in Cython, however the libraries can be accessed from both pure Python and Cython.
- Reliability
- Performance
- Testability
- Modularity
- Maintainability
- Scalability
The documentation for the latest version of the package can be found at:
Logo | ID | Status |
---|---|---|
IB | ||
OANDA | ||
CCXT-exchange_id |
||
BINANCE | ||
BITMEX | ||
BETFAIR |
CCXT Pro is an algorithmic crypto-trading library which currently includes integrations to 27 crypto exchanges https://github.com/ccxt/ccxt.
The adapter requires the ccxtpro
package, which in turn requires a license.
See https://ccxt.pro for more information.
CCXT Pro advanced execution clients |
---|
BINANCE |
BITMEX |
Advanced execution clients include additional order management options such as
post_only
, hidden
, reduce_only
, and all the TimeInForce
options. These
advanced execution clients will be incrementally added to and additional help
from ccxtpro users is welcome!
The other CCXT Pro exchanges are available through the unified API with a more limited order feature set including simple vanilla MARKET and LIMIT orders.
The master
branch will always reflect the code of the latest release version.
Also, the documentation is always current for the latest version.
The package is tested against Python 3.7 - 3.9 on Windows, MacOS and Linux 64-bit. We recommend running the platform with the latest stable version of Python.
It is a goal for the project to keep dependencies focused, however there are
still a large number of dependencies as found in the pyproject.toml
file.
Therefore we recommend you create a new virtual environment for NautilusTrader
to isolate the dependencies.
For Unix machines, pyenv
is the recommended tool for handling system wide
Python installations and virtual environments.
Installation can be achieved through one of the following options;
To install the latest binary wheel (or sdist package) from PyPI, run:
pip install -U nautilus_trader
To install a binary wheel from GitHub, first navigate to the latest release.
https://github.com/nautechsystems/nautilus_trader/releases/latest/
Download the appropriate .whl
for your operating system and Python version, then run:
pip install <file-name>.whl
Installation from source requires Cython to compile the Python C extensions.
-
To install Cython, run:
pip install -U Cython==3.0a6
-
Then to install NautilusTrader using
pip
, run:pip install -U git+https://github.com/nautechsystems/nautilus_trader
Or clone the source with
git
, and install from the projects root directory by running:git clone https://github.com/nautechsystems/nautilus_trader cd nautilus_trader pip install .
Examples of both backtest and live trading launch scripts are available in the examples
directory.
These can run through PyCharm, or by running:
python <name_of_script>.py
The following market data types can be requested historically, and also subscribed to as live streams when available from an exchange/broker, and implemented in an integrations adapter.
Instrument
OrderBook
(L1, L2 and L3 if available. Streaming or interval snapshots)QuoteTick
TradeTick
Bar
The following PriceType
options can be used for bar aggregations;
BID
ASK
MID
LAST
The following BarAggregation
options are possible;
SECOND
MINUTE
HOUR
DAY
TICK
VOLUME
VALUE
(a.k.a Dollar bars)TICK_IMBALANCE
(TBA)TICK_RUNS
(TBA)VOLUME_IMBALANCE
(TBA)VOLUME_RUNS
(TBA)VALUE_IMBALANCE
(TBA)VALUE_RUNS
(TBA)
The price types and bar aggregations can be combined with step sizes >= 1 in any
way through BarSpecification
objects. This enables maximum flexibility and now
allows alternative bars to be produced for live trading.
# BarSpecification examples
tick_bars = BarSpecification(100, BarAggregation.TICK, PriceType.LAST)
time_bars = BarSpecification(1, BarAggregation.MINUTE, PriceType.BID)
volume_bars = BarSpecification(100, BarAggregation.VOLUME, PriceType.MID)
value_bars = BarSpecification(1_000_000, BarAggregation.VALUE, PriceType.MID)
Bars can be either internally or externally aggregated (alternative bar types are only available by internal aggregation). External aggregation is normally for standard bar periods as available from the data client through an integrations adapter.
Custom data types can also be requested through a users custom handler, and fed
back to the strategies on_data
method.
The following order types are available (when possible on an exchange);
Market
Limit
StopMarket
StopLimit
More will be added in due course including MarketIfTouched
, LimitIfTouched
and icebergs. Users are invited to open discussion issues to request specific
order types or features.
For development we recommend using the PyCharm Professional edition IDE, as it interprets Cython syntax. Alternatively, you could use Visual Studio Code with a Cython extension.
pyenv
is the recommended tool for handling Python installations and virtual environments.
poetry
is the preferred tool for handling all Python package and dev dependencies.
pre-commit
is used to automatically run various checks, auto-formatters and linting tools
at commit.
The following steps are for Unix-like systems, and only need to be completed once.
-
Install
poetry
by running:curl -sSL https://raw.githubusercontent.com/python-poetry/poetry/master/get-poetry.py | python -
-
Then install all Python package dependencies, and compile the C extensions by running:
poetry install
-
Install the
pre-commit
package by running:pip install pre-commit
-
Setup the
pre-commit
hook which will then run automatically at commit by running:pre-commit install
Following any changes to .pyx
or .pxd
files, you can re-compile by running:
poetry run python build.py
Refer to the Developer Guide for further information.
Even as some issues are marked with the help wanted
label - this does not imply
that help is only wanted on those issues. The label indicates where 'extra attention'
is needed.
Involvement from the trading community is a goal for this project. All help is welcome! Developers can open issues on GitHub to discuss proposed enhancements/changes, or to make bug reports.
Please make all pull requests to the develop
branch.
Refer to the CONTRIBUTING.md for further information.
NautilusTrader is licensed under the LGPL v3.0 as found in the LICENSE file.
Contributors are also required to sign a standard Contributor License Agreement (CLA), which is administered automatically through CLAassistant.
Copyright (C) 2015-2021 Nautech Systems Pty Ltd. All rights reserved.