Alpaca and polygon data difference for symbol MMM

which one is correct:
alpaca:
{‘High’: 178.67, ‘Low’: 178.57, ‘Open’: 178.62, ‘Close’: 178.67, ‘TotalVolume’: 2402.0, ‘Epoch’: 1642604280000, ‘Time’: datetime.datetime(2022, 1, 19, 14, 58)}

polygon:
{‘Open’: 178.62, ‘Close’: 178.57, ‘High’: 178.67, ‘Low’: 178.57, ‘TotalVolume’: 2402, ‘Epoch’: 1642604280000, ‘Time’: datetime.datetime(2022, 1, 19, 14, 58)}

The close price is different.

another difference on hour candle, this time I think alpaca is correct:
same symbol MMM
alpaca:
{‘High’: 175.55, ‘Low’: 175.55, ‘Open’: 175.55, ‘Close’: 175.55, ‘TotalVolume’: 1292.0, ‘Epoch’: 1637956800000, ‘Time’: datetime.datetime(2021, 11, 26, 20, 0)}
{‘High’: 175.5, ‘Low’: 174.0, ‘Open’: 174.51, ‘Close’: 174.0, ‘TotalVolume’: 3944.0, ‘Epoch’: 1637960400000, ‘Time’: datetime.datetime(2021, 11, 26, 21, 0)}

Polygon:
{‘Open’: 175.52, ‘Close’: 175.52, ‘High’: 175.52, ‘Low’: 175.52, ‘TotalVolume’: 240947, ‘Epoch’: 1637953200000, ‘Time’: datetime.datetime(2021, 11, 26, 19, 0)}
{‘Open’: 175.52, ‘Close’: 175.52, ‘High’: 175.52, ‘Low’: 175.52, ‘TotalVolume’: 0, ‘Epoch’: 1637960400000, ‘Time’: datetime.datetime(2021, 11, 26, 21, 0)}

@sheep The general approach to troubleshooting bar data ‘discrepancies’ is to start with the trades. Fetch all the trades during the bar in question, filter those trades by the trade condition (to leave only valid trades), then calculate the high, low, open, close, and volume as the max, min, first, last, and sum of the respective fields. There is tutorial on how bars are calculated here.

Sometimes the discrepancy can be found as a missing trade or including/excluding different trade conditions. Less frequently, bars may be different because of how each source handles “trade corrections”. Trade corrections are sent by the SIPs to correct, and therefore change, a previously reported trade. These are infrequent but do happen. Alpaca queues all these corrections and applies them at the end of the day, then re-calculates any impacted bars. Alpaca does not update any trades or bars from previous days (only the current one). Other data providers may handle trade corrections differently.

1 Like