Simple Science

Cutting edge science explained simply

# Quantitative Finance # Information Retrieval # Computational Finance

Predicting Stock Prices with Language Models

Using language models to forecast stock price movements through financial and news data.

Ali Elahi, Fatemeh Taghvaei

― 5 min read


Stock Price Prediction Stock Price Prediction Insights models. Evaluating stock prices using language
Table of Contents

Predicting stock prices is like guessing whether your cat will knock over a glass of water. It involves looking at a lot of factors, from a company’s financial performance to what people are saying on social media. If you combine financial reports, past stock prices, and recent News Articles, you can create a pretty good picture of what might happen next.

Combining Different Types of Data

To make our stock predictions, we need to pull together information from multiple places. This includes:

  • Financial Data: This is the nitty-gritty stuff like income statements and balance sheets. Every public company in the U.S. has to share this information quarterly. It’s like showing your report card to your parents.

  • Historical Price Data: This looks at how a stock has performed in the past. If a company’s stock price has gone up and down like a roller coaster, it might give us clues about what could happen in the future.

  • News Articles: Investors often pay close attention to news. Social media and news stories are like the gossip of the stock market; they can influence how people feel about a company.

Using Language Models

We decided to use some fancy technology called Large Language Models (LLMs) to help us make predictions. These models are like very smart robots that can read and understand text. They can handle both structured data (like numbers) and unstructured data (like news articles). By feeding the model financial data and relevant news articles, we prompt it to predict whether a stock's price might go up or down.

For our experiments, we used several types of LLMs, including GPT-3, GPT-4, and LLaMA versions. These models have shown they can classify both types of data effectively.

How We Did It

We gathered a bunch of news articles and financial reports for 20 publicly traded companies. These were chosen based on how frequently their stocks are traded. We then created a dataset that included:

  • 5,000 news articles covering these companies from October 2021 to January 2024.
  • Financial data from the companies’ 10-K reports, which include various financial metrics.

We used a method called "retrieval augmentation" to find the most relevant news articles and attach them to the company’s financial data. This way, when we asked our models to predict stock price movements, they had all the necessary context.

Summarizing News Articles

With so much news out there, we had to figure out how to summarize it. We employed a couple of methods:

  1. Extractive Summarization: This method picks out important sentences from an article. It’s like finding the best quotes from a movie without watching the whole thing.

  2. Abstractive Summarization: This technique generates new sentences that capture the essence of the articles. Imagine someone summarizing a two-hour film into a single sentence.

By using these summarization techniques, we could focus on the parts of the news that most influenced stock prices.

Creating Prompts for Predictions

When we fed information into our LLMs, we needed to be careful about how we structured our prompts. Think of prompts as questions you ask to get an answer. We experimented with different ways of organizing the information we provided, since the order can really change how well the model performs. We included sections about the company, its recent news, its financial data, and then we asked our main question: "Should I invest in this company?"

Testing Our Predictions

To see how well our models did, we prepared a set of sample prompts. We tested our models under different settings-zero-shot, two-shot, and four-shot-to see which one worked best.

  • Zero-shot setting: We just asked the model the question with no prior examples.
  • Two-shot setting: We provided two examples.
  • Four-shot setting: We provided four examples.

Surprisingly, adding more examples didn’t always lead to better accuracy. It was like trying to teach an old dog new tricks-it doesn’t always work!

Results and Findings

Our research showed that different models performed differently. Some models like GPT-4 and LLaMA3 were better at predicting stock price movements. The best results came from models that could balance both types of data-financial numbers and news snippets.

Why It Matters

So why should anyone care about these predictions? Well, knowing if a stock's price might go up or down can help investors make better decisions. If a model can accurately predict these movements, it could save people from making poor investment choices-like buying a stock just before it tumbles down.

Future Directions

We learned that while using large language models in this way is promising, there’s still a lot to improve on. For our next steps, we plan to fine-tune smaller models that combine both textual and numerical data. We’re also interested in changing our approach from simple predictions of whether the stock will go up or down to predicting how much it might change in percentage terms. Stocks are a tricky business, but we’re eager to keep learning!

Conclusion

In the end, predicting stock prices is a complex but exciting challenge. With the right mix of financial data, news articles, and smart technology, we can improve our chances of making accurate predictions. And who knows? Maybe one day, there will be a cat that doesn’t knock over any water glasses!

Original Source

Title: Combining Financial Data and News Articles for Stock Price Movement Prediction Using Large Language Models

Abstract: Predicting financial markets and stock price movements requires analyzing a company's performance, historic price movements, industry-specific events alongside the influence of human factors such as social media and press coverage. We assume that financial reports (such as income statements, balance sheets, and cash flow statements), historical price data, and recent news articles can collectively represent aforementioned factors. We combine financial data in tabular format with textual news articles and employ pre-trained Large Language Models (LLMs) to predict market movements. Recent research in LLMs has demonstrated that they are able to perform both tabular and text classification tasks, making them our primary model to classify the multi-modal data. We utilize retrieval augmentation techniques to retrieve and attach relevant chunks of news articles to financial metrics related to a company and prompt the LLMs in zero, two, and four-shot settings. Our dataset contains news articles collected from different sources, historic stock price, and financial report data for 20 companies with the highest trading volume across different industries in the stock market. We utilized recently released language models for our LLM-based classifier, including GPT- 3 and 4, and LLaMA- 2 and 3 models. We introduce an LLM-based classifier capable of performing classification tasks using combination of tabular (structured) and textual (unstructured) data. By using this model, we predicted the movement of a given stock's price in our dataset with a weighted F1-score of 58.5% and 59.1% and Matthews Correlation Coefficient of 0.175 for both 3-month and 6-month periods.

Authors: Ali Elahi, Fatemeh Taghvaei

Last Update: 2024-11-02 00:00:00

Language: English

Source URL: https://arxiv.org/abs/2411.01368

Source PDF: https://arxiv.org/pdf/2411.01368

Licence: https://creativecommons.org/licenses/by/4.0/

Changes: This summary was created with assistance from AI and may have inaccuracies. For accurate information, please refer to the original source documents linked here.

Thank you to arxiv for use of its open access interoperability.

More from authors

Similar Articles