longport/trade/requests/
replace_order.rs1use rust_decimal::Decimal;
2use serde::Serialize;
3
4#[derive(Debug, Serialize, Clone)]
6pub struct ReplaceOrderOptions {
7 order_id: String,
8 quantity: Decimal,
9 #[serde(skip_serializing_if = "Option::is_none")]
10 price: Option<Decimal>,
11 #[serde(skip_serializing_if = "Option::is_none")]
12 trigger_price: Option<Decimal>,
13 #[serde(skip_serializing_if = "Option::is_none")]
14 limit_offset: Option<Decimal>,
15 #[serde(skip_serializing_if = "Option::is_none")]
16 trailing_amount: Option<Decimal>,
17 #[serde(skip_serializing_if = "Option::is_none")]
18 trailing_percent: Option<Decimal>,
19 #[serde(skip_serializing_if = "Option::is_none")]
20 limit_depth_level: Option<i32>,
21 #[serde(skip_serializing_if = "Option::is_none")]
22 trigger_count: Option<i32>,
23 #[serde(skip_serializing_if = "Option::is_none")]
24 monitor_price: Option<Decimal>,
25 #[serde(skip_serializing_if = "Option::is_none")]
26 remark: Option<String>,
27}
28
29impl ReplaceOrderOptions {
30 #[inline]
32 pub fn new(order_id: impl Into<String>, quantity: Decimal) -> Self {
33 Self {
34 order_id: order_id.into(),
35 quantity,
36 price: None,
37 trigger_price: None,
38 limit_offset: None,
39 trailing_amount: None,
40 trailing_percent: None,
41 limit_depth_level: None,
42 trigger_count: None,
43 monitor_price: None,
44 remark: None,
45 }
46 }
47
48 #[inline]
50 #[must_use]
51 pub fn price(self, price: Decimal) -> Self {
52 Self {
53 price: Some(price),
54 ..self
55 }
56 }
57
58 #[inline]
60 #[must_use]
61 pub fn trigger_price(self, trigger_price: Decimal) -> Self {
62 Self {
63 trigger_price: Some(trigger_price),
64 ..self
65 }
66 }
67
68 #[inline]
70 #[must_use]
71 pub fn limit_offset(self, limit_offset: Decimal) -> Self {
72 Self {
73 limit_offset: Some(limit_offset),
74 ..self
75 }
76 }
77
78 #[inline]
80 #[must_use]
81 pub fn trailing_amount(self, trailing_amount: Decimal) -> Self {
82 Self {
83 trailing_amount: Some(trailing_amount),
84 ..self
85 }
86 }
87
88 #[inline]
90 #[must_use]
91 pub fn trailing_percent(self, trailing_percent: Decimal) -> Self {
92 Self {
93 trailing_percent: Some(trailing_percent),
94 ..self
95 }
96 }
97
98 #[inline]
100 #[must_use]
101 pub fn limit_depth_level(self, limit_depth_level: i32) -> Self {
102 Self {
103 limit_depth_level: Some(limit_depth_level),
104 ..self
105 }
106 }
107
108 #[inline]
110 #[must_use]
111 pub fn trigger_count(self, trigger_count: i32) -> Self {
112 Self {
113 trigger_count: Some(trigger_count),
114 ..self
115 }
116 }
117
118 #[inline]
120 #[must_use]
121 pub fn monitor_price(self, monitor_price: Decimal) -> Self {
122 Self {
123 monitor_price: Some(monitor_price),
124 ..self
125 }
126 }
127
128 #[inline]
130 #[must_use]
131 pub fn remark(self, remark: impl Into<String>) -> Self {
132 Self {
133 remark: Some(remark.into()),
134 ..self
135 }
136 }
137}