nautilus_kraken/websocket/spot_v2/
enums.rs

1// -------------------------------------------------------------------------------------------------
2//  Copyright (C) 2015-2025 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//! Enumerations for Kraken WebSocket v2 API.
17
18use serde::{Deserialize, Serialize};
19use strum::{AsRefStr, Display, EnumString, FromRepr};
20
21#[derive(
22    Clone,
23    Copy,
24    Debug,
25    Display,
26    AsRefStr,
27    EnumString,
28    FromRepr,
29    PartialEq,
30    Eq,
31    Hash,
32    Serialize,
33    Deserialize,
34)]
35#[cfg_attr(
36    feature = "python",
37    pyo3::pyclass(module = "nautilus_trader.core.nautilus_pyo3.kraken", eq, eq_int)
38)]
39#[serde(rename_all = "lowercase")]
40#[strum(ascii_case_insensitive, serialize_all = "lowercase")]
41pub enum KrakenWsMethod {
42    Subscribe,
43    Unsubscribe,
44    Ping,
45    Pong,
46}
47
48#[derive(
49    Clone,
50    Copy,
51    Debug,
52    Display,
53    AsRefStr,
54    EnumString,
55    FromRepr,
56    PartialEq,
57    Eq,
58    Hash,
59    Serialize,
60    Deserialize,
61)]
62#[cfg_attr(
63    feature = "python",
64    pyo3::pyclass(module = "nautilus_trader.core.nautilus_pyo3.kraken", eq, eq_int)
65)]
66#[serde(rename_all = "lowercase")]
67#[strum(ascii_case_insensitive, serialize_all = "lowercase")]
68pub enum KrakenWsChannel {
69    Ticker,
70    #[serde(rename = "trade")]
71    #[strum(serialize = "trade")]
72    Trade,
73    #[serde(rename = "book")]
74    #[strum(serialize = "book")]
75    Book,
76    #[serde(rename = "ohlc")]
77    #[strum(serialize = "ohlc")]
78    Ohlc,
79    #[serde(rename = "spread")]
80    #[strum(serialize = "spread")]
81    Spread,
82    // Private channels
83    #[serde(rename = "executions")]
84    #[strum(serialize = "executions")]
85    Executions,
86    #[serde(rename = "balances")]
87    #[strum(serialize = "balances")]
88    Balances,
89}
90
91#[derive(
92    Clone,
93    Copy,
94    Debug,
95    Display,
96    AsRefStr,
97    EnumString,
98    FromRepr,
99    PartialEq,
100    Eq,
101    Hash,
102    Serialize,
103    Deserialize,
104)]
105#[cfg_attr(
106    feature = "python",
107    pyo3::pyclass(module = "nautilus_trader.core.nautilus_pyo3.kraken", eq, eq_int)
108)]
109#[serde(rename_all = "lowercase")]
110#[strum(ascii_case_insensitive, serialize_all = "lowercase")]
111pub enum KrakenWsMessageType {
112    Heartbeat,
113    Status,
114    Subscribe,
115    Unsubscribe,
116    Update,
117    Snapshot,
118    Error,
119}
120
121/// Execution type from the Kraken executions channel.
122#[derive(
123    Clone,
124    Copy,
125    Debug,
126    Display,
127    AsRefStr,
128    EnumString,
129    FromRepr,
130    PartialEq,
131    Eq,
132    Hash,
133    Serialize,
134    Deserialize,
135)]
136#[serde(rename_all = "snake_case")]
137#[strum(ascii_case_insensitive, serialize_all = "snake_case")]
138pub enum KrakenExecType {
139    /// Order is pending submission to the exchange.
140    #[serde(rename = "pending_new")]
141    #[strum(serialize = "pending_new")]
142    PendingNew,
143    /// Order has been accepted by the exchange.
144    New,
145    /// Order has been partially or fully filled.
146    Trade,
147    /// Order has been completely filled.
148    Filled,
149    /// Iceberg order refill.
150    #[serde(rename = "iceberg_refill")]
151    #[strum(serialize = "iceberg_refill")]
152    IcebergRefill,
153    /// Order has been canceled.
154    Canceled,
155    /// Order has expired.
156    Expired,
157    /// Order has been amended (user-initiated modification).
158    Amended,
159    /// Order has been restated (engine-initiated adjustment).
160    Restated,
161    /// Order status update without state change.
162    Status,
163}
164
165/// Order status from the Kraken WebSocket v2 executions channel.
166#[derive(
167    Clone,
168    Copy,
169    Debug,
170    Display,
171    AsRefStr,
172    EnumString,
173    FromRepr,
174    PartialEq,
175    Eq,
176    Hash,
177    Serialize,
178    Deserialize,
179)]
180#[serde(rename_all = "snake_case")]
181#[strum(ascii_case_insensitive, serialize_all = "snake_case")]
182pub enum KrakenWsOrderStatus {
183    /// Order is pending submission.
184    #[serde(rename = "pending_new")]
185    #[strum(serialize = "pending_new")]
186    PendingNew,
187    /// Order has been accepted.
188    New,
189    /// Order has been partially filled.
190    #[serde(rename = "partially_filled")]
191    #[strum(serialize = "partially_filled")]
192    PartiallyFilled,
193    /// Order has been completely filled.
194    Filled,
195    /// Order has been canceled.
196    Canceled,
197    /// Order has expired.
198    Expired,
199    /// Conditional order has been triggered.
200    Triggered,
201}
202
203/// Liquidity indicator from trade executions.
204#[derive(
205    Clone,
206    Copy,
207    Debug,
208    Display,
209    AsRefStr,
210    EnumString,
211    FromRepr,
212    PartialEq,
213    Eq,
214    Hash,
215    Serialize,
216    Deserialize,
217)]
218#[serde(rename_all = "lowercase")]
219#[strum(ascii_case_insensitive, serialize_all = "lowercase")]
220pub enum KrakenLiquidityInd {
221    /// Maker (limit order that added liquidity).
222    #[serde(rename = "m")]
223    #[strum(serialize = "m")]
224    Maker,
225    /// Taker (order that removed liquidity).
226    #[serde(rename = "t")]
227    #[strum(serialize = "t")]
228    Taker,
229}