nautilus_bybit/common/types.rs
1// -------------------------------------------------------------------------------------------------
2// Copyright (C) 2015-2026 Nautech Systems Pty Ltd. All rights reserved.
3// https://nautechsystems.io
4//
5// Licensed under the GNU Lesser General Public License Version 3.0 (the "License");
6// You may not use this file except in compliance with the License.
7// You may obtain a copy of the License at https://www.gnu.org/licenses/lgpl-3.0.en.html
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14// -------------------------------------------------------------------------------------------------
15
16//! Result types for Bybit margin operations.
17//!
18//! These types are used for strategy-level communication of margin operation results.
19
20/// Result from a Bybit borrow operation for strategy consumption.
21#[derive(Clone, Debug)]
22#[cfg_attr(
23 feature = "python",
24 pyo3::pyclass(module = "nautilus_trader.core.nautilus_pyo3.bybit", from_py_object)
25)]
26#[cfg_attr(
27 feature = "python",
28 pyo3_stub_gen::derive::gen_stub_pyclass(module = "nautilus_trader.bybit")
29)]
30pub struct BybitMarginBorrowResult {
31 /// The coin that was borrowed.
32 pub coin: String,
33 /// The amount that was borrowed.
34 pub amount: String,
35 /// Whether the borrow operation was successful.
36 pub success: bool,
37 /// Error message if the operation failed.
38 pub message: String,
39 /// UNIX timestamp (nanoseconds) when the event occurred.
40 pub ts_event: u64,
41 /// UNIX timestamp (nanoseconds) when the object was initialized.
42 pub ts_init: u64,
43}
44
45/// Result from a Bybit repay operation for strategy consumption.
46#[derive(Clone, Debug)]
47#[cfg_attr(
48 feature = "python",
49 pyo3::pyclass(module = "nautilus_trader.core.nautilus_pyo3.bybit", from_py_object)
50)]
51#[cfg_attr(
52 feature = "python",
53 pyo3_stub_gen::derive::gen_stub_pyclass(module = "nautilus_trader.bybit")
54)]
55pub struct BybitMarginRepayResult {
56 /// The coin that was repaid.
57 pub coin: String,
58 /// The amount that was repaid (None if repaying all).
59 pub amount: Option<String>,
60 /// Whether the repay operation was successful.
61 pub success: bool,
62 /// The result status from Bybit API.
63 pub result_status: String,
64 /// Error message if the operation failed.
65 pub message: String,
66 /// UNIX timestamp (nanoseconds) when the event occurred.
67 pub ts_event: u64,
68 /// UNIX timestamp (nanoseconds) when the object was initialized.
69 pub ts_init: u64,
70}
71
72/// Result with current borrowed amount on Bybit.
73#[derive(Clone, Debug)]
74#[cfg_attr(
75 feature = "python",
76 pyo3::pyclass(module = "nautilus_trader.core.nautilus_pyo3.bybit", from_py_object)
77)]
78#[cfg_attr(
79 feature = "python",
80 pyo3_stub_gen::derive::gen_stub_pyclass(module = "nautilus_trader.bybit")
81)]
82pub struct BybitMarginStatusResult {
83 /// The coin being queried.
84 pub coin: String,
85 /// The current borrowed amount.
86 pub borrow_amount: String,
87 /// UNIX timestamp (nanoseconds) when the event occurred.
88 pub ts_event: u64,
89 /// UNIX timestamp (nanoseconds) when the object was initialized.
90 pub ts_init: u64,
91}