nautilus_data/engine/config.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
16use std::{collections::HashMap, time::Duration};
17
18use nautilus_model::{
19 enums::{BarAggregation, BarIntervalType},
20 identifiers::ClientId,
21};
22use serde::{Deserialize, Serialize};
23
24/// Configuration for `DataEngine` instances.
25#[cfg_attr(
26 feature = "python",
27 pyo3::pyclass(module = "nautilus_trader.core.nautilus_pyo3.data", from_py_object)
28)]
29#[cfg_attr(
30 feature = "python",
31 pyo3_stub_gen::derive::gen_stub_pyclass(module = "nautilus_trader.data")
32)]
33#[derive(Clone, Debug, Deserialize, Serialize, bon::Builder)]
34#[serde(default, deny_unknown_fields)]
35pub struct DataEngineConfig {
36 /// If time bar aggregators will build and emit bars with no new market updates.
37 #[builder(default = true)]
38 pub time_bars_build_with_no_updates: bool,
39 /// If time bar aggregators will timestamp `ts_event` on bar close.
40 /// If False, then will timestamp on bar open.
41 #[builder(default = true)]
42 pub time_bars_timestamp_on_close: bool,
43 /// If time bar aggregators will skip emitting a bar if the aggregation starts mid-interval.
44 #[builder(default)]
45 pub time_bars_skip_first_non_full_bar: bool,
46 /// Determines the type of interval used for time aggregation.
47 /// - `LeftOpen`: start time is excluded and end time is included (default).
48 /// - `RightOpen`: start time is included and end time is excluded.
49 #[builder(default = BarIntervalType::LeftOpen)]
50 pub time_bars_interval_type: BarIntervalType,
51 /// The time delay (microseconds) before building and emitting a bar.
52 #[builder(default)]
53 pub time_bars_build_delay: u64,
54 /// A dictionary mapping time bar aggregations to their origin time offsets.
55 #[builder(default)]
56 pub time_bars_origins: HashMap<BarAggregation, Duration>,
57 /// If data objects timestamp sequencing will be validated and handled.
58 #[builder(default)]
59 pub validate_data_sequence: bool,
60 /// If order book deltas should be buffered until the `F_LAST` flag is set for a delta.
61 #[builder(default)]
62 pub buffer_deltas: bool,
63 /// If quotes should be emitted on order book updates.
64 #[builder(default)]
65 pub emit_quotes_from_book: bool,
66 /// If quotes should be emitted on order book depth updates.
67 #[builder(default)]
68 pub emit_quotes_from_book_depths: bool,
69 /// The client IDs declared for external stream processing.
70 /// The data engine will not attempt to send data commands to these client IDs.
71 pub external_clients: Option<Vec<ClientId>>,
72 /// If debug mode is active (will provide extra debug logging).
73 #[builder(default)]
74 pub debug: bool,
75}
76
77impl Default for DataEngineConfig {
78 fn default() -> Self {
79 Self::builder().build()
80 }
81}