nautilus_bybit/python/
types.rs1use pyo3::prelude::*;
19
20use crate::common::types::{
21 BybitMarginBorrowResult, BybitMarginRepayResult, BybitMarginStatusResult,
22};
23
24#[pymethods]
25impl BybitMarginBorrowResult {
26 #[new]
27 #[must_use]
28 pub fn py_new(
29 coin: String,
30 amount: String,
31 success: bool,
32 message: String,
33 ts_event: u64,
34 ts_init: u64,
35 ) -> Self {
36 Self {
37 coin,
38 amount,
39 success,
40 message,
41 ts_event,
42 ts_init,
43 }
44 }
45
46 #[getter]
47 #[must_use]
48 pub fn coin(&self) -> &str {
49 &self.coin
50 }
51
52 #[getter]
53 #[must_use]
54 pub fn amount(&self) -> &str {
55 &self.amount
56 }
57
58 #[getter]
59 #[must_use]
60 pub fn success(&self) -> bool {
61 self.success
62 }
63
64 #[getter]
65 #[must_use]
66 pub fn message(&self) -> &str {
67 &self.message
68 }
69
70 #[getter]
71 #[must_use]
72 pub fn ts_event(&self) -> u64 {
73 self.ts_event
74 }
75
76 #[getter]
77 #[must_use]
78 pub fn ts_init(&self) -> u64 {
79 self.ts_init
80 }
81
82 fn __repr__(&self) -> String {
83 format!(
84 "BybitMarginBorrowResult(coin='{}', amount='{}', success={}, message='{}')",
85 self.coin, self.amount, self.success, self.message
86 )
87 }
88}
89
90#[pymethods]
91impl BybitMarginRepayResult {
92 #[new]
93 #[pyo3(signature = (coin, amount, success, result_status, message, ts_event, ts_init))]
94 #[must_use]
95 pub fn py_new(
96 coin: String,
97 amount: Option<String>,
98 success: bool,
99 result_status: String,
100 message: String,
101 ts_event: u64,
102 ts_init: u64,
103 ) -> Self {
104 Self {
105 coin,
106 amount,
107 success,
108 result_status,
109 message,
110 ts_event,
111 ts_init,
112 }
113 }
114
115 #[getter]
116 #[must_use]
117 pub fn coin(&self) -> &str {
118 &self.coin
119 }
120
121 #[getter]
122 #[must_use]
123 pub fn amount(&self) -> Option<&str> {
124 self.amount.as_deref()
125 }
126
127 #[getter]
128 #[must_use]
129 pub fn success(&self) -> bool {
130 self.success
131 }
132
133 #[getter]
134 #[must_use]
135 pub fn result_status(&self) -> &str {
136 &self.result_status
137 }
138
139 #[getter]
140 #[must_use]
141 pub fn message(&self) -> &str {
142 &self.message
143 }
144
145 #[getter]
146 #[must_use]
147 pub fn ts_event(&self) -> u64 {
148 self.ts_event
149 }
150
151 #[getter]
152 #[must_use]
153 pub fn ts_init(&self) -> u64 {
154 self.ts_init
155 }
156
157 fn __repr__(&self) -> String {
158 format!(
159 "BybitMarginRepayResult(coin='{}', success={}, result_status='{}')",
160 self.coin, self.success, self.result_status
161 )
162 }
163}
164
165#[pymethods]
166impl BybitMarginStatusResult {
167 #[new]
168 #[must_use]
169 pub fn py_new(coin: String, borrow_amount: String, ts_event: u64, ts_init: u64) -> Self {
170 Self {
171 coin,
172 borrow_amount,
173 ts_event,
174 ts_init,
175 }
176 }
177
178 #[getter]
179 #[must_use]
180 pub fn coin(&self) -> &str {
181 &self.coin
182 }
183
184 #[getter]
185 #[must_use]
186 pub fn borrow_amount(&self) -> &str {
187 &self.borrow_amount
188 }
189
190 #[getter]
191 #[must_use]
192 pub fn ts_event(&self) -> u64 {
193 self.ts_event
194 }
195
196 #[getter]
197 #[must_use]
198 pub fn ts_init(&self) -> u64 {
199 self.ts_init
200 }
201
202 fn __repr__(&self) -> String {
203 format!(
204 "BybitMarginStatusResult(coin='{}', borrow_amount='{}')",
205 self.coin, self.borrow_amount
206 )
207 }
208}