nautilus_live/execution/client.rs
1// -------------------------------------------------------------------------------------------------
2// Copyright (C) 2015-2025 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//! Execution client definitions for live trading.
17//!
18//! This trait extends the base `ExecutionClient` trait with async methods
19//! for generating execution reports used in reconciliation.
20
21use std::fmt::Debug;
22
23use async_trait::async_trait;
24use nautilus_common::messages::execution::{
25 GenerateFillReports, GenerateOrderStatusReport, GeneratePositionReports,
26};
27use nautilus_execution::client::ExecutionClient;
28use nautilus_model::reports::{
29 ExecutionMassStatus, FillReport, OrderStatusReport, PositionStatusReport,
30};
31
32/// Live execution client trait with async report generation methods.
33///
34/// Extends `ExecutionClient` with async methods for generating execution reports
35/// used by the `ExecutionManager` for reconciliation.
36#[async_trait(?Send)]
37pub trait LiveExecutionClient: ExecutionClient {
38 /// Generates a single order status report.
39 ///
40 /// # Errors
41 ///
42 /// Returns an error if report generation fails.
43 async fn generate_order_status_report(
44 &self,
45 cmd: &GenerateOrderStatusReport,
46 ) -> anyhow::Result<Option<OrderStatusReport>> {
47 log_not_implemented(cmd);
48 Ok(None)
49 }
50
51 /// Generates multiple order status reports.
52 ///
53 /// # Errors
54 ///
55 /// Returns an error if report generation fails.
56 async fn generate_order_status_reports(
57 &self,
58 cmd: &GenerateOrderStatusReport,
59 ) -> anyhow::Result<Vec<OrderStatusReport>> {
60 log_not_implemented(cmd);
61 Ok(Vec::new())
62 }
63
64 /// Generates fill reports based on execution results.
65 ///
66 /// # Errors
67 ///
68 /// Returns an error if fill report generation fails.
69 async fn generate_fill_reports(
70 &self,
71 cmd: GenerateFillReports,
72 ) -> anyhow::Result<Vec<FillReport>> {
73 log_not_implemented(&cmd);
74 Ok(Vec::new())
75 }
76
77 /// Generates position status reports.
78 ///
79 /// # Errors
80 ///
81 /// Returns an error if generation fails.
82 async fn generate_position_status_reports(
83 &self,
84 cmd: &GeneratePositionReports,
85 ) -> anyhow::Result<Vec<PositionStatusReport>> {
86 log_not_implemented(cmd);
87 Ok(Vec::new())
88 }
89
90 /// Generates mass status for executions.
91 ///
92 /// # Errors
93 ///
94 /// Returns an error if status generation fails.
95 async fn generate_mass_status(
96 &self,
97 lookback_mins: Option<u64>,
98 ) -> anyhow::Result<Option<ExecutionMassStatus>> {
99 log_not_implemented(&lookback_mins);
100 Ok(None)
101 }
102}
103
104#[inline(always)]
105fn log_not_implemented<T: Debug>(cmd: &T) {
106 log::warn!("{cmd:?} – handler not implemented");
107}