All work

Real-time Financial Data Infrastructure

An Azure data layer for 160+ Swedish-listed companies, turning press releases and financial PDFs into classified events, standardized metrics, and consolidated tables for the KalqylAI research bots.

2023–2025AI & ML ConsultantPredli Consulting ABin production

<30s

ingest → consumable

160+

stocks tracked

8,000+

events published downstream

Multi-format

PR + PDF + tables

Stack:pythonazurewebsocketsnaive-bayesdocument-extractionretrievaletlfastapievent-driven

Context

Kalqyl, a Swedish financial media brand owned by Spotlight Group, wanted to publish AI-driven equity research and real-time market commentary across 160+ Swedish-listed companies. Two consumer-facing products were planned on top: a real-time bot (@KalqylAI) that reacts to fresh press releases on X, and a long-form analytical bot that writes structured research reports.

Both products needed a data layer that could detect market-moving disclosures within seconds and turn their attachments into usable financial data. A figure needed its metric, unit, and reporting period before either bot could use it in a comparison or a report.

As the AI & ML consultant from Predli, I owned this infrastructure end to end. That included the event pipeline and the full module for extracting, standardizing, and validating numerical data from the varied financial PDFs attached to press releases.

The problem

The disclosure feed posed four problems:

  1. It arrives in many shapes. A press release is a body of text, but it almost always carries attachments — PDFs of investor decks, Excel tables of financials, image-based scans of legal notices. Reading just the body throws away most of the substance.
  2. A number needs context. Financial PDFs vary in layout, metric names, and units. Figures recur in tables, narrative text, and quarterly filings; quarter labels also need company-specific rules, including for firms with broken-quarter reporting periods.
  3. Volume is bursty, not steady. Quiet days have a handful of releases; quarterly reporting days have dozens of companies reporting in the same hour. The pipeline has to absorb the spike without losing or reordering events.
  4. Not every release matters equally. A board appointment and a profit warning live in the same feed. Downstream agents need to know what they’re looking at before they decide whether to fire.

Publishing to 16,000 investors without human review required attachment parsing, delivery within seconds, and classification before generation. Body-only scraping and minute-scale polling would not meet those requirements.

Architecture

Data infrastructure (Azure)WebSocket listenersAzure Functions for 160+ tickersDocument + financial extractiontext, consolidated tables, metadataRelevancy filterretain material disclosuresPR classifierNaive Bayes: financial vs non-financialEnriched eventshared downstream contractTwitter bot@KalqylAIAnalytical botresearch reports

Scroll sideways to see the full diagram. Use the arrow keys when focused.

Disclosure ingestion, financial enrichment, and the shared event consumed by both bots

The pipeline runs on Azure as a set of decoupled functions, each with one job and a clean handoff to the next.

1. Always-on WebSocket listeners

A pool of Azure Functions subscribes to disclosure feeds for 160+ tickers on the Swedish market. They’re the only stateful part of the system — long-lived connections that wake up downstream functions when a new disclosure lands.

2. Multi-format ingestion and financial enrichment

When a PR drops, the ingestion stage extracts at three levels:

  • Body text — the press release prose itself, cleaned of boilerplate.
  • Attached documents — PDFs and decks get layout-aware parsing instead of being flattened to a wall of text, so headings, captions, and table boundaries survive into the downstream payload.
  • Structured tables — financial statements and KPI tables retain their rows, columns, and headers, so a downstream agent can associate each figure with its label.

The financial PDF module then turns extracted tables into a consolidated numerical view, with standardized metrics, units, and quarter metadata. This enrichment becomes part of the event keyed to the disclosure.

3. Relevancy filter

A first-pass filter drops routine fund holding disclosures, calendar reminders, and regulatory boilerplate before classification or LLM processing. This reduces compute costs and prevents the bots from publishing updates about these routine events.

4. Naive Bayes PR classifier

A Naive Bayes classifier sorts each surviving release into financial (earnings, dividends, capital actions, profit warnings) vs non-financial (personnel, legal, product, M&A intent). The label is a routing key, not the final output — downstream consumers branch on it to pick the right prompt template, the right schema, and the right validation rules.

I chose Naive Bayes for its low cost and adjustable thresholds. The error costs were asymmetric: misrouting a financial release could put an incorrect number in a published tweet, while misrouting a non-financial release could produce a summary in the wrong tone. Calibration focused on that difference.

5. Enriched event → consumers

The final payload brings together the body text, parsed attachments, consolidated financial tables, source and reporting-period metadata, classification, confidence scores, and a stable ID for deduplication. Both bots consume this contract, so they can work from the same financial data without re-parsing the source.

Financial PDF extraction

I developed the complete numerical extraction module, from finding relevant pages to assembling a consolidated table. Extracting a cell was only one step: its label, unit, and quarter had to remain meaningful through validation and consolidation.

Financial PDF attachmentsdocuments linked to press releasesTag relevant pagestables and balance sheetsExtract quarter metadatabroken-quarter rulesExtract table valuesfigures with their metric labelsStandardize metrics + unitsvalues with reporting-period contextCross-check sourcespages, text, quarterly filingsValidate across sourcescompare numerical candidatesConsolidated financial tablemost repeated comparable values

Scroll sideways to see the full diagram. Use the arrow keys when focused.

Financial PDFs to consolidated values, refined through parsing, chunking, and retrieval experiments

Find the pages and reporting context

The module tagged pages containing relevant tables and identified balance sheet pages. It also extracted quarter information and applied company-specific rules for broken-quarter firms, so the output carried a usable reporting period alongside the numbers.

Extract and standardize the numbers

From those pages, the module extracted numerical table entries with their row labels and column context. It standardized metric names and units across the different PDF formats, giving differently presented figures a consistent representation for comparison.

Validate and consolidate

The extracted values were checked against other pages, narrative text, and quarterly filings. For each standardized metric and reporting period, the module assembled the consolidated view by selecting the value that appeared most often across the checked material.

This made repeated agreement an explicit selection rule. The output was a consolidated financial table with metric names, normalized units, and quarter metadata that the research bots could consume directly.

Parsing, chunking, and retrieval experiments

I ran parsing, chunking, and retrieval experiments throughout this work. The central question was whether the document representation preserved enough context to extract a figure and find supporting information elsewhere.

  • Parsing: extracting tables while retaining the labels, headers, and surrounding text needed to interpret them.
  • Chunking: choosing boundaries that kept financial values connected to their metric, unit, and reporting period.
  • Retrieval: finding relevant passages and quarterly filing content for cross-checking the extracted values.

These experiments informed the extraction and validation workflow, as well as how the resulting data was prepared for downstream consumption.

Why this matters as a data layer

Both KalqylAI consumer products got the same answer to the same question: given a fresh disclosure, what can you tell me, fast and accurately? Splitting the data infrastructure out as its own concern is what made that possible:

  • One financial representation. Both bots receive the same consolidated metrics, units, and reporting periods. Improvements to page tagging, extraction, or quarter handling reach both products through the shared event.
  • Cost lives in the right place. Heavy parsing happens once, in the data layer, and is cached against the disclosure ID. Downstream LLM calls operate on already-extracted structure instead of redoing OCR per consumer.
  • Failure modes are localized. A flaky upstream feed shows up as listener errors, not as a hallucinated tweet. A bad classifier threshold shows up as a queue of misrouted events, not as a corrupted research report.

Results

The infrastructure has powered KalqylAI in production since 2023. 8,000+ reports and insights have been published downstream of it, generating 4.6M+ annual views and reaching 16,000+ investors. The case study is on Predli's site.

The bots that ride on it are documented separately as the KalqylAI Bot Suite.

Reflection

The boundary between ingestion and generation mattered most at the level of a single financial value. Page selection, metric names, units, and quarter rules all shaped what that value meant. Resolving that context in the data layer gave both bots a consistent input and made extraction failures easier to separate from generation failures.