nautilus_execution/python/
fee.rs1use nautilus_core::python::to_pyruntime_err;
19use nautilus_model::types::Money;
20use pyo3::prelude::*;
21use rust_decimal::Decimal;
22
23use crate::models::fee::{
24 CappedOptionFeeModel, FixedFeeModel, MakerTakerFeeModel, PerContractFeeModel,
25 TieredNotionalOptionFeeModel,
26};
27
28#[pymethods]
29#[pyo3_stub_gen::derive::gen_stub_pymethods]
30impl FixedFeeModel {
31 #[new]
37 #[pyo3(signature = (commission, change_commission_once=None))]
38 fn py_new(commission: Money, change_commission_once: Option<bool>) -> PyResult<Self> {
39 Self::new(commission, change_commission_once).map_err(to_pyruntime_err)
40 }
41
42 fn __repr__(&self) -> String {
43 format!("{self:?}")
44 }
45}
46
47#[pymethods]
48#[pyo3_stub_gen::derive::gen_stub_pymethods]
49impl MakerTakerFeeModel {
50 #[new]
51 fn py_new() -> Self {
52 Self
53 }
54
55 fn __repr__(&self) -> String {
56 format!("{self:?}")
57 }
58}
59
60#[pymethods]
61#[pyo3_stub_gen::derive::gen_stub_pymethods]
62impl PerContractFeeModel {
63 #[new]
69 fn py_new(commission: Money) -> PyResult<Self> {
70 Self::new(commission).map_err(to_pyruntime_err)
71 }
72
73 fn __repr__(&self) -> String {
74 format!("{self:?}")
75 }
76}
77
78#[pymethods]
79#[pyo3_stub_gen::derive::gen_stub_pymethods]
80impl CappedOptionFeeModel {
81 #[new]
83 #[pyo3(signature = (maker_rate=None, taker_rate=None, cap_rate=None))]
84 fn py_new(
85 maker_rate: Option<Decimal>,
86 taker_rate: Option<Decimal>,
87 cap_rate: Option<Decimal>,
88 ) -> PyResult<Self> {
89 Self::new(maker_rate, taker_rate, cap_rate).map_err(to_pyruntime_err)
90 }
91
92 fn __repr__(&self) -> String {
93 format!("{self:?}")
94 }
95}
96
97#[pymethods]
98#[pyo3_stub_gen::derive::gen_stub_pymethods]
99impl TieredNotionalOptionFeeModel {
100 #[new]
106 #[pyo3(signature = (maker_rate=None, taker_rate=None))]
107 fn py_new(maker_rate: Option<Decimal>, taker_rate: Option<Decimal>) -> PyResult<Self> {
108 Self::new(maker_rate, taker_rate).map_err(to_pyruntime_err)
109 }
110
111 fn __repr__(&self) -> String {
112 format!("{self:?}")
113 }
114}