Emulated orders on rc6: first order ignores the cached quote, and RiskEngine checks are skipped
Confirmation
- I've re-read the relevant sections of the documentation.
- I've searched existing issues and discussions to avoid duplicates.
- I've reviewed or skimmed the source code (or examples) to confirm the behavior is not by design.
- I've tested this issue using a recent pre-release or development wheel (
2.0.0rcN,devdevelop, oranightly) and can still reproduce it.
Found a few things with emulated orders on the rc6 nightly (2.0.0rc6.dev20260928). Same small repro shows all of them, so I've put them in one issue. Can split them if that's easier.
The first emulated order on a symbol ignores the quote that's already cached. The strategy subscribes to quotes (bid 2.00 / ask 2.02 comes in), then submits a buy stop at 2.01 with emulation_trigger=BID_ASK. It just sits there EMULATED until the next quote arrives. A second identical order submitted after a tick releases immediately. From what I can tell, the matching core starts empty and isn't seeded from cache.quote(), and the emulator's own quote subscription gets deduped because the strategy already subscribed.
The RiskEngine doesn't check emulated orders. emulated.md says it checks at submit and again at release, but with max_notional_per_order=150 a plain market order for 202 gets denied while the emulated ones release and fill. execution/index.md shows the emulator going straight to the execution engine, so one of the docs is off.
After release, command.order in the exec client is still the original STOP_MARKET (the cache has the MARKET). The live adapter template only accepts MARKET there, so it would reject every released order.
When an order releases inside submit_order (the second order in #1), on_order_released in my Python strategy blows up on the first self.log call with
RuntimeError: Already mutably borrowed. It gets logged and swallowed and the order still fills. Maybe related to #4726.
Steps to reproduce
- LiveNode with a test data client that sends one quote when a quote subscription arrives and nothing after, plus a stub exec client that fills market orders at the cached quote.
- Strategy subscribes to quotes, then submits BUY STOP_MARKET 100 @ 2.01, emulation_trigger=BID_ASK. Stays EMULATED.
- Push another quote. It releases, and command.order is still STOP_MARKET.
- Submit the same order again. It releases inside submit_order and the borrow error is logged.
- Add max_notional_per_order=150 for the instrument. Emulated orders still fill, and a plain market order of the same size is denied.
Can share the repro script if useful.
Specifications
- OS platform: macOS-26.1-arm64
- Python version: 3.14.0
- nautilus_trader version: 2.0.0rc6.dev20260928 (b916d05)
- Installed from: nightly wheel (packages.nautechsystems.io)
- Adapter/venue: none, test clients
Source: nautechsystems/nautilus_trader