penumbra-zone / web

Apache License 2.0
10 stars 7 forks source link

Interpolate candlestick data #1266

Closed turbocrime closed 3 weeks ago

turbocrime commented 3 weeks ago

The candlestick graph in #1220 only renders a candlestick for individual price records, which are specific to single blocks. Price records are created when transactions happen (the best available price is consumed), so records will tend to record downward movement only.

New liquidity may appear in the same block if there is enough at once, but generally, it will appear between the price records. We could visualize this as a candlestick by interpolating between the records.

This creates conceptual issues such as how to choose the window, how to identify a meaningful open/close price for the interpolated window, and perhaps inconsistent candle width, especially with sparse data. But, it would make the graph more legible and accurate - without this feature, a series of downwards candles may actually trend upwards.

This issue may be irrelevant or change significantly with denser price data from denser trading activity.

hdevalence commented 3 weeks ago

I don’t think we want to do any interpolation here. The system works in discrete time, with all trades in the same block happening at the same “time”. If that’s not being reflected in the data then the data is wrong.

hdevalence commented 3 weeks ago

Price records are created when transactions happen (the best available price is consumed), so records will tend to record downward movement only.

This doesn’t make sense — a descending price from one direction is the same as an ascending price from the other direction. Are we only loading half the candlestick data? (See the comment on the RPC method).