@@ -25,9 +25,9 @@ use std::{
25
25
rc:: Rc ,
26
26
} ;
27
27
28
- use nautilus_common:: cache:: Cache ;
28
+ use nautilus_common:: { cache:: Cache , clock :: Clock } ;
29
29
use nautilus_core:: {
30
- AtomicTime , UnixNanos ,
30
+ UnixNanos ,
31
31
correctness:: { FAILED , check_equal} ,
32
32
} ;
33
33
use nautilus_execution:: {
@@ -105,7 +105,7 @@ pub struct SimulatedExchange {
105
105
matching_engines : HashMap < InstrumentId , OrderMatchingEngine > ,
106
106
leverages : HashMap < InstrumentId , Decimal > ,
107
107
modules : Vec < Box < dyn SimulationModule > > ,
108
- clock : & ' static AtomicTime ,
108
+ clock : Rc < RefCell < dyn Clock > > ,
109
109
cache : Rc < RefCell < Cache > > ,
110
110
message_queue : VecDeque < TradingCommand > ,
111
111
inflight_queue : BinaryHeap < InflightCommand > ,
@@ -134,7 +134,7 @@ impl SimulatedExchange {
134
134
leverages : HashMap < InstrumentId , Decimal > ,
135
135
modules : Vec < Box < dyn SimulationModule > > ,
136
136
cache : Rc < RefCell < Cache > > ,
137
- clock : & ' static AtomicTime ,
137
+ clock : Rc < RefCell < dyn Clock > > ,
138
138
fill_model : FillModel ,
139
139
fee_model : FeeModelAny ,
140
140
book_type : BookType ,
@@ -249,7 +249,7 @@ impl SimulatedExchange {
249
249
self . book_type ,
250
250
self . oms_type ,
251
251
self . account_type ,
252
- self . clock ,
252
+ self . clock . clone ( ) ,
253
253
Rc :: clone ( & self . cache ) ,
254
254
matching_engine_config,
255
255
) ;
@@ -380,7 +380,7 @@ impl SimulatedExchange {
380
380
vec ! [ current_balance] ,
381
381
margins. values ( ) . copied ( ) . collect ( ) ,
382
382
true ,
383
- self . clock . get_time_ns ( ) ,
383
+ self . clock . borrow ( ) . timestamp_ns ( ) ,
384
384
)
385
385
. unwrap ( ) ;
386
386
}
@@ -606,7 +606,7 @@ impl SimulatedExchange {
606
606
}
607
607
608
608
pub fn process ( & mut self , ts_now : UnixNanos ) {
609
- self . clock . set_time ( ts_now) ;
609
+ // TODO implement correct clock fixed time setting self.clock.set_time(ts_now);
610
610
611
611
// Process inflight commands
612
612
while let Some ( inflight) = self . inflight_queue . peek ( ) {
@@ -684,7 +684,7 @@ impl SimulatedExchange {
684
684
685
685
if let Some ( exec_client) = & self . exec_client {
686
686
exec_client
687
- . generate_account_state ( balances, vec ! [ ] , true , self . clock . get_time_ns ( ) )
687
+ . generate_account_state ( balances, vec ! [ ] , true , self . clock . borrow ( ) . timestamp_ns ( ) )
688
688
. unwrap ( ) ;
689
689
}
690
690
@@ -766,7 +766,7 @@ mod tests {
766
766
cache : Option < Rc < RefCell < Cache > > > ,
767
767
) -> Rc < RefCell < SimulatedExchange > > {
768
768
let cache = cache. unwrap_or ( Rc :: new ( RefCell :: new ( Cache :: default ( ) ) ) ) ;
769
-
769
+ let clock = Rc :: new ( RefCell :: new ( TestClock :: new ( ) ) ) ;
770
770
let exchange = Rc :: new ( RefCell :: new (
771
771
SimulatedExchange :: new (
772
772
venue,
@@ -778,7 +778,7 @@ mod tests {
778
778
HashMap :: new ( ) ,
779
779
vec ! [ ] ,
780
780
cache. clone ( ) ,
781
- & ATOMIC_TIME ,
781
+ clock ,
782
782
FillModel :: default ( ) ,
783
783
FeeModelAny :: MakerTaker ( MakerTakerFeeModel ) ,
784
784
book_type,
0 commit comments