--- title: Nifty News Analysis emoji: 📈 colorFrom: blue colorTo: green sdk: streamlit sdk_version: 1.45.1 app_file: app.py pinned: false license: mit --- # Nifty News Analysis A Streamlit app that analyzes NIFTY 50 stocks and news, built by @MtotoWaJemo. # NIFTY 50 News Analysis ## Overview This project is a Streamlit-based web application that analyzes news sentiment for companies in the NIFTY 50 index, categorized by sectors. It fetches news articles using the NewsAPI, summarizes them using the T5 model, and performs sentiment analysis using DistilBERT. The app provides insights into sector and company sentiment to guide investment decisions. ## Features - **Sector Selection**: Choose from NIFTY 50 sectors (e.g., Financials, Healthcare). - **Time Frame Analysis**: Analyze news from different periods (1D, 5D, 1M, 6M, YTD, 1Y, 5Y). - **Sentiment Analysis**: Summarizes news and classifies sentiment as Positive, Negative, or Neutral. - **Investment Insights**: Provides sentiment scores and recommendations for companies. - **Interactive UI**: Built with Streamlit, featuring a user-friendly interface with tables and visualizations. ## Installation 1. Clone the repository: ```bash git clone https://github.com/mtotowajemo0/nifty-news-analysis.git ``` 2. Navigate to the project directory: ```bash cd nifty-news-analysis ``` 3. Install dependencies: ```bash pip install -r requirements.txt ``` ## Requirements - Python 3.8+ - Libraries listed in `requirements.txt`: - streamlit - newsapi-python - transformers - streamlit-extras - pandas ## Usage 1. Obtain a NewsAPI key from [newsapi.org](https://newsapi.org/). 2. Replace the `api_key` in `app.py` with your NewsAPI key. 3. Run the Streamlit app: ```bash streamlit run app.py ``` 4. Open the app in your browser, select a sector and time frame, and click "Analyze News" to view results. ## Files - `app.py`: Main application script with Streamlit code, news fetching, and sentiment analysis. - `requirements.txt`: List of Python dependencies. - `README.md`: Project documentation (this file). ## Notes - The app uses the `t5-small` model for summarization and `distilbert-base-uncased-finetuned-sst-2-english` for sentiment analysis. - News articles are filtered based on a weighted keyword system to ensure relevance. - Sentiment scores are calculated as (Positive - Negative) / Total Articles. - **Disclaimer**: Insights are for informational purposes only and not financial advice. ## License MIT License. See [LICENSE](LICENSE) for details.