File size: 2,855 Bytes
1c7734c
d613d41
488ceb9
 
1c7734c
 
 
 
14cabc2
1c7734c
dccf87f
1c7734c
 
4cb284c
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
---
title: Swift Stock Screener
emoji: 💹
colorFrom: green
colorTo: gray
sdk: gradio
sdk_version: 5.29.0
app_file: app.py
pinned: true
license: apache-2.0
short_description: Search over 12k companies by theme (VSS) or similarity (NNS)
---

## Overview

**Swift Stock Screener (SSS)** is an interactive application that enables semantic and similarity-based stock screening across ~13,000 equities.  
It combines **semantic vector search** on company descriptions with **nearest neighbor search** on financial fundamentals.  

The app allows two main modes:
- **Theme search**: find stocks relevant to a concept (e.g., *“lithium”*, *“cloud computing”*).
- **Ticker similarity search**: find peers to a given stock (e.g., *NVDA* → other semiconductors).

Data (fundamentals and descriptions) is sourced from **Yahoo Finance**. Company **descriptions used in the semantic search** come directly from Yahoo Finance long summaries.

---

## Features

- **Semantic Theme Search**  
  Uses `FinLang/finance-embeddings-investopedia` to embed queries and company descriptions.  
  DuckDB with **HNSW vector index** executes approximate nearest neighbor search.  
  Re-ranking adds:
  - **Literal rewards** (companies explicitly mentioning query terms boosted).
  - **Brevity penalties** (companies with very short descriptions are penalized).

- **Ticker Similarity Search**  
  Uses normalized numeric fundamentals (e.g., Market Cap, P/E, Revenue Growth, Volatility).  
  Scikit-learn **NearestNeighbors** finds the closest peers.  
  A **Similarity Index (0–100)** is computed with a gamma distribution scaling to give intuitive scores.

- **Interactive Results Table**  
  Paginated grid view with columns:
  - Name, Country, Sector, Market Cap
  - 1yr Return, Volatility, P/E, Revenue Growth, Dividend Yield, Beta  
  Negative values are highlighted red.  

- **Dynamic Filtering**  
  Click on a sector, industry, or country in the grid to filter results interactively.  
  Multiple filters can be applied in succession.

- **Company Details View**  
  - Company name + Yahoo Finance description.  
  - Full fundamentals table.  
  - **Radar chart** of 5 normalized metrics: Beta, Debt/Equity, 1yr Return, Revenue Growth, Volatility.

- **Controls**  
  - **Theme box**: free text search.  
  - **Ticker box**: find peers to a stock.  
  - **Search** / **Reset** / **Random ticker** buttons.  
  - Sorting by any metric.  

---

## Architecture

- **Data**: Yahoo Finance fundamentals + descriptions.  
- **Embeddings**: `FinLang/finance-embeddings-investopedia` (768-dim vectors).  
- **Vector DB**: DuckDB with VSS extension + HNSW cosine index.  
- **Ticker similarity**: Scikit-learn `NearestNeighbors` with Euclidean distance over normalized features.  
- **UI**: Python + Gradio Blocks.  
- **Visualization**: Plotly for radar chart.

---