@@ -110,6 +110,8 @@ pub trait BarAggregator: Any + Debug {
110110 /// Sets the weak reference to the aggregator wrapper (for historical mode).
111111 /// Default implementation does nothing, `TimeBarAggregator` overrides.
112112 fn set_aggregator_weak ( & mut self , _weak : Weak < RefCell < Box < dyn BarAggregator > > > ) { }
113+ /// Configures the continuous-future price adjustment for the underlying builder.
114+ fn set_adjustment ( & mut self , _adjustment : Decimal , _mode : ContinuousFutureAdjustmentType ) { }
113115}
114116
115117impl dyn BarAggregator {
@@ -427,6 +429,10 @@ impl BarAggregatorCore {
427429 let bar = self . builder . build ( ts_event, ts_init) ;
428430 ( self . handler ) ( bar) ;
429431 }
432+
433+ fn set_adjustment ( & mut self , adjustment : Decimal , mode : ContinuousFutureAdjustmentType ) {
434+ self . builder . set_adjustment ( adjustment, mode) ;
435+ }
430436}
431437
432438macro_rules! impl_set_historical_handler {
@@ -437,6 +443,14 @@ macro_rules! impl_set_historical_handler {
437443 } ;
438444}
439445
446+ macro_rules! impl_set_adjustment {
447+ ( ) => {
448+ fn set_adjustment( & mut self , adjustment: Decimal , mode: ContinuousFutureAdjustmentType ) {
449+ self . core. set_adjustment( adjustment, mode) ;
450+ }
451+ } ;
452+ }
453+
440454/// Provides a means of building tick bars aggregated from quote and trades.
441455///
442456/// When received tick count reaches the step threshold of the bar
@@ -485,6 +499,7 @@ impl BarAggregator for TickBarAggregator {
485499 }
486500
487501 impl_set_historical_handler ! ( ) ;
502+ impl_set_adjustment ! ( ) ;
488503
489504 /// Apply the given update to the aggregator.
490505 fn update ( & mut self , price : Price , size : Quantity , ts_init : UnixNanos ) {
@@ -557,6 +572,7 @@ impl BarAggregator for TickImbalanceBarAggregator {
557572 }
558573
559574 impl_set_historical_handler ! ( ) ;
575+ impl_set_adjustment ! ( ) ;
560576
561577 /// Apply the given update to the aggregator.
562578 ///
@@ -644,6 +660,7 @@ impl BarAggregator for TickRunsBarAggregator {
644660 }
645661
646662 impl_set_historical_handler ! ( ) ;
663+ impl_set_adjustment ! ( ) ;
647664
648665 /// Apply the given update to the aggregator.
649666 ///
@@ -738,6 +755,7 @@ impl BarAggregator for VolumeBarAggregator {
738755 }
739756
740757 impl_set_historical_handler ! ( ) ;
758+ impl_set_adjustment ! ( ) ;
741759
742760 /// Apply the given update to the aggregator.
743761 fn update ( & mut self , price : Price , size : Quantity , ts_init : UnixNanos ) {
@@ -852,6 +870,7 @@ impl BarAggregator for VolumeImbalanceBarAggregator {
852870 }
853871
854872 impl_set_historical_handler ! ( ) ;
873+ impl_set_adjustment ! ( ) ;
855874
856875 /// Apply the given update to the aggregator.
857876 ///
@@ -957,6 +976,7 @@ impl BarAggregator for VolumeRunsBarAggregator {
957976 }
958977
959978 impl_set_historical_handler ! ( ) ;
979+ impl_set_adjustment ! ( ) ;
960980
961981 /// Apply the given update to the aggregator.
962982 ///
@@ -1074,6 +1094,7 @@ impl BarAggregator for ValueBarAggregator {
10741094 }
10751095
10761096 impl_set_historical_handler ! ( ) ;
1097+ impl_set_adjustment ! ( ) ;
10771098
10781099 /// Apply the given update to the aggregator.
10791100 fn update ( & mut self , price : Price , size : Quantity , ts_init : UnixNanos ) {
@@ -1220,6 +1241,7 @@ impl BarAggregator for ValueImbalanceBarAggregator {
12201241 }
12211242
12221243 impl_set_historical_handler ! ( ) ;
1244+ impl_set_adjustment ! ( ) ;
12231245
12241246 /// Apply the given update to the aggregator.
12251247 ///
@@ -1388,6 +1410,7 @@ impl BarAggregator for ValueRunsBarAggregator {
13881410 }
13891411
13901412 impl_set_historical_handler ! ( ) ;
1413+ impl_set_adjustment ! ( ) ;
13911414
13921415 /// Apply the given update to the aggregator.
13931416 ///
@@ -1529,6 +1552,7 @@ impl BarAggregator for RenkoBarAggregator {
15291552 }
15301553
15311554 impl_set_historical_handler ! ( ) ;
1555+ impl_set_adjustment ! ( ) ;
15321556
15331557 /// Apply the given update to the aggregator.
15341558 ///
@@ -2055,6 +2079,10 @@ impl BarAggregator for TimeBarAggregator {
20552079 fn start_timer ( & mut self , aggregator_rc : Option < Rc < RefCell < Box < dyn BarAggregator > > > > ) {
20562080 self . start_timer_internal ( aggregator_rc) ;
20572081 }
2082+
2083+ fn set_adjustment ( & mut self , adjustment : Decimal , mode : ContinuousFutureAdjustmentType ) {
2084+ self . core . set_adjustment ( adjustment, mode) ;
2085+ }
20582086}
20592087
20602088fn is_below_min_size ( size : f64 , precision : u8 ) -> bool {
0 commit comments