nautilus-system 0.57.0

System orchestration for the Nautilus trading engine
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
// -------------------------------------------------------------------------------------------------
//  Copyright (C) 2015-2026 Nautech Systems Pty Ltd. All rights reserved.
//  https://nautechsystems.io
//
//  Licensed under the GNU Lesser General Public License Version 3.0 (the "License");
//  You may not use this file except in compliance with the License.
//  You may obtain a copy of the License at https://www.gnu.org/licenses/lgpl-3.0.en.html
//
//  Unless required by applicable law or agreed to in writing, software
//  distributed under the License is distributed on an "AS IS" BASIS,
//  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
//  See the License for the specific language governing permissions and
//  limitations under the License.
// -------------------------------------------------------------------------------------------------

use std::{cell::RefCell, fmt::Debug, rc::Rc, time::Duration};

use nautilus_common::{
    cache::{CacheConfig, database::CacheDatabaseAdapter},
    clock::Clock,
    enums::Environment,
    logging::logger::LoggerConfig,
};
use nautilus_core::UUID4;
use nautilus_data::engine::config::DataEngineConfig;
use nautilus_execution::engine::config::ExecutionEngineConfig;
use nautilus_model::identifiers::TraderId;
use nautilus_portfolio::config::PortfolioConfig;
use nautilus_risk::engine::config::RiskEngineConfig;

use crate::{
    config::KernelConfig,
    event_store::{EventStoreFactory, KernelEventStore},
    kernel::NautilusKernel,
};

/// Builder for constructing a [`NautilusKernel`] with a fluent API.
///
/// Provides a convenient way to configure and build a kernel instance with
/// optional components and settings.
pub struct NautilusKernelBuilder {
    name: String,
    trader_id: TraderId,
    environment: Environment,
    instance_id: Option<UUID4>,
    load_state: bool,
    save_state: bool,
    logging: Option<LoggerConfig>,
    timeout_connection: Duration,
    timeout_reconciliation: Duration,
    timeout_portfolio: Duration,
    timeout_disconnection: Duration,
    delay_post_stop: Duration,
    timeout_shutdown: Duration,
    cache: Option<CacheConfig>,
    cache_database: Option<Box<dyn CacheDatabaseAdapter>>,
    data_engine: Option<DataEngineConfig>,
    risk_engine: Option<RiskEngineConfig>,
    exec_engine: Option<ExecutionEngineConfig>,
    portfolio: Option<PortfolioConfig>,
    event_store_factory: Option<EventStoreFactory>,
}

impl Debug for NautilusKernelBuilder {
    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
        f.debug_struct(stringify!(NautilusKernelBuilder))
            .field("name", &self.name)
            .field("trader_id", &self.trader_id)
            .field("environment", &self.environment)
            .field("instance_id", &self.instance_id)
            .field("load_state", &self.load_state)
            .field("save_state", &self.save_state)
            .field("logging", &self.logging)
            .field("timeout_connection", &self.timeout_connection)
            .field("timeout_reconciliation", &self.timeout_reconciliation)
            .field("timeout_portfolio", &self.timeout_portfolio)
            .field("timeout_disconnection", &self.timeout_disconnection)
            .field("delay_post_stop", &self.delay_post_stop)
            .field("timeout_shutdown", &self.timeout_shutdown)
            .field("cache", &self.cache)
            .field("cache_database", &self.cache_database.is_some())
            .field("data_engine", &self.data_engine)
            .field("risk_engine", &self.risk_engine)
            .field("exec_engine", &self.exec_engine)
            .field("portfolio", &self.portfolio)
            .field("event_store_factory", &self.event_store_factory.is_some())
            .finish_non_exhaustive()
    }
}

impl NautilusKernelBuilder {
    /// Creates a new [`NautilusKernelBuilder`] with required parameters.
    #[must_use]
    pub const fn new(name: String, trader_id: TraderId, environment: Environment) -> Self {
        Self {
            name,
            trader_id,
            environment,
            instance_id: None,
            load_state: true,
            save_state: true,
            logging: None,
            timeout_connection: Duration::from_secs(60),
            timeout_reconciliation: Duration::from_secs(30),
            timeout_portfolio: Duration::from_secs(10),
            timeout_disconnection: Duration::from_secs(10),
            delay_post_stop: Duration::from_secs(10),
            timeout_shutdown: Duration::from_secs(5),
            cache: None,
            cache_database: None,
            data_engine: None,
            risk_engine: None,
            exec_engine: None,
            portfolio: None,
            event_store_factory: None,
        }
    }

    /// Set the instance ID for the kernel.
    #[must_use]
    pub const fn with_instance_id(mut self, instance_id: UUID4) -> Self {
        self.instance_id = Some(instance_id);
        self
    }

    /// Configure whether to load state on startup.
    #[must_use]
    pub const fn with_load_state(mut self, load_state: bool) -> Self {
        self.load_state = load_state;
        self
    }

    /// Configure whether to save state on shutdown.
    #[must_use]
    pub const fn with_save_state(mut self, save_state: bool) -> Self {
        self.save_state = save_state;
        self
    }

    /// Set the logging configuration.
    #[must_use]
    pub fn with_logging_config(mut self, config: LoggerConfig) -> Self {
        self.logging = Some(config);
        self
    }

    /// Set the connection timeout in seconds.
    #[must_use]
    pub const fn with_timeout_connection(mut self, timeout_secs: u64) -> Self {
        self.timeout_connection = Duration::from_secs(timeout_secs);
        self
    }

    /// Set the reconciliation timeout in seconds.
    #[must_use]
    pub const fn with_timeout_reconciliation(mut self, timeout_secs: u64) -> Self {
        self.timeout_reconciliation = Duration::from_secs(timeout_secs);
        self
    }

    /// Set the portfolio initialization timeout in seconds.
    #[must_use]
    pub const fn with_timeout_portfolio(mut self, timeout_secs: u64) -> Self {
        self.timeout_portfolio = Duration::from_secs(timeout_secs);
        self
    }

    /// Set the disconnection timeout in seconds.
    #[must_use]
    pub const fn with_timeout_disconnection(mut self, timeout_secs: u64) -> Self {
        self.timeout_disconnection = Duration::from_secs(timeout_secs);
        self
    }

    /// Set the post-stop delay in seconds.
    #[must_use]
    pub const fn with_delay_post_stop(mut self, delay_secs: u64) -> Self {
        self.delay_post_stop = Duration::from_secs(delay_secs);
        self
    }

    /// Set the shutdown timeout in seconds.
    #[must_use]
    pub const fn with_timeout_shutdown(mut self, timeout_secs: u64) -> Self {
        self.timeout_shutdown = Duration::from_secs(timeout_secs);
        self
    }

    /// Set the cache configuration.
    #[must_use]
    pub fn with_cache_config(mut self, config: CacheConfig) -> Self {
        self.cache = Some(config);
        self
    }

    /// Inject a durable cache database adapter.
    ///
    /// The adapter is passed straight to [`nautilus_common::cache::Cache::new`] so
    /// generic cache state (including event-store snapshot blobs) is restored on
    /// startup without an external caller pre-seeding the in-memory cache. Adapter
    /// construction lives outside this crate to keep `nautilus-system` decoupled
    /// from concrete backing stores such as Redis or Postgres.
    #[must_use]
    pub fn with_cache_database(mut self, adapter: Box<dyn CacheDatabaseAdapter>) -> Self {
        self.cache_database = Some(adapter);
        self
    }

    /// Set the data engine configuration.
    #[must_use]
    pub fn with_data_engine_config(mut self, config: DataEngineConfig) -> Self {
        self.data_engine = Some(config);
        self
    }

    /// Set the risk engine configuration.
    #[must_use]
    pub fn with_risk_engine_config(mut self, config: RiskEngineConfig) -> Self {
        self.risk_engine = Some(config);
        self
    }

    /// Set the execution engine configuration.
    #[must_use]
    pub fn with_exec_engine_config(mut self, config: ExecutionEngineConfig) -> Self {
        self.exec_engine = Some(config);
        self
    }

    /// Set the portfolio configuration.
    #[must_use]
    pub const fn with_portfolio_config(mut self, config: PortfolioConfig) -> Self {
        self.portfolio = Some(config);
        self
    }

    /// Inject an event-store implementation to drive run-lifecycle capture.
    ///
    /// The factory is invoked with the kernel's instance id and clock during
    /// construction, so the returned [`KernelEventStore`] scans the same run directory
    /// and shares the same time source the kernel uses for `RunStarted`/`RunEnded` and
    /// any drop-seal fallback. The concrete implementation lives outside this crate
    /// (typically in `nautilus-event-store`); callers build it inside the closure.
    #[must_use]
    pub fn with_event_store<F>(mut self, factory: F) -> Self
    where
        F: FnOnce(UUID4, Rc<RefCell<dyn Clock>>) -> anyhow::Result<Box<dyn KernelEventStore>>
            + 'static,
    {
        self.event_store_factory = Some(Box::new(factory));
        self
    }

    /// Build the [`NautilusKernel`] with the configured settings.
    ///
    /// # Errors
    ///
    /// Returns an error if kernel initialization fails.
    pub fn build(self) -> anyhow::Result<NautilusKernel> {
        let config = KernelConfig {
            environment: self.environment,
            trader_id: self.trader_id,
            load_state: self.load_state,
            save_state: self.save_state,
            logging: self.logging.unwrap_or_default(),
            instance_id: self.instance_id,
            timeout_connection: self.timeout_connection,
            timeout_reconciliation: self.timeout_reconciliation,
            timeout_portfolio: self.timeout_portfolio,
            timeout_disconnection: self.timeout_disconnection,
            delay_post_stop: self.delay_post_stop,
            timeout_shutdown: self.timeout_shutdown,
            cache: self.cache,
            msgbus: None, // msgbus config - not exposed in builder yet
            data_engine: self.data_engine,
            risk_engine: self.risk_engine,
            exec_engine: self.exec_engine,
            portfolio: self.portfolio,
            streaming: None,
        };

        NautilusKernel::new_with(
            self.name,
            config,
            self.cache_database,
            self.event_store_factory,
        )
    }
}

impl Default for NautilusKernelBuilder {
    /// Create a default builder with minimal configuration for testing/development.
    fn default() -> Self {
        Self::new(
            "NautilusKernel".to_string(),
            TraderId::default(),
            Environment::Backtest,
        )
    }
}

#[cfg(test)]
mod tests {
    use ahash::AHashMap;
    use bytes::Bytes;
    use nautilus_common::{
        cache::{
            Cache,
            database::{CacheDatabaseAdapter, CacheMap},
        },
        clock::Clock,
        signal::Signal,
    };
    use nautilus_core::UnixNanos;
    use nautilus_execution::engine::SnapshotAnchorer;
    use nautilus_model::{
        accounts::AccountAny,
        data::{
            Bar, CustomData, DataType, FundingRateUpdate, QuoteTick, TradeTick,
            greeks::{GreeksData, YieldCurveData},
        },
        events::{OrderEventAny, OrderSnapshot, position::snapshot::PositionSnapshot},
        identifiers::{
            AccountId, ClientId, ClientOrderId, ComponentId, InstrumentId, PositionId, StrategyId,
            TraderId, VenueOrderId,
        },
        instruments::{InstrumentAny, SyntheticInstrument},
        orderbook::OrderBook,
        orders::OrderAny,
        position::Position,
        types::Currency,
    };
    use rstest::*;
    use ustr::Ustr;

    use super::*;
    use crate::event_store::RegisteredComponents;

    #[rstest]
    fn test_builder_default() {
        let builder = NautilusKernelBuilder::default();
        assert_eq!(builder.name, "NautilusKernel");
        assert_eq!(builder.environment, Environment::Backtest);
        assert!(builder.load_state);
        assert!(builder.save_state);
    }

    #[rstest]
    fn test_builder_fluent_api() {
        let trader_id = TraderId::from("TRADER-001");
        let instance_id = UUID4::new();

        let builder =
            NautilusKernelBuilder::new("TestKernel".to_string(), trader_id, Environment::Live)
                .with_instance_id(instance_id)
                .with_load_state(false)
                .with_save_state(false)
                .with_timeout_connection(30);

        assert_eq!(builder.name, "TestKernel");
        assert_eq!(builder.trader_id, trader_id);
        assert_eq!(builder.environment, Environment::Live);
        assert_eq!(builder.instance_id, Some(instance_id));
        assert!(!builder.load_state);
        assert!(!builder.save_state);
        assert_eq!(builder.timeout_connection, Duration::from_secs(30));
    }

    #[cfg(feature = "python")]
    #[rstest]
    fn test_builder_build() {
        let result = NautilusKernelBuilder::default().build();
        assert!(result.is_ok());

        let kernel = result.unwrap();
        assert_eq!(kernel.name(), "NautilusKernel".to_string());
        assert_eq!(kernel.environment(), Environment::Backtest);
    }

    #[rstest]
    fn test_builder_with_configs() {
        let cache_config = CacheConfig::default();
        let data_engine_config = DataEngineConfig::default();

        let builder = NautilusKernelBuilder::default()
            .with_cache_config(cache_config)
            .with_data_engine_config(data_engine_config);

        assert!(builder.cache.is_some());
        assert!(builder.data_engine.is_some());
    }

    #[rstest]
    fn test_builder_with_cache_database() {
        let builder = NautilusKernelBuilder::default().with_cache_database(Box::new(NoopAdapter));

        assert!(builder.cache_database.is_some());
    }

    #[rstest]
    fn test_builder_default_has_no_event_store() {
        let kernel = NautilusKernelBuilder::default()
            .build()
            .expect("kernel builds without an event store");

        assert!(kernel.event_store().is_none());
    }

    #[rstest]
    fn test_builder_with_event_store_invokes_factory_with_kernel_args() {
        type FactoryArgs = (UUID4, Rc<RefCell<dyn Clock>>);

        let known_id = UUID4::new();
        let captured: Rc<RefCell<Option<FactoryArgs>>> = Rc::new(RefCell::new(None));
        let captured_for_closure = captured.clone();

        let kernel = NautilusKernelBuilder::default()
            .with_instance_id(known_id)
            .with_event_store(move |instance_id, clock| {
                *captured_for_closure.borrow_mut() = Some((instance_id, clock));
                Ok(Box::new(NoopKernelEventStore))
            })
            .build()
            .expect("kernel");

        let (received_id, received_clock) =
            captured.borrow_mut().take().expect("factory invoked once");

        assert_eq!(
            received_id, known_id,
            "factory must receive kernel instance_id"
        );
        assert!(
            Rc::ptr_eq(&received_clock, &kernel.clock()),
            "factory must receive the kernel's clock Rc, not a fresh allocation",
        );
    }

    #[rstest]
    fn test_builder_with_event_store_propagates_factory_error() {
        let result = NautilusKernelBuilder::default()
            .with_event_store(|_instance_id, _clock| Err(anyhow::anyhow!("factory boom")))
            .build();

        let err = result.expect_err("factory error must surface from build()");

        assert!(
            err.to_string().contains("factory boom"),
            "error must propagate the factory's message; got: {err}",
        );
    }

    #[rstest]
    fn test_builder_with_all_engine_configs() {
        let builder = NautilusKernelBuilder::default()
            .with_data_engine_config(DataEngineConfig::default())
            .with_risk_engine_config(RiskEngineConfig::default())
            .with_exec_engine_config(ExecutionEngineConfig::default())
            .with_portfolio_config(PortfolioConfig::default());

        assert!(builder.data_engine.is_some());
        assert!(builder.risk_engine.is_some());
        assert!(builder.exec_engine.is_some());
        assert!(builder.portfolio.is_some());
    }

    #[rstest]
    fn test_builder_with_all_timeouts() {
        let builder = NautilusKernelBuilder::default()
            .with_timeout_connection(10)
            .with_timeout_reconciliation(20)
            .with_timeout_portfolio(30)
            .with_timeout_disconnection(40)
            .with_delay_post_stop(50)
            .with_timeout_shutdown(60);

        assert_eq!(builder.timeout_connection, Duration::from_secs(10));
        assert_eq!(builder.timeout_reconciliation, Duration::from_secs(20));
        assert_eq!(builder.timeout_portfolio, Duration::from_secs(30));
        assert_eq!(builder.timeout_disconnection, Duration::from_secs(40));
        assert_eq!(builder.delay_post_stop, Duration::from_secs(50));
        assert_eq!(builder.timeout_shutdown, Duration::from_secs(60));
    }

    #[rstest]
    fn test_builder_default_timeouts() {
        let builder = NautilusKernelBuilder::default();

        assert_eq!(builder.timeout_connection, Duration::from_secs(60));
        assert_eq!(builder.timeout_reconciliation, Duration::from_secs(30));
        assert_eq!(builder.timeout_portfolio, Duration::from_secs(10));
        assert_eq!(builder.timeout_disconnection, Duration::from_secs(10));
        assert_eq!(builder.delay_post_stop, Duration::from_secs(10));
        assert_eq!(builder.timeout_shutdown, Duration::from_secs(5));
    }

    struct NoopAdapter;

    #[async_trait::async_trait]
    impl CacheDatabaseAdapter for NoopAdapter {
        fn close(&mut self) -> anyhow::Result<()> {
            Ok(())
        }

        fn flush(&mut self) -> anyhow::Result<()> {
            Ok(())
        }

        async fn load_all(&self) -> anyhow::Result<CacheMap> {
            Ok(CacheMap::default())
        }

        fn load(&self) -> anyhow::Result<AHashMap<String, Bytes>> {
            Ok(AHashMap::new())
        }

        async fn load_currencies(&self) -> anyhow::Result<AHashMap<Ustr, Currency>> {
            Ok(AHashMap::new())
        }

        async fn load_instruments(&self) -> anyhow::Result<AHashMap<InstrumentId, InstrumentAny>> {
            Ok(AHashMap::new())
        }

        async fn load_synthetics(
            &self,
        ) -> anyhow::Result<AHashMap<InstrumentId, SyntheticInstrument>> {
            Ok(AHashMap::new())
        }

        async fn load_accounts(&self) -> anyhow::Result<AHashMap<AccountId, AccountAny>> {
            Ok(AHashMap::new())
        }

        async fn load_orders(&self) -> anyhow::Result<AHashMap<ClientOrderId, OrderAny>> {
            Ok(AHashMap::new())
        }

        async fn load_positions(&self) -> anyhow::Result<AHashMap<PositionId, Position>> {
            Ok(AHashMap::new())
        }

        fn load_index_order_position(&self) -> anyhow::Result<AHashMap<ClientOrderId, Position>> {
            Ok(AHashMap::new())
        }

        fn load_index_order_client(&self) -> anyhow::Result<AHashMap<ClientOrderId, ClientId>> {
            Ok(AHashMap::new())
        }

        async fn load_currency(&self, _code: &Ustr) -> anyhow::Result<Option<Currency>> {
            Ok(None)
        }

        async fn load_instrument(
            &self,
            _instrument_id: &InstrumentId,
        ) -> anyhow::Result<Option<InstrumentAny>> {
            Ok(None)
        }

        async fn load_synthetic(
            &self,
            _instrument_id: &InstrumentId,
        ) -> anyhow::Result<Option<SyntheticInstrument>> {
            Ok(None)
        }

        async fn load_account(
            &self,
            _account_id: &AccountId,
        ) -> anyhow::Result<Option<AccountAny>> {
            Ok(None)
        }

        async fn load_order(
            &self,
            _client_order_id: &ClientOrderId,
        ) -> anyhow::Result<Option<OrderAny>> {
            Ok(None)
        }

        async fn load_position(
            &self,
            _position_id: &PositionId,
        ) -> anyhow::Result<Option<Position>> {
            Ok(None)
        }

        fn load_actor(
            &self,
            _component_id: &ComponentId,
        ) -> anyhow::Result<AHashMap<String, Bytes>> {
            Ok(AHashMap::new())
        }

        fn load_strategy(
            &self,
            _strategy_id: &StrategyId,
        ) -> anyhow::Result<AHashMap<String, Bytes>> {
            Ok(AHashMap::new())
        }

        fn load_signals(&self, _name: &str) -> anyhow::Result<Vec<Signal>> {
            Ok(Vec::new())
        }

        fn load_custom_data(&self, _data_type: &DataType) -> anyhow::Result<Vec<CustomData>> {
            Ok(Vec::new())
        }

        fn load_order_snapshot(
            &self,
            _client_order_id: &ClientOrderId,
        ) -> anyhow::Result<Option<OrderSnapshot>> {
            Ok(None)
        }

        fn load_position_snapshot(
            &self,
            _position_id: &PositionId,
        ) -> anyhow::Result<Option<PositionSnapshot>> {
            Ok(None)
        }

        fn load_quotes(&self, _instrument_id: &InstrumentId) -> anyhow::Result<Vec<QuoteTick>> {
            Ok(Vec::new())
        }

        fn load_trades(&self, _instrument_id: &InstrumentId) -> anyhow::Result<Vec<TradeTick>> {
            Ok(Vec::new())
        }

        fn load_funding_rates(
            &self,
            _instrument_id: &InstrumentId,
        ) -> anyhow::Result<Vec<FundingRateUpdate>> {
            Ok(Vec::new())
        }

        fn load_bars(&self, _instrument_id: &InstrumentId) -> anyhow::Result<Vec<Bar>> {
            Ok(Vec::new())
        }

        fn add(&self, _key: String, _value: Bytes) -> anyhow::Result<()> {
            Ok(())
        }

        fn add_currency(&self, _currency: &Currency) -> anyhow::Result<()> {
            Ok(())
        }

        fn add_instrument(&self, _instrument: &InstrumentAny) -> anyhow::Result<()> {
            Ok(())
        }

        fn add_synthetic(&self, _synthetic: &SyntheticInstrument) -> anyhow::Result<()> {
            Ok(())
        }

        fn add_account(&self, _account: &AccountAny) -> anyhow::Result<()> {
            Ok(())
        }

        fn add_order(&self, _order: &OrderAny, _client_id: Option<ClientId>) -> anyhow::Result<()> {
            Ok(())
        }

        fn add_order_snapshot(&self, _snapshot: &OrderSnapshot) -> anyhow::Result<()> {
            Ok(())
        }

        fn add_position(&self, _position: &Position) -> anyhow::Result<()> {
            Ok(())
        }

        fn add_position_snapshot(&self, _snapshot: &PositionSnapshot) -> anyhow::Result<()> {
            Ok(())
        }

        fn add_order_book(&self, _order_book: &OrderBook) -> anyhow::Result<()> {
            Ok(())
        }

        fn add_signal(&self, _signal: &Signal) -> anyhow::Result<()> {
            Ok(())
        }

        fn add_custom_data(&self, _data: &CustomData) -> anyhow::Result<()> {
            Ok(())
        }

        fn add_quote(&self, _quote: &QuoteTick) -> anyhow::Result<()> {
            Ok(())
        }

        fn add_trade(&self, _trade: &TradeTick) -> anyhow::Result<()> {
            Ok(())
        }

        fn add_funding_rate(&self, _funding_rate: &FundingRateUpdate) -> anyhow::Result<()> {
            Ok(())
        }

        fn add_bar(&self, _bar: &Bar) -> anyhow::Result<()> {
            Ok(())
        }

        fn add_greeks(&self, _greeks: &GreeksData) -> anyhow::Result<()> {
            Ok(())
        }

        fn add_yield_curve(&self, _yield_curve: &YieldCurveData) -> anyhow::Result<()> {
            Ok(())
        }

        fn delete_actor(&self, _component_id: &ComponentId) -> anyhow::Result<()> {
            Ok(())
        }

        fn delete_strategy(&self, _component_id: &StrategyId) -> anyhow::Result<()> {
            Ok(())
        }

        fn delete_order(&self, _client_order_id: &ClientOrderId) -> anyhow::Result<()> {
            Ok(())
        }

        fn delete_position(&self, _position_id: &PositionId) -> anyhow::Result<()> {
            Ok(())
        }

        fn delete_account_event(
            &self,
            _account_id: &AccountId,
            _event_id: &str,
        ) -> anyhow::Result<()> {
            Ok(())
        }

        fn index_venue_order_id(
            &self,
            _client_order_id: ClientOrderId,
            _venue_order_id: VenueOrderId,
        ) -> anyhow::Result<()> {
            Ok(())
        }

        fn index_order_position(
            &self,
            _client_order_id: ClientOrderId,
            _position_id: PositionId,
        ) -> anyhow::Result<()> {
            Ok(())
        }

        fn update_actor(&self) -> anyhow::Result<()> {
            Ok(())
        }

        fn update_strategy(&self) -> anyhow::Result<()> {
            Ok(())
        }

        fn update_account(&self, _account: &AccountAny) -> anyhow::Result<()> {
            Ok(())
        }

        fn update_order(&self, _order_event: &OrderEventAny) -> anyhow::Result<()> {
            Ok(())
        }

        fn update_position(&self, _position: &Position) -> anyhow::Result<()> {
            Ok(())
        }

        fn snapshot_order_state(&self, _order: &OrderAny) -> anyhow::Result<()> {
            Ok(())
        }

        fn snapshot_position_state(&self, _position: &Position) -> anyhow::Result<()> {
            Ok(())
        }

        fn heartbeat(&self, _timestamp: UnixNanos) -> anyhow::Result<()> {
            Ok(())
        }
    }

    #[derive(Debug)]
    struct NoopKernelEventStore;

    impl KernelEventStore for NoopKernelEventStore {
        fn restore_parent_cache(
            &mut self,
            _instance_id: UUID4,
            _cache: &mut Cache,
        ) -> anyhow::Result<()> {
            Ok(())
        }

        fn open(
            &mut self,
            _instance_id: UUID4,
            _components: &RegisteredComponents,
            _environment: Environment,
        ) -> anyhow::Result<()> {
            Ok(())
        }

        fn snapshot_anchorer(&self) -> Option<SnapshotAnchorer> {
            None
        }

        fn seal(&mut self, _ts_init: UnixNanos) {}

        fn run_id(&self) -> Option<&str> {
            None
        }

        fn parent_run_id(&self) -> Option<&str> {
            None
        }

        fn is_halted(&self) -> bool {
            false
        }
    }
}