Skip to content

Commit

Permalink
Release 1.169.0
Browse files Browse the repository at this point in the history
See release notes.
  • Loading branch information
cjdsellers authored Feb 18, 2023
2 parents 5ce9605 + 7e0e9d0 commit 12801be
Show file tree
Hide file tree
Showing 304 changed files with 12,258 additions and 9,857 deletions.
40 changes: 37 additions & 3 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,39 @@ repos:
types_or: [python, cython, rst, markdown]
args: ["-L", "ot,zar,warmup"]

##############################################################################
# Rust formatting and linting
##############################################################################
- repo: local
hooks:
- id: fmt
name: cargo fmt
description: Format files with cargo fmt.
entry: cargo fmt
language: system
types: [rust]
args: ["--manifest-path", "nautilus_core/Cargo.toml", "--all"]
files: \.rs$
pass_filenames: false
- id: cargo-clippy
name: cargo clippy
description: Run the Clippy linter on the package.
entry: cargo clippy
language: system
types: [rust]
args: ["--manifest-path", "nautilus_core/Cargo.toml", "--", "-D", "warnings"]
files: \.rs$
pass_filenames: false
- id: cargo-check
name: cargo check
description: Check the package for errors.
entry: cargo check
language: system
types: [rust]
args: ["--manifest-path", "nautilus_core/Cargo.toml"]
files: \.rs$
pass_filenames: false

##############################################################################
# Python/Cython formatting and linting
##############################################################################
Expand Down Expand Up @@ -64,7 +97,7 @@ repos:
args: ["--settings-file", "pyproject.toml", "."]

- repo: https://github.com/psf/black
rev: 22.12.0
rev: 23.1.0
hooks:
- id: black
types_or: [python, pyi]
Expand All @@ -73,7 +106,7 @@ repos:
exclude: "docs/_pygments/monokai.py"

- repo: https://github.com/pre-commit/mirrors-mypy
rev: v0.991
rev: v1.0.0
hooks:
- id: mypy
args: [
Expand Down Expand Up @@ -107,7 +140,7 @@ repos:
files: ^nautilus_trader/
exclude: "nautilus_trader/test_kit"
args:
- "--ignore=D100,D102,D103,D104,D107,D105,D200,D203,D205,D212,D400,D413,D415"
- "--ignore=D100,D102,D103,D104,D107,D105,D200,D203,D205,D212,D400,D413,D415,D416"
additional_dependencies:
- toml

Expand All @@ -129,3 +162,4 @@ repos:
# D400: First line should end with a period (not always a first line)
# D413: Missing blank line after last section ('Parameters')
# D415: First line should end with a period, question mark, or exclamation point (not always a first line)
# D416: Section name should end with a colon ('Warnings:', not 'Warnings') (incorrect?)
1 change: 0 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ format:
(cd nautilus_core && cargo fmt)

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

update:
Expand Down
24 changes: 12 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@

| Platform | Rust | Python |
|:------------------|:----------|:-------|
| Linux (x86\_64) | `1.66.1+` | `3.9+` |
| macOS (x86\_64) | `1.66.1+` | `3.9+` |
| Windows (x86\_64) | `1.66.1+` | `3.9+` |
| Linux (x86\_64) | `1.67.1+` | `3.9+` |
| macOS (x86\_64) | `1.67.1+` | `3.9+` |
| Windows (x86\_64) | `1.67.1+` | `3.9+` |

- **Website:** https://nautilustrader.io
- **Docs:** https://docs.nautilustrader.io
Expand Down Expand Up @@ -97,7 +97,7 @@ optional C-inspired syntax.

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

## What is Rust?

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

## Architecture (data flow)

Expand Down Expand Up @@ -276,7 +276,7 @@ class EMACross(Strategy):
Cancels all orders and closes all positions on stop.
"""
def __init__(self, config: EMACrossConfig):
def __init__(self, config: EMACrossConfig) -> None:
super().__init__(config)
# Configuration
Expand All @@ -290,7 +290,7 @@ class EMACross(Strategy):
self.instrument: Optional[Instrument] = None # Initialized in on_start
def on_start(self):
def on_start(self) -> None:
"""Actions to be performed on strategy start."""
# Get instrument
self.instrument = self.cache.instrument(self.instrument_id)
Expand All @@ -305,7 +305,7 @@ class EMACross(Strategy):
# Subscribe to live data
self.subscribe_bars(self.bar_type)
def on_bar(self, bar: Bar):
def on_bar(self, bar: Bar) -> None:
"""Actions to be performed when the strategy receives a bar."""
# BUY LOGIC
if self.fast_ema.value >= self.slow_ema.value:
Expand All @@ -322,7 +322,7 @@ class EMACross(Strategy):
self.close_all_positions(self.instrument_id)
self.sell()
def buy(self):
def buy(self) -> None:
"""Users simple buy method (example)."""
order: MarketOrder = self.order_factory.market(
instrument_id=self.instrument_id,
Expand All @@ -332,7 +332,7 @@ class EMACross(Strategy):
self.submit_order(order)
def sell(self):
def sell(self) -> None:
"""Users simple sell method (example)."""
order: MarketOrder = self.order_factory.market(
instrument_id=self.instrument_id,
Expand All @@ -342,7 +342,7 @@ class EMACross(Strategy):
self.submit_order(order)
def on_stop(self):
def on_stop(self) -> None:
"""Actions to be performed when the strategy is stopped."""
# Cleanup orders and positions
self.cancel_all_orders(self.instrument_id)
Expand All @@ -351,7 +351,7 @@ class EMACross(Strategy):
# Unsubscribe from data
self.unsubscribe_bars(self.bar_type)
def on_reset(self):
def on_reset(self) -> None:
"""Actions to be performed when the strategy is reset."""
# Reset indicators here
self.fast_ema.reset()
Expand Down
32 changes: 32 additions & 0 deletions RELEASES.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,35 @@
# NautilusTrader 1.169.0 Beta

Released on 18th February 2023 (UTC).

### Breaking Changes
- `NautilusConfig` objects now _pseudo-immutable_ from new msgspec 0.13.0
- Renamed `OrderFactory.bracket` param `post_only_entry` -> `entry_post_only` (consistency with other params)
- Renamed `OrderFactory.bracket` param `post_only_tp` -> `tp_post_only` (consistency with other params)
- Renamed `build_time_bars_with_no_updates` -> `time_bars_build_with_no_updates` (consistency with new param)
- Renamed `OrderFactory.set_order_count()` -> `set_client_order_id_count()` (clarity)
- Renamed `TradingNode.start()` to `TradingNode.run()`

### Enhancements
- Complete overhaul and improvements to Binance adapter(s), thanks @poshcoe
- Added Binance aggregated trades functionality with `use_agg_trade_ticks`, thanks @poshcoe
- Added `time_bars_timestamp_on_close` option for configurable bar timestamping (True by default)
- Added `OrderFactory.generate_client_order_id()` (calls internal generator)
- Added `OrderFactory.generate_order_list_id()` (calls internal generator)
- Added `OrderFactory.create_list(...)` as easier method for creating order lists
- Added `__len__` implementation for `OrderList` (returns length of orders)
- Implemented optimized logger using Rust MPSC channel and separate thread
- Expose and improve `MatchingEngine` public API for custom functionality
- Exposed `TradingNode.run_async()` for easier running from async context
- Exposed `TradingNode.stop_async()` for easier stopping from async context

### Fixes
- Fixed registration of `SimulationModule` (and refine `Actor` base registration)
- Fixed loading of previously emulated and transformed orders (handles transforming `OrderInitialized` event)
- Fixed handling of `MARKET_TO_LIMIT` orders in matching and risk engines, thanks for reporting @martinsaip

---

# NautilusTrader 1.168.0 Beta

Released on 29th January 2023 (UTC).
Expand Down
16 changes: 3 additions & 13 deletions build.py
Original file line number Diff line number Diff line change
Expand Up @@ -234,14 +234,9 @@ def _get_clang_version() -> str:
return output
except subprocess.CalledProcessError as e:
raise RuntimeError(
"You are installing from source which requires the Clang compiler to be installed.\n"
f"Error running clang: {e.stderr.decode()}",
) from e
except FileNotFoundError as e:
if "clang" in e.strerror:
raise RuntimeError(
"You are installing from source which requires the Clang compiler to be installed.",
) from e
raise


def _get_rustc_version() -> str:
Expand All @@ -256,15 +251,10 @@ def _get_rustc_version() -> str:
return output
except subprocess.CalledProcessError as e:
raise RuntimeError(
"You are installing from source which requires the Rust compiler to "
"be installed.\nFind more information at https://www.rust-lang.org/tools/install\n"
f"Error running rustc: {e.stderr.decode()}",
) from e
except FileNotFoundError as e:
if "rustc" in e.strerror:
raise RuntimeError(
"You are installing from source which requires the Rust compiler to "
"be installed. Find more information at https://www.rust-lang.org/tools/install",
) from e
raise


def build(pyo3_only=False) -> None:
Expand Down
2 changes: 1 addition & 1 deletion docs/getting_started/installation.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ For MacBook Pro M1/M2, make sure your Python installed using pyenv is configured

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

See https://pyo3.rs/v0.17.3/getting_started#virtualenvs.
See https://pyo3.rs/latest/getting_started#virtualenvs.

It's possible to install from source using `pip` if you first install the build dependencies
as specified in the `pyproject.toml`. However, we highly recommend installing using [poetry](https://python-poetry.org/) as below.
Expand Down
17 changes: 9 additions & 8 deletions docs/getting_started/quick_start.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ registering indicators to receive certain data types, however in this example we

```python
from typing import Optional
from nautilus_trader.core.message import Event
from nautilus_trader.trading.strategy import Strategy, StrategyConfig
from nautilus_trader.indicators.macd import MovingAverageConvergenceDivergence
from nautilus_trader.model.data.tick import QuoteTick
Expand All @@ -85,7 +86,7 @@ class MACDConfig(StrategyConfig):


class MACDStrategy(Strategy):
def __init__(self, config: MACDConfig):
def __init__(self, config: MACDConfig) -> None:
super().__init__(config=config)
# Our "trading signal"
self.macd = MovingAverageConvergenceDivergence(
Expand All @@ -99,13 +100,13 @@ class MACDStrategy(Strategy):
# Convenience
self.position: Optional[Position] = None

def on_start(self):
def on_start(self) -> None:
self.subscribe_quote_ticks(instrument_id=self.instrument_id)

def on_stop(self):
def on_stop(self) -> None:
self.unsubscribe_quote_ticks(instrument_id=self.instrument_id)

def on_quote_tick(self, tick: QuoteTick):
def on_quote_tick(self, tick: QuoteTick) -> None:
# Update our MACD
self.macd.handle_quote_tick(tick)
if self.macd.value:
Expand All @@ -115,11 +116,11 @@ class MACDStrategy(Strategy):
if self.position:
assert self.position.quantity <= 1000

def on_event(self, event):
def on_event(self, event: Event) -> None:
if isinstance(event, PositionEvent):
self.position = self.cache.position(event.position_id)

def check_for_entry(self):
def check_for_entry(self) -> None:
if self.cache.positions():
# If we have a position, do not enter again
return
Expand All @@ -136,7 +137,7 @@ class MACDStrategy(Strategy):
)
self.submit_order(order)

def check_for_exit(self):
def check_for_exit(self) -> None:
if not self.cache.positions():
# If we don't have a position, return early
return
Expand All @@ -154,7 +155,7 @@ class MACDStrategy(Strategy):
)
self.submit_order(order)

def on_dispose(self):
def on_dispose(self) -> None:
pass # Do nothing else
```

Expand Down
4 changes: 2 additions & 2 deletions docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ optional additional C-inspired syntax.

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

## What is Rust?

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

## Architecture Quality Attributes

Expand Down
Loading

0 comments on commit 12801be

Please sign in to comment.