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