bybit_async/models/
order.rs1use crate::parser::{string_or_decimal, string_or_decimal_opt};
2use rust_decimal::Decimal;
3use serde::{Deserialize, Serialize};
4
5pub type NewOrderResponse = NewOrder;
9
10#[derive(Debug, Serialize, Deserialize, Clone)]
11#[serde(rename_all = "camelCase")]
12pub struct NewOrder {
13 pub client_order_id: String,
14 #[serde(with = "string_or_decimal")]
15 pub cum_qty: Decimal,
16 #[serde(with = "string_or_decimal")]
17 pub cum_quote: Decimal,
18 #[serde(with = "string_or_decimal")]
19 pub executed_qty: Decimal,
20 pub order_id: u64,
21 #[serde(with = "string_or_decimal")]
22 pub avg_price: Decimal,
23 #[serde(with = "string_or_decimal")]
24 pub orig_qty: Decimal,
25 pub reduce_only: bool,
26 pub side: String,
27 pub position_side: String,
28 pub status: String,
29 #[serde(with = "string_or_decimal")]
30 pub stop_price: Decimal,
31 pub close_position: bool,
32 pub symbol: String,
33 pub time_in_force: String,
34 #[serde(rename = "type")]
35 pub type_name: String,
36 pub orig_type: String,
37 #[serde(default, with = "string_or_decimal_opt")]
38 pub activate_price: Option<Decimal>,
39 #[serde(default, with = "string_or_decimal_opt")]
40 pub price_rate: Option<Decimal>,
41 pub update_time: u64,
42 pub working_type: String,
43 price_protect: bool,
44}
45
46#[derive(Debug, Serialize, Deserialize, Clone)]
47#[serde(rename_all = "camelCase")]
48pub struct OrderInfo {
49 pub symbol: String,
50 pub order_id: u64,
51 pub order_list_id: Option<i64>,
52 pub client_order_id: String,
53 pub transact_time: u64,
54 #[serde(with = "rust_decimal::serde::str")]
55 pub price: Decimal,
56 #[serde(with = "rust_decimal::serde::str")]
57 pub orig_qty: Decimal,
58 #[serde(with = "rust_decimal::serde::str")]
59 pub executed_qty: Decimal,
60 #[serde(with = "rust_decimal::serde::str")]
61 pub cummulative_quote_qty: Decimal,
62 #[serde(with = "rust_decimal::serde::str", default = "default_stop_price")]
63 pub stop_price: Decimal,
64 pub status: String,
65 pub time_in_force: String,
66 #[serde(rename = "type")]
67 pub type_name: String,
68 pub side: String,
69 pub fills: Option<Vec<FillInfo>>,
70}
71
72fn default_stop_price() -> Decimal {
73 Decimal::ZERO
74}
75
76#[derive(Debug, Serialize, Deserialize, Clone)]
77#[serde(rename_all = "camelCase")]
78pub struct FillInfo {
79 #[serde(with = "rust_decimal::serde::str")]
80 pub price: Decimal,
81 #[serde(with = "rust_decimal::serde::str")]
82 pub qty: Decimal,
83 #[serde(with = "rust_decimal::serde::str")]
84 pub commission: Decimal,
85 pub commission_asset: String,
86 pub trade_id: Option<u64>,
87}
88
89pub type CancelOrderResponse = CanceledOrder;
90
91#[derive(Debug, Serialize, Deserialize, Clone)]
92#[serde(rename_all = "camelCase")]
93pub struct CanceledOrder {
94 pub client_order_id: String,
95 #[serde(with = "string_or_decimal")]
96 pub cum_qty: Decimal,
97 #[serde(with = "string_or_decimal")]
98 pub cum_quote: Decimal,
99 #[serde(with = "string_or_decimal")]
100 pub executed_qty: Decimal,
101 pub order_id: u64,
102 #[serde(with = "string_or_decimal")]
103 pub orig_qty: Decimal,
104 pub orig_type: String,
105 #[serde(with = "string_or_decimal")]
106 pub price: Decimal,
107 pub reduce_only: bool,
108 pub side: String,
109 pub position_side: String,
110 pub status: String,
111 #[serde(with = "string_or_decimal")]
112 pub stop_price: Decimal,
113 pub close_position: bool,
114 pub symbol: String,
115 pub time_in_force: String,
116 #[serde(rename = "type")]
117 pub type_name: String,
118 #[serde(default, with = "string_or_decimal_opt")]
119 pub activate_price: Option<Decimal>,
120 #[serde(default, with = "string_or_decimal_opt")]
121 pub price_rate: Option<Decimal>,
122 pub update_time: u64,
123 pub working_type: String,
124 price_protect: bool,
125}