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

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

Polygon uses the “Sale Conditions” attached to each trade to determine if that trade is eligible to update the aggregate

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 article helpful?

https://cdn.sanity.io/images/dhlwe0i3/content/5c0778a9628b11955327f4c7b96b2025589ee7df-32x32.svgJoin us on Slack

Enter your email for an invite to our slack community!

https://cdn.sanity.io/images/dhlwe0i3/content/70ffe6ec85723f74679004a0a6bbdf66ce1fb58f-592x256.png

Modernizing Wall St.

Reimagining financial market data for the 21st century.

About Polygon

Recommended

Can’t find the answer you’re looking for? Contact our team.