Skip to main content

nautilus_risk/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
16//! Provides a configuration for `RiskEngine` instances.
17
18use ahash::AHashMap;
19use nautilus_common::throttler::RateLimit;
20use nautilus_core::datetime::NANOSECONDS_IN_SECOND;
21use nautilus_model::identifiers::InstrumentId;
22use rust_decimal::Decimal;
23use serde::{Deserialize, Serialize};
24
25/// Configuration for `RiskEngineConfig` instances.
26#[cfg_attr(
27    feature = "python",
28    pyo3::pyclass(module = "nautilus_trader.core.nautilus_pyo3.risk", from_py_object)
29)]
30#[cfg_attr(
31    feature = "python",
32    pyo3_stub_gen::derive::gen_stub_pyclass(module = "nautilus_trader.risk")
33)]
34#[derive(Debug, Clone, Deserialize, Serialize, bon::Builder)]
35#[serde(default, deny_unknown_fields)]
36pub struct RiskEngineConfig {
37    #[builder(default)]
38    pub bypass: bool,
39    #[builder(default = RateLimit::new(100, NANOSECONDS_IN_SECOND))]
40    pub max_order_submit: RateLimit,
41    #[builder(default = RateLimit::new(100, NANOSECONDS_IN_SECOND))]
42    pub max_order_modify: RateLimit,
43    #[builder(default)]
44    pub max_notional_per_order: AHashMap<InstrumentId, Decimal>,
45    #[builder(default)]
46    pub debug: bool,
47}
48
49impl Default for RiskEngineConfig {
50    fn default() -> Self {
51        Self::builder().build()
52    }
53}