vegaprotocol / frontend-monorepo

Toolkit for building apps that interact with Vega
https://vega.xyz
MIT License
25 stars 17 forks source link

Overlapping candles on chart #4768

Closed JonRay15 closed 7 months ago

JonRay15 commented 1 year ago

Description

We have overlapping candles on the chart, which is bad.

Steps to Reproduce

  1. Go to LINK market on mainnet (update: its on all 3 actually)
  2. Look at it
  3. See overlapping candles (and screeshot)

Expected behavior

The open / close on two adjacent green candles should nmever overlap, it doesnt make sense. Since candle is only green if close > open it shoud be impossible.

Screenshots

image

Tasks

Device details

Desktop (please complete the following information):

Smartphone (please complete the following information):

n/a

Additional context

Add any other context about the problem here.

mattrussell36 commented 1 year ago

@JonRay15 @barnabee I don't actually see any overlapping here, I think the reduced gaps between candles and the zoom level is making it appear that the candles are touching.

barnabee commented 1 year ago

@mattrussell36 I think you are misreading the ticket - it is about the open and close levels (bottom and top of fat part respeectively, for an upward move) not horizontal width and placement.

barnabee commented 1 year ago

To explain the bug more clearly.

IIRC the original definition of a candle given open, high, low, close data is as follows:

Wick (thin part):

Body (fat part):

Candle colour:

So the issue is suggesting that a green candle's body can never overlap another green candle's body because the colour compares the two closing prices, so if they overlap they'd always be different colours.

It doesn't look like pennant applies the hollow/filled logic at all, and it seems like a good number of centralised crypto exchanges also don't do this (or they have so many trades that open vs close and previous close vs close are almost always the same). However they do all seem to use the comparison between period close prices for colouring the candles, not the the open <> close, as far as I can see.

barnabee commented 1 year ago

On TradingView you can switch the type to "hollow candles" rather than candles and you'll see that where the open <> close direction and the previous close <> close direction differ (and assuming a correct data source that does't always send the previous close as open) you get a hollow red or filled green candle:

image

It would be nice for us to support this (as an additional chart type in the dropdown), as well as fix the colouring of the default view. I'd imagine such support would be quite simple given there's no change to the rendering logic only colours and filled or not.

JonRay15 commented 1 year ago

I dont think we know the correct thing here .... this feels like it needs some more investigation and research, and also could be solkved by having a setting to toggle behaviour.

barnabee commented 1 year ago

@JonRay15 I agree we aren't 100% sure what we want for the normal default filled candles behaviour.

Also think the full "hollow candles" new chart type per the definition at the start of this comment can be split out into a second ticket and that is well defined and could be built if we wish (IMO it'd be cool but not essential, perhaps if we had resource to work on Pennant and not much else to do there).