Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Volume data for different bars not adding up #518

Open
kbuyserd opened this issue Jun 12, 2023 · 0 comments
Open

Volume data for different bars not adding up #518

kbuyserd opened this issue Jun 12, 2023 · 0 comments

Comments

@kbuyserd
Copy link

I'm seeing an issue where volume bar data doesn't sum up to the sum of smaller intraday bars. Unless I'm missing something, it appears in the provided example as if the first smaller bar (1 min) that makes up the larger bar (5 min), is not aggregated properly in the larger bar's volume. The picture illustrates this better.

When we look at prices, the 1min 19:54:00 close is also the close for 5min 19:50:00 bar. The same is true for the 1min 19:59:00 and the 5min 19:55:00 bar (and all other instances I've checked). I don't know the system very well, but it would suggest that the lowest level of granularity (also in the backend) is 1min, for if tick data were available, these close prices for the different granularities would not align. This is all fine though.

However with this logic set, we would then expect the 1min 19:50:00 open, to also be the 5min 19:50:00 open. It is not; we instead find the 5min 19:50:00 price of 427.525 at the 1min 19:51:00 timestamp (and likewise for the 19:56:00). This would suggest the problem is not a specific volume aggregation problem, but rather a more general bar aggregation problem.

The above in part is just describing how I would imagine it should work; if my assumptions are wrong, feel free to point that out and close the issue. Thank you

    daily = finnhub_client.stock_candles('SPY', 1, 1685923200, 1686009600)
    df_daily = pd.DataFrame(daily)
    df_daily['t'] = df_daily['t'].apply(lambda x: dt.datetime.utcfromtimestamp(u))

    print(df_daily.set_index('t').between_time('19:50', '20:00').tail(50))

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant