Skip to content

zahirnik/GraphAlpha-core

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

GraphAlpha

Intelligence in Finance — A Temporal Graph Neural Network platform for corporate stress prediction across the S&P 500.

Python 3.11+ License: MIT Status

GraphAlpha models 503 S&P 500 companies as an evolving network — supply-chain dependencies, shared investors, sector co-movement, and board interlocks — and combines temporal graph attention with LLM-extracted features from 10-K/10-Q filings and earnings calls. The result: early signals of corporate financial distress, before traditional metrics react.


Why GraphAlpha?

Most credit-risk models treat companies in isolation. GraphAlpha treats them as a graph that evolves over time, with three signal layers fused together:

  1. Linguistic drift in SEC filings — a company that diverges from its own historical language and from its peers is signaling stress.
  2. Heterogeneous relationships — risk propagates through supply chains, shared investor bases, and sector co-membership.
  3. Temporal attention — the model learns which relationships and which time windows actually matter for contagion.

End-to-end explainability traces every prediction back through attention weights → signal attribution → source sentences in specific filings.


Platform Overview

Watchlist — Real-Time Risk Monitoring

Interactive dashboard tracking 503 S&P 500 companies with risk scores, signal attribution, and a force-directed network graph with animated edge glow effects.

Watchlist

S&P 500 Network Graph

503-node force-directed graph showing inter-company relationships across 5 edge types. Edges glow to highlight active risk pathways.

Network Graph

Company Deep Dive

Per-company analysis with risk gauge, signal category breakdown, temporal risk timeline, feature attribution charts, and a 1-hop neighbor subgraph.

Company Analysis

AI Analyst — LLM-Powered Insights

Auto-generated analyst notes and interactive chat, grounded in the model's signal attribution and graph context.

AI Analyst

Model Performance Comparison

Benchmarking 5 architectures (MLP, Static GNN, TGN, TGAT, GraphAlpha Transformer) on AUROC, Sharpe ratio, hit rate, and cumulative PnL.

Models


Key Results

Model AUROC AUPRC Hit@20 Sharpe
MLP Baseline 0.700 0.450 50% 1.20
Static GNN 0.736 0.520 58% 1.65
TGN 0.710 0.500 55% 1.40
TGAT 0.720 0.530 60% 1.55
GraphAlpha Transformer 0.742 0.627 67% 2.79

Architecture

SEC Filings          Market Data          Earnings Calls
     │                    │                     │
     └────────┬───────────┴──────────┬──────────┘
              │                      │
         Feature Extraction    LLM Extraction (GPT)
              │                      │
     ┌────────┴───────────┐          │
     │                    │          │
Language Drift      Market Signals   Sentiment / Risk Phrases
(Embeddings)        Fundamentals     Management Tone
     │                    │          │
     └────────┬───────────┴──────────┘
              │
        Graph Construction
              │
     ┌────────┴────────────────────────┐
     │                                 │
Heterogeneous Edges (5 types)     Node Features
  • Supply Chain
  • Shared Investors
  • Sector Co-membership
  • Board Interlocks
  • News Co-mention
     │
     └────────┬────────────────────────┘
              │
   Temporal Graph Transformer (multi-head temporal attention)
              │
         Risk Scores (0-1)
              │
   Explainable Reports (attention → attribution → sources)

Tech Stack

  • Models: PyTorch — custom Temporal Graph Transformer with multi-head temporal attention
  • Backend: FastAPI + PyTorch serving
  • Frontend: React + TypeScript + Vite + Chart.js
  • LLM Integration: OpenAI GPT for feature extraction, analyst note generation, and interactive chat
  • Training infra: Slurm-ready (sbatch_production.sh, train_job.sh, llm_worker*.sh)

Quick Start

git clone https://github.com/zahirnik/GraphAlpha-core.git
cd GraphAlpha-core

pip install -e ".[dev]"

pytest

Run the demo app:

streamlit run app/streamlit_app.py

Or the FastAPI backend:

uvicorn app.api.main:app --reload

Project Structure

GraphAlpha-core/
├── src/                       # Core library
│   ├── ingestion/             # SEC Edgar, market data, earnings transcripts
│   ├── features/              # Language drift, embeddings, market features
│   ├── graph/                 # Graph construction, edge builders, entity resolution
│   ├── models/                # MLP, GNNs, GraphAlpha Transformer, baselines
│   ├── training/              # Lightning modules, losses, data loaders
│   ├── evaluation/            # Metrics, backtesting, portfolio sim, ablations
│   └── explain/               # Attention tracing, signal attribution
├── app/                       # FastAPI + React frontend + Streamlit demo
├── configs/                   # Hydra YAML configs
├── scripts/                   # CLI entry points
├── notebooks/                 # Analysis & case studies
├── tests/                     # Unit & integration tests
├── docs/                      # Architecture, ADRs, writeup
├── run_training.py            # Training entry point
├── run_llm_extraction.py      # LLM feature extraction pipeline
├── augment_graph.py           # Graph augmentation
└── train_production.py        # Production training run

Data Sources

  • SEC Edgar — 10-K / 10-Q filings via edgartools
  • Market data — price & volume via yfinance
  • Earnings transcripts — Whisper-based transcription pipeline
  • Fundamentals — income statement / balance sheet via custom ingestion

Disclaimer

This software is under active development and is not recommended for production use. Provided "as is", without warranty of any kind, express or implied.

  • No investment advice. GraphAlpha does not provide investment recommendations, trading signals, or financial advice.
  • No guarantee of accuracy. Risk scores, model outputs, and AI-generated analyst notes may contain errors and must not be relied upon for financial decisions.
  • No liability. The authors and contributors accept no responsibility or liability for any financial loss, damage, or adverse outcome arising from the use of this software.
  • Use at your own risk. By using this software, you acknowledge that it is under development and agree that the authors bear no obligation for its performance, availability, or suitability for any purpose.

Citation

@software{graphalpha2026,
  title  = {GraphAlpha: Temporal Graph Neural Networks for Corporate Stress Prediction},
  author = {Nikraftar, Zahir},
  year   = {2026},
  url    = {https://github.com/zahirnik/GraphAlpha-core}
}

License

MIT — see LICENSE.

About

A Temporal Graph Neural Network platform for corporate stress prediction across the S&P 500. Combines temporal graph attention, LLM-augmented features from SEC filings, and NLP drift detection to identify financial distress signals before traditional models react.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors