File tree Expand file tree Collapse file tree 2 files changed +46
-1
lines changed
Expand file tree Collapse file tree 2 files changed +46
-1
lines changed Original file line number Diff line number Diff line change @@ -4355,7 +4355,7 @@ cdef class Actor(Component):
43554355
43564356 # Update indicators
43574357 cdef list indicators = self ._indicators_for_bars.get(bar.bar_type.id_spec_key())
4358- if indicators:
4358+ if indicators and not bar.is_revision :
43594359 self ._handle_indicators_for_bar(indicators, bar)
43604360
43614361 if historical:
Original file line number Diff line number Diff line change 3333from nautilus_trader .data .engine import DataEngine
3434from nautilus_trader .data .messages import DataResponse
3535from nautilus_trader .execution .engine import ExecutionEngine
36+ from nautilus_trader .indicators .base import Indicator
3637from nautilus_trader .model .currencies import EUR
3738from nautilus_trader .model .currencies import USD
3839from nautilus_trader .model .data import Bar
@@ -1208,6 +1209,50 @@ def test_handle_bar_when_running_sends_to_on_bar(self) -> None:
12081209 assert actor .calls == ["on_start" , "on_bar" ]
12091210 assert actor .store [0 ] == bar
12101211
1212+ def test_handle_bar_does_not_update_indicators_for_revision_bars (self ) -> None :
1213+ class CountingIndicator (Indicator ):
1214+ def __init__ (self ):
1215+ super ().__init__ ([])
1216+ self .calls = 0
1217+
1218+ def handle_bar (self , bar ):
1219+ self .calls += 1
1220+
1221+ def _reset (self ):
1222+ self .calls = 0
1223+
1224+ # Arrange
1225+ actor = Actor (config = ActorConfig (component_id = self .component_id ))
1226+ actor .register_base (
1227+ portfolio = self .portfolio ,
1228+ msgbus = self .msgbus ,
1229+ cache = self .cache ,
1230+ clock = self .clock ,
1231+ )
1232+
1233+ bar = TestDataStubs .bar_5decimal ()
1234+ actor .register_indicator_for_bars (bar .bar_type , CountingIndicator ())
1235+ indicator = actor .registered_indicators [0 ]
1236+
1237+ revision_bar = Bar (
1238+ bar_type = bar .bar_type ,
1239+ open = bar .open ,
1240+ high = bar .high ,
1241+ low = bar .low ,
1242+ close = bar .close ,
1243+ volume = bar .volume ,
1244+ ts_event = bar .ts_event ,
1245+ ts_init = bar .ts_init ,
1246+ is_revision = True ,
1247+ )
1248+
1249+ # Act
1250+ actor .handle_bar (revision_bar )
1251+ actor .handle_bar (bar )
1252+
1253+ # Assert
1254+ assert indicator .calls == 1
1255+
12111256 def test_handle_bars (self ) -> None :
12121257 # Arrange
12131258 actor = MockActor ()
You can’t perform that action at this time.
0 commit comments