Skip to content

Commit

Permalink
prevent strategy from self trigger
Browse files Browse the repository at this point in the history
  • Loading branch information
Guillaume De Saint Martin committed Apr 28, 2020
1 parent cd30567 commit 2ca3d69
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 6 deletions.
7 changes: 5 additions & 2 deletions octobot_evaluators/evaluator/abstract_evaluator.py
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,8 @@ async def evaluation_completed(self,
time_frame=None,
eval_note=None,
eval_time=0,
notify=True) -> None:
notify=True,
origin_consumer=None) -> None:
"""
Main async method to notify matrix to update
:param cryptocurrency: evaluated cryptocurrency
Expand All @@ -166,6 +167,7 @@ async def evaluation_completed(self,
:param eval_note: if None = self.eval_note
:param eval_time: the time of the evaluation if relevant, default is 0
:param notify: if true, will trigger matrix consumers
:param origin_consumer: the sender consumer if it doesn't want to be notified
:return: None
"""
try:
Expand All @@ -184,7 +186,8 @@ async def evaluation_completed(self,
cryptocurrency=cryptocurrency,
symbol=symbol,
time_frame=time_frame,
notify=notify)
notify=notify,
origin_consumer=origin_consumer)
except Exception as e:
# if ConfigManager.is_in_dev_mode(self.config): # TODO
# raise e
Expand Down
27 changes: 23 additions & 4 deletions octobot_evaluators/evaluator/strategy_evaluator.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,29 @@ async def start(self, bot_id: str) -> bool:
self.strategy_matrix_callback)
return True

async def strategy_completed(self,
cryptocurrency: str = None,
symbol: str = None,
eval_note=None,
eval_time=0,
notify=True) -> None:
"""
Main async method to notify that a strategy has updated its evaluation
:param cryptocurrency: evaluated cryptocurrency
:param symbol: evaluated symbol
:param eval_note: if None = self.eval_note
:param eval_time: the time of the evaluation if relevant, default is 0
:param notify: if true, will trigger matrix consumers
:return: None
"""
return await self.evaluation_completed(cryptocurrency=cryptocurrency,
symbol=symbol,
time_frame=None,
eval_note=eval_note,
eval_time=eval_time,
notify=notify,
origin_consumer=self.consumer_instance)

def is_technical_evaluator_cycle_complete(self, matrix_id, evaluator_name, evaluator_type, exchange_name,
cryptocurrency, symbol, time_frame) -> bool:
"""
Expand Down Expand Up @@ -98,10 +121,6 @@ async def strategy_matrix_callback(self,
cryptocurrency,
symbol,
time_frame):
# TODO: find better way than this if
# avoid self-calls
if evaluator_name == self.get_name():
return
# if this callback is from a technical evaluator: ensure strategy should be notified at this moment
if evaluator_type == EvaluatorMatrixTypes.TA.value:
# ensure this time frame is within the strategy's time frames
Expand Down

0 comments on commit 2ca3d69

Please sign in to comment.