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

[Bug]: Candles stream does not handle empty/zero-volume candles very well #11544

Closed
wwestgarth opened this issue Aug 8, 2024 · 0 comments · Fixed by #11555
Closed

[Bug]: Candles stream does not handle empty/zero-volume candles very well #11544

wwestgarth opened this issue Aug 8, 2024 · 0 comments · Fixed by #11555

Comments

@wwestgarth
Copy link
Contributor

Problem encountered

On discord a user pointed out that the candles stream is a bit odd on markets where no trades occur, and this seems to be due to the handling of empty candles.

On testnet the market 89cc0f6d1616a14c79e7e9a310ef47bdbee0a6874654581ee1f4999c4fcdcd96 is inactive where the last trade occurred on the 20th Jun. If you stream any candles for this market you receive nothing apart from the old candle from months ago where you would expect updates with empty candles:

curl https://api.n00.testnet.vega.rocks/api/v2/stream/candle/data?candleId=trades_candle_15_minutes_89cc0f6d1616a14c79e7e9a310ef47bdbee0a6874654581ee1f4999c4fcdcd96

The reason for this seems to be because when you query candles with no end-timestamp you do not get trailing empty candles. This can bee seen here:

https://api.n00.testnet.vega.rocks/api/v2/candle?candleId=trades_candle_5_minutes_89cc0f6d1616a14c79e7e9a310ef47bdbee0a6874654581ee1f4999c4fcdcd96

but if you do supply an end-timestamp you do get trailing empty candles:

https://api.n00.testnet.vega.rocks/api/v2/candle?candleId=trades_candle_5_minutes_89cc0f6d1616a14c79e7e9a310ef47bdbee0a6874654581ee1f4999c4fcdcd96&toTimestamp=1723112638634349000

The way the candle stream service asks for candles updates is without an end-timestamp:

candles, _, err = s.candleSource.GetCandleDataForTimeSpan(ctx, s.candleID, &start, nil, entities.CursorPagination{})

which in times with no trades will result in no empty candles coming through, and the odd effect where once a trade does occur we will suddenly get all of the empty candles through to the stream at the same time and then the non-empty candle. If a trade never comes through then candle stream remains stuck on the last candle with volume.

Observed behaviour

The stream-candle endpoint does not handle empty-candles very well.

Expected behaviour

The stream-candles endpoint works as expected when empty candles exist.

Steps to reproduce

1. Submit `xyz` transaction
2. With this payload
3. Query `abc` API
4. Observe the error

Software version

develop

Failing test

No response

Jenkins run

No response

Configuration used

No response

Relevant log output

No response

@vega-issues vega-issues moved this to Waiting Review in Core Kanban Aug 12, 2024
@vega-issues vega-issues moved this from Waiting Review to In Review in Core Kanban Aug 12, 2024
@vega-issues vega-issues moved this from In Review to Approved in Core Kanban Aug 12, 2024
@github-project-automation github-project-automation bot moved this from Approved to Merged in Core Kanban Aug 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

1 participant