Knowledge Base/How does Massive create aggregate bars?

How does Massive create aggregate bars?

From eligible trades. Each trade carries sale conditions defined by the CTA and UTP plans, and those conditions decide whether it may update the open, high, low, close or volume, so a bar is a sum of eligible trades rather than of all trades.

Rebuilding a Massive aggregate bar from raw ticks and getting a different answer is the usual reason people read this page. The sale conditions on each US stock trade are why: they decide whether a trade may set the open or the close, extend the high or the low, or add to volume, and one trade can be allowed to do some of those and not the others.

Applies to

  • Plans: any Stocks subscription. Other asset classes follow the same shape with their own eligibility rules.
  • Endpoints: /v2/aggs/ticker/... and the grouped endpoint for the bars, /v3/reference/conditions for the rules, /v3/trades for the trades.
  • Asset classes: US stocks above all; options, indices, forex, crypto and futures also aggregate.

How each timespan is assembled

Each timespan is assembled from trades at the smallest sizes and rolled up above that:

TimespanBuilt from
Per secondEligible trades in that second, published about two seconds later to let late messages arrive
Per minuteEligible trades in that minute, published as they arrive and revised if a late trade changes it
Per hourThe minute bars inside the hour, rolled up
Per dayContinuously recalculated through the session, so it absorbs even very late trades
Week, month, quarter, yearRolled up from the daily bars

Because the hour is a roll-up of minutes, an hour bar's volume is the sum of its minute bars' volume and never includes a trade that no minute bar counted.

Why your reconstruction differs

Your reconstruction differs for one of four reasons, in the order they show up:

  1. Eligibility. If you summed every trade, you included prints that our rules exclude from price, volume, or both. This is the big one.
  2. Which timestamp you bucketed on. Bucketing on the participant timestamp puts trades in different windows from bucketing on the SIP timestamp, and the two differ by the SIP's own latency.
  3. size against decimal_size. The integer size is rounded and can be zero on a fractional-share trade. Sum the decimal field.
  4. Corrections. A trade canceled or corrected after you pulled it still counts in your copy. Bars are revised for about 15 minutes on the stream and again at the end of the day.

Other vendors differ from us for the same reasons, applied differently. There is no universal source of truth for OHLC, which is why we follow the CTA and UTP guidelines rather than inventing our own rules.

How to check one trade's eligibility

Take the conditions array from the trade and ask what those codes do. The conditions endpoint answers per code, and separately for the consolidated tape and for a single market center:

curl -X GET "https://api.massive.com/v3/reference/conditions?asset_class=stocks&data_type=trade&id=2&apiKey=YOUR_API_KEY"

Response

{
  "results": [
    {
      "id": 2, "type": "sale_condition", "name": "Average Price Trade",
      "sip_mapping": { "CTA": "B", "UTP": "W", "FINRA_TDDS": "W" },
      "update_rules": {
        "consolidated": { "updates_high_low": false, "updates_open_close": false, "updates_volume": true }
      }
    }
  ],
  "status": "OK"
}

Condition 2 adds to volume and touches no price, so a minute holding only average-price trades produces no bar at all.

If you see an error

A bar that differs from your own by a small amount is usually size against decimal_size.

A bar that differs a lot, or has a high or low you cannot find in the trades, is eligibility. Check the conditions on the trades at the extremes.

A bar that changed after you stored it is a correction, and the REST value is the current one.

Related


Was this article helpful?

Modernizing Wall St.

Reimagining financial market data for the 21st century.

Schedule a demo

Talk with our market data experts

Recommended

Can't find the answer you're looking for? Contact our team.
  • Title
    Are all indices available through the basic subscription tier?
    Data Coverage Category

    Data Coverage

    Indices Category

    Indices

    Description
    No, and the ones it withholds are the famous ones: SPX, DJI, RUT and VIX all need a paid tier. Basic still reaches more than 10,000 of the 13,000-odd indices Massive publishes, and NDX and the Nasdaq Composite are among them.
  • Title
    Does Massive offer dark pool data?
    Data Coverage Category

    Data Coverage

    Stocks Category

    Stocks

    Description
    Yes. Off-exchange prints, which include dark pool executions, arrive on the ordinary trades feed and are identified by an exchange ID of 4. There is no separate dark pool endpoint, and no way to tell which individual venue a print came from.
  • Title
    Does Massive offer pre-market and after-hours data?
    FAQ Category

    FAQ

    Stocks Category

    Stocks

    Description
    Yes. Every extended-hours trade and quote is published, from 04:00 to 20:00 Eastern. There is no session parameter, so you select a session with timestamps, and expect far fewer aggregate bars outside regular hours because most extended-hours trades do not update a bar.