Skip to content

Commit 59ca217

Browse files
authored
Release 1.205.0
See release notes.
2 parents 3fd212d + 3d62e42 commit 59ca217

File tree

448 files changed

+12599
-4843
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

448 files changed

+12599
-4843
lines changed

.github/workflows/build.yml

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ jobs:
8585
version: ${{ env.POETRY_VERSION }}
8686

8787
- name: Install build dependencies
88-
run: python -m pip install --upgrade pip setuptools wheel pre-commit msgspec
88+
run: python -m pip install --upgrade pip setuptools wheel pre-commit msgspec pytest-codspeed
8989

9090
# ta-lib Python install currently broken
9191
# https://github.com/TA-Lib/ta-lib-python/issues/655
@@ -164,6 +164,14 @@ jobs:
164164
make pytest
165165
make test-examples
166166
167+
# Run codspeed for latest python-version only
168+
# - name: Run benchmarks (Linux)
169+
# if: ${{ matrix.python-version == '3.12' }}
170+
# uses: CodSpeedHQ/action@v3
171+
# with:
172+
# token: ${{ secrets.CODSPEED_TOKEN }}
173+
# run: make test-performance
174+
167175
build-windows:
168176
strategy:
169177
fail-fast: false

.pre-commit-config.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ repos:
8383
exclude: "docs/_pygments/monokai.py"
8484

8585
- repo: https://github.com/astral-sh/ruff-pre-commit
86-
rev: v0.7.0
86+
rev: v0.7.2
8787
hooks:
8888
- id: ruff
8989
args: ["--fix"]
@@ -112,7 +112,7 @@ repos:
112112
]
113113

114114
- repo: https://github.com/pre-commit/mirrors-mypy
115-
rev: v1.12.1
115+
rev: v1.13.0
116116
hooks:
117117
- id: mypy
118118
args: [

Makefile

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,10 @@ pytest:
157157
pytest-coverage:
158158
bash scripts/test-coverage.sh
159159

160+
.PHONY: test-performance
161+
test-performance:
162+
bash scripts/test-performance.sh
163+
160164
.PHONY: test-examples
161165
test-examples:
162166
bash scripts/test-examples.sh

README.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# <img src="https://github.com/nautechsystems/nautilus_trader/blob/develop/docs/_images/nautilus-trader-logo.png" width="500">
22

33
[![codecov](https://codecov.io/gh/nautechsystems/nautilus_trader/branch/master/graph/badge.svg?token=DXO9QQI40H)](https://codecov.io/gh/nautechsystems/nautilus_trader)
4+
[![codspeed](https://img.shields.io/endpoint?url=https://codspeed.io/badge.json)](https://codspeed.io/nautechsystems/nautilus_trader)
45
![pythons](https://img.shields.io/pypi/pyversions/nautilus_trader)
56
![pypi-version](https://img.shields.io/pypi/v/nautilus_trader)
67
![pypi-format](https://img.shields.io/pypi/format/nautilus_trader?color=blue)
@@ -38,7 +39,7 @@ NautilusTraders design, architecture and implementation philosophy holds softwar
3839
highest level, with the aim of supporting Python native, mission-critical, trading system backtesting
3940
and live deployment workloads.
4041

41-
The platform is also univ2rsal and asset class agnostic - with any REST, WebSocket or FIX API able to be integrated via modular
42+
The platform is also universal and asset class agnostic - with any REST, WebSocket or FIX API able to be integrated via modular
4243
adapters. Thus, it can handle high-frequency trading operations for any asset classes
4344
including FX, Equities, Futures, Options, CFDs, Crypto and Betting - across multiple venues simultaneously.
4445

@@ -136,7 +137,7 @@ The following integrations are currently supported:
136137
| [Interactive Brokers](https://www.interactivebrokers.com) | `INTERACTIVE_BROKERS` | Brokerage (multi-venue) | ![status](https://img.shields.io/badge/stable-green) | [Guide](https://nautilustrader.io/docs/latest/integrations/ib.html) |
137138
| [OKX](https://okx.com) | `OKX` | Crypto Exchange (CEX) | ![status](https://img.shields.io/badge/building-orange) | [Guide](https://nautilustrader.io/docs/latest/integrations/okx.html) |
138139
| [Polymarket](https://polymarket.com) | `POLYMARKET` | Prediction Market (DEX) | ![status](https://img.shields.io/badge/beta-yellow) | [Guide](https://nautilustrader.io/docs/latest/integrations/polymarket.html) |
139-
| [Tardis](https://tardis.dev) | `TARDIS` | Data Provider | ![status](https://img.shields.io/badge/building-orange) | [Guide](https://nautilustrader.io/docs/latest/integrations/tardis.html) |
140+
| [Tardis](https://tardis.dev) | `TARDIS` | Data Provider | ![status](https://img.shields.io/badge/beta-yellow) | [Guide](https://nautilustrader.io/docs/latest/integrations/tardis.html) |
140141

141142
- **ID**: The default client ID for the integrations adapter clients.
142143
- **Type**: The type of integration (often the venue type).

RELEASES.md

Lines changed: 49 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,51 @@
1+
# NautilusTrader 1.205.0 Beta
2+
3+
Released on 3rd November 2024 (UTC).
4+
5+
### Enhancements
6+
- Added Tardis Machine and HTTP API integration in Python and Rust
7+
- Added `LiveExecEngineConfig.open_check_interval_secs` config option to actively reconcile open orders with the venue
8+
- Added aggregation of bars from historical data (#2002), thanks @faysou
9+
- Added monthly and weekly bar aggregations (#2025), thanks @faysou
10+
- Added `raise_exception` optional parameter to `TradingNode.run` (#2021), thanks @faysou
11+
- Added `OrderBook.get_avg_px_qty_for_exposure` in Rust (#1893), thanks @elementace
12+
- Added timeouts to Interactive Brokers adapter configurations (#2026), thanks @rsmb7z
13+
- Added optional time origins for time bar aggregation (#2028), thanks @faysou
14+
- Added Polymarket position status reports and order status report generation based on fill reports
15+
- Added USDC.e (PoS) currency (used by Polymarket) to internal currency map
16+
- Upgraded Polymarket WebSocket API to new version
17+
18+
### Internal Improvements
19+
- Ported analysis subpackage to Rust (#2016), thanks @Pushkarm029
20+
- Improved Postgres testing (#2018), thanks @filipmacek
21+
- Improved Redis version parsing to support truncated versions (improves compatibility with Redis-compliant databases)
22+
- Refined Arrow serialization (record batch functions now also available in Rust)
23+
- Refined core `Bar` API to remove unnecessary unwraps
24+
- Standardized network client logging
25+
- Fixed all pyo3 deprecations for API breaking changes
26+
- Fixed all clippy warning lints for PyO3 changes (#2030), thanks @Pushkarm029
27+
- PyO3 upgrade refactor and repair catalog tests (#2032), thanks @twitu
28+
- Upgraded `pyo3` crate to v0.22.5
29+
- Upgraded `pyo3-async-runtimes` crate to v0.22.0
30+
- Upgraded `tokio` crate to v1.41.0
31+
32+
### Breaking Changes
33+
- Removed pyo3 `DataTransformer` (was being used for namespacing, so refactored to separate functions)
34+
- Moved `TEST_DATA_DIR` constant from `tests` to `nautilus_trader` package (#2020), thanks @faysou
35+
36+
### Fixes
37+
- Fixed use of Redis `KEYS` command which, is unsupported in cluster environments (replaced with `SCAN` for compatibility)
38+
- Fixed decoding fill HTTP messages for dYdX (#2022), thanks @davidsblom
39+
- Fixed account balance report for dYdX (#2024), thanks @davidsblom
40+
- Fixed Interactive Brokers market data client subscription log message (#2012), thanks @marcodambros
41+
- Fixed Polymarket execution reconciliation (was not able to reconcile from closed orders)
42+
- Fixed catalog query mem leak test (#2031), thanks @Pushkarm029
43+
- Fixed `OrderInitialized.to_dict()` `tags` value type to `list[str]` (was a concatenated `str`)
44+
- Fixed `OrderInitialized.to_dict()` `linked_order_ids` value type to `list[str]` (was a concatenated `str`)
45+
- Fix Betfair clients shutdown (#2037), thanks @limx0
46+
47+
---
48+
149
# NautilusTrader 1.204.0 Beta
250

351
Released on 22nd October 2024 (UTC).
@@ -33,7 +81,7 @@ Released on 22nd October 2024 (UTC).
3381
- Removed legacy `TardisQuoteDataLoader` (now redundant with new Rust implemented loader)
3482
- Removed legacy `TardisTradeDataLoader` (now redundant with new Rust implemented loader)
3583
- Custom signals are now passed to `on_signal(signal)` instead of `on_data(data)`
36-
- Changed `Position.to_dict()` `commissions` value type to `list[str]` (rather than an optional `str` of a list of strings)
84+
- Changed `Position.to_dict()` `commissions` value type to `list[str]` (was an optional `str` of a list of strings)
3785
- Changed `Position.to_dict()` `avg_px_open` value type to `float`
3886
- Changed `Position.to_dict()` `avg_px_close` value type to `float | None`
3987
- Changed `Position.to_dict()` `realized_return` value type to `float | None`

docs/api_reference/adapters/index.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,4 +19,5 @@
1919
interactive_brokers.md
2020
okx.md
2121
polymarket.md
22+
tardis.md
2223
```
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# Tardis
2+
3+
```{eval-rst}
4+
.. automodule:: nautilus_trader.adapters.tardis
5+
:show-inheritance:
6+
:inherited-members:
7+
:members:
8+
:member-order: bysource
9+
```
10+
11+
## Loaders
12+
13+
```{eval-rst}
14+
.. automodule:: nautilus_trader.adapters.tardis.loaders
15+
:show-inheritance:
16+
:inherited-members:
17+
:members:
18+
:member-order: bysource
19+
```

docs/concepts/backtesting.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,14 @@ Data provided for backtesting drives the execution flow. Since a variety of data
6464
it's crucial that your venue configurations align with the data being provided for backtesting.
6565
Mismatches between data and configuration can lead to unexpected behavior during execution.
6666

67+
:::info
68+
NautilusTrader is primarily designed and optimized for backtesting on order book or tick data, providing the highest
69+
execution granularity and realism. If order book or tick data is unavailable or unsuitable, backtests
70+
can also be run on bar data; however, users should note that this results in a loss of information and detail,
71+
reducing execution precision and realism.
72+
:::
73+
74+
6775
## Venues
6876

6977
When initializing a venue for backtesting, you must specify its internal order `book_type` for execution processing from the following options:

docs/concepts/data.md

Lines changed: 97 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,25 @@ These data types include:
99
- `QuoteTick`: Represents the best bid and ask prices along with their sizes at the top-of-book.
1010
- `TradeTick`: A single trade/match event between counterparties.
1111
- `Bar`: OHLCV (Open, High, Low, Close, Volume) bar/candle, aggregated using a specified *aggregation method*.
12-
- `InstrumentStatus`: An instrument level status event.
13-
- `InstrumentClose`: An instrument closing price.
12+
- `InstrumentStatus`: An instrument-level status event.
13+
- `InstrumentClose`: The closing price of an instrument.
14+
15+
NautilusTrader is designed primarily to operate on granular order book data, providing the highest realism
16+
for execution simulations in backtesting.
17+
However, backtests can also be conducted on any of the supported market data types, depending on the desired simulation fidelity.
18+
19+
## Order books
20+
21+
A high-performance order book implemented in Rust is available to maintain order book state based on provided data.
22+
23+
`OrderBook` instances are maintained per instrument for both backtesting and live trading, with the following book types available:
24+
- `L3_MBO`: **Market by order (MBO)** or L3 data, uses every order book event at every price level, keyed by order ID.
25+
- `L2_MBP`: **Market by price (MBP)** or L2 data, aggregates order book events by price level.
26+
- `L1_MBP`: **Market by price (MBP)** or L1 data, also known as best bid and offer (BBO), captures only top-level updates.
27+
28+
:::note
29+
Top-of-book data, such as `QuoteTick`, `TradeTick` and `Bar`, can also be used for backtesting, with markets operating on `L1_MBP` book types.
30+
:::
1431

1532
## Timestamps
1633

@@ -43,6 +60,84 @@ The following instrument definitions are available:
4360
- `OptionsSpread`: Represents a generic options spread instrument.
4461
- `Synthetic`: Represents a synthetic instrument with prices derived from component instruments using a formula.
4562

63+
## Bars and aggregation
64+
65+
A *bar*—also known as a candle, candlestick, or kline—is a data structure that represents price and
66+
volume information over a specific period, including the opening price, highest price, lowest price, closing price,
67+
and traded volume (or ticks as a volume proxy). These values are generated using an *aggregation method*,
68+
which groups data based on specific criteria to create the bar.
69+
70+
The implemented aggregation methods are:
71+
72+
| Name | Description | Category |
73+
|:-------------------|:---------------------------------------------------------------------------|:-------------|
74+
| `TICK` | Aggregation of a number of ticks. | Threshold |
75+
| `TICK_IMBALANCE` | Aggregation of the buy/sell imbalance of ticks. | Threshold |
76+
| `TICK_RUNS` | Aggregation of sequential buy/sell runs of ticks. | Information |
77+
| `VOLUME` | Aggregation of traded volume. | Threshold |
78+
| `VOLUME_IMBALANCE` | Aggregation of the buy/sell imbalance of traded volume. | Threshold |
79+
| `VOLUME_RUNS` | Aggregation of sequential runs of buy/sell traded volume. | Information |
80+
| `VALUE` | Aggregation of the notional value of trades (also known as "Dollar bars"). | Threshold |
81+
| `VALUE_IMBALANCE` | Aggregation of the buy/sell imbalance of trading by notional value. | Information |
82+
| `VALUE_RUNS` | Aggregation of sequential buy/sell runs of trading by notional value. | Threshold |
83+
| `MILLISECOND` | Aggregation of time intervals with millisecond granularity. | Time |
84+
| `SECOND` | Aggregation of time intervals with second granularity. | Time |
85+
| `MINUTE` | Aggregation of time intervals with minute granularity. | Time |
86+
| `HOUR` | Aggregation of time intervals with hour granularity. | Time |
87+
| `DAY` | Aggregation of time intervals with day granularity. | Time |
88+
| `WEEK` | Aggregation of time intervals with week granularity. | Time |
89+
| `MONTH` | Aggregation of time intervals with month granularity. | Time |
90+
91+
### Bar types
92+
93+
NautilusTrader defines a unique *bar type* (`BarType`) based on the following components:
94+
95+
- **Instrument ID** (`InstrumentId`): Specifies the particular instrument for the bar.
96+
- **Bar Specification** (`BarSpecification`):
97+
- `step`: Defines the interval or frequency of each bar.
98+
- `aggregation`: Specifies the method used for data aggregation (see the list above).
99+
- `price_type`: Indicates the price basis of the bar (e.g., bid, ask, mid, last).
100+
- **Aggregation Source** (`AggregationSource`): Indicates whether the bar was aggregated internally (within Nautilus) or externally (by a trading venue or data provider).
101+
102+
Bar data can be aggregated either internally or externally:
103+
104+
- `INTERNAL`: The bar is aggregated inside the local Nautilus system boundary.
105+
- `EXTERNAL`: The bar is aggregated outside the local Nautilus system boundary (typically by a trading venue or data provider).
106+
107+
Bar types can also be classified as either *standard* or *composite*:
108+
109+
- **Standard**: Generated from granular market data, such as quotes or trade ticks.
110+
- **Composite**: Derived from a higher-granularity bar type through subsampling.
111+
112+
### Defining standard bars
113+
114+
You can define bar types from strings using the following convention:
115+
116+
`{instrument_id}-{step}-{aggregation}-{price_type}-{INTERNAL | EXTERNAL}`
117+
118+
For example, to define a `BarType` for AAPL trades (last price) on Nasdaq (XNAS) using a 5-minute interval, aggregated from trades locally by Nautilus:
119+
```python
120+
bar_type = BarType.from_str("AAPL.XNAS-5-MINUTE-LAST-INTERNAL")
121+
```
122+
123+
### Defining composite bars
124+
125+
Composite bars are derived by aggregating higher-granularity bars into the desired bar type.
126+
To define a composite bar, use a similar convention to standard bars:
127+
128+
`{instrument_id}-{step}-{aggregation}-{price_type}-INTERNAL@{step}-{aggregation}-{INTERNAL | EXTERNAL}`
129+
130+
**Notes**:
131+
- The derived bar type must use an `INTERNAL` aggregation source (since this is how the bar is aggregated).
132+
- The sampled bar type must have a higher granularity than the derived bar type.
133+
- The sampled instrument ID is inferred to match that of the derived bar type.
134+
- Composite bars can be aggregated *from* `INTERNAL` or `EXTERNAL` aggregation sources.
135+
136+
For example, to define a `BarType` for AAPL trades (last price) on Nasdaq (XNAS) using a 5-minute interval, aggregated locally by Nautilus, from 1-minute interval bars aggregated externally:
137+
```python
138+
bar_type = BarType.from_str("AAPL.XNAS-5-MINUTE-LAST-INTERNAL@1-MINUTE-EXTERNAL")
139+
```
140+
46141
## Data flow
47142

48143
The platform ensures consistency by flowing data through the same pathways across all system [environment contexts](/concepts/architecture.md#environment-contexts)

docs/concepts/message_bus.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -64,9 +64,9 @@ def register_serializable_type(
6464
...
6565
```
6666

67-
- `cls`: The type to register
68-
- `to_dict`: The delegate to instantiate a dict of primitive types from the object
69-
- `from_dict`: The delegate to instantiate the object from a dict of primitive types
67+
- `cls`: The type to register.
68+
- `to_dict`: The delegate to instantiate a dict of primitive types from the object.
69+
- `from_dict`: The delegate to instantiate the object from a dict of primitive types.
7070

7171
## Configuration
7272

0 commit comments

Comments
 (0)