Skip to content

Commit fe343cc

Browse files
committed
Improve alert message to be more descriptive
1 parent 56eabb7 commit fe343cc

File tree

1 file changed

+13
-6
lines changed

1 file changed

+13
-6
lines changed

exchange_radar/scheduler/alerts/market_sentiment.py

+13-6
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,12 @@
1616

1717

1818
def _get_message(
19-
coin: str, currency: str, increase_in_percentage: float, *, indicator: dict[str, int | float]
19+
coin: str,
20+
currency: str,
21+
increase_in_percentage: float,
22+
frequency_in_minutes: int,
23+
*,
24+
indicator: dict[str, int | float],
2025
) -> str | None:
2126
key, value = next(iter(indicator.items()))
2227

@@ -30,26 +35,28 @@ def _get_message(
3035
ratio_abs = abs(ratio)
3136

3237
if ratio_abs < increase_in_percentage:
33-
logger.info(f"No new {key.upper()} Alerts for {coin}. Ratio is {ratio}.")
38+
logger.info(
39+
f"No new {key.upper()} alerts for coin:{coin}; frequency_in_minutes:{frequency_in_minutes} ratio: {ratio}."
40+
)
3441
return None
3542

3643
verb = "increased" if ratio > 0 else "decreased"
37-
return f"The {key.upper()} {verb} {ratio_abs:.2f}%"
44+
return f"The {key.upper()} {verb} {ratio_abs:.2f}% in the last {frequency_in_minutes} minute(s)"
3845

3946

4047
@huey.periodic_task(crontab(minute="*/1"))
4148
@huey.lock_task(TASK_LOCK)
4249
def bullish_or_bearish__1_min():
43-
task(increase_in_percentage=1.0)
50+
task(increase_in_percentage=1.0, frequency_in_minutes=1)
4451

4552

4653
@huey.periodic_task(crontab(minute="*/10"))
4754
@huey.lock_task(TASK_LOCK)
4855
def bullish_or_bearish__10_min():
49-
task(increase_in_percentage=4.0)
56+
task(increase_in_percentage=4.0, frequency_in_minutes=10)
5057

5158

52-
def task(*, increase_in_percentage: float):
59+
def task(*, increase_in_percentage: float, frequency_in_minutes: int):
5360
name = datetime.today().date().strftime("%Y-%m-%d")
5461

5562
with redis.pipeline() as pipe:

0 commit comments

Comments
 (0)