From 76a39672beff1b532d079a05cf0e035186a05d4e Mon Sep 17 00:00:00 2001 From: Harwinder Date: Fri, 1 May 2026 17:22:04 -0400 Subject: [PATCH] Remove chart from /signal, explain score bar, and optimize API calls to run concurrently --- main.py | 27 +++++++++++++++++---------- 1 file changed, 17 insertions(+), 10 deletions(-) diff --git a/main.py b/main.py index 41ce2eb..54eb673 100644 --- a/main.py +++ b/main.py @@ -196,10 +196,18 @@ async def chart_cmd(update: Update, ctx: ContextTypes.DEFAULT_TYPE) -> None: async def signal_cmd(update: Update, ctx: ContextTypes.DEFAULT_TYPE) -> None: try: pair, tf = _parse_pair_tf(ctx.args) - df = await fetch_ohlc(pair, tf) - htf = HTF_OF.get(tf) - htf_df = await fetch_ohlc(pair, htf) if htf and htf != tf else None + + # Fetch both timeframes concurrently to double the network speed + import asyncio + if htf and htf != tf: + df, htf_df = await asyncio.gather( + fetch_ohlc(pair, tf), + fetch_ohlc(pair, htf) + ) + else: + df = await fetch_ohlc(pair, tf) + htf_df = None report = analyze(df, htf_df) price = report["price"] @@ -221,12 +229,12 @@ async def signal_cmd(update: Update, ctx: ContextTypes.DEFAULT_TYPE) -> None: "", *_fmt_group(report["readings"], "volatility", "*-- VOLATILITY*"), "", - # Score line — bar + plain-English label so the number has context + "*-- FINAL VERDICT --*", f"`[{_score_bar(report['score'], report['max_score'])}]` " f"{ascii_indicator(verdict)} *{verdict}*", - f"Score `{report['score']:+d}` of +/-`{report['max_score']}` " - f"({_score_label(report['score'], report['max_score'])} signal, " - f"{report['confidence']}% of max)", + f"Score `{report['score']:+d}` of maximum +/-`{report['max_score']}`", + f"_{report['confidence']}% overall strength ({_score_label(report['score'], report['max_score'])} signal)_", + "> _The bar above visualizes the signal strength. The more # symbols, the stronger the conviction. +20 is maximum Buy, -20 is maximum Sell._", ] if report["context"]: @@ -249,9 +257,8 @@ async def signal_cmd(update: Update, ctx: ContextTypes.DEFAULT_TYPE) -> None: f"_ATR-based zones:_ SL `{sl}` | TP `{tp}`", ] - caption = "\n".join(lines) + DISCLAIMER - img = generate_chart(df, pair, tf, verdict=verdict, confidence=report["confidence"]) - await update.message.reply_photo(img, caption=caption, parse_mode="Markdown") + text = "\n".join(lines) + DISCLAIMER + await update.message.reply_text(text, parse_mode="Markdown") except Exception as e: logger.exception("signal_cmd failed") await _reply(update, f"Error: {e}")