nautilus_backtest/python/modules.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//! Python bindings for simulation module types.
17
18use pyo3::prelude::*;
19
20use crate::modules::fx_rollover::{FXRolloverInterestModule, InterestRateRecord};
21
22#[pyo3_stub_gen::derive::gen_stub_pymethods]
23#[pymethods]
24impl InterestRateRecord {
25 /// A single interest rate data entry.
26 #[new]
27 fn py_new(location: String, time: String, value: f64) -> Self {
28 Self {
29 location,
30 time,
31 value,
32 }
33 }
34
35 fn __repr__(&self) -> String {
36 format!("{self:?}")
37 }
38}
39
40#[pyo3_stub_gen::derive::gen_stub_pymethods]
41#[pymethods]
42impl FXRolloverInterestModule {
43 /// Simulates FX rollover (swap) interest applied at 5 PM US/Eastern daily.
44 ///
45 /// When holding FX positions overnight, the interest rate differential
46 /// between the two currencies is credited or debited. Wednesday and Friday
47 /// rollovers are tripled (Wednesday for T+2 settlement, Friday for the weekend).
48 #[new]
49 fn py_new(records: Vec<InterestRateRecord>) -> Self {
50 Self::new(records)
51 }
52
53 fn __repr__(&self) -> String {
54 format!("{self:?}")
55 }
56}