How does Polygon create the OHLCV (open, high, low, close, volume) aggregate bars? ​

Oct 14, 2022
Updated: Jul 12, 2023

You can use the Conditions endpoint to answer this question. For example, if you want to know how condition '2' on a stock trade affects the OHLCV, you can make the following request:

// GET /v3/reference/conditions?asset_class=stocks&data_type=trade&id=2 ​ { "results": [ { "id": 2, "type": "sale_condition", "name": "Average Price Trade", "asset_class": "stocks", "sip_mapping": { "CTA": "B", "UTP": "W", "FINRA_TDDS": "W" }, "update_rules": { "consolidated": { "updates_high_low": false, "updates_open_close": false, "updates_volume": true }, "market_center": { "updates_high_low": false, "updates_open_close": false, "updates_volume": true } }, "data_types": [ "trade" ] } ], "status": "OK", "request_id": "ff53e56b645039df61bd933737b2ce92", "count": 1 } ​
The Conditions endpoint allows for filtering based on 'asset_class', 'data_type', and 'id'. In this case, our 'asset_class' is stocks, our 'data_type' is 'trade', and the condition ID is '2', so our path all together is '/v3/reference/conditions?asset_class=stocks&data_type=trade&id=2'. The same concept applies to Options data as well

The rules for updating the OHLCV are inside the 'update_rules' field. You'll notice that there are two items inside of 'update_rules': the 'consolidated' rules and the 'market_center' rules. The Securities Information Processors publish two sets of guidelines for aggregating based on these sale conditions: the consolidated processing guidelines and the "Market Center" processing guidelines. (See the CTA Output Specification, pg. 64, or the UTP Output Specification, pg. 43, for the sale conditions matrices and their guidelines for aggregation. Also see OPRA Output Specifications, pg. 24, for the option's sale conditions and guidelines). The Market Center guidelines are meant for aggregating on a per-exchange basis. On the other hand, Polygon.io currently only offers aggregates for the "consolidated" feed (meaning trades from all exchanges), so only the consolidated rules apply.

In this particular case, the 'consolidated' rules show that sale condition 2 (or "Average Price Trade") only updates the volume, but not high and low: 'updates_high_low' is false and 'updates_open_close' is false, but 'updates_volume' is true.

Note that OPRA and the Securities Information Processors publish end-of-day daily aggregate data, so their guidelines apply primarily to daily bars. Because we publish minute aggregates, for such data there are slight differences: in particular, trades in extended-hours markets can update OHLC for minute bars (otherwise there would be no minute aggregates during extended trading hours!).


Was this helpful?
Help us improve
contact

Still have questions?

Get in touch with our team

contact
cta icon
Newsletter

Newsletter Sign Up

Submit your email below and get notified via our email newsletter
cta image
cta icon
Public Slack

Join us on Slack

Submit your email below for an invite to the Polygon.io slack community
cta image
cta icon
Public GitHub

Find us on GitHub

Join an active community of developers contributing to polygon.io
Find us on GitHub
cta image
All data provided on Polygon is provided for informational purposes only, and is not intended for trading or investing purposes. Polygon provides all information as is. You must not redistribute information displayed on or provided by Polygon. Stock prices displayed in the ticker are from a subset of exchanges, this price does not represent the real-time price from the SIP.

© Polygon.io, Inc