Skip to content

Commit 12801be

Browse files
authored
Release 1.169.0
See release notes.
2 parents 5ce9605 + 7e0e9d0 commit 12801be

File tree

304 files changed

+12258
-9857
lines changed

Some content is hidden

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

304 files changed

+12258
-9857
lines changed

.pre-commit-config.yaml

+37-3
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,39 @@ repos:
3232
types_or: [python, cython, rst, markdown]
3333
args: ["-L", "ot,zar,warmup"]
3434

35+
##############################################################################
36+
# Rust formatting and linting
37+
##############################################################################
38+
- repo: local
39+
hooks:
40+
- id: fmt
41+
name: cargo fmt
42+
description: Format files with cargo fmt.
43+
entry: cargo fmt
44+
language: system
45+
types: [rust]
46+
args: ["--manifest-path", "nautilus_core/Cargo.toml", "--all"]
47+
files: \.rs$
48+
pass_filenames: false
49+
- id: cargo-clippy
50+
name: cargo clippy
51+
description: Run the Clippy linter on the package.
52+
entry: cargo clippy
53+
language: system
54+
types: [rust]
55+
args: ["--manifest-path", "nautilus_core/Cargo.toml", "--", "-D", "warnings"]
56+
files: \.rs$
57+
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
67+
3568
##############################################################################
3669
# Python/Cython formatting and linting
3770
##############################################################################
@@ -64,7 +97,7 @@ repos:
6497
args: ["--settings-file", "pyproject.toml", "."]
6598

6699
- repo: https://github.com/psf/black
67-
rev: 22.12.0
100+
rev: 23.1.0
68101
hooks:
69102
- id: black
70103
types_or: [python, pyi]
@@ -73,7 +106,7 @@ repos:
73106
exclude: "docs/_pygments/monokai.py"
74107

75108
- repo: https://github.com/pre-commit/mirrors-mypy
76-
rev: v0.991
109+
rev: v1.0.0
77110
hooks:
78111
- id: mypy
79112
args: [
@@ -107,7 +140,7 @@ repos:
107140
files: ^nautilus_trader/
108141
exclude: "nautilus_trader/test_kit"
109142
args:
110-
- "--ignore=D100,D102,D103,D104,D107,D105,D200,D203,D205,D212,D400,D413,D415"
143+
- "--ignore=D100,D102,D103,D104,D107,D105,D200,D203,D205,D212,D400,D413,D415,D416"
111144
additional_dependencies:
112145
- toml
113146

@@ -129,3 +162,4 @@ repos:
129162
# D400: First line should end with a period (not always a first line)
130163
# D413: Missing blank line after last section ('Parameters')
131164
# D415: First line should end with a period, question mark, or exclamation point (not always a first line)
165+
# D416: Section name should end with a colon ('Warnings:', not 'Warnings') (incorrect?)

Makefile

-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ format:
2828
(cd nautilus_core && cargo fmt)
2929

3030
pre-commit: format
31-
(cd nautilus_core && cargo fmt --all -- --check && cargo check -q && cargo clippy --all-targets --all-features -- -D warnings)
3231
pre-commit run --all-files
3332

3433
update:

README.md

+12-12
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@
1515

1616
| Platform | Rust | Python |
1717
|:------------------|:----------|:-------|
18-
| Linux (x86\_64) | `1.66.1+` | `3.9+` |
19-
| macOS (x86\_64) | `1.66.1+` | `3.9+` |
20-
| Windows (x86\_64) | `1.66.1+` | `3.9+` |
18+
| Linux (x86\_64) | `1.67.1+` | `3.9+` |
19+
| macOS (x86\_64) | `1.67.1+` | `3.9+` |
20+
| Windows (x86\_64) | `1.67.1+` | `3.9+` |
2121

2222
- **Website:** https://nautilustrader.io
2323
- **Docs:** https://docs.nautilustrader.io
@@ -97,7 +97,7 @@ optional C-inspired syntax.
9797

9898
The project heavily utilizes Cython to provide static type safety and increased performance
9999
for Python through [C extension modules](https://docs.python.org/3/extending/extending.html). The vast majority of the production code is actually
100-
written in Cython, however the libraries can be accessed from both pure Python and Cython.
100+
written in Cython, however the libraries can be accessed from both Python and Cython.
101101

102102
## What is Rust?
103103

@@ -112,7 +112,7 @@ eliminating many classes of bugs at compile-time.
112112
The project increasingly utilizes Rust for core performance-critical components. Python language binding is handled through
113113
Cython, with static libraries linked at compile-time before the wheel binaries are packaged, so a user
114114
does not need to have Rust installed to run NautilusTrader. In the future as more Rust code is introduced,
115-
[PyO3](https://pyo3.rs/latest/) will be leveraged for easier Python bindings.
115+
[PyO3](https://pyo3.rs/latest) will be leveraged for easier Python bindings.
116116

117117
## Architecture (data flow)
118118

@@ -276,7 +276,7 @@ class EMACross(Strategy):
276276
Cancels all orders and closes all positions on stop.
277277
"""
278278
279-
def __init__(self, config: EMACrossConfig):
279+
def __init__(self, config: EMACrossConfig) -> None:
280280
super().__init__(config)
281281
282282
# Configuration
@@ -290,7 +290,7 @@ class EMACross(Strategy):
290290
291291
self.instrument: Optional[Instrument] = None # Initialized in on_start
292292
293-
def on_start(self):
293+
def on_start(self) -> None:
294294
"""Actions to be performed on strategy start."""
295295
# Get instrument
296296
self.instrument = self.cache.instrument(self.instrument_id)
@@ -305,7 +305,7 @@ class EMACross(Strategy):
305305
# Subscribe to live data
306306
self.subscribe_bars(self.bar_type)
307307
308-
def on_bar(self, bar: Bar):
308+
def on_bar(self, bar: Bar) -> None:
309309
"""Actions to be performed when the strategy receives a bar."""
310310
# BUY LOGIC
311311
if self.fast_ema.value >= self.slow_ema.value:
@@ -322,7 +322,7 @@ class EMACross(Strategy):
322322
self.close_all_positions(self.instrument_id)
323323
self.sell()
324324
325-
def buy(self):
325+
def buy(self) -> None:
326326
"""Users simple buy method (example)."""
327327
order: MarketOrder = self.order_factory.market(
328328
instrument_id=self.instrument_id,
@@ -332,7 +332,7 @@ class EMACross(Strategy):
332332
333333
self.submit_order(order)
334334
335-
def sell(self):
335+
def sell(self) -> None:
336336
"""Users simple sell method (example)."""
337337
order: MarketOrder = self.order_factory.market(
338338
instrument_id=self.instrument_id,
@@ -342,7 +342,7 @@ class EMACross(Strategy):
342342
343343
self.submit_order(order)
344344
345-
def on_stop(self):
345+
def on_stop(self) -> None:
346346
"""Actions to be performed when the strategy is stopped."""
347347
# Cleanup orders and positions
348348
self.cancel_all_orders(self.instrument_id)
@@ -351,7 +351,7 @@ class EMACross(Strategy):
351351
# Unsubscribe from data
352352
self.unsubscribe_bars(self.bar_type)
353353
354-
def on_reset(self):
354+
def on_reset(self) -> None:
355355
"""Actions to be performed when the strategy is reset."""
356356
# Reset indicators here
357357
self.fast_ema.reset()

RELEASES.md

+32
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,35 @@
1+
# NautilusTrader 1.169.0 Beta
2+
3+
Released on 18th February 2023 (UTC).
4+
5+
### Breaking Changes
6+
- `NautilusConfig` objects now _pseudo-immutable_ from new msgspec 0.13.0
7+
- Renamed `OrderFactory.bracket` param `post_only_entry` -> `entry_post_only` (consistency with other params)
8+
- Renamed `OrderFactory.bracket` param `post_only_tp` -> `tp_post_only` (consistency with other params)
9+
- Renamed `build_time_bars_with_no_updates` -> `time_bars_build_with_no_updates` (consistency with new param)
10+
- Renamed `OrderFactory.set_order_count()` -> `set_client_order_id_count()` (clarity)
11+
- Renamed `TradingNode.start()` to `TradingNode.run()`
12+
13+
### Enhancements
14+
- Complete overhaul and improvements to Binance adapter(s), thanks @poshcoe
15+
- Added Binance aggregated trades functionality with `use_agg_trade_ticks`, thanks @poshcoe
16+
- Added `time_bars_timestamp_on_close` option for configurable bar timestamping (True by default)
17+
- Added `OrderFactory.generate_client_order_id()` (calls internal generator)
18+
- Added `OrderFactory.generate_order_list_id()` (calls internal generator)
19+
- Added `OrderFactory.create_list(...)` as easier method for creating order lists
20+
- Added `__len__` implementation for `OrderList` (returns length of orders)
21+
- Implemented optimized logger using Rust MPSC channel and separate thread
22+
- Expose and improve `MatchingEngine` public API for custom functionality
23+
- Exposed `TradingNode.run_async()` for easier running from async context
24+
- Exposed `TradingNode.stop_async()` for easier stopping from async context
25+
26+
### Fixes
27+
- Fixed registration of `SimulationModule` (and refine `Actor` base registration)
28+
- Fixed loading of previously emulated and transformed orders (handles transforming `OrderInitialized` event)
29+
- Fixed handling of `MARKET_TO_LIMIT` orders in matching and risk engines, thanks for reporting @martinsaip
30+
31+
---
32+
133
# NautilusTrader 1.168.0 Beta
234

335
Released on 29th January 2023 (UTC).

build.py

+3-13
Original file line numberDiff line numberDiff line change
@@ -234,14 +234,9 @@ def _get_clang_version() -> str:
234234
return output
235235
except subprocess.CalledProcessError as e:
236236
raise RuntimeError(
237+
"You are installing from source which requires the Clang compiler to be installed.\n"
237238
f"Error running clang: {e.stderr.decode()}",
238239
) from e
239-
except FileNotFoundError as e:
240-
if "clang" in e.strerror:
241-
raise RuntimeError(
242-
"You are installing from source which requires the Clang compiler to be installed.",
243-
) from e
244-
raise
245240

246241

247242
def _get_rustc_version() -> str:
@@ -256,15 +251,10 @@ def _get_rustc_version() -> str:
256251
return output
257252
except subprocess.CalledProcessError as e:
258253
raise RuntimeError(
254+
"You are installing from source which requires the Rust compiler to "
255+
"be installed.\nFind more information at https://www.rust-lang.org/tools/install\n"
259256
f"Error running rustc: {e.stderr.decode()}",
260257
) from e
261-
except FileNotFoundError as e:
262-
if "rustc" in e.strerror:
263-
raise RuntimeError(
264-
"You are installing from source which requires the Rust compiler to "
265-
"be installed. Find more information at https://www.rust-lang.org/tools/install",
266-
) from e
267-
raise
268258

269259

270260
def build(pyo3_only=False) -> None:

docs/getting_started/installation.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ For MacBook Pro M1/M2, make sure your Python installed using pyenv is configured
3030

3131
PYTHON_CONFIGURE_OPTS="--enable-shared" pyenv install <python_version>
3232

33-
See https://pyo3.rs/v0.17.3/getting_started#virtualenvs.
33+
See https://pyo3.rs/latest/getting_started#virtualenvs.
3434

3535
It's possible to install from source using `pip` if you first install the build dependencies
3636
as specified in the `pyproject.toml`. However, we highly recommend installing using [poetry](https://python-poetry.org/) as below.

docs/getting_started/quick_start.md

+9-8
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ registering indicators to receive certain data types, however in this example we
6565

6666
```python
6767
from typing import Optional
68+
from nautilus_trader.core.message import Event
6869
from nautilus_trader.trading.strategy import Strategy, StrategyConfig
6970
from nautilus_trader.indicators.macd import MovingAverageConvergenceDivergence
7071
from nautilus_trader.model.data.tick import QuoteTick
@@ -85,7 +86,7 @@ class MACDConfig(StrategyConfig):
8586

8687

8788
class MACDStrategy(Strategy):
88-
def __init__(self, config: MACDConfig):
89+
def __init__(self, config: MACDConfig) -> None:
8990
super().__init__(config=config)
9091
# Our "trading signal"
9192
self.macd = MovingAverageConvergenceDivergence(
@@ -99,13 +100,13 @@ class MACDStrategy(Strategy):
99100
# Convenience
100101
self.position: Optional[Position] = None
101102

102-
def on_start(self):
103+
def on_start(self) -> None:
103104
self.subscribe_quote_ticks(instrument_id=self.instrument_id)
104105

105-
def on_stop(self):
106+
def on_stop(self) -> None:
106107
self.unsubscribe_quote_ticks(instrument_id=self.instrument_id)
107108

108-
def on_quote_tick(self, tick: QuoteTick):
109+
def on_quote_tick(self, tick: QuoteTick) -> None:
109110
# Update our MACD
110111
self.macd.handle_quote_tick(tick)
111112
if self.macd.value:
@@ -115,11 +116,11 @@ class MACDStrategy(Strategy):
115116
if self.position:
116117
assert self.position.quantity <= 1000
117118

118-
def on_event(self, event):
119+
def on_event(self, event: Event) -> None:
119120
if isinstance(event, PositionEvent):
120121
self.position = self.cache.position(event.position_id)
121122

122-
def check_for_entry(self):
123+
def check_for_entry(self) -> None:
123124
if self.cache.positions():
124125
# If we have a position, do not enter again
125126
return
@@ -136,7 +137,7 @@ class MACDStrategy(Strategy):
136137
)
137138
self.submit_order(order)
138139

139-
def check_for_exit(self):
140+
def check_for_exit(self) -> None:
140141
if not self.cache.positions():
141142
# If we don't have a position, return early
142143
return
@@ -154,7 +155,7 @@ class MACDStrategy(Strategy):
154155
)
155156
self.submit_order(order)
156157

157-
def on_dispose(self):
158+
def on_dispose(self) -> None:
158159
pass # Do nothing else
159160
```
160161

docs/index.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ optional additional C-inspired syntax.
7373

7474
The project heavily utilizes Cython to provide static type safety and increased performance
7575
for Python through [C extension modules](https://docs.python.org/3/extending/extending.html). The vast majority of the production code is actually
76-
written in Cython, however the libraries can be accessed from both pure Python and Cython.
76+
written in Cython, however the libraries can be accessed from both Python and Cython.
7777

7878
## What is Rust?
7979

@@ -88,7 +88,7 @@ eliminating many classes of bugs at compile-time.
8888
The project increasingly utilizes Rust for core performance-critical components. Python language binding is handled through
8989
Cython, with static libraries linked at compile-time before the wheel binaries are packaged, so a user
9090
does not need to have Rust installed to run NautilusTrader. In the future as more Rust code is introduced,
91-
[PyO3](https://pyo3.rs/v0.15.1/) will be leveraged for easier Python bindings.
91+
[PyO3](https://pyo3.rs/latest) will be leveraged for easier Python bindings.
9292

9393
## Architecture Quality Attributes
9494

0 commit comments

Comments
 (0)