Skip to main content

nautilus_derive/websocket/
context.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 message dispatch context for the Derive data client.
17
18use std::sync::Arc;
19
20use nautilus_common::{cache::quote::QuoteCache, messages::DataEvent};
21use nautilus_core::{AtomicMap, AtomicSet, time::AtomicTime};
22use nautilus_model::{identifiers::InstrumentId, instruments::InstrumentAny};
23
24pub(crate) struct WsMessageContext {
25    pub(crate) clock: &'static AtomicTime,
26    pub(crate) data_sender: tokio::sync::mpsc::UnboundedSender<DataEvent>,
27    pub(crate) instruments: Arc<AtomicMap<InstrumentId, InstrumentAny>>,
28    pub(crate) active_book_delta_channels: Arc<AtomicMap<InstrumentId, String>>,
29    pub(crate) active_book_depth10_channels: Arc<AtomicMap<InstrumentId, String>>,
30    pub(crate) active_ticker_channels: Arc<AtomicMap<InstrumentId, String>>,
31    pub(crate) active_quote_subs: Arc<AtomicSet<InstrumentId>>,
32    pub(crate) active_trade_subs: Arc<AtomicSet<InstrumentId>>,
33    pub(crate) active_mark_subs: Arc<AtomicSet<InstrumentId>>,
34    pub(crate) active_index_subs: Arc<AtomicSet<InstrumentId>>,
35    pub(crate) active_funding_subs: Arc<AtomicSet<InstrumentId>>,
36    pub(crate) active_greeks_subs: Arc<AtomicSet<InstrumentId>>,
37    pub(crate) quote_cache: QuoteCache,
38}