(5) Stock Price Prediction with ML in Python: ‘Sentiment Analysis’ for Smarter Trading

Sercan Bugra Gultekin
5 min readJun 9, 2024

Did you know that it’s possible to use sentiment analysis to evaluate stock news published on trading websites?

Sentiment analysis, a key NLP task, involves classifying the sentiment of text as positive, negative, or neutral. VADER is a popular Python tool for this, offering a pre-trained model for effective sentiment analysis.

VADER is a lexicon and rule-based sentiment analysis tool used to determine the sentiment of text. Its lexicon consists of words labeled as positive or negative based on their semantic meaning. With VADER, even unlabelled text data can be effectively analyzed and labeled for sentiment.

Credit By : Big Blue

Before jumping into the sentimental analysis topic, we will need to pass the steps below.

  • Scraping News Articles: Use web scraping tools such as BeautifulSoup, Scrapy, or newspaper3k to gather news articles from trading websites.
  • APIs: Utilize APIs from financial news services to fetch real-time news articles. Examples include the News API and Alpha Vantage.
import pandas as pd
from bs4 import BeautifulSoup

from urllib.request import urlopen, Request
from urllib.error import HTTPError

# Parameters
tickers =…

--

--

Sercan Bugra Gultekin

Lover of edge technologies, coding enthusiast, close follower of AI topics and indomitable advocate of green energy