Skip to main content

nautilus_model/reports/
mod.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//! Status report types for trading operations.
17//!
18//! This module provides report types for tracking and communicating the status
19//! of various trading operations, including order fills, order status, position
20//! status, and mass status requests.
21
22pub mod fill;
23pub mod mass_status;
24pub mod order;
25pub mod position;
26
27// Re-exports
28pub use fill::FillReport;
29pub use mass_status::ExecutionMassStatus;
30use nautilus_core::UnixNanos;
31pub use order::OrderStatusReport;
32pub use position::PositionStatusReport;
33
34use crate::data::HasTsInit;
35
36impl HasTsInit for FillReport {
37    fn ts_init(&self) -> UnixNanos {
38        self.ts_init
39    }
40}
41
42impl HasTsInit for OrderStatusReport {
43    fn ts_init(&self) -> UnixNanos {
44        self.ts_init
45    }
46}
47
48impl HasTsInit for PositionStatusReport {
49    fn ts_init(&self) -> UnixNanos {
50        self.ts_init
51    }
52}
53
54impl HasTsInit for ExecutionMassStatus {
55    fn ts_init(&self) -> UnixNanos {
56        self.ts_init
57    }
58}
59
60#[cfg(test)]
61mod tests {
62    use rstest::rstest;
63
64    use super::*;
65    use crate::{
66        enums::{LiquiditySide, OrderSide, OrderStatus, OrderType, PositionSide, TimeInForce},
67        identifiers::{AccountId, ClientId, InstrumentId, TradeId, Venue, VenueOrderId},
68        types::{Currency, Money, Price, Quantity},
69    };
70
71    #[rstest]
72    fn test_fill_report_ts_init() {
73        let report = FillReport::new(
74            AccountId::from("SIM-001"),
75            InstrumentId::from("AUDUSD.SIM"),
76            VenueOrderId::from("1"),
77            TradeId::from("1"),
78            OrderSide::Buy,
79            Quantity::from("100"),
80            Price::from("0.80000"),
81            Money::new(5.0, Currency::USD()),
82            LiquiditySide::Taker,
83            None,
84            None,
85            UnixNanos::from(1_000_000_000),
86            UnixNanos::from(2_000_000_000),
87            None,
88        );
89
90        assert_eq!(report.ts_init(), UnixNanos::from(2_000_000_000));
91    }
92
93    #[rstest]
94    fn test_order_status_report_ts_init() {
95        let report = OrderStatusReport::new(
96            AccountId::from("SIM-001"),
97            InstrumentId::from("AUDUSD.SIM"),
98            None,
99            VenueOrderId::from("1"),
100            OrderSide::Buy.into(),
101            OrderType::Limit,
102            TimeInForce::Gtc,
103            OrderStatus::Accepted,
104            Quantity::from("100"),
105            Quantity::from("0"),
106            UnixNanos::from(1_000_000_000),
107            UnixNanos::from(2_000_000_000),
108            UnixNanos::from(3_000_000_000),
109            None,
110        );
111
112        assert_eq!(report.ts_init(), UnixNanos::from(3_000_000_000));
113    }
114
115    #[rstest]
116    fn test_position_status_report_ts_init() {
117        let report = PositionStatusReport::new(
118            AccountId::from("SIM-001"),
119            InstrumentId::from("AUDUSD.SIM"),
120            PositionSide::Long,
121            Quantity::from("100"),
122            UnixNanos::from(1_000_000_000),
123            UnixNanos::from(2_000_000_000),
124            None,
125            None,
126            None,
127        );
128
129        assert_eq!(report.ts_init(), UnixNanos::from(2_000_000_000));
130    }
131
132    #[rstest]
133    fn test_execution_mass_status_ts_init() {
134        let report = ExecutionMassStatus::new(
135            ClientId::from("IB"),
136            AccountId::from("IB-DU123456"),
137            Venue::from("NASDAQ"),
138            UnixNanos::from(4_000_000_000),
139            None,
140        );
141
142        assert_eq!(report.ts_init(), UnixNanos::from(4_000_000_000));
143    }
144}