longportwhale/trade/
types.rs

1use strum_macros::{Display, EnumString};
2
3/// Order type
4#[derive(Debug, Copy, Clone, Hash, Eq, PartialEq, EnumString, Display)]
5#[allow(clippy::upper_case_acronyms)]
6pub enum OrderType {
7    /// Unknown
8    #[strum(disabled)]
9    Unknown,
10    /// Limit Order
11    #[strum(serialize = "LO")]
12    LO,
13    /// Enhanced Limit Order
14    #[strum(serialize = "ELO")]
15    ELO,
16    /// Market Order
17    #[strum(serialize = "MO")]
18    MO,
19    /// At-auction Order
20    #[strum(serialize = "AO")]
21    AO,
22    /// At-auction Limit Order
23    #[strum(serialize = "ALO")]
24    ALO,
25    /// Odd Lots
26    #[strum(serialize = "ODD")]
27    ODD,
28    /// Limit If Touched
29    #[strum(serialize = "LIT")]
30    LIT,
31    /// Market If Touched
32    #[strum(serialize = "MIT")]
33    MIT,
34    /// Trailing Limit If Touched (Trailing Amount)
35    #[strum(serialize = "TSLPAMT")]
36    TSLPAMT,
37    /// Trailing Limit If Touched (Trailing Percent)
38    #[strum(serialize = "TSLPPCT")]
39    TSLPPCT,
40    /// Trailing Market If Touched (Trailing Amount)
41    #[strum(serialize = "TSMAMT")]
42    TSMAMT,
43    /// Trailing Market If Touched (Trailing Percent)
44    #[strum(serialize = "TSMPCT")]
45    TSMPCT,
46    /// Special Limit Order
47    #[strum(serialize = "SLO")]
48    SLO,
49}
50
51/// Order status
52#[derive(Debug, Copy, Clone, Hash, Eq, PartialEq, EnumString, Display)]
53pub enum OrderStatus {
54    /// Unknown
55    #[strum(disabled)]
56    Unknown,
57    /// Not reported
58    #[strum(serialize = "NotReported")]
59    NotReported,
60    /// Not reported (Replaced Order)
61    #[strum(serialize = "ReplacedNotReported")]
62    ReplacedNotReported,
63    /// Not reported (Protected Order)
64    #[strum(serialize = "ProtectedNotReported")]
65    ProtectedNotReported,
66    /// Not reported (Conditional Order)
67    #[strum(serialize = "VarietiesNotReported")]
68    VarietiesNotReported,
69    /// Filled
70    #[strum(serialize = "FilledStatus")]
71    Filled,
72    /// Wait To New
73    #[strum(serialize = "WaitToNew")]
74    WaitToNew,
75    /// New
76    #[strum(serialize = "NewStatus")]
77    New,
78    /// Wait To Replace
79    #[strum(serialize = "WaitToReplace")]
80    WaitToReplace,
81    /// Pending Replace
82    #[strum(serialize = "PendingReplaceStatus")]
83    PendingReplace,
84    /// Replaced
85    #[strum(serialize = "ReplacedStatus")]
86    Replaced,
87    /// Partial Filled
88    #[strum(serialize = "PartialFilledStatus")]
89    PartialFilled,
90    /// Wait To Cancel
91    #[strum(serialize = "WaitToCancel")]
92    WaitToCancel,
93    /// Pending Cancel
94    #[strum(serialize = "PendingCancelStatus")]
95    PendingCancel,
96    /// Rejected
97    #[strum(serialize = "RejectedStatus")]
98    Rejected,
99    /// Canceled
100    #[strum(serialize = "CanceledStatus")]
101    Canceled,
102    /// Expired
103    #[strum(serialize = "ExpiredStatus")]
104    Expired,
105    /// Partial Withdrawal
106    #[strum(serialize = "PartialWithdrawal")]
107    PartialWithdrawal,
108}
109
110/// Order side
111#[derive(Debug, Copy, Clone, Hash, Eq, PartialEq, EnumString, Display)]
112pub enum OrderSide {
113    /// Unknown
114    #[strum(disabled)]
115    Unknown,
116    /// Buy
117    #[strum(serialize = "Buy")]
118    Buy,
119    /// Sell
120    #[strum(serialize = "Sell")]
121    Sell,
122}
123
124/// Order tag
125#[derive(Debug, Copy, Clone, Hash, Eq, PartialEq, EnumString, Display)]
126pub enum OrderTag {
127    /// Unknown
128    #[strum(disabled)]
129    Unknown,
130    /// Normal Order
131    #[strum(serialize = "Normal")]
132    Normal,
133    /// Long term Order
134    #[strum(serialize = "GTC")]
135    LongTerm,
136    /// Grey Order
137    #[strum(serialize = "Grey")]
138    Grey,
139    /// Force Selling
140    MarginCall,
141    /// OTC
142    Offline,
143    /// Option Exercise Long
144    Creditor,
145    /// Option Exercise Short
146    Debtor,
147    /// Wavier Of Option Exercise
148    NonExercise,
149    /// Trade Allocation
150    AllocatedSub,
151}
152
153/// Trigger status
154#[derive(Debug, Copy, Clone, Hash, Eq, PartialEq, EnumString, Display)]
155pub enum TriggerStatus {
156    /// Unknown
157    #[strum(disabled)]
158    Unknown,
159    /// Deactive
160    #[strum(serialize = "DEACTIVE")]
161    Deactive,
162    /// Active
163    #[strum(serialize = "ACTIVE")]
164    Active,
165    /// Released
166    #[strum(serialize = "RELEASED")]
167    Released,
168}
169
170impl_serde_for_enum_string!(OrderType, OrderStatus, OrderSide, OrderTag, TriggerStatus);
171
172impl_default_for_enum_string!(OrderType, OrderStatus, OrderSide, OrderTag, TriggerStatus);