From b4195def713c5c8d491965a17ffaf90453b6a383 Mon Sep 17 00:00:00 2001 From: Chris Sellers Date: Sun, 12 Mar 2023 08:34:33 +1100 Subject: [PATCH 1/7] Update dependencies --- nautilus_core/Cargo.lock | 44 ++++++++++++++++++++-------------------- poetry.lock | 12 +++++------ 2 files changed, 28 insertions(+), 28 deletions(-) diff --git a/nautilus_core/Cargo.lock b/nautilus_core/Cargo.lock index 7bc6214f7672..4b5ce103100e 100644 --- a/nautilus_core/Cargo.lock +++ b/nautilus_core/Cargo.lock @@ -587,9 +587,9 @@ checksum = "ee1b05cbd864bcaecbd3455d6d967862d446e4ebfc3c2e5e5b9841e53cba6673" [[package]] name = "futures" -version = "0.3.26" +version = "0.3.27" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "13e2792b0ff0340399d58445b88fd9770e3489eff258a4cbc1523418f12abf84" +checksum = "531ac96c6ff5fd7c62263c5e3c67a603af4fcaee2e1a0ae5565ba3a11e69e549" dependencies = [ "futures-channel", "futures-core", @@ -602,9 +602,9 @@ dependencies = [ [[package]] name = "futures-channel" -version = "0.3.26" +version = "0.3.27" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2e5317663a9089767a1ec00a487df42e0ca174b61b4483213ac24448e4664df5" +checksum = "164713a5a0dcc3e7b4b1ed7d3b433cabc18025386f9339346e8daf15963cf7ac" dependencies = [ "futures-core", "futures-sink", @@ -612,15 +612,15 @@ dependencies = [ [[package]] name = "futures-core" -version = "0.3.26" +version = "0.3.27" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ec90ff4d0fe1f57d600049061dc6bb68ed03c7d2fbd697274c41805dcb3f8608" +checksum = "86d7a0c1aa76363dac491de0ee99faf6941128376f1cf96f07db7603b7de69dd" [[package]] name = "futures-executor" -version = "0.3.26" +version = "0.3.27" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e8de0a35a6ab97ec8869e32a2473f4b1324459e14c29275d14b10cb1fd19b50e" +checksum = "1997dd9df74cdac935c76252744c1ed5794fac083242ea4fe77ef3ed60ba0f83" dependencies = [ "futures-core", "futures-task", @@ -629,15 +629,15 @@ dependencies = [ [[package]] name = "futures-io" -version = "0.3.26" +version = "0.3.27" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bfb8371b6fb2aeb2d280374607aeabfc99d95c72edfe51692e42d3d7f0d08531" +checksum = "89d422fa3cbe3b40dca574ab087abb5bc98258ea57eea3fd6f1fa7162c778b91" [[package]] name = "futures-macro" -version = "0.3.26" +version = "0.3.27" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "95a73af87da33b5acf53acfebdc339fe592ecf5357ac7c0a7734ab9d8c876a70" +checksum = "3eb14ed937631bd8b8b8977f2c198443447a8355b6e3ca599f38c975e5a963b6" dependencies = [ "proc-macro2", "quote", @@ -646,15 +646,15 @@ dependencies = [ [[package]] name = "futures-sink" -version = "0.3.26" +version = "0.3.27" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f310820bb3e8cfd46c80db4d7fb8353e15dfff853a127158425f31e0be6c8364" +checksum = "ec93083a4aecafb2a80a885c9de1f0ccae9dbd32c2bb54b0c3a65690e0b8d2f2" [[package]] name = "futures-task" -version = "0.3.26" +version = "0.3.27" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dcf79a1bf610b10f42aea489289c5a2c478a786509693b80cd39c44ccd936366" +checksum = "fd65540d33b37b16542a0438c12e6aeead10d4ac5d05bd3f805b8f35ab592879" [[package]] name = "futures-timer" @@ -664,9 +664,9 @@ checksum = "e64b03909df88034c26dc1547e8970b91f98bdb65165d6a4e9110d94263dbb2c" [[package]] name = "futures-util" -version = "0.3.26" +version = "0.3.27" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9c1d6de3acfef38d2be4b1f543f553131788603495be83da675e180c8d6b7bd1" +checksum = "3ef6b17e481503ec85211fed8f39d1970f128935ca1f814cd32ac4a6842e84ab" dependencies = [ "futures-channel", "futures-core", @@ -1453,18 +1453,18 @@ checksum = "e6b44e8fc93a14e66336d230954dda83d18b4605ccace8fe09bc7514a71ad0bc" [[package]] name = "serde" -version = "1.0.154" +version = "1.0.155" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8cdd151213925e7f1ab45a9bbfb129316bd00799784b174b7cc7bcd16961c49e" +checksum = "71f2b4817415c6d4210bfe1c7bfcf4801b2d904cb4d0e1a8fdb651013c9e86b8" dependencies = [ "serde_derive", ] [[package]] name = "serde_derive" -version = "1.0.154" +version = "1.0.155" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4fc80d722935453bcafdc2c9a73cd6fac4dc1938f0346035d84bf99fa9e33217" +checksum = "d071a94a3fac4aff69d023a7f411e33f40f3483f8c5190b1953822b6b76d7630" dependencies = [ "proc-macro2", "quote", diff --git a/poetry.lock b/poetry.lock index 660e1befd2c3..213c406fb652 100644 --- a/poetry.lock +++ b/poetry.lock @@ -1045,14 +1045,14 @@ nest-asyncio = "*" [[package]] name = "identify" -version = "2.5.19" +version = "2.5.20" description = "File identification library for Python" category = "dev" optional = false python-versions = ">=3.7" files = [ - {file = "identify-2.5.19-py2.py3-none-any.whl", hash = "sha256:3ee3533e7f6f5023157fbebbd5687bb4b698ce6f305259e0d24b2d7d9efb72bc"}, - {file = "identify-2.5.19.tar.gz", hash = "sha256:4102ecd051f6884449e7359e55b38ba6cd7aafb6ef27b8e2b38495a5723ea106"}, + {file = "identify-2.5.20-py2.py3-none-any.whl", hash = "sha256:5dfef8a745ca4f2c95f27e9db74cb4c8b6d9916383988e8791f3595868f78a33"}, + {file = "identify-2.5.20.tar.gz", hash = "sha256:c8b288552bc5f05a08aff09af2f58e6976bf8ac87beb38498a0e3d98ba64eb18"}, ] [package.extras] @@ -2677,14 +2677,14 @@ files = [ [[package]] name = "types-redis" -version = "4.5.1.4" +version = "4.5.1.5" description = "Typing stubs for redis" category = "dev" optional = false python-versions = "*" files = [ - {file = "types-redis-4.5.1.4.tar.gz", hash = "sha256:7660178754d60a4cfacf5b33ee063aa0625311791c62075cd936136627a3f7bf"}, - {file = "types_redis-4.5.1.4-py3-none-any.whl", hash = "sha256:4ad21473605b9e1f96162b1298383dcbc73daa3bec2abe1fd3e81d077753f9ab"}, + {file = "types-redis-4.5.1.5.tar.gz", hash = "sha256:f516254bd593023110a38b77e80d5a76a7f033f1d94c53bee09a7d5d0433f34d"}, + {file = "types_redis-4.5.1.5-py3-none-any.whl", hash = "sha256:43d92b4d6315a45bb0e9a790683ba4448ada88cd1233f3f9886fa6f783f53956"}, ] [package.dependencies] From 3edfb906c9634fa4b1267ba241609d98f8f8546b Mon Sep 17 00:00:00 2001 From: Chris Sellers Date: Sun, 12 Mar 2023 08:34:51 +1100 Subject: [PATCH 2/7] Repair workflows for macos --- .github/workflows/release.yml | 44 +++++++++++++++++------------------ 1 file changed, 22 insertions(+), 22 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index efe79ac2882e..393c45520eb3 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -27,12 +27,21 @@ jobs: uses: actions/checkout@v3 # Rust setup (ensures latest stable) - - name: Set up Rust tool-chain + - name: Set up Rust tool-chain (Liux/Windows) + if: runner.os != 'macOS' uses: actions-rust-lang/setup-rust-toolchain@v1 with: toolchain: stable components: rustfmt, clippy + - name: Set up Rust tool-chain (macOS) + if: runner.os == 'macOS' + uses: actions-rs/toolchain@v1 + with: + toolchain: stable + override: true + components: rustfmt, clippy + # Python setup - name: Set up Python environment uses: actions/setup-python@v4 @@ -78,18 +87,9 @@ jobs: run: python -m pip install --upgrade pip setuptools wheel pre-commit poetry==1.3.2 # Setup Poetry caching - - name: Set output (Linux) - if: runner.os == 'Linux' - run: echo "dir=$(poetry config cache-dir)" >> $GITHUB_ENV - - - name: Set output (macOS) - if: runner.os == 'macOS' + - name: Set output run: echo "dir=$(poetry config cache-dir)" >> $GITHUB_ENV - - name: Set output (Windows) - if: runner.os == 'Windows' - run: echo "dir=$(poetry config cache-dir)" | Out-File -FilePath $env:GITHUB_ENV -Append >> $GITHUB_ENV - - name: Poetry cache id: cached-poetry uses: actions/cache@v3 @@ -159,18 +159,9 @@ jobs: run: python -m pip install --upgrade pip setuptools wheel pre-commit poetry==1.3.2 # Setup Poetry caching - - name: Set output (Linux) - if: runner.os == 'Linux' - run: echo "dir=$(poetry config cache-dir)" >> $GITHUB_ENV - - - name: Set output (macOS) - if: runner.os == 'macOS' + - name: Set output run: echo "dir=$(poetry config cache-dir)" >> $GITHUB_ENV - - name: Set output (Windows) - if: runner.os == 'Windows' - run: echo "dir=$(poetry config cache-dir)" | Out-File -FilePath $env:GITHUB_ENV -Append >> $GITHUB_ENV - - name: Poetry cache id: cached-poetry uses: actions/cache@v3 @@ -231,12 +222,21 @@ jobs: uses: actions/checkout@v3 # Rust setup (ensures latest stable) - - name: Set up Rust tool-chain + - name: Set up Rust tool-chain (Liux/Windows) + if: runner.os != 'macOS' uses: actions-rust-lang/setup-rust-toolchain@v1 with: toolchain: stable components: rustfmt, clippy + - name: Set up Rust tool-chain (macOS) + if: runner.os == 'macOS' + uses: actions-rs/toolchain@v1 + with: + toolchain: stable + override: true + components: rustfmt, clippy + # Python setup - name: Set up Python environment uses: actions/setup-python@v4 From 1060b745f492d61267d49a7f2c6ba298006f9388 Mon Sep 17 00:00:00 2001 From: Chris Sellers Date: Sun, 12 Mar 2023 09:00:04 +1100 Subject: [PATCH 3/7] Fix import order in examples --- examples/notebooks/backtest_fx_usdjpy.ipynb | 4 ++-- examples/notebooks/external_data_backtest.ipynb | 4 ++-- examples/notebooks/quick_start.ipynb | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/examples/notebooks/backtest_fx_usdjpy.ipynb b/examples/notebooks/backtest_fx_usdjpy.ipynb index 9e34920784f6..fa48fcc011df 100644 --- a/examples/notebooks/backtest_fx_usdjpy.ipynb +++ b/examples/notebooks/backtest_fx_usdjpy.ipynb @@ -19,7 +19,6 @@ "from nautilus_trader.backtest.models import FillModel\n", "from nautilus_trader.backtest.modules import FXRolloverInterestConfig\n", "from nautilus_trader.backtest.modules import FXRolloverInterestModule\n", - "from nautilus_trader.test_kit.providers import TestInstrumentProvider\n", "from nautilus_trader.config.common import RiskEngineConfig\n", "from nautilus_trader.examples.strategies.ema_cross import EMACross\n", "from nautilus_trader.examples.strategies.ema_cross import EMACrossConfig\n", @@ -29,7 +28,8 @@ "from nautilus_trader.model.identifiers import Venue\n", "from nautilus_trader.model.objects import Money\n", "from nautilus_trader.persistence.wranglers import QuoteTickDataWrangler\n", - "from nautilus_trader.test_kit.providers import TestDataProvider" + "from nautilus_trader.test_kit.providers import TestDataProvider\n", + "from nautilus_trader.test_kit.providers import TestInstrumentProvider\n" ] }, { diff --git a/examples/notebooks/external_data_backtest.ipynb b/examples/notebooks/external_data_backtest.ipynb index fd96db0cdd7a..1e08467d96bc 100644 --- a/examples/notebooks/external_data_backtest.ipynb +++ b/examples/notebooks/external_data_backtest.ipynb @@ -18,12 +18,12 @@ "from nautilus_trader.model.data.tick import QuoteTick\n", "from nautilus_trader.model.objects import Price, Quantity\n", "\n", - "from nautilus_trader.test_kit.providers import TestInstrumentProvider\n", "from nautilus_trader.backtest.node import BacktestNode, BacktestVenueConfig, BacktestDataConfig, BacktestRunConfig, BacktestEngineConfig\n", "from nautilus_trader.config.common import ImportableStrategyConfig\n", "from nautilus_trader.persistence.catalog import ParquetDataCatalog\n", "from nautilus_trader.persistence.external.core import process_files, write_objects\n", - "from nautilus_trader.persistence.external.readers import TextReader" + "from nautilus_trader.persistence.external.readers import TextReader\n", + "from nautilus_trader.test_kit.providers import TestInstrumentProvider\n" ] }, { diff --git a/examples/notebooks/quick_start.ipynb b/examples/notebooks/quick_start.ipynb index 6b29f9a8706b..06d0cfa6644b 100644 --- a/examples/notebooks/quick_start.ipynb +++ b/examples/notebooks/quick_start.ipynb @@ -32,12 +32,12 @@ "from nautilus_trader.model.data.tick import QuoteTick\n", "from nautilus_trader.model.objects import Price, Quantity\n", "\n", - "from nautilus_trader.test_kit.providers import TestInstrumentProvider\n", "from nautilus_trader.backtest.node import BacktestNode, BacktestVenueConfig, BacktestDataConfig, BacktestRunConfig, BacktestEngineConfig\n", "from nautilus_trader.config.common import ImportableStrategyConfig\n", "from nautilus_trader.persistence.catalog import ParquetDataCatalog\n", "from nautilus_trader.persistence.external.core import process_files, write_objects\n", - "from nautilus_trader.persistence.external.readers import TextReader" + "from nautilus_trader.persistence.external.readers import TextReader\n", + "from nautilus_trader.test_kit.providers import TestInstrumentProvider\n" ] }, { From 4ec2d0649537f8e40a45af30a64d9b8af5ce7bfa Mon Sep 17 00:00:00 2001 From: Chris Sellers Date: Sun, 12 Mar 2023 09:02:11 +1100 Subject: [PATCH 4/7] Fix import order in examples --- examples/notebooks/backtest_fx_usdjpy.ipynb | 2 +- examples/notebooks/external_data_backtest.ipynb | 2 +- examples/notebooks/quick_start.ipynb | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/examples/notebooks/backtest_fx_usdjpy.ipynb b/examples/notebooks/backtest_fx_usdjpy.ipynb index fa48fcc011df..e79da6857cd3 100644 --- a/examples/notebooks/backtest_fx_usdjpy.ipynb +++ b/examples/notebooks/backtest_fx_usdjpy.ipynb @@ -29,7 +29,7 @@ "from nautilus_trader.model.objects import Money\n", "from nautilus_trader.persistence.wranglers import QuoteTickDataWrangler\n", "from nautilus_trader.test_kit.providers import TestDataProvider\n", - "from nautilus_trader.test_kit.providers import TestInstrumentProvider\n" + "from nautilus_trader.test_kit.providers import TestInstrumentProvider" ] }, { diff --git a/examples/notebooks/external_data_backtest.ipynb b/examples/notebooks/external_data_backtest.ipynb index 1e08467d96bc..4801cf7e5e71 100644 --- a/examples/notebooks/external_data_backtest.ipynb +++ b/examples/notebooks/external_data_backtest.ipynb @@ -23,7 +23,7 @@ "from nautilus_trader.persistence.catalog import ParquetDataCatalog\n", "from nautilus_trader.persistence.external.core import process_files, write_objects\n", "from nautilus_trader.persistence.external.readers import TextReader\n", - "from nautilus_trader.test_kit.providers import TestInstrumentProvider\n" + "from nautilus_trader.test_kit.providers import TestInstrumentProvider" ] }, { diff --git a/examples/notebooks/quick_start.ipynb b/examples/notebooks/quick_start.ipynb index 06d0cfa6644b..efc6804bc4e6 100644 --- a/examples/notebooks/quick_start.ipynb +++ b/examples/notebooks/quick_start.ipynb @@ -37,7 +37,7 @@ "from nautilus_trader.persistence.catalog import ParquetDataCatalog\n", "from nautilus_trader.persistence.external.core import process_files, write_objects\n", "from nautilus_trader.persistence.external.readers import TextReader\n", - "from nautilus_trader.test_kit.providers import TestInstrumentProvider\n" + "from nautilus_trader.test_kit.providers import TestInstrumentProvider" ] }, { From 67faa814ae55a30cdd3e947baba1625eb0ac23b7 Mon Sep 17 00:00:00 2001 From: Chris Sellers Date: Sun, 12 Mar 2023 09:45:04 +1100 Subject: [PATCH 5/7] Use simpler pd.Timestamp.value --- nautilus_trader/adapters/betfair/parsing/requests.py | 2 +- nautilus_trader/adapters/betfair/parsing/streaming.py | 2 +- nautilus_trader/backtest/engine.pyx | 4 ++-- nautilus_trader/trading/filters.pyx | 4 ++-- tests/unit_tests/persistence/external/test_core.py | 5 +---- tests/unit_tests/persistence/external/test_parsers.py | 6 ++---- 6 files changed, 9 insertions(+), 14 deletions(-) diff --git a/nautilus_trader/adapters/betfair/parsing/requests.py b/nautilus_trader/adapters/betfair/parsing/requests.py index 1a706ce6c562..bc1e94c0f590 100644 --- a/nautilus_trader/adapters/betfair/parsing/requests.py +++ b/nautilus_trader/adapters/betfair/parsing/requests.py @@ -240,7 +240,7 @@ async def generate_trades_list( self._log.warn(f"Found no existing order for {venue_order_id}") return [] fill = filled["clearedOrders"][0] - ts_event = int(pd.Timestamp(fill["lastMatchedDate"]).to_datetime64()) + ts_event = pd.Timestamp(fill["lastMatchedDate"]).value return [ TradeReport( client_order_id=self.venue_order_id_to_client_order_id[venue_order_id], diff --git a/nautilus_trader/adapters/betfair/parsing/streaming.py b/nautilus_trader/adapters/betfair/parsing/streaming.py index 6cbb7fd64976..ce473e8b91fb 100644 --- a/nautilus_trader/adapters/betfair/parsing/streaming.py +++ b/nautilus_trader/adapters/betfair/parsing/streaming.py @@ -737,7 +737,7 @@ async def generate_trades_list( self._log.warn(f"Found no existing order for {venue_order_id}") return [] fill = filled[0] - ts_event = int(pd.Timestamp(fill.lastMatchedDate).to_datetime64()) + ts_event = pd.Timestamp(fill.lastMatchedDate).value return [ TradeReport( account_id=AccountId("BETFAIR"), diff --git a/nautilus_trader/backtest/engine.pyx b/nautilus_trader/backtest/engine.pyx index 17007eae6f39..826749024f9a 100644 --- a/nautilus_trader/backtest/engine.pyx +++ b/nautilus_trader/backtest/engine.pyx @@ -887,14 +887,14 @@ cdef class BacktestEngine: start = unix_nanos_to_dt(start_ns) else: start = pd.to_datetime(start, utc=True) - start_ns = int(start.to_datetime64()) + start_ns = start.value if end is None: # Set `end` to end of data end_ns = self._data[-1].ts_init end = unix_nanos_to_dt(end_ns) else: end = pd.to_datetime(end, utc=True) - end_ns = int(end.to_datetime64()) + end_ns = end.value Condition.true(start_ns < end_ns, "start was >= end") Condition.not_empty(self._data, "data") diff --git a/nautilus_trader/trading/filters.pyx b/nautilus_trader/trading/filters.pyx index 281b72151a6f..e9399d6326a2 100644 --- a/nautilus_trader/trading/filters.pyx +++ b/nautilus_trader/trading/filters.pyx @@ -479,7 +479,7 @@ cdef class EconomicNewsEventFilter: cdef int index = 0 row = events.iloc[index] - cdef uint64_t ts_event = int(pd.Timestamp(events.index[index]).to_datetime64()) + cdef uint64_t ts_event = pd.Timestamp(events.index[index]).value return NewsEvent( NewsImpact[row["Impact"]], row["Name"], @@ -528,7 +528,7 @@ cdef class EconomicNewsEventFilter: cdef int index = -1 row = events.iloc[index] - cdef uint64_t ts_event = int(pd.Timestamp(events.index[index]).to_datetime64()) + cdef uint64_t ts_event = pd.Timestamp(events.index[index]).value return NewsEvent( NewsImpact[row["Impact"]], row["Name"], diff --git a/tests/unit_tests/persistence/external/test_core.py b/tests/unit_tests/persistence/external/test_core.py index fadcae7f594b..40aa616a05b5 100644 --- a/tests/unit_tests/persistence/external/test_core.py +++ b/tests/unit_tests/persistence/external/test_core.py @@ -291,10 +291,7 @@ def test_repartition_dataset(self): { "value": np.arange(5), "instrument_id": ["a", "a", "a", "b", "b"], - "ts_init": [ - int(ts.to_datetime64()) - for ts in pd.date_range(start_date, periods=5, tz="UTC") - ], + "ts_init": [ts.value for ts in pd.date_range(start_date, periods=5, tz="UTC")], }, ) write_parquet( diff --git a/tests/unit_tests/persistence/external/test_parsers.py b/tests/unit_tests/persistence/external/test_parsers.py index b14fd9ee70b8..b08b9518796f 100644 --- a/tests/unit_tests/persistence/external/test_parsers.py +++ b/tests/unit_tests/persistence/external/test_parsers.py @@ -52,9 +52,7 @@ def test_line_preprocessor_preprocess(self): def test_line_preprocessor_post_process(self): obj = TestDataStubs.trade_tick_5decimal() - data = { - "ts_init": int(pd.Timestamp("2021-06-29T06:04:11.943000", tz="UTC").to_datetime64()), - } + data = {"ts_init": pd.Timestamp("2021-06-29T06:04:11.943000", tz="UTC").value} obj = self.line_preprocessor.post_process(obj=obj, state=data) assert obj.ts_init == 1624946651943000000 @@ -62,7 +60,7 @@ def test_byte_reader_parser(self): def block_parser(block: bytes): for raw in block.split(b"\\n"): ts, line = raw.split(b" - ") - state = {"ts_init": int(pd.Timestamp(ts.decode(), tz="UTC").to_datetime64())} + state = {"ts_init": pd.Timestamp(ts.decode(), tz="UTC").value} line = line.strip().replace(b"b'", b"") msgspec.json.decode(line) for obj in BetfairTestStubs.parse_betfair( From 298a921920bb92b629baafe06999cd480c2796b4 Mon Sep 17 00:00:00 2001 From: Chris Sellers Date: Sun, 12 Mar 2023 09:47:11 +1100 Subject: [PATCH 6/7] Fix kernel logger clock setup --- nautilus_trader/system/kernel.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/nautilus_trader/system/kernel.py b/nautilus_trader/system/kernel.py index 53fad026a1be..069407647825 100644 --- a/nautilus_trader/system/kernel.py +++ b/nautilus_trader/system/kernel.py @@ -219,8 +219,10 @@ def __init__( # noqa (too complex) f"environment {environment} not recognized", # pragma: no cover (design-time error) ) + # Setup the logger with a `LiveClock` initially, + # which is later swapped out for a `TestClock` in the `BacktestEngine`. self._logger = Logger( - clock=self._clock, + clock=self._clock if isinstance(self._clock, LiveClock) else LiveClock(), trader_id=self._trader_id, machine_id=self._machine_id, instance_id=self._instance_id, From d47a776b3a663c5091daeaa6776a7d4faa14f9b9 Mon Sep 17 00:00:00 2001 From: Chris Sellers Date: Sun, 12 Mar 2023 10:12:44 +1100 Subject: [PATCH 7/7] Allow reject after a pending state --- nautilus_trader/model/orders/base.pyx | 2 ++ 1 file changed, 2 insertions(+) diff --git a/nautilus_trader/model/orders/base.pyx b/nautilus_trader/model/orders/base.pyx index bf2b41f3ea9f..0514f1aa11fb 100644 --- a/nautilus_trader/model/orders/base.pyx +++ b/nautilus_trader/model/orders/base.pyx @@ -90,6 +90,7 @@ cdef dict _ORDER_STATE_TABLE = { (OrderStatus.ACCEPTED, OrderStatus.FILLED): OrderStatus.FILLED, (OrderStatus.CANCELED, OrderStatus.PARTIALLY_FILLED): OrderStatus.PARTIALLY_FILLED, # Real world possibility (OrderStatus.CANCELED, OrderStatus.FILLED): OrderStatus.FILLED, # Real world possibility + (OrderStatus.PENDING_UPDATE, OrderStatus.REJECTED): OrderStatus.REJECTED, # Real world possibility (OrderStatus.PENDING_UPDATE, OrderStatus.ACCEPTED): OrderStatus.ACCEPTED, (OrderStatus.PENDING_UPDATE, OrderStatus.CANCELED): OrderStatus.CANCELED, (OrderStatus.PENDING_UPDATE, OrderStatus.EXPIRED): OrderStatus.EXPIRED, @@ -98,6 +99,7 @@ cdef dict _ORDER_STATE_TABLE = { (OrderStatus.PENDING_UPDATE, OrderStatus.PENDING_CANCEL): OrderStatus.PENDING_CANCEL, (OrderStatus.PENDING_UPDATE, OrderStatus.PARTIALLY_FILLED): OrderStatus.PARTIALLY_FILLED, (OrderStatus.PENDING_UPDATE, OrderStatus.FILLED): OrderStatus.FILLED, + (OrderStatus.PENDING_CANCEL, OrderStatus.REJECTED): OrderStatus.REJECTED, # Real world possibility (OrderStatus.PENDING_CANCEL, OrderStatus.PENDING_CANCEL): OrderStatus.PENDING_CANCEL, # Allow multiple requests (OrderStatus.PENDING_CANCEL, OrderStatus.CANCELED): OrderStatus.CANCELED, (OrderStatus.PENDING_CANCEL, OrderStatus.ACCEPTED): OrderStatus.ACCEPTED, # Allows failed cancel requests