Skip to content

Commit 2ef7a5e

Browse files
committed
add before bar
1 parent 1777708 commit 2ef7a5e

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed

demeter/core/actuator.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -425,6 +425,9 @@ def run(self, print_result: bool = True):
425425
# execute strategy, and some calculate
426426
self._currents.timestamp = timestamp_index.to_pydatetime()
427427
snapshot = self.__get_snapshot(timestamp_index, row_id, current_price)
428+
429+
self._strategy.before_bar(snapshot)
430+
428431
if self._strategy.triggers:
429432
for trigger in self._strategy.triggers:
430433
if trigger.when(snapshot):

demeter/strategy/strategy.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,12 @@ def initialize(self):
3737
"""
3838
pass
3939

40+
def before_bar(self, snapshot: Snapshot):
41+
"""
42+
Called before trigger and on_bar on each iteration
43+
"""
44+
pass
45+
4046
def on_bar(self, snapshot: Snapshot):
4147
"""
4248
Called after triggers on each iteration, at this time, market are not updated yet(Take uniswap market for example, fee of this minute are not added to positions).

0 commit comments

Comments
 (0)