The List / Trading, Investment, and Portfolio Management / paper
FinLlama: Financial Sentiment Classification for Algorithmic Trading Applications
Abstract
There are multiple sources of financial news online which influence market movements and trader's decisions. This highlights the need for accurate sentiment analysis, in addition to having appropriate algorithmic trading techniques, to arrive at better informed trading decisions. Standard lexicon based sentiment approaches have demonstrated their power in aiding financial decisions. However, they are known to suffer from issues related to context sensitivity and word ordering. Large Language Models (LLMs) can also be used in this context, but they are not finance-specific and tend to require significant computational resources. To facilitate a finance specific LLM framework, we introduce a novel approach based on the Llama 2 7B foundational model, in order to benefit from its generative nature and comprehensive language manipulation. This is achieved by fine-tuning the Llama2 7B model on a small portion of supervised financial sentiment analysis data, so as to jointly handle the complexities of financial lexicon and context, and further equipping it with a neural network based decision mechanism. Such a generator-classifier scheme, referred to as FinLlama, is trained not only to classify the sentiment valence but also quantify its strength, thus offering traders a nuanced insight into financial news articles. Complementing this, the implementation of parameter-efficient fine-tuning through LoRA optimises trainable parameters, thus minimising computational and memory requirements, without sacrificing accuracy. Simulation results demonstrate the ability of the proposed FinLlama to provide a framework for enhanced portfolio management decisions and increased market returns. These results underpin the ability of FinLlama to construct high-return portfolios which exhibit enhanced resilience, even during volatile periods and unpredictable market events.
In one sentence
Summary
The paper addresses the limitations of standard lexicon-based sentiment analysis and general-purpose LLMs in finance, where context sensitivity and computational costs are significant barriers. The authors propose FinLlama, a finance-specific framework built on the Llama 2 7B foundation model. By adding a SoftMax classification layer and employing Low-Rank Adaptation (LoRA), the model is fine-tuned to classify sentiment valence (positive, negative, neutral) and quantify its strength. This approach significantly reduces trainable parameters to 4.2 million, enabling efficient training on standard hardware without sacrificing accuracy, thereby bridging the gap between academic benchmarks and practical, resource-constrained deployment in algorithmic trading. The methodology involves fine-tuning the model on a curated dataset of 34,180 labeled financial news samples. For evaluation, the authors construct a long-short portfolio using daily sentiment signals derived from 204,017 news articles covering 417 S&P 500 companies from 2015 to 2021. The portfolio allocates 35% of capital to long positions (highest positive sentiment) and 35% to short positions (highest negative sentiment), with equal weighting. Performance is assessed against four baselines: LMD, HIV-4, VADER, and FinBERT, using real-world financial metrics including cumulative returns, annualized return, volatility, and the Sharpe ratio, rather than just classification accuracy. Results demonstrate that FinLlama outperforms all baselines, achieving 308.2% cumulative returns compared to FinBERT's 213.0% and the S&P 500's 83.1%. It also yields the highest Sharpe ratio (2.4) and lowest annualized volatility (18.6%), indicating enhanced risk-adjusted performance and resilience during volatile periods. The study highlights the value of domain-specific fine-tuning for actionable trading signals. However, limitations include the reliance on a relatively small fine-tuning dataset and the potential for overfitting, as well as the exclusion of transaction costs and slippage in the simulation, which may affect real-world applicability.
Research problem
The paper addresses the need for accurate, context-aware financial sentiment analysis that can drive algorithmic trading decisions. It highlights the shortcomings of lexicon-based methods in handling financial nuance and the high computational costs of general-purpose LLMs. The core problem is how to tailor a large language model for financial sentiment classification efficiently, enabling accessible and high-performance trading signals.
Core contributions
- Introduction of FinLlama, a fine-tuned Llama 2 7B model for financial sentiment classification.
- Implementation of LoRA for parameter-efficient fine-tuning, reducing trainable parameters to 0.06% of the base model.
- Development of a generator-classifier scheme that quantifies both sentiment valence and strength.
- Integration of sentiment signals into a long-short portfolio strategy for real-world performance evaluation.
- Demonstration of superior risk-adjusted returns compared to FinBERT and lexicon-based baselines.
Method
- Base model: Llama 2 7B initialized with pre-trained weights.
- Fine-tuning: 5 epochs using AdamW optimizer with LoRA adapters.
- Classification head: SoftMax layer added for three-class sentiment output.
- Data processing: NER and text pre-processing to filter irrelevant articles.
- Sentiment aggregation: Daily average sentiment calculated for companies with multiple articles.
- Portfolio construction: Equally-weighted 35% long/35% short allocation based on sentiment rank.
Results & findings
- FinLlama achieved 308.2% cumulative returns, outperforming FinBERT (213.0%) and S&P 500 (83.1%).
- Highest Sharpe ratio of 2.4 compared to 1.5 for FinBERT and 0.62 for S&P 500.
- Lowest annualized volatility of 18.6% among all methods.
- LoRA reduced trainable parameters to 4.2M, enabling single-GPU training.
- Deep learning methods generally outperformed lexicon-based approaches.
- Performance was particularly strong during high-volatility periods like Q1 2020.
Data & experiments
- Training data: 34,180 labeled financial news samples from four public datasets.
- Evaluation data: 204,017 news articles and daily stock returns for 417 S&P 500 companies (2015-2021).
- Baselines: LMD, HIV-4, VADER, and FinBERT.
- Experiment: Construction of 35% long-short portfolios based on daily sentiment rankings.
- Metrics: Cumulative returns, annualized return, volatility, and Sharpe ratio.
Limitations & caveats
- Simulation does not account for transaction costs, slippage, or market impact.
- Training dataset is relatively small (34k samples), potentially limiting generalizability.
- Risk-free rate assumption of 0% may not reflect real-world conditions accurately.
- Model performance may degrade if news sources or market regimes change significantly.
- Excludes companies with no news coverage, potentially introducing selection bias.
Curator notes
Discovery status: round1_promoted_seed_for_round2. Source links: A Survey of Large Language Models for Financial Applications: Progress, Prospects and Challenges; BloombergGPT: A Large Language Model for Finance; FinBERT: Financial Sentiment Analysis with Pre-trained Language Models; FinGPT: Democratizing Internet-scale Data for Financial Large Language Models; FinGPT: Open-Source Financial Large Language Models; From Deep Learning to Large Language Models: A Survey of Artificial Intelligence in Quantitative Investment; Instruct-FinGPT: Financial Sentiment An