Code Monkey home page Code Monkey logo

krishna-aditi / nlp-sentiment-analysis-on-stock-news-and-price-monitoring Goto Github PK

View Code? Open in Web Editor NEW
9.0 2.0 4.0 3.19 MB

WebApp to bring together Text Summarization and Sentiment Analysis of the stock related news to better understand the stock price trends.

License: MIT License

Makefile 2.97% Python 33.39% Jupyter Notebook 63.64%
aws-ec2 aws-lambda fastapi gcp-app-engine gcp-bigquery gcp-storage news-scraper newspaper3k python sentiment-analysis streamlit text-summarization web-crawler yahoo-finance-api gcp-datastudio airflow-dags bert-model docker huggingface-transformers

nlp-sentiment-analysis-on-stock-news-and-price-monitoring's Introduction

NLP and Sentiment Analysis on Stock News and Price Monitoring

Overview

Stock market analysis is a difficult task to execute because of market volatility and a multitude of other dependent and independent factors that influence the market value of a particular stock. One of these factors - investor sentiment, is very much capable of influencing the stock price. News and social media are few of the ways to capture it. We aim to bring together Natural Language Processing and Sentiment Analysis of the stock related news to better understand the stock price trends.

Goals

Goal is to create a platform with curated information about a company's profile, stock specific news (from 24 hours), and the stock price trend from the past year. We focus on summarizing the news using NLP models, and labeling it as positive or negative using sentiment analysis. The platform aims to help the user make informed trading decisions.

  1. Create a workflow to web-scrape company specific information using YFinance library in Python
  2. Build a Streamlit interface for the FastAPI to render stock price trends, company’s financials, and description of the business
  3. Create an Airflow DAG to do the following:
  4. Web-scrape company specific stock news with the help of NewsAPI and Newspaper3K API
  5. Call the Summarization API (Lambda function) for summarization on each news article’s content
  6. Call Sentiment Analysis API (Lambda function) for extracting the sentiment of each news article
  7. Summarized news, along with the associated sentiment will be rendered on the Streamlit

Main Requirements

To test pretrained models and train API requires

  • Python 3.8
  • pandas
  • numpy
  • Streamlit
  • Python-jose
  • Passlib
  • Transformers 3.4
  • Torch
  • GCSFS
  • Plotly
  • Yfinance
  • NewsAPI
  • Newspaper3K

Use cases

  1. Single hub for stock trends and associated news to help the investor to make informed decisions
  2. Platform for learning about company stocks, or, stock market analysis

Data

Following libraries will be potentially used to web-scrape data off Yahoo Finance:

  1. yfinance
  2. BeautifulSoup (bs4)
  3. news-api
  4. newspaper3k

Process Outline

  • FastAPI for data scraping for stock prices
  • JWT Authentication for FastAPI
  • Data scraping for stock news
  • Dashboard creation using Google Data Studio
  • Building lambda functions for news summarization
  • Building lambda functions for sentiment analysis
  • Deploying Serverless lambda
  • Developing UI using Streamlit
  • Deploy on Streamlit Cloud

Deployment Details:

  1. Language: Python
  2. Container: Docker, AWS ECR
  3. Cloud ecosystems: AWS, Google cloud platform
  4. Cloud tools: AWS Lambda, AWS Cloudwatch, AWS Gateway, GCP Cloud Storage, Google BigQuery, Google App Engine, Google DataStudio
  5. Tools for analysis: Google Colab, Anaconda Spyder, Microsoft Azure Visual Studio
  6. Other tools and frameworks: FastAPI, Pytest, Streamlit, Airflow

Workflow

image

Fig. Proposed workflow

References:

  1. https://python.plainenglish.io/build-a-stock-data-api-using-web-scraping-and-fastapi-dcbcdbd3d2ec
  2. https://zzhu17.medium.com/web-scraping-yahoo-finance-news-a18f9b20ee8a
  3. https://www.analyticsvidhya.com/blog/2021/06/download-financial-dataset-using-yahoo-finance-in-python-a-complete-guide/
  4. https://www.parsehub.com/blog/scrape-yahoo-finance/
  5. https://newspaper.readthedocs.io/en/latest/
  6. https://huggingface.co/blog/sentiment-analysis-python
  7. https://newsapi.org/docs/client-libraries/python
  8. https://fastapi.tiangolo.com/tutorial/first-steps/
  9. https://www.youtube.com/watch?v=1zMQBe0l1bM&ab_channel=AbhishekThakur
  10. https://docs.streamlit.io/streamlit-cloud/get-started/deploy-an-app
  11. https://www.philschmid.de/serverless-bert-with-huggingface-aws-lambda-docker
  12. https://pypi.org/project/yfinance/
  13. https://www.thepythoncode.com/article/text-summarization-using-huggingface-transformers-python
  14. https://huggingface.co/blog/sentiment-analysis-python
  15. https://newspaper.readthedocs.io/en/latest/

Project Organization

├── LICENSE
├── Makefile           <- Makefile with commands like `make data` or `make train`
├── README.md          <- The top-level README for developers using this project.
├── data
│   ├── external       <- Data from third party sources.
│   ├── interim        <- Intermediate data that has been transformed.
│   ├── processed      <- The final, canonical data sets for modeling.
│   └── raw            <- The original, immutable data dump.
│
├── docs               <- A default Sphinx project; see sphinx-doc.org for details
│
├── models             <- Trained and serialized models, model predictions, or model summaries
│
├── notebooks          <- Jupyter notebooks. Naming convention is a number (for ordering),
│                         the creator's initials, and a short `-` delimited description, e.g.
│                         `1.0-jqp-initial-data-exploration`.
│
├── references         <- Data dictionaries, manuals, and all other explanatory materials.
│
├── reports            <- Generated analysis as HTML, PDF, LaTeX, etc.
│   └── figures        <- Generated graphics and figures to be used in reporting
│
├── requirements.txt   <- The requirements file for reproducing the analysis environment, e.g.
│                         generated with `pip freeze > requirements.txt`
│
├── setup.py           <- makes project pip installable (pip install -e .) so src can be imported
├── src                <- Source code for use in this project.
│   ├── __init__.py    <- Makes src a Python module
│   │
│   ├── data           <- Scripts to download or generate data
│   │   └── stock_main.py
|   │   ├── news_scrapper.py
|   │   ├── streamlit-app.py
|   │   ├── test.py    
|   │   ├── airflow_dag
|   │   │   └── news_airflow.py
│   │   ├── news_summary
|   |   │   ├── handler.py
|   |   │   ├── get_models.py
|   │   |   ├── dockerfile
|   |   │   ├── serverless.yaml
|   |   │   └── requirements.txt
│   │   ├── news_sentiment
|   |   │   ├── handler.py
|   |   │   ├── get_models.py
|   │   |   ├── dockerfile
|   |   │   ├── serverless.yaml
|   |   │   └── requirements.txt
|   |   |
│   ├── features       <- Scripts to turn raw data into features for modeling
│   │   └── build_features.py
│   │
│   ├── models         <- Scripts to train models and then use trained models to make
│   │                     predictions
│   │
│   └── visualization  <- Scripts to create exploratory and results oriented visualizations
│       └── visualize.py
│
└── tox.ini            <- tox file with settings for running tox; see tox.readthedocs.io

Project based on the cookiecutter data science project template. #cookiecutterdatascience

Submitted by:

image

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.