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