AI-powered financial intelligence for Telegram — real-time crypto, forex, stocks, and macro analysis with long-polling on Render.
StrideBot is a Telegram-native bot that delivers financial intelligence across multiple asset classes:
- Crypto — real-time price feeds (Binance → CoinGecko → Kraken), whale activity, and market signals
- Macro — global economic trends and regime analysis
- Forex — currency pair tracking and analysis
- Stocks — equity market intelligence and research
The bot leverages Groq AI for low-latency analysis, EventBus for reactive scheduling, and a multi-tier system for premium features, all orchestrated by a robust Python backend running on Render.
- Python 3.11.15 (via
uvor direct installation) - UV package manager (
curl -LsSf https://astral.sh/uv/install.sh | sh) - .env file with required secrets (see Environment Variables)
# Install dependencies (if not done)
uv sync
# Start the bot
python bot/bot.pyThe bot will:
- Load environment variables and initialize Sentry
- Clear any lingering webhooks
- Set up database and Groq client
- Register commands and event handlers
- Start the health dashboard (HTTP server)
- Begin polling for Telegram updates
# Quick test run
uv run pytest bot/tests/ -v
# With coverage (matches CI pipeline)
uv run pytest bot/tests/ --cov=bot --cov-report=xml --cov-report=term-missing -v# Check code style
uv run ruff check .
uv run ruff format --check .
# Apply formatting
uv run ruff format .Required in .env:
TELEGRAM_BOT_TOKEN=your_telegram_bot_token_here
ADMIN_USER_ID=your_admin_user_id
LOG_LEVEL=INFO
DAILY_AI_CAP=100
# Additional optional variables (Groq, Sentry, etc.) as neededThe single entry point orchestrates:
- Environment loading and Sentry initialization
- SIGTERM trap for graceful shutdown on Render deploys
- Webhook cleanup to avoid polling/webhook conflicts
- Database initialization
- Telegram
ApplicationBuildersetup - Command and handler registration
- Scheduler job wiring
- Health server startup
- Polling retry loop with exponential backoff
client.py— Groq API wrappercontext.py— Conversation context managementpipeline.py— Request/response pipelinesearch.py— Web search integration (Tavily)tiers.py— Token budgeting per user tierbackground.py— Async insight generation
Domain modules for:
users— user accounts and tier managementhistory— conversation historypremium— subscription trackingalerts— price alerts and conditionswatchlist— asset trackingpredictions— forecast storagememory— user preferences and contextanalytics— usage statisticssecurity— rate limiting and auth- And more domain-specific modules
prices.py— Binance → CoinGecko → Kraken chain with 60s TTL cachenews.py— Financial news aggregationforex.py— Currency pair feedsstocks.py— Equity datamarket.py— Market-wide aggregationcircuit_breaker.py— Fault tolerance
core.py— Core command utilities, HTML sanitization, cooldownsmarket.py— Market data commandsalerts.py— Alert managementpremium.py— Premium feature handlersadmin.py— Admin-only commandsguest.py— Guest user handlerssecretary.py— Daily briefing commands- Plus utilities, mini-apps, rate limiting, streaming support
core.py— Scheduling utilities (deduplication, safe sends, cooldowns)posts.py— All post generators (market updates, briefs, etc.)intelligence.py— Breaking news, market signals, trending assets, regime changesalerts.py— Alert checking and triggeringimages.py— Image generation with Pillow
congress.py— Congressional trading analysiswhale.py— Large transaction trackingpolymarket.py— Prediction market datatrends.py— Trend identification and scoringmarket_regime.py— Market regime classificationnews_sources.py— News source credibilityresearch.py— Research paper aggregation
bus.py— Central EventBus for pub/subtypes.py— Event types (AlertTriggered, BreakingNewsDetected, etc.)
System prompts, analysis templates, scheduler prompts, organized by function.
Salience-trimmed memory for multi-turn conversations.
server.py— HTTP health check endpoint and dashboard- Re-exported at top level for easy access
- 27 test files in
bot/tests/ - Fixtures in
bot/tests/conftest.py:mock_db— patchesdatabasemodulemock_ai— patchesaimodulemock_crypto— patchesdatamodulemock_tavily— patches search
- Uses stdlib
monkeypatch, notunittest.mock - No
pytest.inineeded; config inpyproject.toml[tool.coverage.*]sections
uv run pytest bot/tests/test_handlers.py -v -k "test_market_command".github/workflows/ci.yml runs on PRs to main/master/dev:
- Lint —
ruff check+ruff format --check - Syntax —
ast.parseon all changed.pyfiles - Test — Full pytest suite with coverage
- Test Baseline — Non-blocking baseline on base branch
- Coverage Gate — Regression check, requires ≥80% diff coverage
Single required status check: ci-required (aggregator job)
StrideBot deploys on Render with long-polling:
- Start Command:
python bot/bot.py - Environment: Python 3.11.15
- Health Endpoint: HTTP dashboard at configured port
- Graceful Shutdown: SIGTERM/SIGINT trap calls
os._exit(0)for immediate stop
clear_webhook()called at module load time to avoid polling/webhook conflicts- SIGTERM handler ensures immediate shutdown on Render restarts
- Webhook setup is disabled; polling is the transport layer
This is intentional and critical. The absence of bot/__init__.py allows:
- Pytest's prepend-mode to add
bot/tosys.pathonly once - Tests to use bare imports (
import database,import handlers, etc.) bot/bot.pyto use bare imports when executed directly
Creating bot/__init__.py will break the test suite. See docs/specs/ci-pipeline-spec.md for full details.
✅ Real-Time Market Data — Multi-source price feeds with intelligent fallback
✅ AI Analysis — Groq-powered insights with token budgeting
✅ Event-Driven — Reactive scheduler via EventBus
✅ Premium Tiers — Multi-tier feature access control
✅ Whale Tracking — Large transaction alerts
✅ News Intelligence — Breaking news detection and delivery
✅ Rate Limiting — Per-user and global cooldowns
✅ Memory Management — Salience-trimmed context windows
✅ Health Monitoring — Dedicated health dashboard
✅ Graceful Shutdown — Clean Render deploys
- Language: Python 97.2%, HTML 2.7%
- Python Version: 3.11.15
- Test Coverage: Enforced ≥80% on new lines
- Test Files: 27
- Linter: Ruff
- Package Manager: UV
- Create a feature branch
- Write tests for new code (required for CI)
- Run
uv run pytest bot/tests/ -vlocally - Ensure
ruff check .andruff format .pass - Submit a PR to
main/dev - CI pipeline must pass (lint, syntax, test, coverage)
See LICENSE file (if present) for details.
For issues, questions, or feature requests, please open a GitHub issue in this repository.
Happy trading! 📈🚀