Skip to main content

nautilus_derive/websocket/
mod.rs

1// -------------------------------------------------------------------------------------------------
2//  Copyright (C) 2015-2026 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//! WebSocket transport for the Derive JSON-RPC stream.
17//!
18//! The module is split into:
19//!
20//! - [`error`]: [`DeriveWsError`] taxonomy.
21//! - [`messages`]: wire payloads and a discriminated inbound frame.
22//! - [`parse`]: typed public market data payload parsers.
23//! - [`handler`]: inner I/O loop owning the `WebSocketClient`.
24//! - [`client`]: outer client orchestrating connect / login / subscribe.
25
26pub mod client;
27pub mod context;
28pub mod dispatch;
29pub mod error;
30pub mod handler;
31pub mod messages;
32pub mod parse;
33
34pub use client::{
35    DeriveWebSocketClient, DeriveWebSocketSubscriptionHandle, DeriveWsCredentials,
36    DeriveWsExecutionHandle,
37};
38pub(crate) use context::WsMessageContext;
39pub use dispatch::{ORDER_DEDUP_CAPACITY, OrderIdentity, TRADE_DEDUP_CAPACITY, WsDispatchState};
40pub use error::DeriveWsError;
41pub use handler::DeriveWsMessage;
42pub(crate) use messages::{
43    DEFAULT_ORDERBOOK_DEPTH, DEFAULT_ORDERBOOK_GROUP, DEFAULT_TICKER_INTERVAL,
44};
45pub use messages::{
46    DeriveOrderbookData, DeriveOrderbookLevel, DeriveOrderbookMsg, DeriveOrdersSubscriptionData,
47    DerivePublicWsData, DeriveTickerData, DeriveTickerMsg, DeriveTradesMsg,
48    DeriveTradesSubscriptionData, DeriveWsChannel, DeriveWsFrame, WsLoginParams, WsLoginResult,
49    WsRequestParams, WsSubscribeParams, WsSubscribeResult, WsSubscriptionFrame,
50    WsSubscriptionPayload, WsUnsubscribeParams, WsUnsubscribeResult, balances_channel, methods,
51    orderbook_channel, orders_channel, private_trades_channel, ticker_channel, trades_channel,
52};
53pub use parse::{
54    bar_spec_to_derive_period, parse_candle_record, parse_funding_rate,
55    parse_funding_rate_history_record, parse_index_price, parse_mark_price, parse_option_greeks,
56    parse_orderbook_deltas, parse_orderbook_depth10, parse_orderbook_msg, parse_public_ws_data,
57    parse_ticker_msg, parse_ticker_quote, parse_ticker_quote_from_rest, parse_trade_tick,
58    parse_trades_msg,
59};