An automated Twitter bot that posts regular Bitcoin price updates with detailed metrics and analytics.
- Automated Bitcoin price tracking and reporting
- Multiple message formats:
- Standard format (50% probability): Price and price changes across different time periods
- Detailed format (30% probability): Focused on supply metrics, volume, market cap, ATH and key performance indicators
- Blocks format (20% probability): Bitcoin blockchain statistics, block height, halving countdown
- Market analysis with top movers report
- Data sourced from CoinMarketCap API for current prices and metrics
- Historical data from Yahoo Finance for long-term analysis
- Automatic tweet posting (with mock option for testing)
- GitHub Actions integration for scheduled posts
- Python 3.8+
- Twitter API credentials
- CoinMarketCap API key
- Clone the repository
- Install dependencies:
pip install -r requirements.txt - Configure environment variables:
- Copy
.env.exampleto.env - Fill in your API keys in the
.envfile
- Copy
Run the bot locally with:
python main.py
This will:
- Fetch current Bitcoin data from CoinMarketCap
- Generate a tweet with either standard or detailed format (randomly selected)
- Post the tweet to the configured Twitter account
- Generate and post a market analysis of top movers
This repo is configured to run automatically using GitHub Actions. To set this up:
- Go to your GitHub repository's Settings tab
- Click on "Secrets and variables" → "Actions"
- Add the following repository secrets:
BTC_ACCESS_TOKENBTC_ACCESS_TOKEN_SECRETBTC_BEARERBTC_API_KEYBTC_API_KEY_SECRETNEWS_ACCESS_TOKENNEWS_ACCESS_TOKEN_SECRETNEWS_BEARERNEWS_API_KEYNEWS_API_KEY_SECRETCMC_API_KEY
The workflow is configured to run every 6 hours and can also be triggered manually from the Actions tab.
main.py- Entry point for the applicationsrc/crypto_tracker.py- Bitcoin price and metrics trackingtwitter_client.py- Twitter API interactionmarket_analyzer.py- Market analysis functionality
config/api_keys.py- Loads API credentials from environment variablesconstants.py- Application constants and emojis
.github/workflows/bitcoin_tweet.yml- GitHub Actions workflow configuration
docs/workflow.drawio- Visual diagram of the application flow
- API keys are stored as GitHub Actions secrets and never committed to the repository
- For local development, use the
.envfile (which is ignored by git) - The
.env.examplefile provides a template for required environment variables
MIT