Skip to content

Commit 7b5e5d3

Browse files
authored
Release 1.172.0
See release notes.
2 parents 68c2e56 + 93dab19 commit 7b5e5d3

File tree

346 files changed

+13261
-5754
lines changed

Some content is hidden

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

346 files changed

+13261
-5754
lines changed

.github/workflows/build.yml

+3-2
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,12 @@ jobs:
1515
matrix:
1616
arch: [x64]
1717
os: [ubuntu-latest, macos-latest, windows-latest]
18-
python-version: ["3.9", "3.10"]
18+
python-version: ["3.9", "3.10", "3.11"]
1919
name: build - Python ${{ matrix.python-version }} (${{ matrix.arch }} ${{ matrix.os }})
2020
runs-on: ${{ matrix.os }}
2121
env:
2222
BUILD_MODE: debug
23+
RUST_BACKTRACE: 1
2324

2425
steps:
2526
- name: Checkout repository
@@ -120,6 +121,6 @@ jobs:
120121
if: runner.os == 'Windows'
121122
run: |
122123
poetry install --with test --all-extras
123-
poetry run pytest --ignore=tests/performance_tests -k "not no_ci" --new-first --failed-first
124+
poetry run pytest --ignore=tests/performance_tests --new-first --failed-first
124125
env:
125126
PARALLEL_BUILD: false

.gitignore

+3
Original file line numberDiff line numberDiff line change
@@ -30,14 +30,17 @@
3030
__pycache__
3131
_build/
3232
build/
33+
data_catalog/
3334
dist/
3435
env/
3536
log/
3637
logs/
38+
*temp/
3739
*target/
3840
venv*/
3941

4042
.DS_Store
43+
null-ls*
4144
PERF.JSON
4245
output.json
4346
*dask-worker-space*

.pre-commit-config.yaml

+10-17
Original file line numberDiff line numberDiff line change
@@ -55,15 +55,6 @@ repos:
5555
args: ["--manifest-path", "nautilus_core/Cargo.toml", "--", "-D", "warnings"]
5656
files: \.rs$
5757
pass_filenames: false
58-
- id: cargo-check
59-
name: cargo check
60-
description: Check the package for errors.
61-
entry: cargo check
62-
language: system
63-
types: [rust]
64-
args: ["--manifest-path", "nautilus_core/Cargo.toml"]
65-
files: \.rs$
66-
pass_filenames: false
6758

6859
##############################################################################
6960
# Python/Cython formatting and linting
@@ -81,7 +72,7 @@ repos:
8172
- id: isort
8273
types_or: [python, cython]
8374
entry: "isort"
84-
args: ["--settings-file", "pyproject.toml", "."]
75+
args: ["--settings-file", "pyproject.toml"]
8576

8677
- repo: https://github.com/psf/black
8778
rev: 23.3.0
@@ -92,13 +83,20 @@ repos:
9283
args: ["--config", "pyproject.toml"]
9384
exclude: "docs/_pygments/monokai.py"
9485

86+
- repo: https://github.com/charliermarsh/ruff-pre-commit
87+
rev: v0.0.263
88+
hooks:
89+
- id: ruff
90+
args: ["--fix"]
91+
9592
- repo: https://github.com/pre-commit/mirrors-mypy
96-
rev: v1.1.1
93+
rev: v1.2.0
9794
hooks:
9895
- id: mypy
9996
args: [
100-
--no-strict-optional,
10197
--ignore-missing-imports,
98+
--allow-incomplete-defs,
99+
--no-strict-optional, # Fixing in progress
102100
--warn-no-return,
103101
]
104102
additional_dependencies: [
@@ -110,11 +108,6 @@ repos:
110108
types-toml,
111109
]
112110

113-
- repo: https://github.com/charliermarsh/ruff-pre-commit
114-
rev: v0.0.260
115-
hooks:
116-
- id: ruff
117-
118111
- repo: https://github.com/kynan/nbstripout
119112
rev: 0.6.1
120113
hooks:

Makefile

+11-2
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,22 @@ IMAGE_FULL?=${IMAGE}:${GIT_TAG}
1010
.PHONY: pytest pytest-coverage
1111

1212
install:
13-
poetry install --with dev,test --all-extras
13+
BUILD_MODE=release poetry install --with dev,test --all-extras
14+
15+
install-debug:
16+
BUILD_MODE=debug poetry install --with dev,test --all-extras
1417

1518
install-just-deps:
1619
poetry install --with dev,test --all-extras --no-root
1720

21+
install-just-deps-all:
22+
poetry install --with dev,test,docs --all-extras --no-root
23+
1824
build: nautilus_trader
19-
poetry run python build.py
25+
BUILD_MODE=release poetry run python build.py
26+
27+
build-debug: nautilus_trader
28+
BUILD_MODE=debug poetry run python build.py
2029

2130
clean:
2231
git clean -fxd

README.md

+21-10
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,12 @@
1313
| `master` | ![version](https://img.shields.io/endpoint?url=https%3A%2F%2Fraw.githubusercontent.com%2Fnautechsystems%2Fnautilus_trader%2Fmaster%2Fversion.json) | [![build](https://github.com/nautechsystems/nautilus_trader/actions/workflows/build.yml/badge.svg?branch=master)](https://github.com/nautechsystems/nautilus_trader/actions/workflows/build.yml) |
1414
| `develop` | ![version](https://img.shields.io/endpoint?url=https%3A%2F%2Fraw.githubusercontent.com%2Fnautechsystems%2Fnautilus_trader%2Fdevelop%2Fversion.json) | [![build](https://github.com/nautechsystems/nautilus_trader/actions/workflows/build.yml/badge.svg?branch=develop)](https://github.com/nautechsystems/nautilus_trader/actions/workflows/build.yml) |
1515

16-
| Platform | Rust | Python |
17-
|:------------------|:----------|:-------|
18-
| Linux (x86\_64) | `1.68.2+` | `3.9+` |
19-
| macOS (x86\_64) | `1.68.2+` | `3.9+` |
20-
| Windows (x86\_64) | `1.68.2+` | `3.9+` |
16+
| Platform | Rust | Python |
17+
|:-------------------|:--------|:-------|
18+
| `Linux (x86_64)` | 1.69.0+ | 3.9+ |
19+
| `macOS (x86_64)` | 1.69.0+ | 3.9+ |
20+
| `macOS (arm64)` | 1.69.0+ | 3.9+ |
21+
| `Windows (x86_64)` | 1.69.0+ | 3.9+ |
2122

2223
- **Website:** https://nautilustrader.io
2324
- **Docs:** https://docs.nautilustrader.io
@@ -114,6 +115,10 @@ Cython, with static libraries linked at compile-time before the wheel binaries a
114115
does not need to have Rust installed to run NautilusTrader. In the future as more Rust code is introduced,
115116
[PyO3](https://pyo3.rs/latest) will be leveraged for easier Python bindings.
116117

118+
This project makes the [Soundness Pledge](https://raphlinus.github.io/rust/2020/01/18/soundness-pledge.html):
119+
> “The intent of this project is to be free of soundness bugs.
120+
> The developers will do their best to avoid them, and welcome help in analyzing and fixing them.”
121+
117122
## Architecture (data flow)
118123

119124
![Architecture](https://github.com/nautechsystems/nautilus_trader/blob/develop/docs/_images/architecture-overview.png?raw=true "architecture")
@@ -212,13 +217,16 @@ point we will follow a formal process for releases, with deprecation periods for
212217
## Makefile
213218
214219
A `Makefile` is provided to automate most installation and build tasks for development. It provides the following targets:
215-
- `make install` -- Installs the main, dev and test dependencies then installs the package using poetry
216-
- `make install-just-deps` -- Installs just the main, dev and test dependencies (does not install package)
217-
- `make build` -- Runs the Cython build script
218-
- `make clean` -- Cleans all non-source artifacts from the repository
220+
- `make install` -- Installs in `release` build mode with `main`, `dev` and `test` dependencies then installs the package using poetry (default)
221+
- `make install-debug` -- Same as `make install` but with `debug` build mode
222+
- `make install-just-deps` -- Installs just the `main`, `dev` and `test` dependencies (does not install package)
223+
- `make install-just-deps-all` -- Same as `make install-just-deps` and additionally installs `docs` dependencies
224+
- `make build` -- Runs the Cython build script in `release` build mode (default)
225+
- `make build-debug` -- Runs the Cython build script in `debug` build mode
226+
- `make clean` -- **CAUTION** Cleans all non-source artifacts from the repository
219227
- `make docs` -- Builds the documentation HTML using Sphinx
220228
- `make pre-commit` -- Runs the pre-commit checks over all files
221-
- `make ruff` -- Runs ruff over all files using the pyproject.toml config
229+
- `make ruff` -- Runs ruff over all files using the `pyproject.toml` config
222230
- `make pytest` -- Runs all tests with `pytest` (except performance tests)
223231
- `make pytest-coverage` -- Same as `make pytest` and additionally runs with test coverage and produces a report
224232
@@ -395,6 +403,9 @@ Contributions to the project are welcome and require the completion of a standar
395403

396404
NautilusTrader is developed and maintained by Nautech Systems, a technology
397405
company specializing in the development of high-performance trading systems.
406+
Although the project utilizes the Rust programming language and benefits from its ecosystem,
407+
Nautech Systems is not affiliated with the Rust Foundation, and this project is not an official
408+
work of the Rust Foundation.
398409
For more information, visit https://nautilustrader.io.
399410

400411
Copyright (C) 2015-2023 Nautech Systems Pty Ltd. All rights reserved.

RELEASES.md

+38
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,41 @@
1+
# NautilusTrader 1.172.0 Beta
2+
3+
Released on 30th April 2023 (UTC).
4+
5+
### Breaking Changes
6+
- Removed legacy Rust parquet data catalog backend (based on arrow2)
7+
- Removed Binance config for `clock_sync_interval_secs` (redundant/unused and should be handled at system level)
8+
- Removed redundant rate limiting from Rust logger (and associated `rate_limit` config params)
9+
- Renamed `Future` instrument to `FuturesContract` (avoids ambiguity)
10+
- Renamed `Option` instrument to `OptionsContract` (avoids ambiguity and naming conflicts in Rust)
11+
- Reinstate hours and minutes time component for default order and position identifiers (easier debugging, less collisions)
12+
- Setting time alerts for in the past or current time will generate an immediate `TimeEvent` (rather than being invalid).
13+
14+
### Enhancements
15+
- Added new DataFusion Rust parquet data catalog backend (yet to be integrated into Python)
16+
- Added `external_order_claims` config option for `StrategyConfig` (for claiming external orders per instrument)
17+
- Added `Order.signed_decimal_qty()`
18+
- Added `Cache.orders_for_exec_algorithm(...)`
19+
- Added `Cache.orders_for_exec_spawn(...)`
20+
- Added `TWAPExecAlgorithm` and `TWAPExecAlgorithmConfig` to examples
21+
- Build out `ExecAlgorithm` base class for implementing 'first class' executon algorithms
22+
- Rewired execution for improved flow flexibility between emulated orders, execution algorithms and the `RiskEngine`
23+
- Improved handling for `OrderEmulator` updating of contingency orders from execution algorithms
24+
- Define public API for instruments can now import directly from `nautilus_trader.model.instruments` (denest namespace)
25+
- Define public API for orders, can now import directly from `nautilus_trader.model.orders` (denest namespace)
26+
- Define public API for order book, can now import directly from `nautilus_trader.model.orderbook` (denest namespace)
27+
- Now stripping debug symbols after build (reduced binary sizes)
28+
- Refined build and added additional `debug` Makefile convenience targets
29+
30+
### Fixes
31+
- Fixed processing of contingency orders when in a pending update state
32+
- Fixed calculation of PnL for flipped positions (only book realized PnL against open position)
33+
- Fixed `WebSocketClient` session disconnect, thanks for reporting @miller-moore
34+
- Added missing `BinanceSymbolFilterType.NOTIONAL`
35+
- Fixed incorrect `Mul` trait for `Price` and `Quantity` (not being used in Cython/Python layer)
36+
37+
---
38+
139
# NautilusTrader 1.171.0 Beta
240

341
Released on 30th March 2023 (UTC).

build.py

+47-9
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
import sysconfig
99
from datetime import datetime
1010
from pathlib import Path
11+
from typing import Optional
1112

1213
import numpy as np
1314
from Cython.Build import build_ext
@@ -68,6 +69,7 @@
6869
# Directories with headers to include
6970
RUST_INCLUDES = ["nautilus_trader/core/includes"]
7071
RUST_LIB_PATHS: list[Path] = [
72+
TARGET_DIR / f"{RUST_LIB_PFX}nautilus_backtest.{RUST_STATIC_LIB_EXT}",
7173
TARGET_DIR / f"{RUST_LIB_PFX}nautilus_common.{RUST_STATIC_LIB_EXT}",
7274
TARGET_DIR / f"{RUST_LIB_PFX}nautilus_core.{RUST_STATIC_LIB_EXT}",
7375
TARGET_DIR / f"{RUST_LIB_PFX}nautilus_model.{RUST_STATIC_LIB_EXT}",
@@ -80,11 +82,21 @@ def _build_rust_libs() -> None:
8082
try:
8183
# Build the Rust libraries using Cargo
8284
build_options = " --release" if BUILD_MODE == "release" else ""
83-
extra_flags = ""
8485
print("Compiling Rust libraries...")
85-
build_cmd = f"(cd nautilus_core && cargo build{build_options}{extra_flags} --all-features)"
86-
print(build_cmd)
87-
os.system(build_cmd)
86+
87+
cmd_args = [
88+
"cargo",
89+
"build",
90+
*build_options.split(),
91+
"--all-features",
92+
]
93+
print(" ".join(cmd_args))
94+
95+
subprocess.run(
96+
cmd_args, # noqa
97+
cwd="nautilus_core",
98+
check=True,
99+
)
88100
except subprocess.CalledProcessError as e:
89101
raise RuntimeError(
90102
f"Error running cargo: {e.stderr.decode()}",
@@ -121,7 +133,9 @@ def _build_extensions() -> list[Extension]:
121133
# disable it with " "#define NPY_NO_DEPRECATED_API NPY_1_7_API_VERSION"
122134
# https://stackoverflow.com/questions/52749662/using-deprecated-numpy-api
123135
# From the Cython docs: "For the time being, it is just a warning that you can ignore."
124-
define_macros = [("NPY_NO_DEPRECATED_API", "NPY_1_7_API_VERSION")]
136+
define_macros: list[tuple[str, Optional[str]]] = [
137+
("NPY_NO_DEPRECATED_API", "NPY_1_7_API_VERSION"),
138+
]
125139
if PROFILE_MODE or ANNOTATION_MODE:
126140
# Profiling requires special macro directives
127141
define_macros.append(("CYTHON_TRACE", "1"))
@@ -131,6 +145,9 @@ def _build_extensions() -> list[Extension]:
131145

132146
if platform.system() == "Darwin":
133147
extra_compile_args.append("-Wno-unreachable-code-fallthrough")
148+
extra_link_args.append("-flat_namespace")
149+
extra_link_args.append("-undefined")
150+
extra_link_args.append("suppress")
134151

135152
if platform.system() != "Windows":
136153
# Suppress warnings produced by Cython boilerplate
@@ -216,9 +233,8 @@ def _copy_rust_dylibs_to_project() -> None:
216233
def _get_clang_version() -> str:
217234
try:
218235
result = subprocess.run(
219-
"clang --version",
236+
["clang", "--version"], # noqa
220237
check=True,
221-
shell=True,
222238
capture_output=True,
223239
)
224240
output = (
@@ -239,9 +255,8 @@ def _get_clang_version() -> str:
239255
def _get_rustc_version() -> str:
240256
try:
241257
result = subprocess.run(
242-
"rustc --version",
258+
["rustc", "--version"], # noqa
243259
check=True,
244-
shell=True,
245260
capture_output=True,
246261
)
247262
output = result.stdout.decode().lstrip("rustc ")[:-1]
@@ -254,6 +269,26 @@ def _get_rustc_version() -> str:
254269
) from e
255270

256271

272+
def _strip_unneeded_symbols() -> None:
273+
try:
274+
print("Stripping unneeded symbols from binaries...")
275+
for so in itertools.chain(Path("nautilus_trader").rglob("*.so")):
276+
if platform.system() == "Linux":
277+
strip_cmd = f"strip --strip-unneeded {so}"
278+
elif platform.system() == "Darwin":
279+
strip_cmd = f"strip -x {so}"
280+
else:
281+
raise RuntimeError(f"Cannot strip symbols for platform {platform.system()}")
282+
subprocess.run(
283+
strip_cmd, # noqa
284+
check=True,
285+
shell=True, # noqa
286+
capture_output=True,
287+
)
288+
except subprocess.CalledProcessError as e:
289+
raise RuntimeError(f"Error when stripping symbols.\n{e.stderr.decode()}") from e
290+
291+
257292
def build() -> None:
258293
"""Construct the extensions and distribution."""
259294
_build_rust_libs()
@@ -276,6 +311,9 @@ def build() -> None:
276311
# Copy the build back into the source tree for development and wheel packaging
277312
_copy_build_dir_to_project(cmd)
278313

314+
if platform.system() in ("Linux", "Darwin"):
315+
_strip_unneeded_symbols()
316+
279317

280318
if __name__ == "__main__":
281319
print("\033[36m")

docs/api_reference/execution.md

+26
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,16 @@
44
.. automodule:: nautilus_trader.execution
55
```
66

7+
## Components
8+
9+
```{eval-rst}
10+
.. automodule:: nautilus_trader.execution.algorithm
11+
:show-inheritance:
12+
:inherited-members:
13+
:members:
14+
:member-order: bysource
15+
```
16+
717
```{eval-rst}
818
.. automodule:: nautilus_trader.execution.client
919
:show-inheritance:
@@ -12,6 +22,14 @@
1222
:member-order: bysource
1323
```
1424

25+
```{eval-rst}
26+
.. automodule:: nautilus_trader.execution.emulator
27+
:show-inheritance:
28+
:inherited-members:
29+
:members:
30+
:member-order: bysource
31+
```
32+
1533
```{eval-rst}
1634
.. automodule:: nautilus_trader.execution.engine
1735
:show-inheritance:
@@ -20,6 +38,14 @@
2038
:member-order: bysource
2139
```
2240

41+
```{eval-rst}
42+
.. automodule:: nautilus_trader.execution.matching_core
43+
:show-inheritance:
44+
:inherited-members:
45+
:members:
46+
:member-order: bysource
47+
```
48+
2349
## Messages
2450

2551
```{eval-rst}

0 commit comments

Comments
 (0)