Skip to content

Commit

Permalink
Release 1.182.0
Browse files Browse the repository at this point in the history
See release notes.
  • Loading branch information
cjdsellers authored Dec 23, 2023
2 parents 63c191b + d5fb56a commit f1b643d
Show file tree
Hide file tree
Showing 383 changed files with 21,416 additions and 4,217 deletions.
6 changes: 6 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,12 @@ jobs:
- name: Install build dependencies
run: python -m pip install --upgrade pip setuptools wheel pre-commit msgspec

- name: Install TA-Lib (Linux)
if: runner.os == 'Linux'
run: |
make install-talib
poetry run pip install ta-lib
- name: Setup cached pre-commit
id: cached-pre-commit
uses: actions/cache@v3
Expand Down
6 changes: 5 additions & 1 deletion .github/workflows/coverage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ jobs:
working-directory: ${{ github.workspace }}

- name: Set up Rust tool-chain (Linux, Windows) stable
if: (runner.os == 'Linux') || (runner.os == 'Windows')
uses: actions-rust-lang/[email protected]
with:
toolchain: ${{ env.RUST_VERSION }}
Expand All @@ -54,6 +53,11 @@ jobs:
- name: Install build dependencies
run: python -m pip install --upgrade pip setuptools wheel pre-commit msgspec

- name: Install TA-Lib (Linux)
run: |
make install-talib
poetry run pip install ta-lib
- name: Setup cached pre-commit
id: cached-pre-commit
uses: actions/cache@v3
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ jobs:

- name: Get branch name
id: branch-name
uses: tj-actions/branch-names@v6
uses: tj-actions/branch-names@v7.0.7

- name: Build nautilus_trader image (develop)
if: ${{ steps.branch-name.outputs.current_branch == 'develop' }}
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ jobs:

- name: Get branch name
id: branch-name
uses: tj-actions/branch-names@v6
uses: tj-actions/branch-names@v7.0.7

- name: Build Python docs
run: make docs-python
Expand Down
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
*.key_secret
*.sqlite
*.env
*.tar.gz*
*.zip

.benchmarks*
.coverage*
Expand All @@ -41,6 +43,7 @@ env/
log/
logs/
secrets/
ta-lib/
*temp/
*target/
venv*/
Expand Down
8 changes: 4 additions & 4 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ repos:
types: [python]

- repo: https://github.com/psf/black
rev: 23.11.0
rev: 23.12.0
hooks:
- id: black
types_or: [python, pyi]
Expand All @@ -82,13 +82,13 @@ repos:
exclude: "docs/_pygments/monokai.py"

- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.1.6
rev: v0.1.9
hooks:
- id: ruff
args: ["--fix"]

- repo: https://github.com/pycqa/isort
rev: 5.12.0
rev: 5.13.2
hooks:
- id: isort
name: isort (cython)
Expand All @@ -111,7 +111,7 @@ repos:
]

- repo: https://github.com/pre-commit/mirrors-mypy
rev: v1.7.1
rev: v1.8.0
hooks:
- id: mypy
args: [
Expand Down
4 changes: 4 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,10 @@ pytest-coverage:
test-examples:
bash scripts/test-examples.sh

.PHONY: install-talib
install-talib:
bash scripts/install-talib.sh

.PHONY: init-db
init-db:
(cd nautilus_core && cargo run --bin init-db)
Expand Down
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@

| Platform | Rust | Python |
| :----------------- | :------ | :----- |
| `Linux (x86_64)` | 1.74.0+ | 3.10+ |
| `macOS (x86_64)` | 1.74.0+ | 3.10+ |
| `macOS (arm64)` | 1.74.0+ | 3.10+ |
| `Windows (x86_64)` | 1.74.0+ | 3.10+ |
| `Linux (x86_64)` | 1.74.1+ | 3.10+ |
| `macOS (x86_64)` | 1.74.1+ | 3.10+ |
| `macOS (arm64)` | 1.74.1+ | 3.10+ |
| `Windows (x86_64)` | 1.74.1+ | 3.10+ |

- **Website:** https://nautilustrader.io
- **Docs:** https://docs.nautilustrader.io
Expand Down
40 changes: 40 additions & 0 deletions RELEASES.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,43 @@
# NautilusTrader 1.182.0 Beta

Released on 23rd December 2023 (UTC).

### Enhancements
- Added `CacheDatabaseFacade` and `CacheDatabaseAdapter` to abstract backing technology from Python codebase
- Added `RedisCacheDatabase` implemented in Rust with separate MPSC channel thread for insert, update and delete operations
- Added TA-Lib integration, thanks @rsmb7z
- Added `OrderBookDelta` and `OrderBookDeltas` to serializable and publishable types
- Moved `PortfolioFacade` to `Actor`
- Improved `Actor` and `Strategy` usability to be more lenient to mistaken calls to `clock` and `logger` from the constructor (warnings also added to docs)
- Removed `redis` and `hiredis` dependencies from Python codebase

### Breaking Changes
- Changed configuration objects to take stronger types as these are now serializable when registered (rather than primitives)
- Changed `NautilusKernelConfig.trader_id` to type `TraderId`
- Changed `BacktestDataConfig.instrument_id` to type `InstrumentId`
- Changed `ActorConfig.component_id` to type `ComponentId | None`
- Changed `StrategyConfig.strategy_id` to type `StrategyId | None`
- Changed `Instrument`, `OrderFilled` and `AccountState` `info` field serialization due below fix (you'll need to flush your cache)
- Changed `CacheConfig` to take a `DatabaseConfig` (better symmetry with `MessageBusConfig`)
- Changed `RedisCacheDatabase` data structure for currencies from hashset to simpler key-value (you'll need to clear cache or delete all curreny keys)
- Changed `Actor` state loading to now use the standard `Serializer`
- Renamed `register_json_encoding` to `register_config_encoding`
- Renamed `register_json_decoding` to `register_config_decoding`
- Removed `CacheDatabaseConfig` (due above config change)
- Removed `infrastructure` subpackage (now redundant with new Rust implementation)

### Fixes
- Fixed `json` encoding for `CacheDatabaseAdapter` from `info` field serialization fix below
- Fixed `Instrument`, `OrderFilled` and `AccountState` `info` field serialization to retain JSON serializable dicts (rather than double encoding and losing information)
- Fixed Binance Futures `good_till_date` value when `time_in_force` not GTD, such as when strategy is managing the GTD (was incorrectly passing through UNIX milliseconds)
- Fixed `Executor` handling of queued task IDs (was not discarding from queued tasks on completion)
- Fixed `DataEngine` handling of order book snapshots with very small intervals (now handles as short as 20 milliseconds)
- Fixed `BacktestEngine.clear_actors()`, `BacktestEngine.clear_strategies()` and `BacktestEngine.clear_exec_algorithms()`, thanks for reporting @davidsblom
- Fixed `BacktestEngine` OrderEmulator reset, thanks @davidsblom
- Fixed `Throttler.reset` and reset of `RiskEngine` throttlers, thanks @davidsblom

---

# NautilusTrader 1.181.0 Beta

Released on 2nd December (UTC).
Expand Down
7 changes: 3 additions & 4 deletions build.py
Original file line number Diff line number Diff line change
Expand Up @@ -277,15 +277,14 @@ def _strip_unneeded_symbols() -> None:
print("Stripping unneeded symbols from binaries...")
for so in itertools.chain(Path("nautilus_trader").rglob("*.so")):
if platform.system() == "Linux":
strip_cmd = f"strip --strip-unneeded {so}"
strip_cmd = ["strip", "--strip-unneeded", so]
elif platform.system() == "Darwin":
strip_cmd = f"strip -x {so}"
strip_cmd = ["strip", "-x", so]
else:
raise RuntimeError(f"Cannot strip symbols for platform {platform.system()}")
subprocess.run(
strip_cmd,
strip_cmd, # type: ignore [arg-type] # noqa
check=True,
shell=True, # noqa
capture_output=True,
)
except subprocess.CalledProcessError as e:
Expand Down
4 changes: 4 additions & 0 deletions docs/api_reference/model/book.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,8 @@

```{eval-rst}
.. automodule:: nautilus_trader.model.book
:show-inheritance:
:inherited-members:
:members:
:member-order: bysource
```
4 changes: 4 additions & 0 deletions docs/api_reference/model/data.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,8 @@

```{eval-rst}
.. automodule:: nautilus_trader.model.data
:show-inheritance:
:inherited-members:
:members:
:member-order: bysource
```
2 changes: 1 addition & 1 deletion docs/concepts/message_bus.md
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ message_bus=MessageBusConfig(

### Database config
A `DatabaseConfig` must be provided, for a default Redis setup on the local
loopback, you can simple pass a `DatabaseConfig()` which will use defaults to match.
loopback you can pass a `DatabaseConfig()`, which will use defaults to match.

### Trader keys

Expand Down
5 changes: 5 additions & 0 deletions docs/concepts/strategies.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,11 @@ class MyStrategy(Strategy):
super().__init__() # <-- the super class must be called to initialize the strategy
```

```{warning}
Do not call components such as `clock` and `logger` in the `__init__` constructor (which is prior to registration).
This is because the systems clock and MPSC channel thread for logging have not yet been setup on initialization.
```

From here, you can implement handlers as necessary to perform actions based on state transitions
and events.

Expand Down
5 changes: 2 additions & 3 deletions docs/getting_started/installation.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,10 @@ Install optional dependencies as 'extras' for specific integrations:
- `betfair`: Betfair adapter
- `docker`: Needed for Docker when using the IB gateway
- `ib`: Interactive Brokers adapter
- `redis`: Use Redis as a cache database

To install with specific extras using _pip_:

pip install -U "nautilus_trader[docker,ib,redis]"
pip install -U "nautilus_trader[docker,ib]"

## From Source
Installation from source requires the `Python.h` header file, which is included in development releases such as `python-dev`.
Expand Down Expand Up @@ -75,4 +74,4 @@ To install a binary wheel from GitHub, first navigate to the [latest release](ht
Download the appropriate `.whl` for your operating system and Python version, then run:

pip install <file-name>.whl

2 changes: 1 addition & 1 deletion examples/backtest/betfair_backtest_orderbook_imbalance.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@
strategies = [
OrderBookImbalance(
config=OrderBookImbalanceConfig(
instrument_id=instrument.id.value,
instrument_id=instrument.id,
max_trade_size=Decimal(10),
order_id_tag=instrument.selection_id,
),
Expand Down
5 changes: 3 additions & 2 deletions examples/backtest/crypto_ema_cross_ethusdt_trade_ticks.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
from nautilus_trader.examples.strategies.ema_cross_twap import EMACrossTWAPConfig
from nautilus_trader.model.currencies import ETH
from nautilus_trader.model.currencies import USDT
from nautilus_trader.model.data import BarType
from nautilus_trader.model.enums import AccountType
from nautilus_trader.model.enums import OmsType
from nautilus_trader.model.identifiers import Venue
Expand Down Expand Up @@ -71,8 +72,8 @@

# Configure your strategy
config = EMACrossTWAPConfig(
instrument_id=str(ETHUSDT_BINANCE.id),
bar_type="ETHUSDT.BINANCE-250-TICK-LAST-INTERNAL",
instrument_id=ETHUSDT_BINANCE.id,
bar_type=BarType.from_str("ETHUSDT.BINANCE-250-TICK-LAST-INTERNAL"),
trade_size=Decimal("0.10"),
fast_ema_period=10,
slow_ema_period=20,
Expand Down
5 changes: 3 additions & 2 deletions examples/backtest/crypto_ema_cross_ethusdt_trailing_stop.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
from nautilus_trader.examples.strategies.ema_cross_trailing_stop import EMACrossTrailingStopConfig
from nautilus_trader.model.currencies import ETH
from nautilus_trader.model.currencies import USDT
from nautilus_trader.model.data import BarType
from nautilus_trader.model.enums import AccountType
from nautilus_trader.model.enums import OmsType
from nautilus_trader.model.identifiers import Venue
Expand Down Expand Up @@ -63,8 +64,8 @@

# Configure your strategy
config = EMACrossTrailingStopConfig(
instrument_id=str(ETHUSDT_BINANCE.id),
bar_type="ETHUSDT.BINANCE-100-TICK-LAST-INTERNAL",
instrument_id=ETHUSDT_BINANCE.id,
bar_type=BarType.from_str("ETHUSDT.BINANCE-100-TICK-LAST-INTERNAL"),
trade_size=Decimal("0.10"),
fast_ema_period=10,
slow_ema_period=20,
Expand Down
5 changes: 3 additions & 2 deletions examples/backtest/crypto_ema_cross_with_binance_provider.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
from nautilus_trader.config import LoggingConfig
from nautilus_trader.examples.strategies.ema_cross_trailing_stop import EMACrossTrailingStop
from nautilus_trader.examples.strategies.ema_cross_trailing_stop import EMACrossTrailingStopConfig
from nautilus_trader.model.data import BarType
from nautilus_trader.model.enums import AccountType
from nautilus_trader.model.enums import OmsType
from nautilus_trader.model.identifiers import InstrumentId
Expand Down Expand Up @@ -97,7 +98,7 @@ async def create_provider():

engine.add_instrument(instrument)

bar_type = f"{instrument_id.value}-1-MINUTE-BID-INTERNAL"
bar_type = BarType.from_str(f"{instrument_id.value}-1-MINUTE-BID-INTERNAL")
wrangler = QuoteTickDataWrangler(instrument=instrument)
ticks = wrangler.process_bar_data(
bid_data=TestDataProvider().read_csv_bars("btc-perp-20211231-20220201_1m.csv"),
Expand All @@ -108,7 +109,7 @@ async def create_provider():

# Configure your strategy
config = EMACrossTrailingStopConfig(
instrument_id=str(instrument.id),
instrument_id=instrument.id,
bar_type=bar_type,
trade_size=Decimal("1"),
fast_ema_period=10,
Expand Down
2 changes: 1 addition & 1 deletion examples/backtest/crypto_orderbook_imbalance.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@

# Configure your strategy
config = OrderBookImbalanceConfig(
instrument_id=str(BTCUSDT_BINANCE.id),
instrument_id=BTCUSDT_BINANCE.id,
max_trade_size=Decimal("1.000"),
min_seconds_between_triggers=1.0,
book_type=book_type_to_str(book_type),
Expand Down
5 changes: 3 additions & 2 deletions examples/backtest/fx_ema_cross_audusd_bars_from_ticks.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
from nautilus_trader.examples.strategies.ema_cross import EMACross
from nautilus_trader.examples.strategies.ema_cross import EMACrossConfig
from nautilus_trader.model.currencies import USD
from nautilus_trader.model.data import BarType
from nautilus_trader.model.enums import AccountType
from nautilus_trader.model.enums import OmsType
from nautilus_trader.model.identifiers import Venue
Expand Down Expand Up @@ -73,8 +74,8 @@

# Configure your strategy
config = EMACrossConfig(
instrument_id=str(AUDUSD_SIM.id),
bar_type="AUD/USD.SIM-1-MINUTE-MID-INTERNAL",
instrument_id=AUDUSD_SIM.id,
bar_type=BarType.from_str("AUD/USD.SIM-1-MINUTE-MID-INTERNAL"),
fast_ema_period=10,
slow_ema_period=20,
trade_size=Decimal(1_000_000),
Expand Down
5 changes: 3 additions & 2 deletions examples/backtest/fx_ema_cross_audusd_ticks.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
from nautilus_trader.examples.strategies.ema_cross import EMACross
from nautilus_trader.examples.strategies.ema_cross import EMACrossConfig
from nautilus_trader.model.currencies import USD
from nautilus_trader.model.data import BarType
from nautilus_trader.model.enums import AccountType
from nautilus_trader.model.enums import OmsType
from nautilus_trader.model.identifiers import Venue
Expand Down Expand Up @@ -84,8 +85,8 @@

# Configure your strategy
config = EMACrossConfig(
instrument_id=str(AUDUSD_SIM.id),
bar_type="AUD/USD.SIM-100-TICK-MID-INTERNAL",
instrument_id=AUDUSD_SIM.id,
bar_type=BarType.from_str("AUD/USD.SIM-100-TICK-MID-INTERNAL"),
trade_size=Decimal(1_000_000),
fast_ema_period=10,
slow_ema_period=20,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,8 +106,8 @@

# Configure your strategy
config = EMACrossBracketConfig(
instrument_id=str(GBPUSD_SIM.id),
bar_type="GBP/USD.SIM-1-MINUTE-BID-EXTERNAL",
instrument_id=GBPUSD_SIM.id,
bar_type=BarType.from_str("GBP/USD.SIM-1-MINUTE-BID-EXTERNAL"),
fast_ema_period=10,
slow_ema_period=20,
bracket_distance_atr=3.0,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
from nautilus_trader.examples.strategies.ema_cross_bracket import EMACrossBracket
from nautilus_trader.examples.strategies.ema_cross_bracket import EMACrossBracketConfig
from nautilus_trader.model.currencies import USD
from nautilus_trader.model.data import BarType
from nautilus_trader.model.enums import AccountType
from nautilus_trader.model.enums import OmsType
from nautilus_trader.model.identifiers import Venue
Expand Down Expand Up @@ -93,8 +94,8 @@

# Configure your strategy
config = EMACrossBracketConfig(
instrument_id=str(GBPUSD_SIM.id),
bar_type="GBP/USD.SIM-5-MINUTE-BID-INTERNAL",
instrument_id=GBPUSD_SIM.id,
bar_type=BarType.from_str("GBP/USD.SIM-5-MINUTE-BID-INTERNAL"),
fast_ema_period=10,
slow_ema_period=20,
bracket_distance_atr=3.0,
Expand Down
Loading

0 comments on commit f1b643d

Please sign in to comment.