nautilus_coinbase_intx/python/
fix.rs
1use 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 pub fn py_endpoint(&self) -> &str {
41 self.endpoint()
42 }
43
44 #[getter]
45 #[pyo3(name = "api_key")]
46 pub fn py_api_key(&self) -> &str {
47 self.api_key()
48 }
49
50 #[getter]
51 #[pyo3(name = "portfolio_id")]
52 pub fn py_portfolio_id(&self) -> &str {
53 self.portfolio_id()
54 }
55
56 #[getter]
57 #[pyo3(name = "sender_comp_id")]
58 pub fn py_sender_comp_id(&self) -> &str {
59 self.sender_comp_id()
60 }
61
62 #[getter]
63 #[pyo3(name = "target_comp_id")]
64 pub fn py_target_comp_id(&self) -> &str {
65 self.target_comp_id()
66 }
67
68 #[pyo3(name = "is_connected")]
69 fn py_is_connected(&self) -> bool {
70 self.is_connected()
71 }
72
73 #[pyo3(name = "is_logged_on")]
74 fn py_is_logged_on(&self) -> bool {
75 self.is_logged_on()
76 }
77
78 #[pyo3(name = "connect")]
79 fn py_connect<'py>(
80 &mut self,
81 py: Python<'py>,
82 handler: PyObject,
83 ) -> PyResult<Bound<'py, PyAny>> {
84 let mut client = self.clone();
85
86 pyo3_async_runtimes::tokio::future_into_py(py, async move {
87 client.connect(handler).await.map_err(to_pyruntime_err)
88 })
89 }
90
91 #[pyo3(name = "close")]
92 fn py_close<'py>(&mut self, py: Python<'py>) -> PyResult<Bound<'py, PyAny>> {
93 let mut client = self.clone();
94
95 pyo3_async_runtimes::tokio::future_into_py(py, async move {
96 client.close().await.map_err(to_pyruntime_err)
97 })
98 }
99}