@tradecanvas/core 0.1.1 → 0.1.3
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 -0
- package/README.md +92 -0
- package/dist/features/ChartState.d.ts.map +1 -1
- package/dist/index.cjs +2 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +30 -6
- package/dist/index.js.map +1 -1
- package/dist/indicators/IndicatorEngine.d.ts +5 -0
- package/dist/indicators/IndicatorEngine.d.ts.map +1 -1
- package/dist/viewport/Viewport.d.ts +1 -0
- package/dist/viewport/Viewport.d.ts.map +1 -1
- package/package.json +16 -9
package/LICENSE
ADDED
|
@@ -0,0 +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.
|
package/README.md
ADDED
|
@@ -0,0 +1,92 @@
|
|
|
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/#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
|
+
Multi-layer canvas rendering for optimal performance -- only dirty layers repaint each frame:
|
|
20
|
+
|
|
21
|
+
```
|
|
22
|
+
UI Layer (price axis, legend, live price) z=3
|
|
23
|
+
Overlay Layer (drawings, trading positions/orders) z=2
|
|
24
|
+
Main Layer (candles, indicators, volume) z=1
|
|
25
|
+
Background (grid, watermark) z=0
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
- `RenderEngine` -- orchestrates the render pipeline
|
|
29
|
+
- `LayerManager` -- manages canvas layer stack
|
|
30
|
+
- `RenderLoop` -- requestAnimationFrame loop with dirty tracking
|
|
31
|
+
- `DPRManager` -- device pixel ratio handling for crisp rendering
|
|
32
|
+
|
|
33
|
+
### Chart Renderers (11 types)
|
|
34
|
+
|
|
35
|
+
`CandlestickRenderer`, `HollowCandleRenderer`, `BarRenderer`, `LineRenderer`, `AreaRenderer`, `BaselineRenderer`, `RenkoRenderer`, `KagiRenderer`, `PointAndFigureRenderer`, `VolumeRenderer`, `CompareRenderer`
|
|
36
|
+
|
|
37
|
+
Data transforms: `toHeikinAshi`, `toRenko`, `toLineBreak`, `toKagi`, `toPointAndFigure`
|
|
38
|
+
|
|
39
|
+
### Indicators (26 built-in)
|
|
40
|
+
|
|
41
|
+
**Overlay** (on price chart): SMA, EMA, Bollinger Bands, Keltner Channel, Donchian Channel, Ichimoku Cloud, Parabolic SAR, Supertrend, VWAP
|
|
42
|
+
|
|
43
|
+
**Panel** (separate sub-chart): RSI, MACD, Stochastic, ATR, ADX, CCI, CMF, MFI, OBV, ROC, TSI, Williams %R, Volume Profile, VROC, Standard Deviation, Accumulation/Distribution, Aroon
|
|
44
|
+
|
|
45
|
+
Extensible via `IndicatorBase` for custom indicators.
|
|
46
|
+
|
|
47
|
+
### Drawing Tools (23)
|
|
48
|
+
|
|
49
|
+
Trendline, Horizontal/Vertical Lines, Ray, Extended Line, Parallel Channel, Fibonacci Retracement/Extension, Rectangle, Ellipse, Triangle, Arrow, Pitchfork, Gann Fan/Box, Elliott Wave, Regression Channel, Date/Price Range, Measure, Anchored VWAP, Volume Profile Range, Text Annotation
|
|
50
|
+
|
|
51
|
+
All tools support magnet snapping, undo/redo, and serialization. Extensible via `DrawingBase`.
|
|
52
|
+
|
|
53
|
+
### Trading
|
|
54
|
+
|
|
55
|
+
- `TradingManager` -- manage positions and orders
|
|
56
|
+
- `TradingRenderer` -- render entry lines, P&L zones, SL/TP markers
|
|
57
|
+
- `OrderRenderer` -- render pending orders with drag-to-modify
|
|
58
|
+
- `DepthOverlay` -- bid/ask depth visualization
|
|
59
|
+
|
|
60
|
+
### Real-Time Streaming
|
|
61
|
+
|
|
62
|
+
- `StreamManager` -- manage data connections with auto-reconnect
|
|
63
|
+
- `BinanceAdapter` -- built-in Binance WebSocket adapter
|
|
64
|
+
- `MockAdapter` -- testing and demo data
|
|
65
|
+
- `TickAggregator` -- aggregate raw ticks into OHLC bars
|
|
66
|
+
- `ReconnectManager` -- exponential backoff reconnection
|
|
67
|
+
|
|
68
|
+
### Interaction
|
|
69
|
+
|
|
70
|
+
- Pan, zoom (wheel/pinch), crosshair tracking
|
|
71
|
+
- Keyboard shortcuts (arrows, +/-, Home/End, Space)
|
|
72
|
+
- Drawing tool interaction with magnet snapping
|
|
73
|
+
|
|
74
|
+
### Features
|
|
75
|
+
|
|
76
|
+
- `AlertManager` -- price and indicator alerts
|
|
77
|
+
- `ReplayManager` -- bar-by-bar historical replay
|
|
78
|
+
- `ChartStateManager` -- save/load chart state as JSON
|
|
79
|
+
- `UndoRedoManager` -- undo/redo for drawings
|
|
80
|
+
- `DataExporter` -- export visible/all data as CSV or JSON
|
|
81
|
+
|
|
82
|
+
### UI
|
|
83
|
+
|
|
84
|
+
- `ChartLegend` -- OHLCV overlay display
|
|
85
|
+
- `Screenshot` -- export chart as PNG
|
|
86
|
+
- `Watermark` -- background text watermark
|
|
87
|
+
- `BarCountdown` -- time until candle close
|
|
88
|
+
- `SessionBreaks` -- market session visualization
|
|
89
|
+
|
|
90
|
+
## License
|
|
91
|
+
|
|
92
|
+
[MIT](https://github.com/bonguynvan/tradecanvas/blob/main/LICENSE)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ChartState.d.ts","sourceRoot":"","sources":["../../src/features/ChartState.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,YAAY,EAAE,YAAY,EAAE,eAAe,EAAE,KAAK,EAAE,MAAM,sBAAsB,CAAC;AAC1G,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAEpD;;;GAGG;AACH,MAAM,WAAW,aAAa;IAC5B,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,EAAE,MAAM,CAAC;IAGlB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,SAAS,EAAE,SAAS,CAAC;IAGrB,QAAQ,EAAE;QACR,QAAQ,EAAE,MAAM,C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