Skip to content

Commit d6e6444

Browse files
authored
Release 1.145.0
See release notes.
2 parents 313d769 + bf0f87b commit d6e6444

File tree

116 files changed

+2744
-1088
lines changed

Some content is hidden

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

116 files changed

+2744
-1088
lines changed

.gitignore

+1-1
Original file line numberDiff line numberDiff line change
@@ -46,5 +46,5 @@ output.json
4646
examples/backtest/notebooks/catalog
4747
nautilus_trader/**/.gitignore
4848
docs/**/*.ipynb
49-
!nautilus_trader/core/pytime.h
5049
!nautilus_core/lib/**/*
50+
!nautilus_trader/core/includes/**

RELEASES.md

+20
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,23 @@
1+
# NautilusTrader 1.145.0 Beta
2+
3+
Released on 15th May 2022 (UTC).
4+
5+
This is an early release due to the build error in the sdist for `1.144.0`.
6+
The error is due to the `nautilus_core` Rust source not being included in the sdist package.
7+
8+
### Breaking Changes
9+
- All raw order constructors now take `expire_time_ns` int64 rather than a datetime
10+
- All order serializations due to `expire_time_ns` option handling
11+
- `PortfolioAnalyzer` moved from `Trader` to `Portfolio`
12+
13+
### Enhancements
14+
- `PortfolioAnalyzer` now available to strategies via `self.portfolio.analyzer`
15+
16+
### Fixes
17+
None
18+
19+
---
20+
121
# NautilusTrader 1.144.0 Beta
222

323
Released on 10th May 2022 (UTC).

docs/user_guide/advanced/portfolio_statistics.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ These statistics can then be registered with a traders `PortfolioAnalyzer`.
4444
```python
4545
stat = WinRate()
4646

47-
engine.trader.analyzer.register_statistic(stat)
47+
engine.portfolio.analyzer.register_statistic(stat)
4848
```
4949

5050
```{tip}

docs/user_guide/backtest_example.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Complete Backtest Example
22

3-
This notebook runs through a complete backtest example using raw data (external to nautilus) to a parameterised run
3+
This notebook runs through a complete backtest example using raw data (external to Nautilus) to a single backtest run.
44

55
<!-- #region tags=[] -->
66

@@ -29,7 +29,7 @@ from nautilus_trader.persistence.external.readers import TextReader
2929

3030
## Getting some raw data
3131

32-
Before we start the notebook - as a once off we need to download some sample data for backtesting
32+
Before we start the notebook - as a once off we need to download some sample data for backtesting.
3333

3434
For this notebook we will use FX data from `histdata.com`, simply go to https://www.histdata.com/download-free-forex-historical-data/?/ascii/tick-data-quotes/ and select an FX pair, and one or more months of data to download.
3535

@@ -40,7 +40,7 @@ Once you have downloaded the data, set the variable `DATA_DIR` below to the dire
4040
DATA_DIR = "~/Downloads/"
4141
```
4242

43-
Run the cell below; you should see the files that you downloaded
43+
Run the cell below; you should see the files that you downloaded:
4444

4545
```python
4646
fs = fsspec.filesystem('file')

docs/user_guide/core_concepts.md

+30-12
Original file line numberDiff line numberDiff line change
@@ -6,27 +6,42 @@ performance with a high quality user experience, within the bounds of a robust P
66
- Backtesting trading strategies
77
- Deploying trading strategies live
88

9+
The projects codebase provides a framework for implementing systems to achieve the above. You will find
10+
the default `backtest` and `live` system implementations in their respectively named subpackages. All examples
11+
will also either utilize the default backtest or live system implementations.
12+
913
## System Architecture
14+
15+
### Common core
16+
NautilusTrader has been designed to share as much common code between backtest and live systems as possible. This
17+
is formalized in the `system` subpackage, where you will find the `NautilusKernel` class, providing a common core system kernel.
18+
19+
A _ports and adapters_ architectural style allows modular components to be 'plugged into' the
20+
core system, providing many hook points for user defined / custom implementations.
21+
22+
### Messaging
23+
To facilitate this modularity and loose coupling, an extremely efficient `MessageBus` passes data, commands and events as messages between components.
24+
1025
From a high level architectural view, it's important to understand that the platform has been designed to run efficiently
1126
on a single thread, for both backtesting and live trading. A lot of research and testing
1227
resulted in arriving at this design, as it was found the overhead of context switching between threads
1328
didn't pay off in better performance.
1429

15-
For live trading, extremely high performance (benchmarks pending) can be achieved running asynchronously on a single [event loop](https://docs.python.org/3/library/asyncio-eventloop.html),
16-
especially leveraging the [uvloop](https://github.com/MagicStack/uvloop) implementation (available for Linux and macOS only).
30+
When considering the logic of how your trading will work within the system boundary, you can expect each component to consume messages
31+
in a predictable synchronous way (_similar_ to the [actor model](https://en.wikipedia.org/wiki/Actor_model)).
1732

1833
```{note}
19-
Of interest is the LMAX exchange architectire, which achieves award winning performance running on
34+
Of interest is the LMAX exchange architecture, which achieves award winning performance running on
2035
a single thread. You can read about their _disruptor_ pattern based architecture in [this interesting article](https://martinfowler.com/articles/lmax.html) by Martin Fowler.
2136
```
2237

23-
When considering the logic of how your trading will work within the system boundary, you can expect each component to consume messages
24-
in a predictable synchronous way (_similar_ to the [actor model](https://en.wikipedia.org/wiki/Actor_model)).
25-
2638
## Trading Live
2739
A `TradingNode` can host a fleet of trading strategies, with data able to be ingested from multiple data clients, and order execution handled through multiple execution clients.
2840
Live deployments can use both demo/paper trading accounts, or real accounts.
2941

42+
For live trading, extremely high performance (benchmarks pending) can be achieved running asynchronously on a single [event loop](https://docs.python.org/3/library/asyncio-eventloop.html),
43+
especially leveraging the [uvloop](https://github.com/MagicStack/uvloop) implementation (available for Linux and macOS only).
44+
3045
## Data Types
3146
The following market data types can be requested historically, and also subscribed to as live streams when available from a data publisher, and implemented in an integrations adapter.
3247
- `OrderBookDelta`
@@ -44,10 +59,13 @@ The following PriceType options can be used for bar aggregations;
4459
- `LAST`
4560

4661
The following BarAggregation options are possible;
62+
- `MILLISECOND`
4763
- `SECOND`
4864
- `MINUTE`
4965
- `HOUR`
5066
- `DAY`
67+
- `WEEK`
68+
- `MONTH`
5169
- `TICK`
5270
- `VOLUME`
5371
- `VALUE` (a.k.a Dollar bars)
@@ -58,16 +76,16 @@ The following BarAggregation options are possible;
5876
- `VALUE_IMBALANCE`
5977
- `VALUE_RUNS`
6078

61-
The price types and bar aggregations can be combined with step sizes >= 1 in any way through `BarSpecification`.
62-
This enables maximum flexibility and now allows alternative bars to be produced for live trading.
79+
The price types and bar aggregations can be combined with step sizes >= 1 in any way through a `BarSpecification`.
80+
This enables maximum flexibility and now allows alternative bars to be aggregated for live trading.
6381

6482
## Account Types
6583
The following account types are available for both live and backtest environments;
6684

67-
- `Cash` single-currency (base currency).
68-
- `Cash` multi-currency.
69-
- `Margin` single-currency (base currency).
70-
- `Margin` multi-currency.
85+
- `Cash` single-currency (base currency)
86+
- `Cash` multi-currency
87+
- `Margin` single-currency (base currency)
88+
- `Margin` multi-currency
7189

7290
## Order Types
7391
The following order types are available (when possible on an exchange);

docs/user_guide/strategies.md

+31-34
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ trading strategies. Defining a trading strategy is achieved by inheriting the `S
55
and implementing the methods required by the strategy.
66

77
Using the basic building blocks of data ingest and order management (which we will discuss
8-
below), it's possible to implement any type of trading strategy including positional, momentum, re-balancing,
9-
pairs trading, market making etc.
8+
below), it's possible to implement any type of trading strategy including directional, momentum, re-balancing,
9+
pairs, market making etc.
1010

1111
Please refer to the [API Reference](../api_reference/trading.md#strategy) for a complete description
1212
of all the possible functionality.
@@ -19,6 +19,16 @@ There are two main parts of a Nautilus trading strategy:
1919
Once a strategy is defined, the same source can be used for backtesting and live trading.
2020
```
2121

22+
## Implementation
23+
Since a trading strategy is a class which inherits from `Strategy`, you must define
24+
a constructor where you can handle initialization. Minimally the base/super class needs to be initialized:
25+
26+
```python
27+
class MyStrategy(Strategy):
28+
def __init__(self):
29+
super().__init__() # <-- the super class must be called to initialize the strategy
30+
```
31+
2232
## Configuration
2333
The main purpose of a separate configuration class is to provide total flexibility
2434
over where and how a trading strategy can be instantiated. This includes being able
@@ -37,7 +47,7 @@ from decimal import Decimal
3747
from nautilus_trader.config import StrategyConfig
3848

3949

40-
class MyStrategy(StrategyConfig):
50+
class MyStrategyConfig(StrategyConfig):
4151
instrument_id: str
4252
bar_type: str
4353
fast_ema_period: int = 10
@@ -53,6 +63,24 @@ config = MyStrategy(
5363
)
5464
```
5565

66+
Once a configuration is defined and instantiated, we can pass this to our trading strategy. Here we simply add an instrument ID
67+
as a string, to parameterize the instrument the strategy will trade.
68+
69+
```python
70+
class MyStrategy(Strategy):
71+
def __init__(self, config: MyStrategyConfig):
72+
super().__init__(config)
73+
74+
# Configuration
75+
self.instrument_id = InstrumentId.from_str(config.instrument_id)
76+
```
77+
78+
```{note}
79+
Even though it often makes sense to define a strategy which will trade a single
80+
instrument. There is actually no limit to the number of instruments a single strategy
81+
can work with.
82+
```
83+
5684
### Multiple strategies
5785
If you intend running multiple instances of the same strategy, with different
5886
configurations (such as trading different instruments), then you will need to define
@@ -71,34 +99,3 @@ example the above config would result in a strategy ID of `MyStrategy-001`.
7199
```{tip}
72100
See the `StrategyId` [documentation](../api_reference/model/identifiers.md) for further details.
73101
```
74-
75-
## Implementation
76-
Since a trading strategy is a class which inherits from `Strategy`, you must define
77-
a constructor where you can handle initialization. Minimally the base/super class needs to be initialized:
78-
79-
```python
80-
class MyStrategy(Strategy):
81-
def __init__(self):
82-
super().__init__() # <-- the super class must be called to initialize the strategy
83-
```
84-
85-
As per the above, it's also possible to define a configuration. Here we simply add an instrument ID
86-
as a string, to parameterize the instrument the strategy will trade.
87-
88-
```python
89-
class MyStrategyConfig(StrategyConfig):
90-
instrument_id: str
91-
92-
class MyStrategy(Strategy):
93-
def __init__(self, config: MyStrategyConfig):
94-
super().__init__(config)
95-
96-
# Configuration
97-
self.instrument_id = InstrumentId.from_str(config.instrument_id)
98-
```
99-
100-
```{note}
101-
Even though it often makes sense to define a strategy which will trade a single
102-
instrument. There is actually no limit to the number of instruments a single strategy
103-
can work with.
104-
```

examples/notebooks/backtest_example.ipynb

+1-1
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@
8282
" bar_type=\"EUR/USD.SIM-15-MINUTE-BID-INTERNAL\",\n",
8383
" fast_ema=10,\n",
8484
" slow_ema=20,\n",
85-
" trade_size=Decimal(1_000_000),\n",
85+
" trade_size=Decimal(100_000),\n",
8686
" ),\n",
8787
" ),\n",
8888
"]\n",

nautilus_core/.cargo/config.toml

+9-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,13 @@
11
[target.x86_64-pc-windows-msvc]
2-
rustflags = ["-C", "target-feature=+crt-static"]
2+
rustflags = [
3+
"-C", "target-feature=+crt-static",
4+
]
5+
6+
[target.x86_64-apple-darwin]
7+
rustflags = [
8+
"-C", "link-arg=-undefined",
9+
"-C", "link-arg=dynamic_lookup",
10+
]
311

412
[target.x86_64-unknown-linux-musl]
513
linker = "rust-lld"

0 commit comments

Comments
 (0)