nautilus_common/
signal.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//! A user signal type.
17
18use std::fmt::Debug;
19
20use nautilus_core::UnixNanos;
21use serde::{Deserialize, Serialize};
22use ustr::Ustr;
23
24/// Represents a generic signal.
25#[repr(C)]
26#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
27#[cfg_attr(
28    feature = "python",
29    pyo3::pyclass(module = "nautilus_trader.core.nautilus_pyo3.common")
30)]
31pub struct Signal {
32    pub name: Ustr,
33    pub value: String,
34    pub ts_event: UnixNanos,
35    pub ts_init: UnixNanos,
36}
37
38impl Signal {
39    /// Creates a new [`Signal`] instance.
40    #[must_use]
41    pub const fn new(name: Ustr, value: String, ts_event: UnixNanos, ts_init: UnixNanos) -> Self {
42        Self {
43            name,
44            value,
45            ts_event,
46            ts_init,
47        }
48    }
49}