> For the complete documentation index, see [llms.txt](https://statalpha.gitbook.io/statalpha-docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://statalpha.gitbook.io/statalpha-docs/stats/news_reaction.md).

# News Reaction Intelligence (Experimental, Confidence: Low)

> **Status:** Experimental. **Confidence:** Low. This module is research-grade and not a final production signal.

News Reaction Intelligence connects already-classified event records with actual market reactions. It does not classify sentiment again. The collector stores event data, and the statistics layer calculates returns, alignment, divergences, and deterministic scores from QuestDB bar data.

## Event Sources

StatAlpha currently stores several event tables in QuestDB:

* `events_earnings`: equity earnings events with actual and expected EPS fields
* `events_crypto`: non-sentiment crypto event calendar records
* `events_macro`: macroeconomic events from FRED, currently broad-market and not symbol-specific
* `events_sentiment`: equity/ETF news sentiment records
* `events_sentiment_crypto`: crypto news sentiment records

News Reaction Intelligence V1 focuses on the sentiment-specific tables:

* `event_source=sentiment` reads from `events_sentiment` and maps to equity/ETF bar tables such as `bars_aapl` or `bars_qqq`
* `event_source=sentiment_crypto` reads from `events_sentiment_crypto` and maps to crypto bar tables using the same collector naming convention, for example `BTC/USD` or `BTCUSD` -> `bars_btcusd`

If `event_source` is omitted, the API defaults to `sentiment`. Crypto requests should pass `event_source=sentiment_crypto` explicitly; V1 does not silently mix equity and crypto sentiment tables.

Earnings, macro, and non-sentiment crypto reactions are roadmap sources. They should be added with source-specific logic rather than forced into the sentiment model.

## Sentiment vs. Market Reaction

Sentiment answers what the headline implies before looking at price action:

* `negative`
* `neutral`
* `positive`
* `impact_score` from `0.0` to `1.0`

Market reaction answers what price actually did after the classified news timestamp. StatAlpha calculates post-news returns over:

* 5 minutes
* 15 minutes
* 30 minutes
* 60 minutes
* end of day, when same-day bars exist

For intraday windows, StatAlpha uses the first available bar at or after the news timestamp as the baseline and the first available bar at or shortly after each target window. Missing bars produce `null` reaction values instead of failing the response.

OpenAI is used by the collector for headline classification only. Returns, alignment labels, and scores are calculated deterministically by StatAlpha.

## Alignment And Divergence

The reaction layer compares the classified sentiment with the 60-minute market reaction:

* `aligned_positive`: positive sentiment followed by an upward move
* `bearish_divergence`: positive sentiment followed by a downward move
* `aligned_negative`: negative sentiment followed by a downward move
* `bullish_absorption`: negative sentiment followed by an upward move
* `neutral_or_unclear`: neutral sentiment, flat price reaction, or missing bars

## Endpoints

| Endpoint                            | Description                                                    |
| ----------------------------------- | -------------------------------------------------------------- |
| `GET /stats/news/reactions`         | Event-level classified news and post-news reaction windows     |
| `GET /stats/news/reactions/summary` | Aggregated reaction metrics for the selected symbol and period |

Common parameters:

* `symbol`
* `event_source`
* `time_window`
* `start_date` / `end_date`
* `direction`
* `min_impact_score`
* `limit`

Examples:

```
/stats/news/reactions?symbol=AAPL&event_source=sentiment&time_window=6M
/stats/news/reactions?symbol=BTCUSD&event_source=sentiment_crypto&time_window=6M
```

## Example Raw Response

```json
{
  "symbol": "AAPL",
  "event_source": "sentiment",
  "time_window": "12M",
  "reaction_windows": ["5m", "15m", "30m", "60m", "eod"],
  "events": [
    {
      "event_source": "sentiment",
      "source_table": "events_sentiment",
      "asset_class": "equity",
      "event_timestamp": "2025-09-12T14:30:00+00:00",
      "title": "AAPL shares rise after product launch",
      "headline": "AAPL shares rise after product launch",
      "direction": "positive",
      "impact_score": 0.72,
      "reactions": {
        "5m": {"return_pct": 0.18, "direction": "up", "absolute_move_pct": 0.18},
        "60m": {"return_pct": 0.64, "direction": "up", "absolute_move_pct": 0.64}
      },
      "reaction_alignment": "aligned_positive",
      "sentiment_reaction_alignment_score": 0.66,
      "impact_realization_score": 0.6,
      "absorption_score": null
    }
  ]
}
```

## Example Summary Response

```json
{
  "symbol": "AAPL",
  "event_source": "sentiment",
  "summary": {
    "total_news_events": 42,
    "average_impact_score": 0.58,
    "dominant_sentiment": "positive",
    "average_return_5m": 0.04,
    "average_return_15m": 0.08,
    "average_return_30m": 0.11,
    "average_return_60m": 0.15,
    "aligned_count": 21,
    "divergence_count": 9,
    "bullish_absorption_count": 4,
    "bearish_divergence_count": 5,
    "average_alignment_score": 0.61,
    "average_impact_realization_score": 0.74
  }
}
```

Future roadmap: `/stats/news/reactions/analyze` may send a compact structured statistics package to OpenAI for customer-friendly interpretation, but not for calculating probabilities, returns, scores, or other hard statistics.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://statalpha.gitbook.io/statalpha-docs/stats/news_reaction.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
