Stock Embeddings: Learning Distributed Representations for Financial Assets

Rian Dolphin, Barry Smyth, Ruihai DongarXiv 2022

In the world of quantitative finance, most machine learning efforts are poured into the "holy grail" of price forecasting. However, knowing where a single stock is going is only half the battle. For portfolio managers, understanding the complex web of relationships between assets—how they move together or apart—is just as critical for hedging and diversification.

A new paper from researchers at University College Dublin, titled "Stock Embeddings: Learning Distributed Representations for Financial Assets," suggests that we’ve been looking at asset relationships through a straw. By borrowing "distributional semantics" from Natural Language Processing (NLP), they propose a way to map stocks into a dense vector space that captures nuanced relationships far better than traditional correlation metrics.

TL;DR

This paper introduces a neural framework to learn "stock embeddings"—dense vector representations of financial assets—based purely on historical returns. By treating stocks that exhibit similar price movements at the same time as "context," the model learns latent relationships that outperform traditional Pearson correlation in portfolio hedging and accurately reconstruct market sectors without any prior categorical knowledge.

What Problem Does This Paper Address?

Modern Portfolio Theory has relied on the same tool for decades: the Pearson correlation coefficient. While useful, simple pairwise correlation often fails to capture the "nuanced and non-linear" relationships inherent in noisy financial markets.

Furthermore, while NLP has been revolutionized by embeddings (like Word2Vec and BERT) that represent words based on their context, financial ML has mostly used these tools to analyze textual data (news, reports). There is a significant gap in applying these powerful representation learning techniques directly to the "language" of the market itself: price movements.

Methods

The authors propose a neural model inspired by the Continuous Bag-of-Words (CBOW) architecture. The core idea is the Distributional Hypothesis: just as a word is characterized by the company it keeps, a stock can be characterized by the other stocks that behave similarly to it.

1. Generating Training Data

For every stock (target) at every time step $t$, the model identifies a "context set" of $C$ other stocks that had the closest absolute return at that same moment.

![Fig.

  1. Generating training data, i.e., target:context stock sets](/figures/art_b97a19f36b444499832ce7d898eaf98f)

2. The Architecture

The model (shown in Figure 2) uses an embedding matrix $W$ where each row is a stock's vector. The input is a context set, which is averaged (or weighted) into a hidden layer $h$. The model then tries to predict the target stock using a softmax output layer. Through backpropagation, stocks that frequently appear in each other's contexts are pushed closer together in the $N$-dimensional embedding space.

![Fig.

  1. Model Architecture](/figures/art_5ad1296ca5f6491e98afad3d1a44b373)

3. Taming the Noise

Financial data is notoriously noisy. The authors introduce two key strategies:

  • Distributional Weighting: Context stocks are weighted by how often they co-occur with the target across the entire dataset.
  • IQR Filtering: Training samples are ignored if the target stock's return is within the Interquartile Range (IQR) for that day. This ensures the model learns from significant market moves rather than random daily churn.

Datasets

The study uses a publicly available dataset of daily pricing for 611 US stocks spanning the period from 2000 to 2018. For evaluation, they use the Global Industry Classification Standard (GICS) labels (e.g., Finance, Technology, Energy) to see if the learned embeddings naturally align with human-defined sectors.

Key Insights and Ideas

  • Implicit Sector Discovery: Even though the model never "saw" a sector label, the embeddings naturally clustered stocks into their respective business sectors. Figure 3 shows a clear separation of Energy, Finance, and Tech stocks based solely on return patterns.
  • Correcting Human Labels: The model identified "high similarity mismatches"—stocks that humans put in different sectors but the market treats as identical. For example, Lennar Corp (Basic Industries) and KB Home (Capital Goods) have a 0.98 embedding similarity because they are both homebuilders, despite their different high-level GICS tags.
  • Beyond Correlation: Traditional correlation is a "shallow" measure. Embeddings allow for Analogical Inference. Just as King - Man + Woman = Queen, the authors found they could solve financial analogies like: American Express is to Finance as Hewlett Packard is to Technology.

![Fig.

  1. Graphical Visualisaion of Stock Embeddings Coloured by Business Sector](/figures/art_1a0e82b66f9645dba3c8a3ce1b2cc98a)

Key Results

The authors evaluated their embeddings on two primary tasks:

  1. Sector Classification: Using the embeddings as features for a Support Vector Classifier, they achieved 60% accuracy across 11 sectors. This is a strong result given that the model uses zero fundamental or categorical data.
  2. Portfolio Hedging: They simulated two-asset portfolios where a "query" stock was hedged with the most dissimilar stock found via embeddings vs. traditional baselines.
  3. Embedding-based hedging achieved an average volatility of 21.3%.
  4. Pearson correlation (the industry standard) lagged behind at 23.8%.
  5. The results were statistically significant ($p < 0.01$), showing that embeddings find more effective "diversifiers" than simple correlation.

![Fig.

  1. Distribution of Volatility for Hedged Portfolios](/figures/art_59830b9464c94bdd87fa0c3d57b42ced)

Limitations and Future Work

While promising, the study has a few constraints:

  • Simplified Portfolios: The hedging evaluation was limited to two-asset portfolios. Real-world portfolios are far more complex.
  • Static Embeddings: The current model learns a single representation for a stock over a long period. In reality, company relationships evolve (e.g., a tech company pivoting to finance).
  • Lagged Relationships: The authors suggest exploring "lagged embeddings"—learning if a move in Apple today predicts a move in its suppliers tomorrow.

This research provides a compelling argument for moving beyond simple correlation matrices and treating the stock market as a structured "language" that can be decoded using modern representation learning.

Summary updated

BibTeX
@misc{dolphin2022stock,
  author = {Rian Dolphin and Barry Smyth and Ruihai Dong},
  title = {{Stock Embeddings: Learning Distributed Representations for Financial Assets}},
  year = {2022},
  eprint = {2202.08968},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2202.08968},
}
Figure