Skip to main content

nautilus_live/execution/
submission.rs

1// -------------------------------------------------------------------------------------------------
2//  Copyright (C) 2015-2026 Nautech Systems Pty Ltd. All rights reserved.
3//  https://nautechsystems.io
4//
5//  Licensed under the GNU Lesser General Public License Version 3.0 (the "License");
6//  You may not use this file except in compliance with the License.
7//  You may obtain a copy of the License at https://www.gnu.org/licenses/lgpl-3.0.en.html
8//
9//  Unless required by applicable law or agreed to in writing, software
10//  distributed under the License is distributed on an "AS IS" BASIS,
11//  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12//  See the License for the specific language governing permissions and
13//  limitations under the License.
14// -------------------------------------------------------------------------------------------------
15
16//! Native policy and diagnostics for exhausted submission recovery.
17
18use nautilus_core::UnixNanos;
19use nautilus_model::identifiers::{ClientId, ClientOrderId, InstrumentId, StrategyId, TraderId};
20use serde::{Deserialize, Serialize};
21
22/// Policy when recovery queries cannot establish a submission's venue outcome.
23///
24/// This configuration is reserved for submission recovery. The runtime currently
25/// uses local resolution for both variants; retention is not implemented yet.
26#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Serialize, Deserialize)]
27#[serde(rename_all = "snake_case")]
28#[cfg_attr(
29    feature = "python",
30    pyo3::pyclass(
31        frozen,
32        eq,
33        eq_int,
34        module = "nautilus_trader.live",
35        from_py_object,
36        rename_all = "SCREAMING_SNAKE_CASE",
37    )
38)]
39#[cfg_attr(
40    feature = "python",
41    pyo3_stub_gen::derive::gen_stub_pyclass_enum(module = "nautilus_trader.live")
42)]
43pub enum SubmissionRecoveryPolicy {
44    /// Selects local resolution using the existing timeout and missing-order policies.
45    #[default]
46    ResolveLocally,
47    /// Selects retention without further automatic per-order queries (not implemented yet).
48    RetainUnresolved,
49}
50
51/// Recovery path which exhausted its query budget.
52#[derive(Clone, Copy, Debug, PartialEq, Eq)]
53pub enum SubmissionRecoverySource {
54    /// The scheduled inflight checker exhausted its retry limit.
55    Inflight,
56    /// Full-history reconciliation and its targeted query found no definitive outcome.
57    MissingOrder,
58}
59
60/// A submission's recovery budget expired without establishing its venue outcome.
61///
62/// This diagnostic is not an order event and does not change order status.
63/// It defines the payload only; the runtime does not emit it yet.
64#[derive(Clone, Debug, PartialEq, Eq)]
65pub struct SubmissionRecoveryExhausted {
66    /// Trader which submitted the order.
67    pub trader_id: TraderId,
68    /// Execution client responsible for the order, when known.
69    pub client_id: Option<ClientId>,
70    /// Strategy which submitted the order.
71    pub strategy_id: StrategyId,
72    /// Instrument traded by the order.
73    pub instrument_id: InstrumentId,
74    /// Original client order identity.
75    pub client_order_id: ClientOrderId,
76    /// Recovery path which exhausted its budget.
77    pub source: SubmissionRecoverySource,
78    /// Native retry counter at exhaustion, not a count of wire requests.
79    pub retry_count: u32,
80    /// UNIX timestamp in nanoseconds when recovery was exhausted.
81    pub ts_event: UnixNanos,
82}