nautilus_bybit/websocket/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 Bybit WebSocket operations and channels.
17
18use serde::{Deserialize, Serialize};
19use strum::{AsRefStr, Display, EnumIter, EnumString};
20
21/// WebSocket operation type.
22#[derive(
23 Clone,
24 Debug,
25 Display,
26 PartialEq,
27 Eq,
28 Hash,
29 AsRefStr,
30 EnumIter,
31 EnumString,
32 Serialize,
33 Deserialize,
34)]
35#[serde(rename_all = "lowercase")]
36#[strum(serialize_all = "lowercase")]
37pub enum BybitWsOperation {
38 /// Subscribe to topics.
39 Subscribe,
40 /// Unsubscribe from topics.
41 Unsubscribe,
42 /// Authenticate connection.
43 Auth,
44 /// Ping message.
45 Ping,
46 /// Pong message.
47 Pong,
48}
49
50/// Private authenticated channel types.
51#[derive(
52 Clone,
53 Debug,
54 Display,
55 PartialEq,
56 Eq,
57 Hash,
58 AsRefStr,
59 EnumIter,
60 EnumString,
61 Serialize,
62 Deserialize,
63)]
64#[serde(rename_all = "lowercase")]
65#[strum(serialize_all = "lowercase")]
66pub enum BybitWsPrivateChannel {
67 /// Order updates.
68 Order,
69 /// Execution/fill updates.
70 Execution,
71 /// Position updates.
72 Position,
73 /// Wallet/balance updates.
74 Wallet,
75}
76
77/// Public channel types.
78#[derive(
79 Clone,
80 Debug,
81 Display,
82 PartialEq,
83 Eq,
84 Hash,
85 AsRefStr,
86 EnumIter,
87 EnumString,
88 Serialize,
89 Deserialize,
90)]
91#[serde(rename_all = "lowercase")]
92#[strum(serialize_all = "lowercase")]
93pub enum BybitWsPublicChannel {
94 /// Order book updates.
95 #[serde(rename = "orderbook")]
96 #[strum(serialize = "orderbook")]
97 OrderBook,
98 /// Public trades.
99 #[serde(rename = "publicTrade")]
100 #[strum(serialize = "publicTrade")]
101 PublicTrade,
102 /// Trade updates.
103 Trade,
104 /// Kline/candlestick updates.
105 Kline,
106 /// Ticker updates.
107 Tickers,
108}