[Python] trying to create a Telegram Call and Channel analyzer for Solana Memecoins

Discussão em 'Python' iniciado por Stack, Setembro 10, 2025.

  1. Stack

    Stack Membro Participativo

    For weeks I have been trying to create a script to analyze telegram calls and channels for Solana memecoins. The call scraping function works fine but the metrics never come our right. No matter what API source I try to use I always get errors. Here is exactly what I need if there is anyone who can help..

    build a bug-free production-ready Python script that analyzes Solana memecoin calls from Telegram channels. The script should combine Telegram scraping, price history analysis, ROI metrics, ATH detection, drawdown calculations, liquidity/safety checks, and per-channel aggregation.

    Please follow this exact specification:

    It must:

    • Use Telethon with an existing session file (not new login).
    • Be asyncio-based with efficient batching and checkpointing.
    • Produce complete metrics without missing values.
    • Output per-call audit CSV + per-channel leaderboard CSV.

    Inputs

    • CSV file usernames.csv with column username (Telegram handles).
    • Existing Telethon session file for login.
    • Configurable options: days of history, max messages per channel, concurrency, cache toggle, database toggle.

    Telegram Scraper

    • Use Telethon with session string/file.
    • Scrape last N days of messages per channel (configurable).
    • Extract all Solana mint addresses (32–44 base58).
    • For each valid mint call, collect:
      • channel_username
      • message_id
      • message_timestamp
      • message_excerpt (truncate 500 chars)
      • deep_link
      • mint_address

    Deduplicate calls on (channel_username, message_id, mint_address).

    Per-Call Metrics (include all of the following)

    • price_at_call
    • price_at_call_ts
    • price_at_call_source
    • ath_price
    • ath_timestamp
    • current_price
    • roi_ath
    • roi_current
    • ath_time_to_peak
    • market_cap_ath
    • volume_24h_ath
    • liquidity
    • safety_score
    • rugcheck_score
    • tokensniffer_score

    Price & ROI Engine

    • Use at least FOUR APIs (Birdeye, DexScreener, GeckoTerminal - SOURMUST HAVE HISTORICAL PRICE DATA FOR NEW AND/OR LOW CAP SOLANA MEMECOINS, BE ABLE TO OBTAIN PRICE AT SPECIFIC TIME, MUST BE ABLE TO GET ATH DATA).
    • Apply retries + fallback if one fails.
    • Compute metrics:
      • Entry price: last 1m candle before call timestamp.
      • ROI windows: 5m, 30m, 1h, 4h, 24h after call.
      • ATH:
        • Scan candles after call timestamp.
        • Record ath_price, ath_timestamp, roi_ath, time_to_ath.
      • Drawdown: lowest price in 6h window after entry.

    Safety Checks

    • Query RugCheck, TokenSniffer, Ave.ai, AND ANY OTHER ADDITIONAL SOURCES, etc.
    • Normalize into 0–100 safety score.
    • Collect:
      • rugcheck_score
      • tokensniffer_score
      • ai_safety_score
      • lp_lock_percent
      • top10_holders_percent
    • Add heuristic:
      • If drawdown_6h <= -90% → set rug_flag=1.

    Liquidity & Fundamentals

    • Collect (from DexScreener / Raydium / [Pump.fun] AND/OR ANY OTHER SOURCES THAT PROVIDE THE NECESSARY INFO):
      • liquidity_usd
      • 24h_volume
      • market_cap_at_call
      • market_cap_ath

    Per-Channel Aggregation

    For each channel:

    • total_calls
    • successful_calls
    • avg_roi_1h, avg_roi_24h, avg_roi_ath
    • median_roi_1h, median_roi_24h, median_roi_ath
    • win_rates (% reaching >1x, 2x, 5x, 10x ATH)
    • rug_rate (% flagged rugs)
    • avg_safety_score
    • avg_time_to_ath
    • avg_ath_market_ca
    • calls_with_ath
    • avg_roi_current
    • ath_win_rate
    • two_x_ath_rate
    • five_x_ath_rate
    • ten_x_ath_rate
    • avg_time_to_ath
    • survivorship_rate
    • avg_market_cap_ath
    • consistency_score
    • outlier_dependence
    • discrepancy_score

    Outputs

    1. Per-call CSV (per_call_audit.csv)
      • All raw + derived metrics per mint call.
    2. Per-channel CSV (per_channel_leaderboard.csv)
      • Aggregated stats per channel.
    3. Log file (analyzer.log)
      • Errors, retries, skipped calls.
    4. Cache file (cache.json)
      • Prevent duplicate analysis of the same mint.

    Robustness

    • Retries (3×, exponential backoff).
    • Fallback between APIs.
    • Skip bad data gracefully (never crash).
    • Detect and filter invalid data:

      • ROI > 10,000× → ignore.


      • Market cap > $1B → ignore.


      • Checkpointing for resume support.


      • SQLite or other DB backend optional, but CSV export required.

    Deliverable

    • Single Python script using asyncio.
    • Runs with python script.py.
    • Produces 2 CSVs every run with no missing data.
    • Well-commented and easy to maintain.

    Please generate the complete working script following this exact spec.


    Problems Encountered

    1. No Rug/Safety Info

    • RugCheck and TokenSniffer often return None or partial data.
    • APIs sometimes change endpoints or rate-limit heavily.
    • Your pipeline falls back poorly: if RugCheck fails, it doesn’t retry another provider.
    • Safety scores are often empty → rug rate and avg safety become useless.
    2. Inaccurate ROI & Prices

    • Price-at-call is unreliable:
      • Wrong candle resolution (using 1h instead of 1m).
      • Inconsistent timezones / unix timestamps.
      • Sometimes takes the nearest future candle instead of last closed before the call.
    • Current prices overwrite entry prices, so ROI is skewed.
    • ATH often equals current price because historical peak isn’t calculated correctly.
    3. Missing ATH Data

    • ATH fetches from DexScreener/Birdeye/GeckoTerminal are inconsistent.
    • If one fails, script doesn’t aggregate others.
    • ATH timestamp not properly aligned → “time-to-ATH” is missing or negative.
    4. No Price at Call Time

    • Many calls end up with price_at_call=None.
    • Missing entry price → ROI is invalid or set to 0.
    • Candlestick fetching window too narrow (±5 min) → often misses relevant data.
    5. Channel Summary CSV Incomplete

    • Some metrics (win rates, rug rate, time-to-ATH) are missing or always None.
    • Survivorship calculation is inconsistent (sometimes divides by 0).
    • Outlier filtering is weak → unrealistic ROI (10000x+) corrupts averages.
    6. Other Issues

    • Concurrency not tuned → occasional rate limits, skipped channels.
    • Cache system doesn’t de-dupe well; duplicate mint calls are analyzed separately.
    • Error handling inconsistent: some exceptions are logged, others silently skipped.
    • No clear backup/fallback strategy for each metric.

    I tried scripts from chatgpt, grok, copilot, deep seek, claude.. I was expecting csv output files with the metrics previously mentioned.

    Continue reading...

Compartilhe esta Página