17
17
#![ allow( dead_code) ]
18
18
#![ allow( unused_variables) ]
19
19
20
+ use std:: { cell:: RefCell , rc:: Rc } ;
21
+
22
+ use nautilus_common:: {
23
+ cache:: { Cache , CacheConfig , database:: CacheDatabaseAdapter } ,
24
+ clock:: Clock ,
25
+ } ;
20
26
use nautilus_core:: UUID4 ;
21
27
use nautilus_data:: engine:: DataEngine ;
28
+ use nautilus_execution:: engine:: ExecutionEngine ;
29
+ use nautilus_model:: identifiers:: TraderId ;
22
30
use ustr:: Ustr ;
23
31
24
32
use crate :: config:: NautilusKernelConfig ;
@@ -27,27 +35,61 @@ use crate::config::NautilusKernelConfig;
27
35
pub struct NautilusKernel {
28
36
pub name : Ustr ,
29
37
pub instance_id : UUID4 ,
38
+ pub config : NautilusKernelConfig ,
30
39
pub data_engine : DataEngine ,
31
- config : NautilusKernelConfig ,
40
+ pub exec_engine : ExecutionEngine ,
41
+ pub cache : Rc < RefCell < Cache > > ,
42
+ pub clock : Rc < RefCell < dyn Clock > > ,
32
43
}
33
44
34
45
impl NautilusKernel {
35
46
#[ must_use]
36
47
pub fn new ( name : Ustr , config : NautilusKernelConfig ) -> Self {
37
48
let instance_id = config. instance_id . unwrap_or_default ( ) ;
38
49
let data_engine = Self :: initialize_data_engine ( ) ;
50
+ let exec_engine = Self :: initialize_exec_engine ( ) ;
51
+ let cache = Self :: initialize_cache ( config. trader_id , & instance_id, config. cache . clone ( ) ) ;
52
+ let clock = Self :: initialize_clock ( ) ;
39
53
Self {
40
54
name,
41
55
instance_id,
42
56
data_engine,
57
+ exec_engine,
43
58
config,
59
+ cache,
60
+ clock,
44
61
}
45
62
}
46
63
64
+ fn initialize_clock ( ) -> Rc < RefCell < dyn Clock > > {
65
+ todo ! ( "initialize_clock" )
66
+ }
67
+
68
+ fn initialize_cache (
69
+ trader_id : TraderId ,
70
+ instance_id : & UUID4 ,
71
+ cache_config : Option < CacheConfig > ,
72
+ ) -> Rc < RefCell < Cache > > {
73
+ let cache_config = cache_config. unwrap_or_default ( ) ;
74
+ let cache_database: Option < Box < dyn CacheDatabaseAdapter > > =
75
+ if let Some ( cache_database_config) = & cache_config. database {
76
+ todo ! ( "initialize_cache_database" )
77
+ } else {
78
+ None
79
+ } ;
80
+
81
+ let cache = Cache :: new ( Some ( cache_config) , cache_database) ;
82
+ Rc :: new ( RefCell :: new ( cache) )
83
+ }
84
+
47
85
fn initialize_data_engine ( ) -> DataEngine {
48
86
todo ! ( "initialize_data_engine" )
49
87
}
50
88
89
+ fn initialize_exec_engine ( ) -> ExecutionEngine {
90
+ todo ! ( "initialize_exec_engine" )
91
+ }
92
+
51
93
fn start ( & self ) {
52
94
todo ! ( "implement start" )
53
95
}
0 commit comments