Commit ·
6a1b2b8
1
Parent(s): 2b13083
Scan alerts: symbols link to thumbnail chart
Browse files- modules/telegram_alert.py +10 -2
modules/telegram_alert.py
CHANGED
|
@@ -6,6 +6,14 @@ def _creds():
|
|
| 6 |
chat = os.environ.get("TELEGRAM_CHAT_ID", "")
|
| 7 |
return token, chat
|
| 8 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 9 |
def send_telegram_message(text: str) -> bool:
|
| 10 |
"""Send an HTML-formatted message to the configured Telegram chat."""
|
| 11 |
token, chat = _creds()
|
|
@@ -47,7 +55,7 @@ def format_buy_signals(scan_data: dict) -> str:
|
|
| 47 |
|
| 48 |
for r in signals:
|
| 49 |
lines.append(
|
| 50 |
-
f"• <b>{r['symbol']}</b> — "
|
| 51 |
f"Z:<code>{r['zscore']}</code> | "
|
| 52 |
f"RSI:<code>{r['rsi']}</code> | "
|
| 53 |
f"Mom:<code>{r['momentum']}%</code> | "
|
|
@@ -110,7 +118,7 @@ def format_scan_summary(scan_data: dict) -> str:
|
|
| 110 |
except (TypeError, ValueError):
|
| 111 |
_sc_txt = str(_sc)
|
| 112 |
header += ("\nHighest scoring coin was <b>"
|
| 113 |
-
+
|
| 114 |
+ "</b> with a score of <b>" + _sc_txt + "</b>")
|
| 115 |
# report the actual blocking criterion for the top coin
|
| 116 |
_crit = {"conservative": {"zscore": -1.0, "momentum": 5.0,
|
|
|
|
| 6 |
chat = os.environ.get("TELEGRAM_CHAT_ID", "")
|
| 7 |
return token, chat
|
| 8 |
|
| 9 |
+
def _sym_link(sym):
|
| 10 |
+
"""Symbol as a clickable link to its 24h thumbnail chart."""
|
| 11 |
+
import urllib.parse as _up
|
| 12 |
+
s = str(sym)
|
| 13 |
+
return ('<a href="https://charts.blind-monkeys.com/grid/symbol-chart?symbol='
|
| 14 |
+
+ _up.quote(s) + '">' + s + '</a>')
|
| 15 |
+
|
| 16 |
+
|
| 17 |
def send_telegram_message(text: str) -> bool:
|
| 18 |
"""Send an HTML-formatted message to the configured Telegram chat."""
|
| 19 |
token, chat = _creds()
|
|
|
|
| 55 |
|
| 56 |
for r in signals:
|
| 57 |
lines.append(
|
| 58 |
+
f"• <b>{_sym_link(r['symbol'])}</b> — "
|
| 59 |
f"Z:<code>{r['zscore']}</code> | "
|
| 60 |
f"RSI:<code>{r['rsi']}</code> | "
|
| 61 |
f"Mom:<code>{r['momentum']}%</code> | "
|
|
|
|
| 118 |
except (TypeError, ValueError):
|
| 119 |
_sc_txt = str(_sc)
|
| 120 |
header += ("\nHighest scoring coin was <b>"
|
| 121 |
+
+ _sym_link(top.get("symbol", "?"))
|
| 122 |
+ "</b> with a score of <b>" + _sc_txt + "</b>")
|
| 123 |
# report the actual blocking criterion for the top coin
|
| 124 |
_crit = {"conservative": {"zscore": -1.0, "momentum": 5.0,
|