@tradecanvas/core 1.7.0 → 1.10.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -21
- package/README.md +107 -107
- package/dist/WebGLSeriesRenderer-DQOPCwno.js +1643 -0
- package/dist/WebGLSeriesRenderer-DQOPCwno.js.map +1 -0
- package/dist/WebGLSeriesRenderer-DspCYR38.cjs +429 -0
- package/dist/WebGLSeriesRenderer-DspCYR38.cjs.map +1 -0
- package/dist/axis/GridRenderer.d.ts.map +1 -1
- package/dist/axis/PriceAxis.d.ts +3 -1
- package/dist/axis/PriceAxis.d.ts.map +1 -1
- package/dist/axis/TimeAxis.d.ts.map +1 -1
- package/dist/axis/gridLines.d.ts +9 -0
- package/dist/axis/gridLines.d.ts.map +1 -0
- package/dist/charts/BarRenderer.d.ts.map +1 -1
- package/dist/charts/CandlestickRenderer.d.ts.map +1 -1
- package/dist/charts/HollowCandleRenderer.d.ts.map +1 -1
- package/dist/charts/VolumeRenderer.d.ts +6 -3
- package/dist/charts/VolumeRenderer.d.ts.map +1 -1
- package/dist/charts/denseBars.d.ts.map +1 -1
- package/dist/charts/pixelGrid.d.ts +49 -0
- package/dist/charts/pixelGrid.d.ts.map +1 -0
- package/dist/drawings/DrawingBase.d.ts +4 -0
- package/dist/drawings/DrawingBase.d.ts.map +1 -1
- package/dist/drawings/DrawingRenderer.d.ts +2 -2
- package/dist/drawings/DrawingRenderer.d.ts.map +1 -1
- package/dist/drawings/tools/CrossLine.d.ts.map +1 -1
- package/dist/drawings/tools/DateRange.d.ts.map +1 -1
- package/dist/drawings/tools/ElliottWave.d.ts.map +1 -1
- package/dist/drawings/tools/FibChannel.d.ts.map +1 -1
- package/dist/drawings/tools/FibExtension.d.ts.map +1 -1
- package/dist/drawings/tools/FibRetracement.d.ts.map +1 -1
- package/dist/drawings/tools/FibSpeedResistanceFan.d.ts.map +1 -1
- package/dist/drawings/tools/FibTimeZones.d.ts.map +1 -1
- package/dist/drawings/tools/GannBox.d.ts.map +1 -1
- package/dist/drawings/tools/GannFan.d.ts.map +1 -1
- package/dist/drawings/tools/HorizontalLine.d.ts.map +1 -1
- package/dist/drawings/tools/HorizontalRay.d.ts.map +1 -1
- package/dist/drawings/tools/RiskReward.d.ts.map +1 -1
- package/dist/drawings/tools/TextAnnotation.d.ts.map +1 -1
- package/dist/drawings/tools/TrendAngle.d.ts.map +1 -1
- package/dist/drawings/tools/VerticalLine.d.ts.map +1 -1
- package/dist/drawings/tools/annotations.d.ts.map +1 -1
- package/dist/drawings/tools/fibGeometry.d.ts.map +1 -1
- package/dist/drawings/tools/labels.d.ts +26 -0
- package/dist/drawings/tools/labels.d.ts.map +1 -1
- package/dist/drawings/tools/options.d.ts +8 -0
- package/dist/drawings/tools/options.d.ts.map +1 -1
- package/dist/drawings/tools/priceLevels.d.ts.map +1 -1
- package/dist/drawings/tools/textBox.d.ts.map +1 -1
- package/dist/engine/LayerManager.d.ts +23 -0
- package/dist/engine/LayerManager.d.ts.map +1 -1
- package/dist/engine/RenderEngine.d.ts +32 -3
- package/dist/engine/RenderEngine.d.ts.map +1 -1
- package/dist/engine/gpu.d.ts +83 -0
- package/dist/engine/gpu.d.ts.map +1 -0
- package/dist/engine/index.d.ts +2 -0
- package/dist/engine/index.d.ts.map +1 -1
- package/dist/engine/loadWebGL.d.ts +9 -0
- package/dist/engine/loadWebGL.d.ts.map +1 -0
- package/dist/engine/plotSteps.d.ts +39 -0
- package/dist/engine/plotSteps.d.ts.map +1 -0
- package/dist/gridLines-J41F0DQ6.cjs +2 -0
- package/dist/gridLines-J41F0DQ6.cjs.map +1 -0
- package/dist/gridLines-kFhXyH-u.js +218 -0
- package/dist/gridLines-kFhXyH-u.js.map +1 -0
- package/dist/index.cjs +10 -10
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +2982 -2683
- package/dist/index.js.map +1 -1
- package/dist/indicators/IndicatorBase.d.ts.map +1 -1
- package/dist/indicators/IndicatorEngine.d.ts +2 -0
- package/dist/indicators/IndicatorEngine.d.ts.map +1 -1
- package/dist/indicators/linePen.d.ts +38 -0
- package/dist/indicators/linePen.d.ts.map +1 -0
- package/dist/indicators/overlay/Alligator.d.ts.map +1 -1
- package/dist/indicators/overlay/AnchoredVWAP.d.ts.map +1 -1
- package/dist/indicators/overlay/BollingerBands.d.ts.map +1 -1
- package/dist/indicators/overlay/EMA.d.ts.map +1 -1
- package/dist/indicators/overlay/HullMA.d.ts.map +1 -1
- package/dist/indicators/overlay/MTFMovingAverage.d.ts.map +1 -1
- package/dist/indicators/overlay/SMA.d.ts.map +1 -1
- package/dist/indicators/overlay/SessionVWAP.d.ts.map +1 -1
- package/dist/indicators/overlay/Supertrend.d.ts.map +1 -1
- package/dist/indicators/overlay/TEMA.d.ts.map +1 -1
- package/dist/indicators/overlay/VWAP.d.ts.map +1 -1
- package/dist/indicators/overlay/VWMA.d.ts.map +1 -1
- package/dist/indicators/overlay/WMA.d.ts.map +1 -1
- package/dist/indicators/plots.d.ts.map +1 -1
- package/dist/interaction/CrosshairHandler.d.ts.map +1 -1
- package/dist/interaction/InteractionManager.d.ts.map +1 -1
- package/dist/trading/PositionRenderer.d.ts.map +1 -1
- package/dist/trading/TradingDragHandler.d.ts.map +1 -1
- package/dist/trading/TradingManager.d.ts +3 -0
- package/dist/trading/TradingManager.d.ts.map +1 -1
- package/dist/trading/TradingRenderer.d.ts +2 -0
- package/dist/trading/TradingRenderer.d.ts.map +1 -1
- package/dist/trading/plot.d.ts +4 -0
- package/dist/trading/plot.d.ts.map +1 -0
- package/dist/ui/SessionBreaks.d.ts +10 -0
- package/dist/ui/SessionBreaks.d.ts.map +1 -1
- package/dist/ui/SessionShading.d.ts +3 -0
- package/dist/ui/SessionShading.d.ts.map +1 -1
- package/dist/ui/Watermark.d.ts +2 -0
- package/dist/ui/Watermark.d.ts.map +1 -1
- package/dist/ui/axisValueLabels.d.ts +17 -0
- package/dist/ui/axisValueLabels.d.ts.map +1 -1
- package/dist/ui/index.d.ts +2 -1
- package/dist/ui/index.d.ts.map +1 -1
- package/dist/webgl/WebGLSeriesRenderer.d.ts +70 -0
- package/dist/webgl/WebGLSeriesRenderer.d.ts.map +1 -0
- package/dist/webgl/commandDrawer.d.ts +31 -0
- package/dist/webgl/commandDrawer.d.ts.map +1 -0
- package/dist/webgl/glColor.d.ts +13 -0
- package/dist/webgl/glColor.d.ts.map +1 -0
- package/dist/webgl/glKit.d.ts +26 -0
- package/dist/webgl/glKit.d.ts.map +1 -0
- package/dist/webgl/index.d.ts +5 -0
- package/dist/webgl/index.d.ts.map +1 -0
- package/dist/webgl/polygonSpans.d.ts +20 -0
- package/dist/webgl/polygonSpans.d.ts.map +1 -0
- package/dist/webgl/recordedCommands.d.ts +75 -0
- package/dist/webgl/recordedCommands.d.ts.map +1 -0
- package/dist/webgl/recordedPath.d.ts +51 -0
- package/dist/webgl/recordedPath.d.ts.map +1 -0
- package/dist/webgl/recordedShaders.d.ts +38 -0
- package/dist/webgl/recordedShaders.d.ts.map +1 -0
- package/dist/webgl/recorder.d.ts +67 -0
- package/dist/webgl/recorder.d.ts.map +1 -0
- package/dist/webgl/seriesUploads.d.ts +40 -0
- package/dist/webgl/seriesUploads.d.ts.map +1 -0
- package/dist/webgl/shaders.d.ts +39 -0
- package/dist/webgl/shaders.d.ts.map +1 -0
- package/dist/webgl/strokeGeometry.d.ts +28 -0
- package/dist/webgl/strokeGeometry.d.ts.map +1 -0
- package/dist/webgl/yMapping.d.ts +32 -0
- package/dist/webgl/yMapping.d.ts.map +1 -0
- package/package.json +2 -2
package/LICENSE
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
MIT License
|
|
2
|
-
|
|
3
|
-
Copyright (c) 2026 TradeCanvas Contributors
|
|
4
|
-
|
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
-
in the Software without restriction, including without limitation the rights
|
|
8
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
-
furnished to do so, subject to the following conditions:
|
|
11
|
-
|
|
12
|
-
The above copyright notice and this permission notice shall be included in all
|
|
13
|
-
copies or substantial portions of the Software.
|
|
14
|
-
|
|
15
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
-
SOFTWARE.
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 TradeCanvas Contributors
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,107 +1,107 @@
|
|
|
1
|
-
# @tradecanvas/core
|
|
2
|
-
|
|
3
|
-
Canvas rendering engine, indicators, drawing tools, trading overlays, and real-time streaming for the [@tradecanvas/chart](https://www.npmjs.com/package/@tradecanvas/chart) library.
|
|
4
|
-
|
|
5
|
-
**[Live Demo](https://bonguynvan.github.io/tradecanvas/)** | **[GitHub](https://github.com/bonguynvan/tradecanvas)** | **[Documentation](https://bonguynvan.github.io/tradecanvas/docs/getting-started/)**
|
|
6
|
-
|
|
7
|
-
## Install
|
|
8
|
-
|
|
9
|
-
You don't need to install this package directly. It's included as a dependency of `@tradecanvas/chart`.
|
|
10
|
-
|
|
11
|
-
```bash
|
|
12
|
-
npm install @tradecanvas/chart
|
|
13
|
-
```
|
|
14
|
-
|
|
15
|
-
## What's Inside
|
|
16
|
-
|
|
17
|
-
### Rendering Engine
|
|
18
|
-
|
|
19
|
-
Two stacked canvases — a hover repaints only the thin top one:
|
|
20
|
-
|
|
21
|
-
```
|
|
22
|
-
Top canvas (crosshair + axis pills, legend, countdown, measure) z=1
|
|
23
|
-
Scene canvas (grid, candles, indicators, drawings, orders, axes) z=0
|
|
24
|
-
```
|
|
25
|
-
|
|
26
|
-
- `RenderEngine` -- orchestrates the render pipeline
|
|
27
|
-
- `LayerManager` -- the scene and top canvases
|
|
28
|
-
- `RenderLoop` -- requestAnimationFrame loop with dirty tracking
|
|
29
|
-
- `DPRManager` -- device pixel ratio handling for crisp rendering
|
|
30
|
-
|
|
31
|
-
### Chart Renderers (17 types)
|
|
32
|
-
|
|
33
|
-
`CandlestickRenderer`, `HollowCandleRenderer`, `BarRenderer`, `LineRenderer`, `AreaRenderer`, `BaselineRenderer`, `RenkoRenderer`, `KagiRenderer`, `PointAndFigureRenderer`, `VolumeRenderer`, `VolumeCandleRenderer`, `EquivolumeRenderer`, `HLCAreaRenderer`, `StepLineRenderer`, `LineWithMarkersRenderer`, `CompareRenderer`. Heikin-Ashi, Line Break, and Range Bars reuse `CandlestickRenderer` against transformed data.
|
|
34
|
-
|
|
35
|
-
Data transforms: `toHeikinAshi`, `toRenko`, `toLineBreak`, `toKagi`, `toPointAndFigure`, `toRangeBars`
|
|
36
|
-
|
|
37
|
-
### Indicators (33 built-in)
|
|
38
|
-
|
|
39
|
-
**Overlay** (on price chart): SMA, EMA, Hull MA, Bollinger Bands, Keltner Channel, Donchian Channel, Ichimoku Cloud, Parabolic SAR, Supertrend, VWAP, Anchored VWAP, Pivot Points (Classic), ZigZag, Linear Regression Channel
|
|
40
|
-
|
|
41
|
-
**Panel** (separate sub-chart): RSI, MACD, Stochastic, ATR, ADX, CCI, CMF, MFI, OBV, ROC, TSI, Williams %R, Awesome Oscillator, Chaikin Oscillator, Volume Profile, VROC, Standard Deviation, Accumulation/Distribution, Aroon
|
|
42
|
-
|
|
43
|
-
Indicator parameters are read through `getNumberParam` / `getIntParam` helpers, so invalid values (NaN, Infinity, missing keys, non-numeric strings) safely fall back to defaults instead of producing NaN-laced calculations.
|
|
44
|
-
|
|
45
|
-
Extensible via `IndicatorBase` for custom indicators.
|
|
46
|
-
|
|
47
|
-
### Web Worker offload
|
|
48
|
-
|
|
49
|
-
`IndicatorWorkerHost` wraps a `Worker` and exposes a Promise-based `calculate()` so heavy charts can run indicator math off the main thread:
|
|
50
|
-
|
|
51
|
-
```ts
|
|
52
|
-
import { IndicatorWorkerHost } from '@tradecanvas/core'
|
|
53
|
-
|
|
54
|
-
const worker = new Worker(new URL('./dist/indicator.worker.js', import.meta.url), { type: 'module' })
|
|
55
|
-
const host = new IndicatorWorkerHost(worker)
|
|
56
|
-
const output = await host.calculate('rsi', config, bars)
|
|
57
|
-
```
|
|
58
|
-
|
|
59
|
-
Pass `null` instead of a worker for synchronous fallback (SSR, tests). The shipped `indicator.worker.js` registers all 33 built-in indicators and supports `calculate` and `ping` requests.
|
|
60
|
-
|
|
61
|
-
### Drawing Tools (24)
|
|
62
|
-
|
|
63
|
-
Trendline, Horizontal/Vertical Lines, Ray, Extended Line, Parallel Channel, Fibonacci Retracement / Extension / **Time Zones** *(new in 0.8)*, Rectangle, Ellipse, Triangle, Arrow, Pitchfork, Gann Fan/Box, Elliott Wave, Regression Channel, Date/Price Range, Measure, Anchored VWAP, Volume Profile Range, Text Annotation
|
|
64
|
-
|
|
65
|
-
All tools support magnet snapping, undo/redo, and serialization. Extensible via `DrawingBase`.
|
|
66
|
-
|
|
67
|
-
### Trading
|
|
68
|
-
|
|
69
|
-
- `TradingManager` -- manage positions and orders
|
|
70
|
-
- `TradingRenderer` -- render entry lines, P&L zones, SL/TP markers
|
|
71
|
-
- `OrderRenderer` -- render pending orders with drag-to-modify
|
|
72
|
-
- `DepthOverlay` -- bid/ask depth visualization
|
|
73
|
-
|
|
74
|
-
### Real-Time Streaming
|
|
75
|
-
|
|
76
|
-
- `StreamManager` -- manage data connections with auto-reconnect
|
|
77
|
-
- `BinanceAdapter` -- built-in Binance WebSocket adapter
|
|
78
|
-
- `MockAdapter` -- testing and demo data
|
|
79
|
-
- `TickAggregator` -- aggregate raw ticks into OHLC bars
|
|
80
|
-
- `ReconnectManager` -- exponential backoff reconnection
|
|
81
|
-
|
|
82
|
-
### Interaction
|
|
83
|
-
|
|
84
|
-
- Pan, zoom (wheel/pinch), crosshair tracking
|
|
85
|
-
- Keyboard shortcuts (arrows, +/-, Home/End, Space)
|
|
86
|
-
- Drawing tool interaction with magnet snapping
|
|
87
|
-
|
|
88
|
-
### Features
|
|
89
|
-
|
|
90
|
-
- `AlertManager` -- price and indicator alerts
|
|
91
|
-
- `ReplayManager` -- bar-by-bar historical replay (Chart-tied)
|
|
92
|
-
- `ReplayController` *(new in 0.8)* -- headless replay decoupled from Chart; powers backtest visualization
|
|
93
|
-
- `ChartStateManager` -- save/load chart state as JSON
|
|
94
|
-
- `UndoRedoManager` -- undo/redo for drawings
|
|
95
|
-
- `DataExporter` -- export visible/all data as CSV or JSON
|
|
96
|
-
|
|
97
|
-
### UI
|
|
98
|
-
|
|
99
|
-
- `ChartLegend` -- OHLCV overlay display
|
|
100
|
-
- `Screenshot` -- export chart as PNG
|
|
101
|
-
- `Watermark` -- background text watermark
|
|
102
|
-
- `BarCountdown` -- time until candle close
|
|
103
|
-
- `SessionBreaks` -- market session visualization
|
|
104
|
-
|
|
105
|
-
## License
|
|
106
|
-
|
|
107
|
-
[MIT](https://github.com/bonguynvan/tradecanvas/blob/main/LICENSE)
|
|
1
|
+
# @tradecanvas/core
|
|
2
|
+
|
|
3
|
+
Canvas rendering engine, indicators, drawing tools, trading overlays, and real-time streaming for the [@tradecanvas/chart](https://www.npmjs.com/package/@tradecanvas/chart) library.
|
|
4
|
+
|
|
5
|
+
**[Live Demo](https://bonguynvan.github.io/tradecanvas/)** | **[GitHub](https://github.com/bonguynvan/tradecanvas)** | **[Documentation](https://bonguynvan.github.io/tradecanvas/docs/getting-started/)**
|
|
6
|
+
|
|
7
|
+
## Install
|
|
8
|
+
|
|
9
|
+
You don't need to install this package directly. It's included as a dependency of `@tradecanvas/chart`.
|
|
10
|
+
|
|
11
|
+
```bash
|
|
12
|
+
npm install @tradecanvas/chart
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
## What's Inside
|
|
16
|
+
|
|
17
|
+
### Rendering Engine
|
|
18
|
+
|
|
19
|
+
Two stacked canvases — a hover repaints only the thin top one:
|
|
20
|
+
|
|
21
|
+
```
|
|
22
|
+
Top canvas (crosshair + axis pills, legend, countdown, measure) z=1
|
|
23
|
+
Scene canvas (grid, candles, indicators, drawings, orders, axes) z=0
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
- `RenderEngine` -- orchestrates the render pipeline
|
|
27
|
+
- `LayerManager` -- the scene and top canvases
|
|
28
|
+
- `RenderLoop` -- requestAnimationFrame loop with dirty tracking
|
|
29
|
+
- `DPRManager` -- device pixel ratio handling for crisp rendering
|
|
30
|
+
|
|
31
|
+
### Chart Renderers (17 types)
|
|
32
|
+
|
|
33
|
+
`CandlestickRenderer`, `HollowCandleRenderer`, `BarRenderer`, `LineRenderer`, `AreaRenderer`, `BaselineRenderer`, `RenkoRenderer`, `KagiRenderer`, `PointAndFigureRenderer`, `VolumeRenderer`, `VolumeCandleRenderer`, `EquivolumeRenderer`, `HLCAreaRenderer`, `StepLineRenderer`, `LineWithMarkersRenderer`, `CompareRenderer`. Heikin-Ashi, Line Break, and Range Bars reuse `CandlestickRenderer` against transformed data.
|
|
34
|
+
|
|
35
|
+
Data transforms: `toHeikinAshi`, `toRenko`, `toLineBreak`, `toKagi`, `toPointAndFigure`, `toRangeBars`
|
|
36
|
+
|
|
37
|
+
### Indicators (33 built-in)
|
|
38
|
+
|
|
39
|
+
**Overlay** (on price chart): SMA, EMA, Hull MA, Bollinger Bands, Keltner Channel, Donchian Channel, Ichimoku Cloud, Parabolic SAR, Supertrend, VWAP, Anchored VWAP, Pivot Points (Classic), ZigZag, Linear Regression Channel
|
|
40
|
+
|
|
41
|
+
**Panel** (separate sub-chart): RSI, MACD, Stochastic, ATR, ADX, CCI, CMF, MFI, OBV, ROC, TSI, Williams %R, Awesome Oscillator, Chaikin Oscillator, Volume Profile, VROC, Standard Deviation, Accumulation/Distribution, Aroon
|
|
42
|
+
|
|
43
|
+
Indicator parameters are read through `getNumberParam` / `getIntParam` helpers, so invalid values (NaN, Infinity, missing keys, non-numeric strings) safely fall back to defaults instead of producing NaN-laced calculations.
|
|
44
|
+
|
|
45
|
+
Extensible via `IndicatorBase` for custom indicators.
|
|
46
|
+
|
|
47
|
+
### Web Worker offload
|
|
48
|
+
|
|
49
|
+
`IndicatorWorkerHost` wraps a `Worker` and exposes a Promise-based `calculate()` so heavy charts can run indicator math off the main thread:
|
|
50
|
+
|
|
51
|
+
```ts
|
|
52
|
+
import { IndicatorWorkerHost } from '@tradecanvas/core'
|
|
53
|
+
|
|
54
|
+
const worker = new Worker(new URL('./dist/indicator.worker.js', import.meta.url), { type: 'module' })
|
|
55
|
+
const host = new IndicatorWorkerHost(worker)
|
|
56
|
+
const output = await host.calculate('rsi', config, bars)
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
Pass `null` instead of a worker for synchronous fallback (SSR, tests). The shipped `indicator.worker.js` registers all 33 built-in indicators and supports `calculate` and `ping` requests.
|
|
60
|
+
|
|
61
|
+
### Drawing Tools (24)
|
|
62
|
+
|
|
63
|
+
Trendline, Horizontal/Vertical Lines, Ray, Extended Line, Parallel Channel, Fibonacci Retracement / Extension / **Time Zones** *(new in 0.8)*, Rectangle, Ellipse, Triangle, Arrow, Pitchfork, Gann Fan/Box, Elliott Wave, Regression Channel, Date/Price Range, Measure, Anchored VWAP, Volume Profile Range, Text Annotation
|
|
64
|
+
|
|
65
|
+
All tools support magnet snapping, undo/redo, and serialization. Extensible via `DrawingBase`.
|
|
66
|
+
|
|
67
|
+
### Trading
|
|
68
|
+
|
|
69
|
+
- `TradingManager` -- manage positions and orders
|
|
70
|
+
- `TradingRenderer` -- render entry lines, P&L zones, SL/TP markers
|
|
71
|
+
- `OrderRenderer` -- render pending orders with drag-to-modify
|
|
72
|
+
- `DepthOverlay` -- bid/ask depth visualization
|
|
73
|
+
|
|
74
|
+
### Real-Time Streaming
|
|
75
|
+
|
|
76
|
+
- `StreamManager` -- manage data connections with auto-reconnect
|
|
77
|
+
- `BinanceAdapter` -- built-in Binance WebSocket adapter
|
|
78
|
+
- `MockAdapter` -- testing and demo data
|
|
79
|
+
- `TickAggregator` -- aggregate raw ticks into OHLC bars
|
|
80
|
+
- `ReconnectManager` -- exponential backoff reconnection
|
|
81
|
+
|
|
82
|
+
### Interaction
|
|
83
|
+
|
|
84
|
+
- Pan, zoom (wheel/pinch), crosshair tracking
|
|
85
|
+
- Keyboard shortcuts (arrows, +/-, Home/End, Space)
|
|
86
|
+
- Drawing tool interaction with magnet snapping
|
|
87
|
+
|
|
88
|
+
### Features
|
|
89
|
+
|
|
90
|
+
- `AlertManager` -- price and indicator alerts
|
|
91
|
+
- `ReplayManager` -- bar-by-bar historical replay (Chart-tied)
|
|
92
|
+
- `ReplayController` *(new in 0.8)* -- headless replay decoupled from Chart; powers backtest visualization
|
|
93
|
+
- `ChartStateManager` -- save/load chart state as JSON
|
|
94
|
+
- `UndoRedoManager` -- undo/redo for drawings
|
|
95
|
+
- `DataExporter` -- export visible/all data as CSV or JSON
|
|
96
|
+
|
|
97
|
+
### UI
|
|
98
|
+
|
|
99
|
+
- `ChartLegend` -- OHLCV overlay display
|
|
100
|
+
- `Screenshot` -- export chart as PNG
|
|
101
|
+
- `Watermark` -- background text watermark
|
|
102
|
+
- `BarCountdown` -- time until candle close
|
|
103
|
+
- `SessionBreaks` -- market session visualization
|
|
104
|
+
|
|
105
|
+
## License
|
|
106
|
+
|
|
107
|
+
[MIT](https://github.com/bonguynvan/tradecanvas/blob/main/LICENSE)
|