# Financial Sentiment

Classifying sentiment in financial text, where domain conventions differ sharply from general sentiment.

**Rests on:** Sentiment Analysis

**Leads to:** Earnings Call Analysis

*Applied Domains · AI in Finance*


## Why learn this

Understanding how AI interprets the mood of financial news is your entry point into using artificial intelligence in finance. Once you can distinguish between general negativity and specific market direction in text, you can build systems that flag risks, support analysts, and inform trading decisions. This capability is exactly what specialized AI models like FinBERT and BloombergGPT are designed for. Mastering this concept unlocks further study of topics such as analyzing executive speeches during earnings calls, reasoning about financial numbers in text, and testing these AI strategies against historical data to see if they would have made money.


## The intuition

Imagine reading a corporate press release that says: 'The company took a one-time charge of $500 million due to an asset write-down, but management remains confident in the long-term outlook.' A general sentiment model — the kind trained on movie reviews — would probably label this as negative, because 'charge' and 'write-down' sound bad. But a financial analyst reads it differently: the charge is a non-recurring event, the company is signalling confidence, and the market might actually react positively if the news was expected. Financial sentiment is not about whether the words feel happy or sad; it is about whether the news moves the price up or down. This is why domain-specific AI models like FinBERT and BloombergGPT exist — because general language models routinely mislabel financial language. The practical consequence is that if you are building a tool that reads earnings calls or news to help a portfolio manager, you cannot reuse a movie-review sentiment classifier and hope it works. You need to know what 'sentiment' means in a financial context, and that meaning is directional impact, not emotional tone.


## An analogy

Think of a weather forecaster versus a commuter. A weather forecaster describes conditions neutrally: 'Overcast, 22 degrees, light breeze.' A commuter hears 'overcast' and thinks 'gloomy' — maybe that is negative for their mood. But the same commuter, if they are a farmer, hears 'overcast' and thinks 'good for crops' — positive. The same word, the same event, but the direction of impact depends on the context. Financial sentiment works the same way. The word 'volatility' is usually bad for a retiree's portfolio, but for a trader who profits from price swings, it is an opportunity. The same text can be negative for one stakeholder and positive for another. The analogy breaks down because the commuter is a human with feelings, while a financial sentiment model is a tool that must produce a number — typically a score between -1 (indicating a prediction that prices will fall) and +1 (indicating a prediction that prices will rise) — and that number must correspond to the expected directional move in the asset price, not to any human emotion. The model has no feelings; it just computes a directional signal. And crucially, that signal is only useful if it is timely: by the time you have read the news, the market may have already priced it in, so your score is worthless for trading — but still valuable for risk assessment or compliance.


## Definition

Financial sentiment is the classification of text as negative for price movement, neutral, or positive for price movement based on the expected directional impact on an asset's price, using domain-specific conventions that often invert everyday emotional tone.


## How it connects

This concept sits at the very start of your AI in Finance path. You have no prerequisites yet — this is the foundation. It connects directly to FinBERT and BloombergGPT, because those are specialized AI models built specifically to handle the financial conventions you are learning here. It also connects to Earnings Call Analysis, where you will extract signal from tone and hedging in executive transcripts — a natural next step. And it connects to Backtesting LLM Strategies, because any strategy that uses sentiment as a signal must be tested against historical data under strict timing rules, which your library notes emphasise as essential.


## The mathematics

The mathematics here is not calculus or algebra — it is simple arithmetic and the idea of a weighted sum. The concept rests on arithmetic because we are combining numbers that represent word scores. Here is the idea: imagine you have a text and you want to score it as generally positive or negative. One crude approach is to look at each word, give it a score — for example, 'profit' might be +2, 'loss' might be -3 — and then add all those scores together. If the total is positive, the text is positive; if negative, negative. That is a weighted sum: each word contributes its score, and the total is the sum of all those contributions. But for financial sentiment, you also need to adjust for context. For instance, the word 'loss' in 'the company reduced its loss' is actually positive. So you might add a multiplier that depends on the surrounding words. But even this is still just arithmetic: you are multiplying and adding numbers. A more realistic model — like FinBERT — uses a neural network, which internally performs many weighted sums in parallel, but the principle is the same. The mathematics section here will walk you through a tiny hand-computed example of a weighted sum, because that is the core operation underneath any sentiment score.

Let the raw sentiment score be S = Σᵢ wᵢ, where wᵢ is the score of the i-th word. Then apply a context adjustment factor c (which may be 1 if there is no special phrase), producing the final score F = c × S. If F > 0, bullish; if F < 0, bearish; if F = 0, neutral.


## A worked example

```
Take a short phrase: 'Despite a loss, the company beat expectations.' We will use a simplified lexicon. Word scores (pre-assigned): 'despite' = 0 (neutral), 'a' = 0, 'loss' = -3 (likely negative), 'the' = 0, 'company' = 0, 'beat' = +4 (positive), 'expectations' = 0. So we have a list of scores: [0, 0, -3, 0, 0, 4, 0]. We will compute the raw sum, then apply a twist: the phrase 'beat expectations' has a special weight of 1.5 because it is a strong positive signal in finance.

Step 1: 0 + 0 + (-3) + 0 + 0 + 4 + 0 = 1   # Simple sum of all word scores. The positive 'beat' outweighs the negative 'loss'.
Step 2: 1 × 1.5 = 1.5   # Multiply the raw sum by a context factor of 1.5 because the phrase 'beat expectations' is a strong bullish signal, amplifying the positive direction.
Step 3: 1.5 > 0 → classify as bullish   # Since the final score is positive, we label the text as positive sentiment (bullish).

Result: The text is classified as positive sentiment (bullish) because the final weighted score is positive.
```


## From scratch, in Python

```python
# We will implement a simple sentiment scorer using dictionaries and a loop.

# Step 1: A dictionary maps words to sentiment scores.
# A dictionary looks things up by name, not by position.
lexicon = {
    "loss": -3,
    "profit": +3,
    "beat": +4,
    "miss": -2,
    "growth": +2,
    "decline": -2
}

# Step 2: A list of words from a sample text.
text_words = ["Despite", "a", "loss", "the", "company", "beat", "expectations"]

# Step 3: Loop through each word, look it up in the dictionary, and add its score.
# A loop repeats the same action for each item in a list.
raw_score = 0
for word in text_words:
    # lower() converts the word to lowercase so it matches the dictionary keys.
    word_lower = word.lower()
    if word_lower in lexicon:
        raw_score = raw_score + lexicon[word_lower]

# Step 4: Apply a context multiplier if a key phrase exists.
# A simple check: if 'beat expectations' is in the text, use 1.5.
full_text = " ".join(text_words)  # join combines list items into a string.
context_multiplier = 1.5 if "beat expectations" in full_text.lower() else 1.0
final_score = raw_score * context_multiplier

# Step 5: Decision rule.
if final_score > 0:
    label = "bullish"
else:
    label = "bearish"  # we ignore neutral for simplicity

print(raw_score, final_score, label)
```


## The same thing, with a framework

```python
In practice, you would not write this from scratch. You would use a pre-trained model like FinBERT via the transformers library. For example:

from transformers import pipeline
sentiment_pipeline = pipeline("text-classification", model="ProsusAI/finbert")
result = sentiment_pipeline("Despite a loss, the company beat expectations.")
print(result)  # [{'label': 'positive', 'score': 0.99}]

Under the hood, FinBERT runs a neural network that computes many weighted sums across layers, exactly like our simple loop but with millions of weights learned from financial text.
```


## What the code does

We start with a dictionary called `lexicon` that maps words to scores. A dictionary is like a phonebook: you give it a name, it gives you a number. Next, we have a list `text_words` holding the words of our text. A list keeps items in order. Then we loop over each word: `for word in text_words` repeats the indented code below it for every word. Inside the loop, we lowercase the word (so 'Loss' matches 'loss') and check if it is in the dictionary; if yes, we add its score to our running total `raw_score`. After the loop, we join the word list back into a full text string to check for a key phrase; if 'beat expectations' appears, we set a multiplier of 1.5. Then we multiply the raw score by that multiplier. Finally, we decide: positive final score means bullish, otherwise bearish. In production, you would not write this from scratch — you would call a library like `transformers` with FinBERT, which internally does the same kind of weighted summing but across many layers and with learned weights.


## Common misconceptions

**General sentiment is the same as financial sentiment** — A model that works for movie reviews should work for financial news.

Financial language inverts everyday sentiment — 'volatility' is not simply bad; 'beat expectations' is strongly positive even if the underlying news has negative words. General models are trained on everyday text and will mislabel these. In fact: Financial sentiment is a different task: it measures directional impact on price, not emotional tone, and requires domain-specific training or adaptation.

**Sentiment score is the final trading signal** — If my model says 'bullish', I should buy.

Sentiment is only useful before it is priced in — if the market already knows the news, the score is worthless for trading. Also, the model's output is a number, not a recommendation; you need a strategy and risk management. In fact: Sentiment is an input to a decision, not the decision itself. Timing matters, and the signal must be evaluated in a backtest under point-in-time discipline.

**Sentiment is all about emotions** — A model scores whether the writer is happy or angry.

Financial text is usually neutral in emotional tone, but still bullish or bearish. 'The company beat expectations' has no emotion, yet it is a strong positive signal. In fact: The label is about expected price movement, not writer emotion. A neutral-sounding sentence can be bearish if it signals a missed target.


## In short

Financial sentiment is directional impact on price, not emotional tone. General models mislabel financial language — that is why FinBERT and BloombergGPT exist. The core arithmetic is a weighted sum of word scores, often adjusted by context. Always separate the raw score from the decision, and remember timing is everything: sentiment is only useful before it is priced in. Point-in-time discipline is non-negotiable in any backtest.


## Where this is used

This concept appears everywhere in financial AI. In large language models (LLMs), sentiment is often a hidden feature in their embeddings — when you prompt a general LLM like GPT-4 to read a news headline and say whether it is bullish or bearish, the model implicitly computes a directional score using attention over words. But general LLMs are known to mislabel financial language — which is why domain models like FinBERT and BloombergGPT exist. They are fine-tuned on financial text so that 'volatility' is not automatically negative — it depends on context. In small language models running on devices (like a phone app for retail investors), you cannot run a 70-billion-parameter model, so you use a distilled version of FinBERT — a model compressed to a few million parameters — and run it locally to summarize sentiment for a portfolio. In retrieval-augmented generation (RAG), you might build a system where a user asks a question about a stock, and the system retrieves relevant news articles, then uses a sentiment classifier to rank them by bullishness before feeding them to an LLM to generate an answer. In agentic systems — like the financial analyst assistant in the book 'Large Language Models in Finance' — the agent plans steps, calls a sentiment analysis tool (maybe a fine-tuned FinBERT) to score a set of documents, then uses that score to decide whether to escalate to a risk manager. In everyday applied machine learning, sentiment is used for recommendation (e.g., filtering out negative news for a long-only portfolio), for forecasting (combining sentiment scores with price data), and for fraud detection (unusual sentiment in communications may flag insider trading). Developers typically use the `transformers` library with a pre-trained FinBERT model, writing something like `pipeline('sentiment-analysis', model='ProsusAI/finbert')`. What breaks when done badly is clear: if you use a general sentiment model, you will mislabel 'the company took a charge' as negative when it might be neutral or positive, leading to wrong trades or false alarms. Also, point-in-time discipline is critical — if your sentiment model was trained on future data (e.g., a news article from 2023 used in a 2020 backtest), your backtest is fiction. That is why backtesting strategies with sentiment signals is a separate topic in your library.


---

Read this on the web: https://basavapurushottam.com/learn-ai/financial-sentiment
