Snapshot daily bar vs get_bars daily bar

Dear Alpaca team,

Thanks for providing such a very good API together with the python bindings.
I’m trying to understand the meaning of the snapshot daily bars. For instance:

>>> print(api.get_bars('AAPL', TimeFrame.Day, start='2022-08-12', end='2022-08-15'))
[Bar({   'c': 172.1,
    'h': 172.17,
    'l': 169.4,
    'n': 557290,
    'o': 169.87,
    't': '2022-08-12T04:00:00Z',
    'v': 67989796,
    'vw': 171.076181}), Bar({   'c': 173.19,
    'h': 173.39,
    'l': 171.345,
    'n': 501625,
    'o': 171.5,
    't': '2022-08-15T04:00:00Z',
    'v': 54091694,
    'vw': 172.625371})]
>>> sn = api.get_snapshot('AAPL')
>>> print(sn.prev_daily_bar)
BarV2({   'c': 172.01,
    'h': 172.01,
    'l': 169.42,
    'n': 12362,
    'o': 169.94,
    't': '2022-08-12T04:00:00Z',
    'v': 1208489,
    'vw': 170.906696})
>>> print(sn.daily_bar)
BarV2({   'c': 173.19,
    'h': 173.385,
    'l': 171.35,
    'n': 8558,
    'o': 171.52,
    't': '2022-08-15T04:00:00Z',
    'v': 786184,
    'vw': 172.62003})

The snapshot daily bar volume is orders of magnitude different from the obtained volume of the get_bars function (here the snapshot is obtained when the market is closed and uses IEX). Does it mean that the daily snapshot bar is not based on a day timeframe? I will have expected the snapshot daily bar to be a cumulative of the minute bars of the current market clock and therefore at the end of the day to match the daily bar obtained with get_bars. I try to use the snapshot daily bar to compute the relative volume live and therefore I expect a minute-based cumulative volume over the market day.

Thanks!

Hey :wave:

The difference you’re seeing is the difference between the IEX and the SIP feed. If you don’t have an Unlimited subscription, the snapshot endpoint (as you know) returns IEX-only data. However, the historical bars endpoint by default returns SIP (all US exchanges) data, if the end argument is older than the last 15 minutes.

If you want, you can query IEX-only data in historical as well using the feed argument:

print(
    api.get_bars(
        symbol="AAPL",
        timeframe=TimeFrame.Day,
        start="2022-08-12",
        end="2022-08-15",
        feed="iex",
    )
)
[Bar({   'c': 172.01,
    'h': 172.01,
    'l': 169.42,
    'n': 12362,
    'o': 169.94,
    't': '2022-08-12T04:00:00Z',
    'v': 1208489,
    'vw': 170.906696}), Bar({   'c': 173.19,
    'h': 173.385,
    'l': 171.35,
    'n': 8558,
    'o': 171.52,
    't': '2022-08-15T04:00:00Z',
    'v': 786184,
    'vw': 172.62003})]

You see that now the volumes match exactly.

Hello!

Thank you for the explanation and the quick answer!

The doc of /bars about the feed parameter is identical as the one for the /snapshot. However, as you explained, feed is SIP by default if the requested time is older than the last 15 minutes and even without a subscription or IEX otherwise. This change of default is an hidden feature! :slight_smile:

Doc statement:
The feed to pull market data from. This is either iex, otc, or sip. sip and otc are only available to those with a subscription. Default is iex for free plans and sip for paid.

In any case, thanks again for your answer, everything is clear now for me.