Logian
A real-time stock sentiment analysis system that scrapes financial news, generates vector embeddings, and scores sentiment using FinBERT — producing BUY / SELL / HOLD signals across 100 tickers simultaneously.
Microsecond signals via cosine similarity against risk-anchor embeddings stored in Actian. No ML inference at runtime.
Full FinBERT inference for high-accuracy scoring. Confirmed embeddings feed back into the fast path anchor cache.
React frontend connected via WebSocket. Live pipeline progress and score updates for all monitored tickers.
Local web UI for querying the vector DB by ticker or natural language. No API server required.
Setup
Prerequisites: Python 3.10+, Node.js 18+, Docker.
1. Install Python dependencies
pip install -r requirements.txt
pip install actiancortex-0.1.0b1-py3-none-any.whl
2. Install frontend dependencies
cd dashboard && npm install && cd ..
3. Start Actian VectorAI DB
# First time
docker run -d --name actian-vectorai -p 50051:50051 \
williamimoh/actian-vectorai-db:1.0b
# After restart
docker start actian-vectorai
4. Configure environment (optional)
# .env
VECTORAI_DB_ADDRESS=localhost:50051
Running
Dashboard (backend + frontend)
./run.sh
Opens the React dashboard at http://localhost:5173 and the API at http://localhost:8000.
CLI — single ticker
python src/main.py NVDA
Dual-path signal engine
# Fast + slow path on 100 tickers (slow path on 10)
python src/signals.py
# Fast path only — no FinBERT inference
python src/signals.py --fast
# Slow path on N tickers
python src/signals.py --slow 20
Batch ingest
# Run mock feed through FinBERT
python src/ingest.py
# Use your own data
python src/ingest.py data.json
Vector DB lookup tool
./run.sh lookup
Opens a local search UI at http://localhost:8050.
Pipeline
The full pipeline runs for each monitored ticker on a 10-second cycle.
- Scrape — Yahoo Finance RSS feed (falls back to HTML parsing). Retry logic with exponential backoff.
- Embed — Headline + summary concatenated and encoded with
all-MiniLM-L6-v2into 384-dim L2-normalised vectors. - Store — Embeddings + metadata (ticker, headline, link, timestamp) written to Actian VectorAI DB via
batch_upsert. - Score — FinBERT classifies each article as positive / negative / neutral with a confidence score.
- Aggregate — Confidence-weighted mean of all article scores, clipped to [-1.0, 1.0]. Score ≥ 0.3 = BUY, ≤ -0.3 = SELL, else HOLD.
Dual-Path Engine
signals.py implements two parallel approaches that trade accuracy for speed.
The feedback loop means the fast path improves as the slow path confirms more scores.
Score calculation
# All vectors are L2-normalised → dot product = cosine similarity
pos_sims = pos_anchors @ avg_vec # shape: (n_pos,)
neg_sims = neg_anchors @ avg_vec # shape: (n_neg,)
raw = mean(pos_sims) - mean(neg_sims) # ≈ [-0.3, +0.3] for financial text
signal = clip(raw * 3.0, -1.0, 1.0) # scale to usable range
Ports
| Port | Service | Protocol | Notes |
|---|---|---|---|
| 50051 | Actian VectorAI DB | gRPC | Internal only — never exposed publicly |
| 8000 | FastAPI backend | HTTP + WS | Public API in production (put Nginx in front) |
| 5173 | React frontend | HTTP | Dev only — npm run build for production |
| 8050 | Lookup tool | HTTP | Local only — not deployed |
API Reference
Interactive docs available at http://localhost:8000/docs when the backend is running.
// Start
{ "action": "start", "tickers": ["NVDA", "AAPL", "TSLA"] }
// Stop
{ "action": "stop", "tickers": ["NVDA"] }
{ "source": "live" } // or "mock"
WebSocket
Connect to ws://localhost:8000/ws for real-time push updates.
Event types
initial_state
Sent immediately on connection with current scores and engine state.
{
"type": "initial_state",
"data": {
"monitored_tickers": ["NVDA", "AAPL"],
"data_source": "mock",
"models_loaded": true,
"scores": { "NVDA": { "score": -0.125, "recommendation": "HOLD" } }
}
}
pipeline_progress
Fired at each pipeline step: scraping → embedding → storing → scoring → done.
{
"type": "pipeline_progress",
"data": { "ticker": "NVDA", "step": "scoring" }
}
score_update
Fired after each completed pipeline cycle with the latest score and top articles.
{
"type": "score_update",
"data": {
"ticker": "NVDA",
"score": -0.125,
"recommendation": "HOLD",
"timestamp": "2025-03-01T14:23:11",
"articles_processed": 30,
"top_articles": [...]
}
}
CLI
Run the full pipeline for a single ticker and print a report to the terminal.
python src/main.py NVDA
======================================================================
STOCK SENTIMENT ANALYSIS REPORT
======================================================================
Ticker: NVDA
Recommendation: HOLD
Sentiment Score: -0.1823 (range: -1.0 to 1.0)
Top 3 Most Influential Articles:
----------------------------------------------------------------------
1. Is Nvidia a Buy on the Post-Earnings Dip?
Sentiment: POSITIVE (84.4% confidence) Score: +0.8438
2. Nvidia Faces Headwinds Amid Macro Uncertainty
Sentiment: NEGATIVE (95.4% confidence) Score: -0.9544
Batch Ingest
Score multiple tickers at once from a structured data file or the built-in mock feed.
# Use built-in mock feed (100 tickers, randomly samples 300 articles)
python src/ingest.py
# Provide your own JSON file
python src/ingest.py data.json
Input format
{
"NVDA": [
{
"source": "Bloomberg",
"headline": "Nvidia Q4 data-center revenue smashes forecasts",
"summary": "Nvidia posted record revenue driven by AI accelerator demand..."
}
]
}
Output
TICKER: NVDA RECOMMENDATION: HOLD SCORE: -0.125 (3 articles)
TICKER: AAPL RECOMMENDATION: BUY SCORE: +0.312 (3 articles)
TICKER: TSLA RECOMMENDATION: SELL SCORE: -0.418 (3 articles)
────────────────────────────────────────────────────────
Total: 100 tickers | 300 articles | 12.4s
Lookup Tool
A self-contained local web UI that queries Actian VectorAI DB directly — no API server needed.
./run.sh lookup
# Opens http://localhost:8050
Supports two modes:
- Ticker Lookup — find all stored articles for a symbol
- Semantic Search — natural language query (e.g. "AI chip demand") finds the most similar articles across all tickers using cosine similarity