nautilus_data/
mocks.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// Under development
17#![allow(dead_code)]
18#![allow(unused_variables)]
19
20use std::{cell::RefCell, rc::Rc};
21
22use nautilus_common::{
23    cache::Cache,
24    messages::data::{
25        RequestBars, RequestBookSnapshot, RequestData, RequestInstrument, RequestInstruments,
26        RequestQuotes, RequestTrades, SubscribeBars, SubscribeBookDeltas, SubscribeBookDepth10,
27        SubscribeBookSnapshots, SubscribeData, SubscribeIndexPrices, SubscribeInstrument,
28        SubscribeInstrumentClose, SubscribeInstrumentStatus, SubscribeInstruments,
29        SubscribeMarkPrices, SubscribeQuotes, SubscribeTrades, UnsubscribeBars,
30        UnsubscribeBookDeltas, UnsubscribeBookDepth10, UnsubscribeBookSnapshots, UnsubscribeData,
31        UnsubscribeIndexPrices, UnsubscribeInstrument, UnsubscribeInstrumentClose,
32        UnsubscribeInstrumentStatus, UnsubscribeInstruments, UnsubscribeMarkPrices,
33        UnsubscribeQuotes, UnsubscribeTrades,
34    },
35};
36use nautilus_model::identifiers::{ClientId, Venue};
37
38use crate::client::DataClient;
39
40pub struct MockDataClient {
41    cache: Rc<RefCell<Cache>>,
42    pub client_id: ClientId,
43    pub venue: Venue,
44}
45
46impl MockDataClient {
47    /// Creates a new [`MockDataClient`] instance.
48    pub const fn new(cache: Rc<RefCell<Cache>>, client_id: ClientId, venue: Venue) -> Self {
49        Self {
50            cache,
51            client_id,
52            venue,
53        }
54    }
55}
56
57impl DataClient for MockDataClient {
58    fn client_id(&self) -> ClientId {
59        self.client_id
60    }
61    fn venue(&self) -> Option<Venue> {
62        Some(self.venue)
63    }
64
65    fn start(&self) {}
66    fn stop(&self) {}
67    fn reset(&self) {}
68    fn dispose(&self) {}
69    fn is_connected(&self) -> bool {
70        true
71    }
72    fn is_disconnected(&self) -> bool {
73        false
74    }
75
76    // -- COMMAND HANDLERS ---------------------------------------------------------------------------
77
78    fn subscribe(&mut self, _cmd: SubscribeData) -> anyhow::Result<()> {
79        Ok(())
80    }
81
82    fn subscribe_instruments(&mut self, _cmd: SubscribeInstruments) -> anyhow::Result<()> {
83        Ok(())
84    }
85
86    fn subscribe_instrument(&mut self, _cmd: SubscribeInstrument) -> anyhow::Result<()> {
87        Ok(())
88    }
89
90    fn subscribe_book_deltas(&mut self, _cmd: SubscribeBookDeltas) -> anyhow::Result<()> {
91        Ok(())
92    }
93
94    fn subscribe_book_depth10(&mut self, _cmd: SubscribeBookDepth10) -> anyhow::Result<()> {
95        Ok(())
96    }
97
98    fn subscribe_book_snapshots(&mut self, _cmd: SubscribeBookSnapshots) -> anyhow::Result<()> {
99        Ok(())
100    }
101
102    fn subscribe_quotes(&mut self, _cmd: SubscribeQuotes) -> anyhow::Result<()> {
103        Ok(())
104    }
105
106    fn subscribe_trades(&mut self, _cmd: SubscribeTrades) -> anyhow::Result<()> {
107        Ok(())
108    }
109
110    fn subscribe_bars(&mut self, _cmd: SubscribeBars) -> anyhow::Result<()> {
111        Ok(())
112    }
113
114    fn subscribe_mark_prices(&mut self, _cmd: SubscribeMarkPrices) -> anyhow::Result<()> {
115        Ok(())
116    }
117
118    fn subscribe_index_prices(&mut self, _cmd: SubscribeIndexPrices) -> anyhow::Result<()> {
119        Ok(())
120    }
121
122    fn subscribe_instrument_status(
123        &mut self,
124        _cmd: SubscribeInstrumentStatus,
125    ) -> anyhow::Result<()> {
126        Ok(())
127    }
128
129    fn subscribe_instrument_close(&mut self, _cmd: SubscribeInstrumentClose) -> anyhow::Result<()> {
130        Ok(())
131    }
132
133    fn unsubscribe(&mut self, _cmd: UnsubscribeData) -> anyhow::Result<()> {
134        Ok(())
135    }
136
137    fn unsubscribe_instruments(&mut self, _cmd: UnsubscribeInstruments) -> anyhow::Result<()> {
138        Ok(())
139    }
140
141    fn unsubscribe_instrument(&mut self, _cmd: UnsubscribeInstrument) -> anyhow::Result<()> {
142        Ok(())
143    }
144
145    fn unsubscribe_book_deltas(&mut self, _cmd: UnsubscribeBookDeltas) -> anyhow::Result<()> {
146        Ok(())
147    }
148
149    fn unsubscribe_book_depth10(&mut self, _cmd: UnsubscribeBookDepth10) -> anyhow::Result<()> {
150        Ok(())
151    }
152
153    fn unsubscribe_book_snapshots(&mut self, _cmd: UnsubscribeBookSnapshots) -> anyhow::Result<()> {
154        Ok(())
155    }
156
157    fn unsubscribe_quotes(&mut self, _cmd: UnsubscribeQuotes) -> anyhow::Result<()> {
158        Ok(())
159    }
160
161    fn unsubscribe_trades(&mut self, _cmd: UnsubscribeTrades) -> anyhow::Result<()> {
162        Ok(())
163    }
164
165    fn unsubscribe_bars(&mut self, _cmd: UnsubscribeBars) -> anyhow::Result<()> {
166        Ok(())
167    }
168
169    fn unsubscribe_mark_prices(&mut self, _cmd: UnsubscribeMarkPrices) -> anyhow::Result<()> {
170        Ok(())
171    }
172
173    fn unsubscribe_index_prices(&mut self, _cmd: UnsubscribeIndexPrices) -> anyhow::Result<()> {
174        Ok(())
175    }
176
177    fn unsubscribe_instrument_status(
178        &mut self,
179        _cmd: UnsubscribeInstrumentStatus,
180    ) -> anyhow::Result<()> {
181        Ok(())
182    }
183
184    fn unsubscribe_instrument_close(
185        &mut self,
186        _cmd: UnsubscribeInstrumentClose,
187    ) -> anyhow::Result<()> {
188        Ok(())
189    }
190
191    // -- DATA REQUEST HANDLERS ---------------------------------------------------------------------------
192
193    fn request_data(&self, request: RequestData) -> anyhow::Result<()> {
194        todo!()
195    }
196
197    fn request_instruments(&self, request: RequestInstruments) -> anyhow::Result<()> {
198        todo!()
199    }
200
201    fn request_instrument(&self, request: RequestInstrument) -> anyhow::Result<()> {
202        todo!()
203    }
204
205    fn request_book_snapshot(&self, request: RequestBookSnapshot) -> anyhow::Result<()> {
206        todo!()
207    }
208
209    fn request_quotes(&self, request: RequestQuotes) -> anyhow::Result<()> {
210        todo!()
211    }
212
213    fn request_trades(&self, request: RequestTrades) -> anyhow::Result<()> {
214        todo!()
215    }
216
217    fn request_bars(&self, request: RequestBars) -> anyhow::Result<()> {
218        todo!()
219    }
220}