This project is a Streamlit web application that provides a comprehensive analysis of major cryptocurrencies. It fetches real-time tweet data from the X (formerly Twitter) API and financial data from Yahoo Finance to deliver insights into market sentiment, price trends, and public discussion topics.
- Real-time Sentiment Analysis: Analyzes recent tweets for a selected cryptocurrency to determine public sentiment (Positive, Negative, Neutral) using VADER.
- Financial Charting: Displays historical price data with moving averages (20-day and 50-day) to identify trends.
- Key Metrics Dashboard: At-a-glance metrics including average sentiment, latest price, annualized volatility, and tweet sentiment distribution.
- Comparative Analysis: Side-by-side comparison of sentiment and volatility for two different cryptocurrencies.
- Deeper NLP Insights: Utilizes LDA (Latent Dirichlet Allocation) for topic modeling to uncover key themes in conversations about a cryptocurrency.
- Frontend: Streamlit
- Data & Analysis: Pandas, NLTK, Gensim, vaderSentiment
- APIs: Tweepy (for X/Twitter API), yfinance (for Yahoo Finance)
- Plotting: Plotly
Follow these steps to get the application running on your local machine.
- Python 3.8+
- Git
Open your terminal and clone the project repository:
git clone <your-repository-url>
cd cryptoSentimentsIt is highly recommended to use a virtual environment to manage project dependencies.
# Create a virtual environment
python3 -m venv .venv
# Activate the environment
# On macOS/Linux:
source .venv/bin/activate
# On Windows (Command Prompt):
.venv\Scripts\activateInstall all the required Python packages using the requirements.txt file.
pip install -r requirements.txtThe application also uses the NLTK stopwords and punkt packages. The first time you run the app, these may be downloaded automatically.
This application requires a Bearer Token from the X Developer Platform to fetch tweets.
- Apply for a Developer Account: If you don't have one, go to the X Developer Platform and apply for an account. You will likely need to apply for the "Free" access level, which is sufficient for this project.
- Create a New Project: Once your account is approved, create a new Project in your developer dashboard.
- Create an App: Inside your project, create a new App.
- Find Your Keys & Tokens: Navigate to your App's "Keys and tokens" tab. You will find your Bearer Token here. Copy it.
Create a secrets file for Streamlit to securely store your Bearer Token.
-
Create a new directory named
.streamlitin the root of your project folder. -
Inside the
.streamlitdirectory, create a new file namedsecrets.toml. -
Add your Bearer Token to this file in the following format:
# .streamlit/secrets.toml BEARER_TOKEN = "PASTE_YOUR_BEARER_TOKEN_HERE"
The application is coded to automatically read this secret.
You are now ready to run the Streamlit app!
streamlit run app.pyYour web browser should open a new tab with the application running at http://localhost:8501.
cryptoSentiments/
├── .streamlit/
│ └── secrets.toml # For storing API keys and secrets
├── app.py # The main Streamlit application script
└── requirements.txt # Python package dependencies