Tucsky / aggr

Cryptocurrency trades aggregator
https://charts.aggr.trade/
GNU General Public License v3.0
836 stars 241 forks source link

Bitcoin chart is showing the wrong price ("Always normalize mean" option) #246

Closed VanessaE closed 1 year ago

VanessaE commented 1 year ago

(using Google Chrome 105.0.5195.125 on Debian "buster" 11.5)

Describe the issue

After some time, the scale of the candles on aggr.trade goes out of sync with the real prices on an exchange. That is to say, you might see a rise of 500 on the exchange, but aggr might only show 200 or so rise.

Expand that over time and it'll look like the scale of the graph itself changes relative to the price scale as it ages, but if you reload the page, the graph will be re-rendered properly. In fact, it seems to be enough to simply change to another candle timeframe, wait for it to load, and then switch back.

For example, here's BTC/USD as shown on my browser when I started writing this issue, after being open and idle for a few hours:

image

Here it is on my favored exchange (note: I had to edit this image to remove something sensitive):

image

Now, I reload the aggr.trade web page, and notice how the apparent scale of the most recent candles over there on the right has changed relative to the older data:

image

Here's a closeup showing the change:

image

(all images above are 15 minute candle timeframe)

Of course one must ignore the very last candle, but as you can see, the relative vertical positions and/or sizes of the several candles preceding it have changed, even though nothing else about the page has changed.

I haven't noticed how far the scaling issue will go, but I do know it can affect at least the most recent few hours' worth of candles.

Steps to reproduce

Just leave the aggr page open for a while, compare the graph to an exchange, then reload aggr and see the difference.

VanessaE commented 1 year ago

Turns out my charts had "Always normalize mean" enabled. No idea how that happened, as I had been explicitly avoiding that setting (since the tooltip mentions it'll create inaccurate prices).

Tucsky commented 1 year ago

yeah that's the one! you most likely have a pair in your selection that don't have historical data

That option is disabled by default now but wasn't before feb of this year

It is only usefull when mixing pairs (diff assets) on the same chart like creating "indexes", the realtime price is the right one. for pairs that don't have historical data, it rerender the whole chart as soon as the first trade is received for that pair and re-attribute that trade price for previous candle avoiding getting those huge cliffs on the realtime chart

For exemple this is 3 charts with btcusdt and btcusdc on the binance exchange the while lines are BINANCE:btcusdt (full data) and BINANCE:btcusdc (realtime only)

image This was drawn using historical data only (I just refreshed it) "Always normalize mean" is ON Notice the while line (btcusdc is the same price that whole chart, to ensure all pairs on that chart have at least a price)

image Again this was drawn using historical data only but "Always normalize mean" is OFF No white line for btcusdc which have no historical data, no price, average (candlestick) is calculated using btcusdt only

image This one was drawn using realtime data. I just let it run for a while "Always normalize mean" is ON

Hate this option because 99% don't need it and it's tricky to explain, in the end it's just data issue because if I had data since forever for all pairs I wouldn't have to implement it 🤔 Wish I could figure a better name for it