-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Description
Bug Report
Confirmation
Before opening a bug report, please confirm:
- 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 development wheel (
devdevelop oranightly) and can still reproduce it.
Checking a recent development wheel can save time because the issue may already have been fixed.
You can install a development wheel by running:
pip install -U nautilus_trader --pre --index-url https://packages.nautechsystems.io/simpleSee the [development-wheels](https://github.com/nautechsystems/nautilus_trader#development-wheels) section for more details.
Expected Behavior
The risk engine should be able to check order risk for TRAILING_STOP_MARKET orders when trigger_price is None but trailing_offset and trailing_offset_type are properly configured.
Since trailing stop orders dynamically calculate the trigger price based on the market price and trailing offset, the risk engine should:
- Recognize that
trailing_offsetandtrailing_offset_typeare set - Calculate an estimated trigger price based on the current market price and trailing offset
- Use this calculated price to perform standard risk checks
This would allow proper risk validation for trailing stop orders without requiring an explicit trigger price at order creation time.
Actual Behavior
The risk engine cannot perform risk checks on TRAILING_STOP_MARKET orders when trigger_price is None, even when both trailing_offset and trailing_offset_type are properly set. The risk engine logs the following warning:
WARNING: Backtest-MyBacktest.RiskEngine: Cannot check TRAILING_STOP_MARKET order risk: no trigger price was set
This prevents the risk engine from validating the order, even though the trailing offset parameters provide sufficient information to estimate risk bounds.
Steps to Reproduce the Problem
- Create a trailing stop market order with
trigger_price=Nonebut with validtrailing_offsetandtrailing_offset_typeparameters - Submit the order through the order factory
- Observe the warning message from the risk engine indicating it cannot check order risk
Code Snippets or Logs
trailing_order = self.order_factory.trailing_stop_market(
instrument_id=instrument_id,
order_side=order_side,
quantity=Quantity.from_int(abs(int(quantity))),
trigger_type=TriggerType.LAST_PRICE,
trigger_price=None,
trailing_offset=Decimal(trailing_stop_max_bps * 10000),
trailing_offset_type=TrailingOffsetType.BASIS_POINTS,
)
self.submit_order(trailing_order)Log output:
WARNING: Backtest-MyBacktest.RiskEngine: Cannot check TRAILING_STOP_MARKET order risk: no trigger price was set
Specifications
- OS platform: Windows 11 Home Version 10.0.26200 Build 26200
- Python version: 3.12.1
nautilus_traderversion: 1.222.0a20251104
Metadata
Metadata
Assignees
Labels
Type
Projects
Status