El-SOUQ Stock Price Forecast Web App

- Published on
- Duration
- 8 Months
- Role
- Researcher, AI Developer



+4
Demo Live Preview
Live Preview
In today's digital age, social media platforms have a significant impact on the financial markets. This project aims to predict stock prices by incorporating the effects of social media data from platforms such as Facebook, LinkedIn, and Twitter. By analyzing the sentiment, trends, and discussions on these platforms, we can gain valuable insights into market behavior and enhance the accuracy of stock price predictions.
So, El-SOUQ Stock Price Predictor is a web application that predicts stock prices based on the effects of social media platforms such as Facebook, LinkedIn, and Twitter. It utilizes historical stock data and employs the Facebook Prophet library to forecast future stock prices. Additionally, the application provides access to trending business news using the News API.
Technology Stack
- Backend: Python
- Web Framework: Streamlit
- Data Analysis: Pandas, NumPy
- Data Visualization: Plotly
- Forecasting Library: Facebook Prophet
- Other Libraries: Pystan, Cython, Nltk
- API Integration: Yahoo Finance API, News API
- Web Scraping: Requests
- Deployment: Streamlit
Key Features
Past Trends: Explore the historical trends of a selected stock, including open and close prices. The data is visualized through interactive candlestick charts.
Predict Stock Price: Forecast future stock prices using the Facebook Prophet library. Adjust the prediction period and view the forecasted prices along with the trend components.
Trending Business News: Stay updated with the latest business news related to the stock market. The application fetches and displays top headlines from the News API.
Key Functions and Algorithms
Stock Price Data Retrieval
Historical stock price data is retrieved from Yahoo Finance using the yfinance
library. Here's an example of fetching stock price data for a given symbol:
import yfinance as yf
def get_stock_price_data(symbol):
# Fetch historical stock price data
data = yf.download(symbol, start='2015-01-01', end='2023-01-01')
return data
Sentiment Analysis
To analyze the sentiment of social media posts related to a particular stock, we utilize natural language processing techniques. The code snippet below demonstrates sentiment analysis using the nltk
library:
import nltk
from nltk.sentiment import SentimentIntensityAnalyzer
def analyze_sentiment(text):
# Perform sentiment analysis on text
sia = SentimentIntensityAnalyzer()
sentiment_scores = sia.polarity_scores(text)
return sentiment_scores
Stock Price Prediction with Fbprophet
Fbprophet is a powerful library for time series forecasting. We utilize it to predict future stock prices based on historical data and social media insights. Here's an example of using Fbprophet
for stock price prediction:
from fbprophet import Prophet
def predict_stock_prices(data):
# Prepare data for Fbprophet
data = data.rename(columns={"Date": "ds", "Close": "y"})
# Create and fit the Fbprophet model
model = Prophet()
model.fit(data)
# Make future predictions
future = model.make_future_dataframe(periods=365) # Predict for one year ahead
forecast = model.predict(future)
return forecast
Conclusion
By incorporating the effects of social media data from platforms like Facebook, LinkedIn, and Twitter, this projectenhances the accuracy of stock price predictions. El-SOUQ web application provides an interactive interface where users can input a stock symbol and view the predicted stock prices for the next four years. The application fetches historical stock price data from Yahoo Finance using the yfinance library and collects social media data through APIs provided by Facebook, LinkedIn, and Twitter.
The social media data is then analyzed using natural language processing techniques to determine the sentiment and extract valuable insights. Sentiment analysis is performed using the nltk library, which provides sentiment scores for text data. These sentiment scores help to gauge the overall sentiment and market sentiment towards a particular stock.
The Fbprophet library, developed by Facebook, is employed for time series forecasting and predicting stock prices. The historical stock price data, along with the social media insights, is used to train the Fbprophet model. The model then generates future predictions for the stock prices.
The predicted stock prices are presented graphically using the Plotly library. The interactive charts and graphs provide users with a visual representation of the predicted trends and fluctuations in stock prices over the next four years.
Overall, this project combines the power of machine learning, social media analysis, and data visualization to predict stock prices based on the effects of social media platforms by more than 84% accuracy. By incorporating social media data, investors can gain deeper insights into market behavior and make more informed investment decisions.