polygon-io / issues

Quickly track and report problems with polygon.io
29 stars 0 forks source link

Minute aggregates vw price sometimes is lower/higher than low/high #205

Closed smartFunX closed 1 year ago

smartFunX commented 2 years ago

URL https://api.polygon.io/v2/aggs/ticker/SPY/range/1/minute/2022-03-23/2022-03-23

Result One of the returned aggregates looks as following: {"v":325698,"vw":448.4448,"a":446.8876,"o":445.02,"c":444.92,"h":445.1,"l":444.92,"t":1648059240000,"n":805,"op":446.91}

Expected Result I'm expecting "vw" price to be within "l" "h" ranges, but here we see that it is significantly higher than "h". I noticed that it is happening several times during a day (roughly ~ 10 times)

Desktop (please complete the following information):

clickingbuttons commented 2 years ago

Whenever we update volume according to the CTA (page 67) and UTP (page 43) specs we update VWAP (which is "vw").

Since some trades that don't update high/low (like odd lots) do update volume you can see a VWAP outside of high/low bounds. Sadly VWAP is not standardized for aggregates by the CTA/UTP spec. We're open to changing "last" to be the updating condition but it'd be breaking for now.

If you want "vw" to always be between high/low you can aggregate our trades v3 API using the "last" condition. If you want a more accurate VWAP you can ignore conditions altogether but they will likely be outside the bounds of your aggs.

smartFunX commented 2 years ago

Odd lots supposed to be of a lower volume compared to the rest of lots. In the example I shared the odd lot volume moves the vw by 0.75% compared to the high price for that minute, which is very significant. Also it is SPY ETF that shouldn't be that much affected by odd lots?

clickingbuttons commented 2 years ago

Odd lots supposed to be of a lower volume compared to the rest of lots.

In practice this isn't always the case. The SEC has a study that shows odd lot trades for the top decile of stocks contribute to 22% of the total volume.

Also it is SPY ETF that shouldn't be that much affected by odd lots?

It's not just odd lot trades that update volume but not high/low. It's also these conditions: