longport/trade/requests/
replace_order.rs
1use 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 remark: Option<String>,
21}
22
23impl ReplaceOrderOptions {
24 #[inline]
26 pub fn new(order_id: impl Into<String>, quantity: Decimal) -> Self {
27 Self {
28 order_id: order_id.into(),
29 quantity,
30 price: None,
31 trigger_price: None,
32 limit_offset: None,
33 trailing_amount: None,
34 trailing_percent: None,
35 remark: None,
36 }
37 }
38
39 #[inline]
41 #[must_use]
42 pub fn price(self, price: Decimal) -> Self {
43 Self {
44 price: Some(price),
45 ..self
46 }
47 }
48
49 #[inline]
51 #[must_use]
52 pub fn trigger_price(self, trigger_price: Decimal) -> Self {
53 Self {
54 trigger_price: Some(trigger_price),
55 ..self
56 }
57 }
58
59 #[inline]
61 #[must_use]
62 pub fn limit_offset(self, limit_offset: Decimal) -> Self {
63 Self {
64 limit_offset: Some(limit_offset),
65 ..self
66 }
67 }
68
69 #[inline]
71 #[must_use]
72 pub fn trailing_amount(self, trailing_amount: Decimal) -> Self {
73 Self {
74 trailing_amount: Some(trailing_amount),
75 ..self
76 }
77 }
78
79 #[inline]
81 #[must_use]
82 pub fn trailing_percent(self, trailing_percent: Decimal) -> Self {
83 Self {
84 trailing_percent: Some(trailing_percent),
85 ..self
86 }
87 }
88
89 #[inline]
91 #[must_use]
92 pub fn remark(self, remark: impl Into<String>) -> Self {
93 Self {
94 remark: Some(remark.into()),
95 ..self
96 }
97 }
98}