How belgrano9/discord-bot works
Project Type and Purpose
• This is a full-stack (bot-centric) Python application: a Discord bot that integrates with financial markets APIs to provide real-time stock/crypto data, portfolio management, alerts, reports, and trading functionality.
• Key purpose: expose commands in Discord channels, process them via “cogs,” fetch/process data via API clients, persist configurations and historical data locally, and issue background tasks (alerts, reports, live price streams).
File Structure
• Top-level:
• Dockerfile/docker-compose: container/deployment setup
• pyproject.toml, requirements.txt: Python packaging
• config files: config.py, reports_config.json, stock_alerts.json, .env driven
• discord_bot/: core application
• webapp/: standalone utility scripts (fee calculators)
• tests/: pytest tests
• Within discord_bot/:
• bot.py & logging_setup.py: entrypoint & logging
• api/: HTTP/WS clients for exchanges & financial data
• feature modules (alerts/, portfolio/, price_tracker/, reports/, stocks/, trading/): each has a Cog (Discord command groups), models, services, storage, command handlers, readmes
• utils/: shared helpers (embeds, validation)
README for Additional Insights
• Architecture overview: Discord.py core, API Clients, local file‐storage DB, scheduled tasks, WebSocket integration for live crypto prices.
• Supported exchanges: KuCoin, Bitvavo, Financial Datasets.
• For “Trading,” show sub‐components: MarketService, OrderService, ReactionHandler
• For “Portfolio,” show Calculator, PriceService, Storage
• Configuration flow:
• .env → config.py → passed into API clients at startup
• Test hooks (e.g. test handlers) if desired