nautilus_coinbase_intx/python/
fix.rs1use nautilus_core::python::{to_pyruntime_err, to_pyvalue_err};
19use pyo3::prelude::*;
20
21use crate::fix::client::CoinbaseIntxFixClient;
22
23#[pymethods]
24impl CoinbaseIntxFixClient {
25 #[new]
26 #[pyo3(signature = (endpoint=None, api_key=None, api_secret=None, api_passphrase=None, portfolio_id=None))]
27 fn py_new(
28 endpoint: Option<String>,
29 api_key: Option<String>,
30 api_secret: Option<String>,
31 api_passphrase: Option<String>,
32 portfolio_id: Option<String>,
33 ) -> PyResult<Self> {
34 Self::new(endpoint, api_key, api_secret, api_passphrase, portfolio_id)
35 .map_err(to_pyvalue_err)
36 }
37
38 #[getter]
39 #[pyo3(name = "endpoint")]
40 #[must_use]
41 pub const fn py_endpoint(&self) -> &str {
42 self.endpoint()
43 }
44
45 #[getter]
46 #[pyo3(name = "api_key")]
47 #[must_use]
48 pub const fn py_api_key(&self) -> &str {
49 self.api_key()
50 }
51
52 #[getter]
53 #[pyo3(name = "api_key_masked")]
54 #[must_use]
55 pub fn py_api_key_masked(&self) -> String {
56 self.api_key_masked()
57 }
58
59 #[getter]
60 #[pyo3(name = "portfolio_id")]
61 #[must_use]
62 pub const fn py_portfolio_id(&self) -> &str {
63 self.portfolio_id()
64 }
65
66 #[getter]
67 #[pyo3(name = "sender_comp_id")]
68 #[must_use]
69 pub const fn py_sender_comp_id(&self) -> &str {
70 self.sender_comp_id()
71 }
72
73 #[getter]
74 #[pyo3(name = "target_comp_id")]
75 #[must_use]
76 pub const fn py_target_comp_id(&self) -> &str {
77 self.target_comp_id()
78 }
79
80 #[pyo3(name = "is_connected")]
81 fn py_is_connected(&self) -> bool {
82 self.is_connected()
83 }
84
85 #[pyo3(name = "is_logged_on")]
86 fn py_is_logged_on(&self) -> bool {
87 self.is_logged_on()
88 }
89
90 #[pyo3(name = "connect")]
91 fn py_connect<'py>(
92 &mut self,
93 py: Python<'py>,
94 handler: Py<PyAny>,
95 ) -> PyResult<Bound<'py, PyAny>> {
96 let mut client = self.clone();
97
98 pyo3_async_runtimes::tokio::future_into_py(py, async move {
99 client.connect(handler).await.map_err(to_pyruntime_err)
100 })
101 }
102
103 #[pyo3(name = "close")]
104 fn py_close<'py>(&mut self, py: Python<'py>) -> PyResult<Bound<'py, PyAny>> {
105 let mut client = self.clone();
106
107 pyo3_async_runtimes::tokio::future_into_py(py, async move {
108 client.close().await.map_err(to_pyruntime_err)
109 })
110 }
111}