NewsCrawler.org

TradeCanvas: an open-source browser trading chart engine built on Canvas 2D and WebGL

TradeCanvas: an open-source browser trading chart engine built on Canvas 2D and WebGL
Image: news.hada.io

TradeCanvas is an open-source trading chart library for browsers, published as @tradecanvas/chart under the MIT license. The author shares how the engine is split so that long price histories and constant ticks[1] stay smooth on an ordinary laptop. The library has no runtime third-party dependencies; its minified and gzipped size is 214 KB for Chart and 411 KB for ChartWidget, and the WebGL renderer adds 16 KB on first use.

Each tick passes through several stages, and indicators are recalculated only from the changed bar onward. With 100,000 bars and four indicators, a full recalculation takes about 27 ms per tick, while continuing from the changed bar takes about 0.001 ms. Canvas 2D is the default renderer, and WebGL is optional: a recorder converts Canvas 2D calls into GPU commands, and the two renderers draw the same pixels. Two stacked canvases mean that mouse movement redraws only the top layer.

In a 10-minute test in headless Chrome on an Intel UHD 770 with 1,000,000 one-second bars, 30,000 trades per second, four indicators and a depth heatmap, the frame rate was 56.4–56.7 per second, against 25.6–34.2 for version 1.68.0. The author lists known weak points: bars are stored as an array of objects, some objects are still allocated every frame, adding work for garbage collection[2], and on integrated graphics compositing[3] alone takes about 23 ms at 2560×1400 with pixel ratio 2. The author asks for feedback on bar storage and on the compositing bottleneck on low-end devices.

Read the original github.comDiscussion on GeekNews

Sources

  • KRGeekNews KO

    TradeCanvas – 서드파티 의존성 없이 Canvas 2D와 WebGL로 그리는 오픈소스 트레이딩 차트 엔진

    2 points0 comments

Published: First seen: Читать по-русски

Open as a page