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, collections::HashMap, rc::Rc};
21
22use nautilus_common::{
23    cache::Cache,
24    messages::data::{DataRequest, Payload},
25    msgbus::MessageBus,
26};
27use nautilus_core::{UUID4, UnixNanos};
28use nautilus_model::{
29    data::{Bar, BarType, DataType, QuoteTick, TradeTick},
30    enums::BookType,
31    identifiers::{ClientId, InstrumentId, Venue},
32    instruments::InstrumentAny,
33};
34
35use crate::client::DataClient;
36
37pub struct MockDataClient {
38    cache: Rc<RefCell<Cache>>,
39    msgbus: Rc<RefCell<MessageBus>>,
40    pub client_id: ClientId,
41    pub venue: Venue,
42}
43
44impl MockDataClient {
45    /// Creates a new [`MockDataClient`] instance.
46    pub const fn new(
47        cache: Rc<RefCell<Cache>>,
48        msgbus: Rc<RefCell<MessageBus>>,
49        client_id: ClientId,
50        venue: Venue,
51    ) -> Self {
52        Self {
53            cache,
54            msgbus,
55            client_id,
56            venue,
57        }
58    }
59}
60
61impl DataClient for MockDataClient {
62    fn client_id(&self) -> ClientId {
63        self.client_id
64    }
65    fn venue(&self) -> Option<Venue> {
66        Some(self.venue)
67    }
68
69    fn start(&self) {}
70    fn stop(&self) {}
71    fn reset(&self) {}
72    fn dispose(&self) {}
73    fn is_connected(&self) -> bool {
74        true
75    }
76    fn is_disconnected(&self) -> bool {
77        false
78    }
79
80    // -- COMMAND HANDLERS ---------------------------------------------------------------------------
81
82    /// Parse command and call specific function
83    fn subscribe(
84        &mut self,
85        _data_type: &DataType,
86        _params: &Option<HashMap<String, String>>,
87    ) -> anyhow::Result<()> {
88        Ok(())
89    }
90
91    fn subscribe_instruments(
92        &mut self,
93        _venue: Option<&Venue>,
94        _params: &Option<HashMap<String, String>>,
95    ) -> anyhow::Result<()> {
96        Ok(())
97    }
98
99    fn subscribe_instrument(
100        &mut self,
101        _instrument_id: &InstrumentId,
102        _params: &Option<HashMap<String, String>>,
103    ) -> anyhow::Result<()> {
104        Ok(())
105    }
106
107    fn subscribe_order_book_deltas(
108        &mut self,
109        _instrument_id: &InstrumentId,
110        _book_type: BookType,
111        _depth: Option<usize>,
112        _params: &Option<HashMap<String, String>>,
113    ) -> anyhow::Result<()> {
114        Ok(())
115    }
116
117    fn subscribe_order_book_snapshots(
118        &mut self,
119        instrument_id: &InstrumentId,
120        book_type: BookType,
121        depth: Option<usize>,
122        params: &Option<HashMap<String, String>>,
123    ) -> anyhow::Result<()> {
124        Ok(())
125    }
126
127    fn subscribe_quote_ticks(
128        &mut self,
129        instrument_id: &InstrumentId,
130        params: &Option<HashMap<String, String>>,
131    ) -> anyhow::Result<()> {
132        Ok(())
133    }
134
135    fn subscribe_trade_ticks(
136        &mut self,
137        instrument_id: &InstrumentId,
138        params: &Option<HashMap<String, String>>,
139    ) -> anyhow::Result<()> {
140        Ok(())
141    }
142
143    fn subscribe_bars(
144        &mut self,
145        bar_type: &BarType,
146        params: &Option<HashMap<String, String>>,
147    ) -> anyhow::Result<()> {
148        Ok(())
149    }
150
151    fn subscribe_instrument_status(
152        &mut self,
153        instrument_id: &InstrumentId,
154        params: &Option<HashMap<String, String>>,
155    ) -> anyhow::Result<()> {
156        Ok(())
157    }
158
159    fn subscribe_instrument_close(
160        &mut self,
161        instrument_id: &InstrumentId,
162        params: &Option<HashMap<String, String>>,
163    ) -> anyhow::Result<()> {
164        Ok(())
165    }
166
167    fn unsubscribe(
168        &mut self,
169        data_type: &DataType,
170        params: &Option<HashMap<String, String>>,
171    ) -> anyhow::Result<()> {
172        Ok(())
173    }
174
175    fn unsubscribe_instruments(
176        &mut self,
177        venue: Option<&Venue>,
178        params: &Option<HashMap<String, String>>,
179    ) -> anyhow::Result<()> {
180        Ok(())
181    }
182
183    fn unsubscribe_instrument(
184        &mut self,
185        instrument_id: &InstrumentId,
186        params: &Option<HashMap<String, String>>,
187    ) -> anyhow::Result<()> {
188        Ok(())
189    }
190
191    fn unsubscribe_order_book_deltas(
192        &mut self,
193        instrument_id: &InstrumentId,
194        params: &Option<HashMap<String, String>>,
195    ) -> anyhow::Result<()> {
196        Ok(())
197    }
198
199    fn unsubscribe_order_book_snapshots(
200        &mut self,
201        instrument_id: &InstrumentId,
202        params: &Option<HashMap<String, String>>,
203    ) -> anyhow::Result<()> {
204        Ok(())
205    }
206
207    fn unsubscribe_quote_ticks(
208        &mut self,
209        instrument_id: &InstrumentId,
210        params: &Option<HashMap<String, String>>,
211    ) -> anyhow::Result<()> {
212        Ok(())
213    }
214
215    fn unsubscribe_trade_ticks(
216        &mut self,
217        instrument_id: &InstrumentId,
218        params: &Option<HashMap<String, String>>,
219    ) -> anyhow::Result<()> {
220        Ok(())
221    }
222
223    fn unsubscribe_bars(
224        &mut self,
225        bar_type: &BarType,
226        params: &Option<HashMap<String, String>>,
227    ) -> anyhow::Result<()> {
228        Ok(())
229    }
230
231    fn unsubscribe_instrument_status(
232        &mut self,
233        instrument_id: &InstrumentId,
234        params: &Option<HashMap<String, String>>,
235    ) -> anyhow::Result<()> {
236        Ok(())
237    }
238
239    fn unsubscribe_instrument_close(
240        &mut self,
241        instrument_id: &InstrumentId,
242        params: &Option<HashMap<String, String>>,
243    ) -> anyhow::Result<()> {
244        Ok(())
245    }
246
247    // -- DATA REQUEST HANDLERS ---------------------------------------------------------------------------
248
249    fn request_data(&self, request: DataRequest) {
250        todo!()
251    }
252
253    fn request_instruments(
254        &self,
255        correlation_id: UUID4,
256        venue: Venue,
257        start: Option<UnixNanos>,
258        end: Option<UnixNanos>,
259        params: &Option<HashMap<String, String>>,
260    ) -> Vec<InstrumentAny> {
261        todo!()
262    }
263
264    fn request_instrument(
265        &self,
266        correlation_id: UUID4,
267        instrument_id: InstrumentId,
268        start: Option<UnixNanos>,
269        end: Option<UnixNanos>,
270        params: &Option<HashMap<String, String>>,
271    ) -> InstrumentAny {
272        todo!()
273    }
274
275    // TODO: figure out where to call this and it's return type
276    fn request_order_book_snapshot(
277        &self,
278        correlation_id: UUID4,
279        instrument_id: InstrumentId,
280        depth: Option<usize>,
281        params: &Option<HashMap<String, String>>,
282    ) -> Payload {
283        todo!()
284    }
285
286    fn request_quote_ticks(
287        &self,
288        correlation_id: UUID4,
289        instrument_id: InstrumentId,
290        start: Option<UnixNanos>,
291        end: Option<UnixNanos>,
292        limit: Option<usize>,
293        params: &Option<HashMap<String, String>>,
294    ) -> Vec<QuoteTick> {
295        todo!()
296    }
297
298    fn request_trade_ticks(
299        &self,
300        correlation_id: UUID4,
301        instrument_id: InstrumentId,
302        start: Option<UnixNanos>,
303        end: Option<UnixNanos>,
304        limit: Option<usize>,
305        params: &Option<HashMap<String, String>>,
306    ) -> Vec<TradeTick> {
307        todo!()
308    }
309
310    fn request_bars(
311        &self,
312        correlation_id: UUID4,
313        bar_type: BarType,
314        start: Option<UnixNanos>,
315        end: Option<UnixNanos>,
316        limit: Option<usize>,
317        params: &Option<HashMap<String, String>>,
318    ) -> Vec<Bar> {
319        todo!()
320    }
321}