Skip to main content

nautilus_model/data/
forward.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//! Forward price data type for derivatives instruments.
17
18use nautilus_core::UnixNanos;
19use rust_decimal::Decimal;
20use serde::{Deserialize, Serialize};
21
22use crate::identifiers::InstrumentId;
23
24/// Represents a forward/underlying price for a derivatives instrument.
25///
26/// This is a general derivatives concept used for ATM determination in option chains
27/// and other forward-price dependent calculations.
28#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
29#[cfg_attr(
30    feature = "python",
31    pyo3::pyclass(module = "nautilus_trader.core.nautilus_pyo3.model", from_py_object)
32)]
33#[cfg_attr(
34    feature = "python",
35    pyo3_stub_gen::derive::gen_stub_pyclass(module = "nautilus_trader.model")
36)]
37pub struct ForwardPrice {
38    /// The instrument ID this forward price applies to.
39    pub instrument_id: InstrumentId,
40    /// The forward/underlying price.
41    pub forward_price: Decimal,
42    /// The underlying index name (e.g. "SYN.BTC-28MAR25"). Exchange-specific metadata.
43    pub underlying_index: Option<String>,
44    /// UNIX timestamp (nanoseconds) when the event occurred.
45    pub ts_event: UnixNanos,
46    /// UNIX timestamp (nanoseconds) when the instance was initialized.
47    pub ts_init: UnixNanos,
48}
49
50impl ForwardPrice {
51    /// Creates a new [`ForwardPrice`] instance.
52    #[must_use]
53    pub fn new(
54        instrument_id: InstrumentId,
55        forward_price: Decimal,
56        underlying_index: Option<String>,
57        ts_event: UnixNanos,
58        ts_init: UnixNanos,
59    ) -> Self {
60        Self {
61            instrument_id,
62            forward_price,
63            underlying_index,
64            ts_event,
65            ts_init,
66        }
67    }
68}