@363045841yyt/klinechart-core 0.8.11-alpha.0 → 0.8.12
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/dist/alerts/createAlertController.d.ts +30 -0
- package/dist/alerts/createAlertController.d.ts.map +1 -0
- package/dist/alerts/createAlertController.js +261 -0
- package/dist/alerts/createAlertController.js.map +1 -0
- package/dist/alerts/index.d.ts +5 -0
- package/dist/alerts/index.d.ts.map +1 -0
- package/dist/alerts/index.js +4 -0
- package/dist/alerts/index.js.map +1 -0
- package/dist/alerts/predicates.d.ts +28 -0
- package/dist/alerts/predicates.d.ts.map +1 -0
- package/dist/alerts/predicates.js +211 -0
- package/dist/alerts/predicates.js.map +1 -0
- package/dist/alerts/rollingVolume.d.ts +15 -0
- package/dist/alerts/rollingVolume.d.ts.map +1 -0
- package/dist/alerts/rollingVolume.js +42 -0
- package/dist/alerts/rollingVolume.js.map +1 -0
- package/dist/alerts/ruleSchema.d.ts +42 -0
- package/dist/alerts/ruleSchema.d.ts.map +1 -0
- package/dist/alerts/ruleSchema.js +240 -0
- package/dist/alerts/ruleSchema.js.map +1 -0
- package/dist/alerts/types.d.ts +169 -0
- package/dist/alerts/types.d.ts.map +1 -0
- package/dist/alerts/types.js +24 -0
- package/dist/alerts/types.js.map +1 -0
- package/dist/chartTypes/heikinAshi.d.ts +49 -0
- package/dist/chartTypes/heikinAshi.d.ts.map +1 -0
- package/dist/chartTypes/heikinAshi.js +94 -0
- package/dist/chartTypes/heikinAshi.js.map +1 -0
- package/dist/chartTypes/index.d.ts +6 -0
- package/dist/chartTypes/index.d.ts.map +1 -0
- package/dist/chartTypes/index.js +5 -0
- package/dist/chartTypes/index.js.map +1 -0
- package/dist/chartTypes/pointAndFigure.d.ts +83 -0
- package/dist/chartTypes/pointAndFigure.d.ts.map +1 -0
- package/dist/chartTypes/pointAndFigure.js +159 -0
- package/dist/chartTypes/pointAndFigure.js.map +1 -0
- package/dist/chartTypes/rangeBars.d.ts +61 -0
- package/dist/chartTypes/rangeBars.d.ts.map +1 -0
- package/dist/chartTypes/rangeBars.js +181 -0
- package/dist/chartTypes/rangeBars.js.map +1 -0
- package/dist/chartTypes/renko.d.ts +94 -0
- package/dist/chartTypes/renko.d.ts.map +1 -0
- package/dist/chartTypes/renko.js +207 -0
- package/dist/chartTypes/renko.js.map +1 -0
- package/dist/chartTypes/types.d.ts +97 -0
- package/dist/chartTypes/types.d.ts.map +1 -0
- package/dist/chartTypes/types.js +39 -0
- package/dist/chartTypes/types.js.map +1 -0
- package/dist/components/anchoredVwap/computeAnchoredVwap.d.ts +76 -0
- package/dist/components/anchoredVwap/computeAnchoredVwap.d.ts.map +1 -0
- package/dist/components/anchoredVwap/computeAnchoredVwap.js +155 -0
- package/dist/components/anchoredVwap/computeAnchoredVwap.js.map +1 -0
- package/dist/components/anchoredVwap/createAnchoredVwapController.d.ts +28 -0
- package/dist/components/anchoredVwap/createAnchoredVwapController.d.ts.map +1 -0
- package/dist/components/anchoredVwap/createAnchoredVwapController.js +282 -0
- package/dist/components/anchoredVwap/createAnchoredVwapController.js.map +1 -0
- package/dist/components/anchoredVwap/index.d.ts +11 -0
- package/dist/components/anchoredVwap/index.d.ts.map +1 -0
- package/dist/components/anchoredVwap/index.js +10 -0
- package/dist/components/anchoredVwap/index.js.map +1 -0
- package/dist/components/anchoredVwap/types.d.ts +171 -0
- package/dist/components/anchoredVwap/types.d.ts.map +1 -0
- package/dist/components/anchoredVwap/types.js +25 -0
- package/dist/components/anchoredVwap/types.js.map +1 -0
- package/dist/components/crosshairSync/createCrosshairSync.d.ts +94 -0
- package/dist/components/crosshairSync/createCrosshairSync.d.ts.map +1 -0
- package/dist/components/crosshairSync/createCrosshairSync.js +118 -0
- package/dist/components/crosshairSync/createCrosshairSync.js.map +1 -0
- package/dist/components/crosshairSync/index.d.ts +2 -0
- package/dist/components/crosshairSync/index.d.ts.map +1 -0
- package/dist/components/crosshairSync/index.js +2 -0
- package/dist/components/crosshairSync/index.js.map +1 -0
- package/dist/components/footprint/aggressor.d.ts +89 -0
- package/dist/components/footprint/aggressor.d.ts.map +1 -0
- package/dist/components/footprint/aggressor.js +106 -0
- package/dist/components/footprint/aggressor.js.map +1 -0
- package/dist/components/footprint/createFootprintController.d.ts +29 -0
- package/dist/components/footprint/createFootprintController.d.ts.map +1 -0
- package/dist/components/footprint/createFootprintController.js +264 -0
- package/dist/components/footprint/createFootprintController.js.map +1 -0
- package/dist/components/footprint/index.d.ts +7 -0
- package/dist/components/footprint/index.d.ts.map +1 -0
- package/dist/components/footprint/index.js +4 -0
- package/dist/components/footprint/index.js.map +1 -0
- package/dist/components/footprint/perBarStats.d.ts +63 -0
- package/dist/components/footprint/perBarStats.d.ts.map +1 -0
- package/dist/components/footprint/perBarStats.js +123 -0
- package/dist/components/footprint/perBarStats.js.map +1 -0
- package/dist/components/footprint/types.d.ts +197 -0
- package/dist/components/footprint/types.d.ts.map +1 -0
- package/dist/components/footprint/types.js +23 -0
- package/dist/components/footprint/types.js.map +1 -0
- package/dist/components/mtfOverlay/alignToBaseIndex.d.ts +45 -0
- package/dist/components/mtfOverlay/alignToBaseIndex.d.ts.map +1 -0
- package/dist/components/mtfOverlay/alignToBaseIndex.js +92 -0
- package/dist/components/mtfOverlay/alignToBaseIndex.js.map +1 -0
- package/dist/components/mtfOverlay/createMtfController.d.ts +7 -0
- package/dist/components/mtfOverlay/createMtfController.d.ts.map +1 -0
- package/dist/components/mtfOverlay/createMtfController.js +134 -0
- package/dist/components/mtfOverlay/createMtfController.js.map +1 -0
- package/dist/components/mtfOverlay/index.d.ts +19 -0
- package/dist/components/mtfOverlay/index.d.ts.map +1 -0
- package/dist/components/mtfOverlay/index.js +18 -0
- package/dist/components/mtfOverlay/index.js.map +1 -0
- package/dist/components/mtfOverlay/resampleBars.d.ts +37 -0
- package/dist/components/mtfOverlay/resampleBars.d.ts.map +1 -0
- package/dist/components/mtfOverlay/resampleBars.js +93 -0
- package/dist/components/mtfOverlay/resampleBars.js.map +1 -0
- package/dist/components/mtfOverlay/types.d.ts +132 -0
- package/dist/components/mtfOverlay/types.d.ts.map +1 -0
- package/dist/components/mtfOverlay/types.js +22 -0
- package/dist/components/mtfOverlay/types.js.map +1 -0
- package/dist/components/orderBookHeatmap/createHeatmapController.d.ts +21 -0
- package/dist/components/orderBookHeatmap/createHeatmapController.d.ts.map +1 -0
- package/dist/components/orderBookHeatmap/createHeatmapController.js +234 -0
- package/dist/components/orderBookHeatmap/createHeatmapController.js.map +1 -0
- package/dist/components/orderBookHeatmap/createOrderBookState.d.ts +18 -0
- package/dist/components/orderBookHeatmap/createOrderBookState.d.ts.map +1 -0
- package/dist/components/orderBookHeatmap/createOrderBookState.js +102 -0
- package/dist/components/orderBookHeatmap/createOrderBookState.js.map +1 -0
- package/dist/components/orderBookHeatmap/deltaArchive.d.ts +25 -0
- package/dist/components/orderBookHeatmap/deltaArchive.d.ts.map +1 -0
- package/dist/components/orderBookHeatmap/deltaArchive.js +106 -0
- package/dist/components/orderBookHeatmap/deltaArchive.js.map +1 -0
- package/dist/components/orderBookHeatmap/index.d.ts +13 -0
- package/dist/components/orderBookHeatmap/index.d.ts.map +1 -0
- package/dist/components/orderBookHeatmap/index.js +12 -0
- package/dist/components/orderBookHeatmap/index.js.map +1 -0
- package/dist/components/orderBookHeatmap/logColorScale.d.ts +20 -0
- package/dist/components/orderBookHeatmap/logColorScale.d.ts.map +1 -0
- package/dist/components/orderBookHeatmap/logColorScale.js +71 -0
- package/dist/components/orderBookHeatmap/logColorScale.js.map +1 -0
- package/dist/components/orderBookHeatmap/snapshotRing.d.ts +16 -0
- package/dist/components/orderBookHeatmap/snapshotRing.d.ts.map +1 -0
- package/dist/components/orderBookHeatmap/snapshotRing.js +61 -0
- package/dist/components/orderBookHeatmap/snapshotRing.js.map +1 -0
- package/dist/components/orderBookHeatmap/types.d.ts +128 -0
- package/dist/components/orderBookHeatmap/types.d.ts.map +1 -0
- package/dist/components/orderBookHeatmap/types.js +16 -0
- package/dist/components/orderBookHeatmap/types.js.map +1 -0
- package/dist/components/volumeProfile/binning.d.ts +54 -0
- package/dist/components/volumeProfile/binning.d.ts.map +1 -0
- package/dist/components/volumeProfile/binning.js +123 -0
- package/dist/components/volumeProfile/binning.js.map +1 -0
- package/dist/components/volumeProfile/createVolumeProfileController.d.ts +31 -0
- package/dist/components/volumeProfile/createVolumeProfileController.d.ts.map +1 -0
- package/dist/components/volumeProfile/createVolumeProfileController.js +179 -0
- package/dist/components/volumeProfile/createVolumeProfileController.js.map +1 -0
- package/dist/components/volumeProfile/index.d.ts +6 -0
- package/dist/components/volumeProfile/index.d.ts.map +1 -0
- package/dist/components/volumeProfile/index.js +5 -0
- package/dist/components/volumeProfile/index.js.map +1 -0
- package/dist/components/volumeProfile/poc.d.ts +35 -0
- package/dist/components/volumeProfile/poc.d.ts.map +1 -0
- package/dist/components/volumeProfile/poc.js +51 -0
- package/dist/components/volumeProfile/poc.js.map +1 -0
- package/dist/components/volumeProfile/types.d.ts +138 -0
- package/dist/components/volumeProfile/types.d.ts.map +1 -0
- package/dist/components/volumeProfile/types.js +19 -0
- package/dist/components/volumeProfile/types.js.map +1 -0
- package/dist/components/volumeProfile/valueArea.d.ts +58 -0
- package/dist/components/volumeProfile/valueArea.d.ts.map +1 -0
- package/dist/components/volumeProfile/valueArea.js +172 -0
- package/dist/components/volumeProfile/valueArea.js.map +1 -0
- package/dist/controllers/createChartController.d.ts.map +1 -1
- package/dist/controllers/createChartController.js +22 -11
- package/dist/controllers/createChartController.js.map +1 -1
- package/dist/controllers/types.d.ts +3 -1
- package/dist/controllers/types.d.ts.map +1 -1
- package/dist/data-fetchers/baostock.d.ts.map +1 -1
- package/dist/data-fetchers/baostock.js +2 -1
- package/dist/data-fetchers/baostock.js.map +1 -1
- package/dist/data-fetchers/dataBuffer.effects.d.ts.map +1 -1
- package/dist/data-fetchers/dataBuffer.effects.js +2 -1
- package/dist/data-fetchers/dataBuffer.effects.js.map +1 -1
- package/dist/data-fetchers/fetcherDefinitionRegistry.d.ts.map +1 -1
- package/dist/data-fetchers/fetcherDefinitionRegistry.js +2 -1
- package/dist/data-fetchers/fetcherDefinitionRegistry.js.map +1 -1
- package/dist/data-fetchers/gotdx.js +4 -3
- package/dist/data-fetchers/gotdx.js.map +1 -1
- package/dist/data-fetchers/router.d.ts.map +1 -1
- package/dist/data-fetchers/router.js +4 -3
- package/dist/data-fetchers/router.js.map +1 -1
- package/dist/data-fetchers/tradingview.js +3 -2
- package/dist/data-fetchers/tradingview.js.map +1 -1
- package/dist/engine/chart.d.ts +13 -0
- package/dist/engine/chart.d.ts.map +1 -1
- package/dist/engine/chart.js +109 -0
- package/dist/engine/chart.js.map +1 -1
- package/dist/engine/data/chartDataManager.d.ts +1 -0
- package/dist/engine/data/chartDataManager.d.ts.map +1 -1
- package/dist/engine/data/chartDataManager.js +27 -4
- package/dist/engine/data/chartDataManager.js.map +1 -1
- package/dist/engine/drawing/toolConfig.d.ts.map +1 -1
- package/dist/engine/drawing/toolConfig.js +2 -1
- package/dist/engine/drawing/toolConfig.js.map +1 -1
- package/dist/engine/indicators/chartIndicatorManager.d.ts.map +1 -1
- package/dist/engine/indicators/chartIndicatorManager.js +2 -1
- package/dist/engine/indicators/chartIndicatorManager.js.map +1 -1
- package/dist/engine/indicators/indicatorDefinitionRegistry.d.ts.map +1 -1
- package/dist/engine/indicators/indicatorDefinitionRegistry.js +2 -1
- package/dist/engine/indicators/indicatorDefinitionRegistry.js.map +1 -1
- package/dist/engine/indicators/indicatorMetadata.d.ts.map +1 -1
- package/dist/engine/indicators/indicatorMetadata.js +2 -1
- package/dist/engine/indicators/indicatorMetadata.js.map +1 -1
- package/dist/engine/indicators/indicatorRegistry.d.ts.map +1 -1
- package/dist/engine/indicators/indicatorRegistry.js +6 -5
- package/dist/engine/indicators/indicatorRegistry.js.map +1 -1
- package/dist/engine/indicators/registerBuiltins.d.ts.map +1 -1
- package/dist/engine/indicators/registerBuiltins.js +2 -1
- package/dist/engine/indicators/registerBuiltins.js.map +1 -1
- package/dist/engine/indicators/scheduler.d.ts +6 -0
- package/dist/engine/indicators/scheduler.d.ts.map +1 -1
- package/dist/engine/indicators/scheduler.js +12 -0
- package/dist/engine/indicators/scheduler.js.map +1 -1
- package/dist/engine/indicators/soa.d.ts.map +1 -1
- package/dist/engine/indicators/soa.js +2 -1
- package/dist/engine/indicators/soa.js.map +1 -1
- package/dist/engine/indicators/stateComposer.d.ts.map +1 -1
- package/dist/engine/indicators/stateComposer.js +2 -1
- package/dist/engine/indicators/stateComposer.js.map +1 -1
- package/dist/engine/subPaneManager.d.ts.map +1 -1
- package/dist/engine/subPaneManager.js +2 -1
- package/dist/engine/subPaneManager.js.map +1 -1
- package/dist/engine/utils/chartZoomController.d.ts +2 -0
- package/dist/engine/utils/chartZoomController.d.ts.map +1 -1
- package/dist/engine/utils/chartZoomController.js +5 -1
- package/dist/engine/utils/chartZoomController.js.map +1 -1
- package/dist/errors-help.d.ts +72 -0
- package/dist/errors-help.d.ts.map +1 -0
- package/dist/errors-help.js +149 -0
- package/dist/errors-help.js.map +1 -0
- package/dist/errors.d.ts +64 -0
- package/dist/errors.d.ts.map +1 -0
- package/dist/errors.js +61 -0
- package/dist/errors.js.map +1 -0
- package/dist/index.d.ts +18 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +22 -0
- package/dist/index.js.map +1 -1
- package/dist/indicators/alma.d.ts +27 -0
- package/dist/indicators/alma.d.ts.map +1 -0
- package/dist/indicators/alma.js +36 -0
- package/dist/indicators/alma.js.map +1 -0
- package/dist/indicators/awesomeOscillator.d.ts +19 -0
- package/dist/indicators/awesomeOscillator.d.ts.map +1 -0
- package/dist/indicators/awesomeOscillator.js +36 -0
- package/dist/indicators/awesomeOscillator.js.map +1 -0
- package/dist/indicators/dpo.d.ts +17 -0
- package/dist/indicators/dpo.d.ts.map +1 -0
- package/dist/indicators/dpo.js +24 -0
- package/dist/indicators/dpo.js.map +1 -0
- package/dist/indicators/fisherTransform.d.ts +26 -0
- package/dist/indicators/fisherTransform.d.ts.map +1 -0
- package/dist/indicators/fisherTransform.js +44 -0
- package/dist/indicators/fisherTransform.js.map +1 -0
- package/dist/indicators/frama.d.ts +25 -0
- package/dist/indicators/frama.d.ts.map +1 -0
- package/dist/indicators/frama.js +61 -0
- package/dist/indicators/frama.js.map +1 -0
- package/dist/indicators/index.d.ts +24 -0
- package/dist/indicators/index.d.ts.map +1 -0
- package/dist/indicators/index.js +26 -0
- package/dist/indicators/index.js.map +1 -0
- package/dist/indicators/lsma.d.ts +21 -0
- package/dist/indicators/lsma.d.ts.map +1 -0
- package/dist/indicators/lsma.js +37 -0
- package/dist/indicators/lsma.js.map +1 -0
- package/dist/indicators/schaffTrendCycle.d.ts +24 -0
- package/dist/indicators/schaffTrendCycle.d.ts.map +1 -0
- package/dist/indicators/schaffTrendCycle.js +70 -0
- package/dist/indicators/schaffTrendCycle.js.map +1 -0
- package/dist/indicators/stochRSI.d.ts +24 -0
- package/dist/indicators/stochRSI.d.ts.map +1 -0
- package/dist/indicators/stochRSI.js +86 -0
- package/dist/indicators/stochRSI.js.map +1 -0
- package/dist/indicators/t3.d.ts +31 -0
- package/dist/indicators/t3.d.ts.map +1 -0
- package/dist/indicators/t3.js +63 -0
- package/dist/indicators/t3.js.map +1 -0
- package/dist/indicators/ultimateOscillator.d.ts +26 -0
- package/dist/indicators/ultimateOscillator.d.ts.map +1 -0
- package/dist/indicators/ultimateOscillator.js +59 -0
- package/dist/indicators/ultimateOscillator.js.map +1 -0
- package/dist/indicators/vidya.d.ts +24 -0
- package/dist/indicators/vidya.d.ts.map +1 -0
- package/dist/indicators/vidya.js +54 -0
- package/dist/indicators/vidya.js.map +1 -0
- package/dist/indicators/zlema.d.ts +16 -0
- package/dist/indicators/zlema.d.ts.map +1 -0
- package/dist/indicators/zlema.js +26 -0
- package/dist/indicators/zlema.js.map +1 -0
- package/dist/input/gesture.d.ts +125 -0
- package/dist/input/gesture.d.ts.map +1 -0
- package/dist/input/gesture.js +249 -0
- package/dist/input/gesture.js.map +1 -0
- package/dist/input/index.d.ts +9 -0
- package/dist/input/index.d.ts.map +1 -0
- package/dist/input/index.js +9 -0
- package/dist/input/index.js.map +1 -0
- package/dist/input/keyboard.d.ts +140 -0
- package/dist/input/keyboard.d.ts.map +1 -0
- package/dist/input/keyboard.js +260 -0
- package/dist/input/keyboard.js.map +1 -0
- package/dist/mcp/chartBridge.d.ts +2 -2
- package/dist/mcp/chartBridge.d.ts.map +1 -1
- package/dist/mcp/chartBridge.js +27 -21
- package/dist/mcp/chartBridge.js.map +1 -1
- package/dist/plugin/PluginHost.d.ts +0 -3
- package/dist/plugin/PluginHost.d.ts.map +1 -1
- package/dist/plugin/PluginHost.js +7 -3
- package/dist/plugin/PluginHost.js.map +1 -1
- package/dist/plugin/PluginRegistry.d.ts +0 -3
- package/dist/plugin/PluginRegistry.d.ts.map +1 -1
- package/dist/plugin/PluginRegistry.js +5 -1
- package/dist/plugin/PluginRegistry.js.map +1 -1
- package/dist/render/Renderer.d.ts +116 -0
- package/dist/render/Renderer.d.ts.map +1 -0
- package/dist/render/Renderer.js +31 -0
- package/dist/render/Renderer.js.map +1 -0
- package/dist/render/SurfaceBackend.d.ts +83 -0
- package/dist/render/SurfaceBackend.d.ts.map +1 -0
- package/dist/render/SurfaceBackend.js +27 -0
- package/dist/render/SurfaceBackend.js.map +1 -0
- package/dist/render/index.d.ts +12 -0
- package/dist/render/index.d.ts.map +1 -0
- package/dist/render/index.js +11 -0
- package/dist/render/index.js.map +1 -0
- package/dist/renderer-tier/detectRendererTier.d.ts +57 -0
- package/dist/renderer-tier/detectRendererTier.d.ts.map +1 -0
- package/dist/renderer-tier/detectRendererTier.js +143 -0
- package/dist/renderer-tier/detectRendererTier.js.map +1 -0
- package/dist/renderer-tier/index.d.ts +12 -0
- package/dist/renderer-tier/index.d.ts.map +1 -0
- package/dist/renderer-tier/index.js +12 -0
- package/dist/renderer-tier/index.js.map +1 -0
- package/dist/renderer-tier/selectBackend.d.ts +106 -0
- package/dist/renderer-tier/selectBackend.d.ts.map +1 -0
- package/dist/renderer-tier/selectBackend.js +113 -0
- package/dist/renderer-tier/selectBackend.js.map +1 -0
- package/dist/renderer-tier/types.d.ts +50 -0
- package/dist/renderer-tier/types.d.ts.map +1 -0
- package/dist/renderer-tier/types.js +24 -0
- package/dist/renderer-tier/types.js.map +1 -0
- package/dist/replay/createReplayController.d.ts +3 -0
- package/dist/replay/createReplayController.d.ts.map +1 -0
- package/dist/replay/createReplayController.js +251 -0
- package/dist/replay/createReplayController.js.map +1 -0
- package/dist/replay/index.d.ts +5 -0
- package/dist/replay/index.d.ts.map +1 -0
- package/dist/replay/index.js +3 -0
- package/dist/replay/index.js.map +1 -0
- package/dist/replay/timeline.d.ts +50 -0
- package/dist/replay/timeline.d.ts.map +1 -0
- package/dist/replay/timeline.js +104 -0
- package/dist/replay/timeline.js.map +1 -0
- package/dist/replay/types.d.ts +94 -0
- package/dist/replay/types.d.ts.map +1 -0
- package/dist/replay/types.js +21 -0
- package/dist/replay/types.js.map +1 -0
- package/dist/scale/anchoredZoom.d.ts +64 -0
- package/dist/scale/anchoredZoom.d.ts.map +1 -0
- package/dist/scale/anchoredZoom.js +67 -0
- package/dist/scale/anchoredZoom.js.map +1 -0
- package/dist/scale/createPriceScale.d.ts +49 -0
- package/dist/scale/createPriceScale.d.ts.map +1 -0
- package/dist/scale/createPriceScale.js +175 -0
- package/dist/scale/createPriceScale.js.map +1 -0
- package/dist/scale/createTimeScale.d.ts +27 -0
- package/dist/scale/createTimeScale.d.ts.map +1 -0
- package/dist/scale/createTimeScale.js +139 -0
- package/dist/scale/createTimeScale.js.map +1 -0
- package/dist/scale/index.d.ts +6 -0
- package/dist/scale/index.d.ts.map +1 -0
- package/dist/scale/index.js +5 -0
- package/dist/scale/index.js.map +1 -0
- package/dist/scale/originShift.d.ts +69 -0
- package/dist/scale/originShift.d.ts.map +1 -0
- package/dist/scale/originShift.js +41 -0
- package/dist/scale/originShift.js.map +1 -0
- package/dist/scale/types.d.ts +90 -0
- package/dist/scale/types.d.ts.map +1 -0
- package/dist/scale/types.js +17 -0
- package/dist/scale/types.js.map +1 -0
- package/dist/scene/createScene.d.ts +22 -0
- package/dist/scene/createScene.d.ts.map +1 -0
- package/dist/scene/createScene.js +114 -0
- package/dist/scene/createScene.js.map +1 -0
- package/dist/scene/index.d.ts +13 -0
- package/dist/scene/index.d.ts.map +1 -0
- package/dist/scene/index.js +11 -0
- package/dist/scene/index.js.map +1 -0
- package/dist/scene/layerRegistry.d.ts +83 -0
- package/dist/scene/layerRegistry.d.ts.map +1 -0
- package/dist/scene/layerRegistry.js +43 -0
- package/dist/scene/layerRegistry.js.map +1 -0
- package/dist/scene/types.d.ts +128 -0
- package/dist/scene/types.d.ts.map +1 -0
- package/dist/scene/types.js +21 -0
- package/dist/scene/types.js.map +1 -0
- package/dist/scheduler/createFrameBudget.d.ts +91 -0
- package/dist/scheduler/createFrameBudget.d.ts.map +1 -0
- package/dist/scheduler/createFrameBudget.js +232 -0
- package/dist/scheduler/createFrameBudget.js.map +1 -0
- package/dist/scheduler/index.d.ts +2 -0
- package/dist/scheduler/index.d.ts.map +1 -0
- package/dist/scheduler/index.js +2 -0
- package/dist/scheduler/index.js.map +1 -0
- package/dist/tokens/themeToCssVars.d.ts.map +1 -1
- package/dist/tokens/themeToCssVars.js +2 -28
- package/dist/tokens/themeToCssVars.js.map +1 -1
- package/dist/version.d.ts +1 -1
- package/dist/version.d.ts.map +1 -1
- package/dist/version.js +1 -1
- package/dist/version.js.map +1 -1
- package/package.json +1 -1
- package/src/__bench__/indicators.bench.ts +215 -0
- package/src/__bench__/orderBookHeatmap.bench.ts +68 -0
- package/src/__bench__/scale.bench.ts +80 -0
- package/src/__bench__/signal.bench.ts +41 -0
- package/src/__bench__/volumeProfile.bench.ts +66 -0
- package/src/__tests__/errors-help.test.ts +184 -0
- package/src/__tests__/errors.test.ts +187 -0
- package/src/alerts/__tests__/controller.test.ts +231 -0
- package/src/alerts/__tests__/predicates.test.ts +374 -0
- package/src/alerts/__tests__/ruleSchema.test.ts +180 -0
- package/src/alerts/createAlertController.ts +312 -0
- package/src/alerts/index.ts +18 -0
- package/src/alerts/predicates.ts +231 -0
- package/src/alerts/rollingVolume.ts +51 -0
- package/src/alerts/ruleSchema.ts +278 -0
- package/src/alerts/types.ts +177 -0
- package/src/chartTypes/__tests__/heikinAshi.test.ts +122 -0
- package/src/chartTypes/__tests__/pointAndFigure.test.ts +167 -0
- package/src/chartTypes/__tests__/rangeBars.test.ts +146 -0
- package/src/chartTypes/__tests__/renko.test.ts +160 -0
- package/src/chartTypes/heikinAshi.ts +116 -0
- package/src/chartTypes/index.ts +5 -0
- package/src/chartTypes/pointAndFigure.ts +278 -0
- package/src/chartTypes/rangeBars.ts +303 -0
- package/src/chartTypes/renko.ts +311 -0
- package/src/chartTypes/types.ts +99 -0
- package/src/components/anchoredVwap/__tests__/computeAnchoredVwap.test.ts +331 -0
- package/src/components/anchoredVwap/__tests__/controller.test.ts +430 -0
- package/src/components/anchoredVwap/computeAnchoredVwap.ts +174 -0
- package/src/components/anchoredVwap/createAnchoredVwapController.ts +358 -0
- package/src/components/anchoredVwap/index.ts +17 -0
- package/src/components/anchoredVwap/types.ts +187 -0
- package/src/components/crosshairSync/__tests__/crosshairSync.test.ts +261 -0
- package/src/components/crosshairSync/createCrosshairSync.ts +187 -0
- package/src/components/crosshairSync/index.ts +5 -0
- package/src/components/footprint/__tests__/aggressor.test.ts +127 -0
- package/src/components/footprint/__tests__/controller.test.ts +130 -0
- package/src/components/footprint/__tests__/perBarStats.test.ts +114 -0
- package/src/components/footprint/aggressor.ts +165 -0
- package/src/components/footprint/createFootprintController.ts +338 -0
- package/src/components/footprint/index.ts +21 -0
- package/src/components/footprint/perBarStats.ts +137 -0
- package/src/components/footprint/types.ts +232 -0
- package/src/components/mtfOverlay/__tests__/alignToBaseIndex.test.ts +103 -0
- package/src/components/mtfOverlay/__tests__/controller.test.ts +172 -0
- package/src/components/mtfOverlay/__tests__/resampleBars.test.ts +106 -0
- package/src/components/mtfOverlay/alignToBaseIndex.ts +108 -0
- package/src/components/mtfOverlay/createMtfController.ts +180 -0
- package/src/components/mtfOverlay/index.ts +26 -0
- package/src/components/mtfOverlay/resampleBars.ts +134 -0
- package/src/components/mtfOverlay/types.ts +148 -0
- package/src/components/orderBookHeatmap/__tests__/controller.test.ts +237 -0
- package/src/components/orderBookHeatmap/__tests__/deltaArchive.test.ts +88 -0
- package/src/components/orderBookHeatmap/__tests__/logColorScale.test.ts +69 -0
- package/src/components/orderBookHeatmap/__tests__/orderBookState.test.ts +113 -0
- package/src/components/orderBookHeatmap/__tests__/snapshotRing.test.ts +53 -0
- package/src/components/orderBookHeatmap/computeShader.wgsl.md +130 -0
- package/src/components/orderBookHeatmap/createHeatmapController.ts +273 -0
- package/src/components/orderBookHeatmap/createOrderBookState.ts +116 -0
- package/src/components/orderBookHeatmap/deltaArchive.ts +113 -0
- package/src/components/orderBookHeatmap/index.ts +25 -0
- package/src/components/orderBookHeatmap/logColorScale.ts +77 -0
- package/src/components/orderBookHeatmap/snapshotRing.ts +65 -0
- package/src/components/orderBookHeatmap/types.ts +168 -0
- package/src/components/volumeProfile/__tests__/binning.test.ts +133 -0
- package/src/components/volumeProfile/__tests__/poc.test.ts +44 -0
- package/src/components/volumeProfile/__tests__/valueArea.test.ts +177 -0
- package/src/components/volumeProfile/binning.ts +133 -0
- package/src/components/volumeProfile/createVolumeProfileController.ts +213 -0
- package/src/components/volumeProfile/index.ts +12 -0
- package/src/components/volumeProfile/poc.ts +53 -0
- package/src/components/volumeProfile/types.ts +148 -0
- package/src/components/volumeProfile/valueArea.ts +187 -0
- package/src/controllers/createChartController.ts +23 -10
- package/src/controllers/types.ts +5 -1
- package/src/data-fetchers/baostock.ts +2 -1
- package/src/data-fetchers/dataBuffer.effects.ts +3 -1
- package/src/data-fetchers/fetcherDefinitionRegistry.ts +2 -1
- package/src/data-fetchers/gotdx.ts +4 -3
- package/src/data-fetchers/router.ts +6 -3
- package/src/data-fetchers/tradingview.ts +3 -2
- package/src/engine/chart.ts +126 -3
- package/src/engine/data/chartDataManager.ts +26 -4
- package/src/engine/drawing/toolConfig.ts +2 -1
- package/src/engine/indicators/chartIndicatorManager.ts +2 -1
- package/src/engine/indicators/indicatorDefinitionRegistry.ts +2 -1
- package/src/engine/indicators/indicatorMetadata.ts +2 -1
- package/src/engine/indicators/indicatorRegistry.ts +6 -5
- package/src/engine/indicators/registerBuiltins.ts +2 -1
- package/src/engine/indicators/scheduler.ts +15 -0
- package/src/engine/indicators/soa.ts +2 -1
- package/src/engine/indicators/stateComposer.ts +2 -1
- package/src/engine/subPaneManager.ts +2 -1
- package/src/engine/utils/chartZoomController.ts +7 -1
- package/src/errors-help.ts +218 -0
- package/src/errors.ts +128 -0
- package/src/index.ts +37 -0
- package/src/indicators/__tests__/maFamily.test.ts +159 -0
- package/src/indicators/__tests__/oscillators.test.ts +150 -0
- package/src/indicators/alma.ts +61 -0
- package/src/indicators/awesomeOscillator.ts +54 -0
- package/src/indicators/dpo.ts +37 -0
- package/src/indicators/fisherTransform.ts +63 -0
- package/src/indicators/frama.ts +87 -0
- package/src/indicators/index.ts +39 -0
- package/src/indicators/lsma.ts +58 -0
- package/src/indicators/schaffTrendCycle.ts +92 -0
- package/src/indicators/stochRSI.ts +108 -0
- package/src/indicators/t3.ts +96 -0
- package/src/indicators/ultimateOscillator.ts +83 -0
- package/src/indicators/vidya.ts +80 -0
- package/src/indicators/zlema.ts +41 -0
- package/src/input/__tests__/gesture.test.ts +271 -0
- package/src/input/__tests__/keyboard.test.ts +317 -0
- package/src/input/gesture.ts +357 -0
- package/src/input/index.ts +26 -0
- package/src/input/keyboard.ts +373 -0
- package/src/mcp/chartBridge.ts +98 -72
- package/src/plugin/PluginHost.ts +4 -3
- package/src/plugin/PluginRegistry.ts +2 -1
- package/src/render/Renderer.ts +127 -0
- package/src/render/SurfaceBackend.ts +94 -0
- package/src/render/__tests__/contract.test.ts +176 -0
- package/src/render/index.ts +27 -0
- package/src/renderer-tier/__tests__/detectRendererTier.test.ts +180 -0
- package/src/renderer-tier/__tests__/selectBackend.test.ts +253 -0
- package/src/renderer-tier/detectRendererTier.ts +168 -0
- package/src/renderer-tier/index.ts +30 -0
- package/src/renderer-tier/selectBackend.ts +201 -0
- package/src/renderer-tier/types.ts +59 -0
- package/src/replay/__tests__/controller.test.ts +309 -0
- package/src/replay/__tests__/timeline.test.ts +99 -0
- package/src/replay/createReplayController.ts +302 -0
- package/src/replay/index.ts +15 -0
- package/src/replay/timeline.ts +106 -0
- package/src/replay/types.ts +107 -0
- package/src/scale/__tests__/anchoredZoom.test.ts +125 -0
- package/src/scale/__tests__/originShift.test.ts +97 -0
- package/src/scale/__tests__/priceScale.test.ts +219 -0
- package/src/scale/__tests__/timeScale.test.ts +119 -0
- package/src/scale/anchoredZoom.ts +104 -0
- package/src/scale/createPriceScale.ts +226 -0
- package/src/scale/createTimeScale.ts +150 -0
- package/src/scale/index.ts +9 -0
- package/src/scale/originShift.ts +111 -0
- package/src/scale/types.ts +100 -0
- package/src/scene/__tests__/layerRegistry.test.ts +207 -0
- package/src/scene/__tests__/scene.test.ts +411 -0
- package/src/scene/createScene.ts +117 -0
- package/src/scene/index.ts +29 -0
- package/src/scene/layerRegistry.ts +117 -0
- package/src/scene/types.ts +143 -0
- package/src/scheduler/__tests__/createFrameBudget.test.ts +315 -0
- package/src/scheduler/createFrameBudget.ts +316 -0
- package/src/scheduler/index.ts +7 -0
- package/src/tokens/themeToCssVars.ts +3 -1
- package/src/version.ts +1 -1
- package/dist/data-fetchers/gotdx/gotdx.d.ts +0 -7
- package/dist/data-fetchers/gotdx/gotdx.d.ts.map +0 -1
- package/dist/data-fetchers/gotdx/gotdx.js +0 -7
- package/dist/data-fetchers/gotdx/gotdx.js.map +0 -1
- package/src/data-fetchers/gotdx/gotdx.ts +0 -6
|
@@ -0,0 +1,234 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* HeatmapController — composes the order-book accumulator, snapshot ring,
|
|
3
|
+
* and delta archive into a single reactive surface.
|
|
4
|
+
*
|
|
5
|
+
* Timing (this is load-bearing): we do **not** schedule snapshots via
|
|
6
|
+
* `setInterval`. The controller treats incoming delta timestamps as the
|
|
7
|
+
* wall clock. When `ingestDelta` sees a delta whose timestamp is more than
|
|
8
|
+
* `snapshotIntervalMs` after the previous snapshot, it pushes a snapshot
|
|
9
|
+
* before applying the new delta. Two upsides:
|
|
10
|
+
*
|
|
11
|
+
* 1. Deterministic tests — no fake timers required.
|
|
12
|
+
* 2. Correct under bursty traffic — snapshot cadence follows market time,
|
|
13
|
+
* not real time, so replay and live observation see the same grid.
|
|
14
|
+
*
|
|
15
|
+
* The `state` signal updates once per delta ingested. It exposes the
|
|
16
|
+
* **latest** snapshot (for read-time convenience) plus the cumulative
|
|
17
|
+
* snapshot / delta counts so adapters can use it as a render trigger.
|
|
18
|
+
*/
|
|
19
|
+
import { createSignal } from '../../reactivity';
|
|
20
|
+
import { KLineChartError } from '../../errors';
|
|
21
|
+
import { createDeltaArchive } from './deltaArchive';
|
|
22
|
+
import { createLogColorScale } from './logColorScale';
|
|
23
|
+
import { createOrderBookState } from './createOrderBookState';
|
|
24
|
+
import { createSnapshotRing } from './snapshotRing';
|
|
25
|
+
const DEFAULT_CONFIG = {
|
|
26
|
+
tickSize: 0.01,
|
|
27
|
+
snapshotIntervalMs: 100,
|
|
28
|
+
snapshotRingCapacity: 600,
|
|
29
|
+
deltaArchiveMaxSize: 1_000_000,
|
|
30
|
+
logColorRange: { sizeMin: 1, sizeMax: 1_000_000 },
|
|
31
|
+
};
|
|
32
|
+
export function createHeatmapController(init) {
|
|
33
|
+
let config = { ...DEFAULT_CONFIG, ...init };
|
|
34
|
+
if (init?.logColorRange) {
|
|
35
|
+
config = { ...config, logColorRange: { ...init.logColorRange } };
|
|
36
|
+
}
|
|
37
|
+
validateConfig(config);
|
|
38
|
+
let book = createOrderBookState({ tickSize: config.tickSize });
|
|
39
|
+
let ring = createSnapshotRing(config.snapshotRingCapacity);
|
|
40
|
+
let archive = createDeltaArchive({
|
|
41
|
+
maxSize: config.deltaArchiveMaxSize,
|
|
42
|
+
});
|
|
43
|
+
const colorScale = createLogColorScale(config.logColorRange.sizeMin, config.logColorRange.sizeMax);
|
|
44
|
+
const state = createSignal({
|
|
45
|
+
latestSnapshot: null,
|
|
46
|
+
snapshotCount: 0,
|
|
47
|
+
deltaCount: 0,
|
|
48
|
+
});
|
|
49
|
+
// `snapshotClock` is the timestamp of the LAST emitted (or anchored)
|
|
50
|
+
// snapshot column. It advances by exactly `snapshotIntervalMs` per
|
|
51
|
+
// emission so we never drift even if deltas cluster mid-interval, and
|
|
52
|
+
// we don't depend on `book.lastTimestamp()` (which lags behind the
|
|
53
|
+
// grid clock when the book is quiescent).
|
|
54
|
+
let snapshotClock = null;
|
|
55
|
+
let snapshotCount = 0;
|
|
56
|
+
let deltaCount = 0;
|
|
57
|
+
let disposed = false;
|
|
58
|
+
function pushSnapshotAt(ts) {
|
|
59
|
+
const raw = book.snapshot();
|
|
60
|
+
const snap = {
|
|
61
|
+
bids: raw.bids,
|
|
62
|
+
asks: raw.asks,
|
|
63
|
+
timestamp: ts,
|
|
64
|
+
};
|
|
65
|
+
ring.push(snap);
|
|
66
|
+
snapshotCount++;
|
|
67
|
+
return snap;
|
|
68
|
+
}
|
|
69
|
+
function publish(latest) {
|
|
70
|
+
state.set({
|
|
71
|
+
latestSnapshot: latest,
|
|
72
|
+
snapshotCount,
|
|
73
|
+
deltaCount,
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
function ingestDelta(delta) {
|
|
77
|
+
if (disposed)
|
|
78
|
+
return;
|
|
79
|
+
const interval = config.snapshotIntervalMs;
|
|
80
|
+
// 1. Anchor the snapshot clock to the first delta we ever see.
|
|
81
|
+
// The first delta does NOT trigger a snapshot — there is no
|
|
82
|
+
// prior column to emit. The snapshot for column N (timestamp
|
|
83
|
+
// `anchor + N * interval`) is emitted when a delta with
|
|
84
|
+
// timestamp ≥ `anchor + (N+1) * interval` arrives.
|
|
85
|
+
if (snapshotClock === null) {
|
|
86
|
+
snapshotClock = delta.timestamp;
|
|
87
|
+
archive.append(delta);
|
|
88
|
+
deltaCount++;
|
|
89
|
+
book.applyDelta(delta);
|
|
90
|
+
publish(state.peek().latestSnapshot);
|
|
91
|
+
return;
|
|
92
|
+
}
|
|
93
|
+
// 2. Emit one snapshot per interval boundary CROSSED. The snapshot
|
|
94
|
+
// captures the book state up to (but not including) `delta`.
|
|
95
|
+
const maxCatchUp = config.snapshotRingCapacity;
|
|
96
|
+
let emitted = 0;
|
|
97
|
+
let latest = state.peek().latestSnapshot;
|
|
98
|
+
while (delta.timestamp - snapshotClock >= interval &&
|
|
99
|
+
emitted < maxCatchUp) {
|
|
100
|
+
snapshotClock += interval;
|
|
101
|
+
latest = pushSnapshotAt(snapshotClock);
|
|
102
|
+
emitted++;
|
|
103
|
+
}
|
|
104
|
+
// 3. Record the raw delta and update the live book.
|
|
105
|
+
archive.append(delta);
|
|
106
|
+
deltaCount++;
|
|
107
|
+
book.applyDelta(delta);
|
|
108
|
+
publish(latest);
|
|
109
|
+
}
|
|
110
|
+
function forceSnapshot() {
|
|
111
|
+
if (disposed)
|
|
112
|
+
return;
|
|
113
|
+
// `forceSnapshot` uses the book's latest delta timestamp as the
|
|
114
|
+
// column timestamp — it's an out-of-band emission, not a
|
|
115
|
+
// grid-aligned one, so we don't advance `snapshotClock`.
|
|
116
|
+
const snap = pushSnapshotAt(book.lastTimestamp());
|
|
117
|
+
publish(snap);
|
|
118
|
+
}
|
|
119
|
+
function replay(fromTimestamp, toTimestamp, snapshotIntervalMs) {
|
|
120
|
+
if (disposed)
|
|
121
|
+
return [];
|
|
122
|
+
if (snapshotIntervalMs <= 0) {
|
|
123
|
+
throw new KLineChartError('HEATMAP_CONFIG_INVALID', 'replay: snapshotIntervalMs must be > 0');
|
|
124
|
+
}
|
|
125
|
+
if (toTimestamp < fromTimestamp)
|
|
126
|
+
return [];
|
|
127
|
+
// Reconstruct from a brand-new book. We don't reuse `book` because
|
|
128
|
+
// replay must be side-effect-free with respect to live state.
|
|
129
|
+
const replayBook = createOrderBookState({ tickSize: config.tickSize });
|
|
130
|
+
// We need ALL deltas up to `toTimestamp` to reach the correct state;
|
|
131
|
+
// we just don't emit snapshots before `fromTimestamp`.
|
|
132
|
+
const deltas = archive.range(Number.NEGATIVE_INFINITY, toTimestamp);
|
|
133
|
+
// Stable sort by timestamp (archive append order is mostly but not
|
|
134
|
+
// strictly monotonic — defending against out-of-order arrivals).
|
|
135
|
+
const sorted = [...deltas].sort((a, b) => a.timestamp - b.timestamp);
|
|
136
|
+
const out = [];
|
|
137
|
+
let nextSnapTs = fromTimestamp;
|
|
138
|
+
let cursor = 0;
|
|
139
|
+
while (nextSnapTs <= toTimestamp) {
|
|
140
|
+
// Apply every delta with ts ≤ nextSnapTs.
|
|
141
|
+
while (cursor < sorted.length && sorted[cursor].timestamp <= nextSnapTs) {
|
|
142
|
+
replayBook.applyDelta(sorted[cursor]);
|
|
143
|
+
cursor++;
|
|
144
|
+
}
|
|
145
|
+
const snap = replayBook.snapshot();
|
|
146
|
+
// Pin the snapshot timestamp to the grid column, not the latest
|
|
147
|
+
// delta — callers want a regular series.
|
|
148
|
+
out.push({
|
|
149
|
+
bids: snap.bids,
|
|
150
|
+
asks: snap.asks,
|
|
151
|
+
timestamp: nextSnapTs,
|
|
152
|
+
});
|
|
153
|
+
nextSnapTs += snapshotIntervalMs;
|
|
154
|
+
}
|
|
155
|
+
return out;
|
|
156
|
+
}
|
|
157
|
+
function setConfig(next) {
|
|
158
|
+
if (disposed)
|
|
159
|
+
return;
|
|
160
|
+
const merged = { ...config, ...next };
|
|
161
|
+
if (next.logColorRange) {
|
|
162
|
+
merged.logColorRange = { ...next.logColorRange };
|
|
163
|
+
}
|
|
164
|
+
validateConfig(merged);
|
|
165
|
+
const tickChanged = merged.tickSize !== config.tickSize;
|
|
166
|
+
const capacityChanged = merged.snapshotRingCapacity !== config.snapshotRingCapacity;
|
|
167
|
+
const archiveMaxChanged = merged.deltaArchiveMaxSize !== config.deltaArchiveMaxSize;
|
|
168
|
+
const colorChanged = merged.logColorRange.sizeMin !== config.logColorRange.sizeMin ||
|
|
169
|
+
merged.logColorRange.sizeMax !== config.logColorRange.sizeMax;
|
|
170
|
+
config = merged;
|
|
171
|
+
if (tickChanged) {
|
|
172
|
+
// Rebuild book against the new tick. Replay archive so the live
|
|
173
|
+
// view stays in sync with what we've already ingested.
|
|
174
|
+
book = createOrderBookState({ tickSize: config.tickSize });
|
|
175
|
+
const all = archive.range(Number.NEGATIVE_INFINITY, Number.POSITIVE_INFINITY);
|
|
176
|
+
for (const d of all)
|
|
177
|
+
book.applyDelta(d);
|
|
178
|
+
}
|
|
179
|
+
if (capacityChanged) {
|
|
180
|
+
const old = ring.toArray();
|
|
181
|
+
ring = createSnapshotRing(config.snapshotRingCapacity);
|
|
182
|
+
// Replay tail into the new ring.
|
|
183
|
+
const start = Math.max(0, old.length - config.snapshotRingCapacity);
|
|
184
|
+
for (let i = start; i < old.length; i++)
|
|
185
|
+
ring.push(old[i]);
|
|
186
|
+
}
|
|
187
|
+
if (archiveMaxChanged) {
|
|
188
|
+
archive.trim(config.deltaArchiveMaxSize);
|
|
189
|
+
}
|
|
190
|
+
if (colorChanged) {
|
|
191
|
+
colorScale.setRange(config.logColorRange.sizeMin, config.logColorRange.sizeMax);
|
|
192
|
+
}
|
|
193
|
+
publish(state.peek().latestSnapshot);
|
|
194
|
+
}
|
|
195
|
+
function dispose() {
|
|
196
|
+
if (disposed)
|
|
197
|
+
return;
|
|
198
|
+
disposed = true;
|
|
199
|
+
book.clear();
|
|
200
|
+
ring.clear();
|
|
201
|
+
archive.clear();
|
|
202
|
+
}
|
|
203
|
+
return {
|
|
204
|
+
state,
|
|
205
|
+
// Canonical verb (API audit BLOCKER-001 harmonisation). Same impl
|
|
206
|
+
// as `ingestDelta` — existing consumers stay working.
|
|
207
|
+
ingest: ingestDelta,
|
|
208
|
+
ingestDelta,
|
|
209
|
+
forceSnapshot,
|
|
210
|
+
replay,
|
|
211
|
+
setConfig,
|
|
212
|
+
dispose,
|
|
213
|
+
};
|
|
214
|
+
}
|
|
215
|
+
function validateConfig(c) {
|
|
216
|
+
if (!(c.tickSize > 0))
|
|
217
|
+
throw new KLineChartError('HEATMAP_CONFIG_INVALID', 'HeatmapController: tickSize must be > 0');
|
|
218
|
+
if (!(c.snapshotIntervalMs > 0)) {
|
|
219
|
+
throw new KLineChartError('HEATMAP_CONFIG_INVALID', 'HeatmapController: snapshotIntervalMs must be > 0');
|
|
220
|
+
}
|
|
221
|
+
if (!Number.isInteger(c.snapshotRingCapacity) || c.snapshotRingCapacity <= 0) {
|
|
222
|
+
throw new KLineChartError('HEATMAP_CONFIG_INVALID', 'HeatmapController: snapshotRingCapacity must be a positive integer');
|
|
223
|
+
}
|
|
224
|
+
if (!(c.deltaArchiveMaxSize >= 0)) {
|
|
225
|
+
throw new KLineChartError('HEATMAP_CONFIG_INVALID', 'HeatmapController: deltaArchiveMaxSize must be ≥ 0');
|
|
226
|
+
}
|
|
227
|
+
if (!(c.logColorRange.sizeMin > 0) || !(c.logColorRange.sizeMax > 0)) {
|
|
228
|
+
throw new KLineChartError('HEATMAP_CONFIG_INVALID', 'HeatmapController: logColorRange bounds must be positive');
|
|
229
|
+
}
|
|
230
|
+
if (c.logColorRange.sizeMax < c.logColorRange.sizeMin) {
|
|
231
|
+
throw new KLineChartError('HEATMAP_CONFIG_INVALID', 'HeatmapController: logColorRange.sizeMax must be ≥ sizeMin');
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
//# sourceMappingURL=createHeatmapController.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"createHeatmapController.js","sourceRoot":"","sources":["../../../src/components/orderBookHeatmap/createHeatmapController.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAEH,OAAO,EAAE,YAAY,E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CAAC;IACD,IAAI,CAAC,CAAC,CAAC,CAAC,mBAAmB,IAAI,CAAC,CAAC,EAAE,CAAC;QAChC,MAAM,IAAI,eAAe,CAAC,wBAAwB,EAAE,oDAAoD,CAAC,CAAA;IAC7G,CAAC;IACD,IAAI,CAAC,CAAC,CAAC,CAAC,aAAa,CAAC,OAAO,GAAG,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,aAAa,CAAC,OAAO,GAAG,CAAC,CAAC,EAAE,CAAC;QACnE,MAAM,IAAI,eAAe,CAAC,wBAAwB,EAAE,0DAA0D,CAAC,CAAA;IACnH,CAAC;IACD,IAAI,CAAC,CAAC,aAAa,CAAC,OAAO,GAAG,CAAC,CAAC,aAAa,CAAC,OAAO,EAAE,CAAC;QACpD,MAAM,IAAI,eAAe,CAAC,wBAAwB,EAAE,4DAA4D,CAAC,CAAA;IACrH,CAAC;AACL,CAAC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Streaming L2 order-book accumulator.
|
|
3
|
+
*
|
|
4
|
+
* Maintains two `Map<tickIndex, size>` (one per side). Prices are quantized
|
|
5
|
+
* to integer tick indices on the way in and dequantized on the way out, so
|
|
6
|
+
* consumers never need to know `tickSize`. A BTree is overkill here — the
|
|
7
|
+
* snapshot path sorts once per snapshot, which the controller calls at most
|
|
8
|
+
* every ~100ms, while applyDelta runs per-tick. Maps + lazy sort is the
|
|
9
|
+
* pragmatic choice the roadmap recommends.
|
|
10
|
+
*
|
|
11
|
+
* `maxLevels`, when set, truncates the snapshot to the levels closest to the
|
|
12
|
+
* best bid/ask. We do not drop levels from the underlying map — a quote that
|
|
13
|
+
* was outside the window may move back in via a subsequent delta. Truncation
|
|
14
|
+
* is purely a snapshot-time concern.
|
|
15
|
+
*/
|
|
16
|
+
import type { OrderBookState, OrderBookStateOptions } from './types';
|
|
17
|
+
export declare function createOrderBookState(opts: OrderBookStateOptions): OrderBookState;
|
|
18
|
+
//# sourceMappingURL=createOrderBookState.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"createOrderBookState.d.ts","sourceRoot":"","sources":["../../../src/components/orderBookHeatmap/createOrderBookState.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,KAAK,EAGR,cAAc,EACd,qBAAqB,EACxB,MAAM,SAAS,CAAA;AAKhB,wBAAgB,oBAAoB,CAChC,IAAI,EAAE,qBAAqB,GAC5B,cAAc,CAuFhB"}
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Streaming L2 order-book accumulator.
|
|
3
|
+
*
|
|
4
|
+
* Maintains two `Map<tickIndex, size>` (one per side). Prices are quantized
|
|
5
|
+
* to integer tick indices on the way in and dequantized on the way out, so
|
|
6
|
+
* consumers never need to know `tickSize`. A BTree is overkill here — the
|
|
7
|
+
* snapshot path sorts once per snapshot, which the controller calls at most
|
|
8
|
+
* every ~100ms, while applyDelta runs per-tick. Maps + lazy sort is the
|
|
9
|
+
* pragmatic choice the roadmap recommends.
|
|
10
|
+
*
|
|
11
|
+
* `maxLevels`, when set, truncates the snapshot to the levels closest to the
|
|
12
|
+
* best bid/ask. We do not drop levels from the underlying map — a quote that
|
|
13
|
+
* was outside the window may move back in via a subsequent delta. Truncation
|
|
14
|
+
* is purely a snapshot-time concern.
|
|
15
|
+
*/
|
|
16
|
+
import { KLineChartError } from '../../errors';
|
|
17
|
+
const EMPTY = [];
|
|
18
|
+
export function createOrderBookState(opts) {
|
|
19
|
+
if (!(opts.tickSize > 0) || !Number.isFinite(opts.tickSize)) {
|
|
20
|
+
throw new KLineChartError('HEATMAP_CONFIG_INVALID', 'createOrderBookState: tickSize must be a positive finite number');
|
|
21
|
+
}
|
|
22
|
+
const tickSize = opts.tickSize;
|
|
23
|
+
const maxLevels = opts.maxLevels === undefined ? Infinity : Math.max(0, Math.floor(opts.maxLevels));
|
|
24
|
+
// tickIndex (integer) → size
|
|
25
|
+
const bids = new Map();
|
|
26
|
+
const asks = new Map();
|
|
27
|
+
let lastTs = 0;
|
|
28
|
+
function quantize(price) {
|
|
29
|
+
return Math.round(price / tickSize);
|
|
30
|
+
}
|
|
31
|
+
function dequantize(tick) {
|
|
32
|
+
// Multiplying back can introduce float dust (e.g. 0.1 * 3 !== 0.3). We
|
|
33
|
+
// round to the nearest representable multiple of tickSize. Because
|
|
34
|
+
// tickSize is fixed for the life of the book, the rounding is stable
|
|
35
|
+
// across snapshots so consumers see consistent prices.
|
|
36
|
+
const raw = tick * tickSize;
|
|
37
|
+
// Normalise float representation: derive precision from tickSize.
|
|
38
|
+
const log10 = Math.log10(tickSize);
|
|
39
|
+
const decimals = log10 < 0 ? Math.min(12, Math.ceil(-log10) + 2) : 0;
|
|
40
|
+
if (decimals === 0)
|
|
41
|
+
return raw;
|
|
42
|
+
const factor = Math.pow(10, decimals);
|
|
43
|
+
return Math.round(raw * factor) / factor;
|
|
44
|
+
}
|
|
45
|
+
function applyDelta(delta) {
|
|
46
|
+
if (!Number.isFinite(delta.price) || !Number.isFinite(delta.size))
|
|
47
|
+
return;
|
|
48
|
+
const tick = quantize(delta.price);
|
|
49
|
+
const map = delta.side === 'bid' ? bids : asks;
|
|
50
|
+
if (delta.size === 0) {
|
|
51
|
+
map.delete(tick);
|
|
52
|
+
}
|
|
53
|
+
else if (delta.size > 0) {
|
|
54
|
+
map.set(tick, delta.size);
|
|
55
|
+
}
|
|
56
|
+
else {
|
|
57
|
+
// negative sizes are nonsensical — treat as remove
|
|
58
|
+
map.delete(tick);
|
|
59
|
+
}
|
|
60
|
+
if (delta.timestamp > lastTs)
|
|
61
|
+
lastTs = delta.timestamp;
|
|
62
|
+
}
|
|
63
|
+
function sortAndTruncate(map, direction) {
|
|
64
|
+
if (map.size === 0)
|
|
65
|
+
return EMPTY;
|
|
66
|
+
// Pull entries → sort by tick index → dequantize.
|
|
67
|
+
const ticks = [];
|
|
68
|
+
for (const k of map.keys())
|
|
69
|
+
ticks.push(k);
|
|
70
|
+
if (direction === 'desc')
|
|
71
|
+
ticks.sort((a, b) => b - a);
|
|
72
|
+
else
|
|
73
|
+
ticks.sort((a, b) => a - b);
|
|
74
|
+
const limit = Number.isFinite(maxLevels)
|
|
75
|
+
? Math.min(ticks.length, maxLevels)
|
|
76
|
+
: ticks.length;
|
|
77
|
+
const out = new Array(limit);
|
|
78
|
+
for (let i = 0; i < limit; i++) {
|
|
79
|
+
const tick = ticks[i];
|
|
80
|
+
const size = map.get(tick);
|
|
81
|
+
out[i] = [dequantize(tick), size];
|
|
82
|
+
}
|
|
83
|
+
return out;
|
|
84
|
+
}
|
|
85
|
+
function snapshot() {
|
|
86
|
+
return {
|
|
87
|
+
bids: sortAndTruncate(bids, 'desc'),
|
|
88
|
+
asks: sortAndTruncate(asks, 'asc'),
|
|
89
|
+
timestamp: lastTs,
|
|
90
|
+
};
|
|
91
|
+
}
|
|
92
|
+
function clear() {
|
|
93
|
+
bids.clear();
|
|
94
|
+
asks.clear();
|
|
95
|
+
lastTs = 0;
|
|
96
|
+
}
|
|
97
|
+
function lastTimestamp() {
|
|
98
|
+
return lastTs;
|
|
99
|
+
}
|
|
100
|
+
return { applyDelta, snapshot, clear, lastTimestamp };
|
|
101
|
+
}
|
|
102
|
+
//# sourceMappingURL=createOrderBookState.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"createOrderBookState.js","sourceRoot":"","sources":["../../../src/components/orderBookHeatmap/createOrderBookState.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAQH,OAAO,EAAE,eAAe,EAAE,MAAM,cAAc,CAAA;AAE9C,MAAM,KAAK,GAA6C,EAAE,CAAA;AAE1D,MAAM,UAAU,oBAAoB,CAChC,IAA2B;IAE3B,IAAI,CAAC,CAAC,IAAI,CAAC,QAAQ,GAAG,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAC,QAAQ,CAAC,EAAE,CAAC;QAC1D,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AC,CAAC,GAAG,CAAC,CAAC,CAAA;QAChC,MAAM,KAAK,GAAG,MAAM,CAAC,QAAQ,CAAC,SAAS,CAAC;YACpC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,MAAM,EAAE,SAAS,CAAC;YACnC,CAAC,CAAC,KAAK,CAAC,MAAM,CAAA;QAClB,MAAM,GAAG,GAAqC,IAAI,KAAK,CAAC,KAAK,CAAC,CAAA;QAC9D,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,KAAK,EAAE,CAAC,EAAE,EAAE,CAAC;YAC7B,MAAM,IAAI,GAAG,KAAK,CAAC,CAAC,CAAC,CAAA;YACrB,MAAM,IAAI,GAAG,GAAG,CAAC,GAAG,CAAC,IAAI,CAAW,CAAA;YACpC,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,UAAU,CAAC,IAAI,CAAC,EAAE,IAAI,CAAC,CAAA;QACrC,CAAC;QACD,OAAO,GAAG,CAAA;IACd,CAAC;IAED,SAAS,QAAQ;QACb,OAAO;YACH,IAAI,EAAE,eAAe,CAAC,IAAI,EAAE,MAAM,CAAC;YACnC,IAAI,EAAE,eAAe,CAAC,IAAI,EAAE,KAAK,CAAC;YAClC,SAAS,EAAE,MAAM;SACpB,CAAA;IACL,CAAC;IAED,SAAS,KAAK;QACV,IAAI,CAAC,KAAK,EAAE,CAAA;QACZ,IAAI,CAAC,KAAK,EAAE,CAAA;QACZ,MAAM,GAAG,CAAC,CAAA;IACd,CAAC;IAED,SAAS,aAAa;QAClB,OAAO,MAAM,CAAA;IACjB,CAAC;IAED,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,KAAK,EAAE,aAAa,EAAE,CAAA;AACzD,CAAC"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Append-only delta log for replay.
|
|
3
|
+
*
|
|
4
|
+
* Background (PR23 critique): the snapshot ring samples the book at fixed
|
|
5
|
+
* intervals — sub-interval "flash orders" (place + cancel within a single
|
|
6
|
+
* sampling window) never appear in the ring. The archive solves this by
|
|
7
|
+
* preserving the raw delta stream so replay can reconstruct any sub-interval
|
|
8
|
+
* state by fold-left.
|
|
9
|
+
*
|
|
10
|
+
* Storage: V8 handles `push` on large arrays well in practice, but holding
|
|
11
|
+
* one >1M-entry contiguous array makes shrink/trim more expensive than it
|
|
12
|
+
* needs to be (the engine reallocates the entire backing store). We chunk
|
|
13
|
+
* into 10 k-entry segments instead — the same total memory but trim drops
|
|
14
|
+
* whole chunks cheaply and range queries seek to the right chunk first.
|
|
15
|
+
*
|
|
16
|
+
* `range(from, to)` returns deltas with `from ≤ ts ≤ to` (inclusive both
|
|
17
|
+
* sides). Within a chunk we use a binary search on timestamps; deltas are
|
|
18
|
+
* appended in arrival order which is generally — but not strictly —
|
|
19
|
+
* monotonic in timestamp. We tolerate small out-of-order arrivals by
|
|
20
|
+
* widening the search window inside chunks; cross-chunk order is preserved
|
|
21
|
+
* by the chunk index alone.
|
|
22
|
+
*/
|
|
23
|
+
import type { DeltaArchive, DeltaArchiveOptions } from './types';
|
|
24
|
+
export declare function createDeltaArchive(opts?: DeltaArchiveOptions): DeltaArchive;
|
|
25
|
+
//# sourceMappingURL=deltaArchive.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"deltaArchive.d.ts","sourceRoot":"","sources":["../../../src/components/orderBookHeatmap/deltaArchive.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAEH,OAAO,KAAK,EAAE,YAAY,EAAE,mBAAmB,EAAkB,MAAM,SAAS,CAAA;AAIhF,wBAAgB,kBAAkB,CAAC,IAAI,CAAC,EAAE,mBAAmB,GAAG,YAAY,CAqF3E"}
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Append-only delta log for replay.
|
|
3
|
+
*
|
|
4
|
+
* Background (PR23 critique): the snapshot ring samples the book at fixed
|
|
5
|
+
* intervals — sub-interval "flash orders" (place + cancel within a single
|
|
6
|
+
* sampling window) never appear in the ring. The archive solves this by
|
|
7
|
+
* preserving the raw delta stream so replay can reconstruct any sub-interval
|
|
8
|
+
* state by fold-left.
|
|
9
|
+
*
|
|
10
|
+
* Storage: V8 handles `push` on large arrays well in practice, but holding
|
|
11
|
+
* one >1M-entry contiguous array makes shrink/trim more expensive than it
|
|
12
|
+
* needs to be (the engine reallocates the entire backing store). We chunk
|
|
13
|
+
* into 10 k-entry segments instead — the same total memory but trim drops
|
|
14
|
+
* whole chunks cheaply and range queries seek to the right chunk first.
|
|
15
|
+
*
|
|
16
|
+
* `range(from, to)` returns deltas with `from ≤ ts ≤ to` (inclusive both
|
|
17
|
+
* sides). Within a chunk we use a binary search on timestamps; deltas are
|
|
18
|
+
* appended in arrival order which is generally — but not strictly —
|
|
19
|
+
* monotonic in timestamp. We tolerate small out-of-order arrivals by
|
|
20
|
+
* widening the search window inside chunks; cross-chunk order is preserved
|
|
21
|
+
* by the chunk index alone.
|
|
22
|
+
*/
|
|
23
|
+
const CHUNK_SIZE = 10_000;
|
|
24
|
+
export function createDeltaArchive(opts) {
|
|
25
|
+
const chunks = [[]];
|
|
26
|
+
let total = 0;
|
|
27
|
+
let maxSize = opts?.maxSize !== undefined ? Math.max(0, opts.maxSize) : Infinity;
|
|
28
|
+
function append(delta) {
|
|
29
|
+
let last = chunks[chunks.length - 1];
|
|
30
|
+
if (last.length >= CHUNK_SIZE) {
|
|
31
|
+
last = [];
|
|
32
|
+
chunks.push(last);
|
|
33
|
+
}
|
|
34
|
+
last.push(delta);
|
|
35
|
+
total++;
|
|
36
|
+
if (Number.isFinite(maxSize) && total > maxSize) {
|
|
37
|
+
trim(maxSize);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
function range(fromTimestamp, toTimestamp) {
|
|
41
|
+
if (total === 0)
|
|
42
|
+
return [];
|
|
43
|
+
if (fromTimestamp > toTimestamp)
|
|
44
|
+
return [];
|
|
45
|
+
const out = [];
|
|
46
|
+
// Linear scan with early-exit per chunk on chunk-min timestamp.
|
|
47
|
+
// Cheaper than maintaining per-chunk indices and good enough since
|
|
48
|
+
// chunks are bounded; full scan worst-case is O(total) which the
|
|
49
|
+
// contract allows.
|
|
50
|
+
for (const chunk of chunks) {
|
|
51
|
+
if (chunk.length === 0)
|
|
52
|
+
continue;
|
|
53
|
+
// Find min/max timestamps in chunk by scanning the ends —
|
|
54
|
+
// because appends are mostly monotonic, ends are reliable
|
|
55
|
+
// bounds in the vast majority of cases. Wider safety: scan all.
|
|
56
|
+
for (const d of chunk) {
|
|
57
|
+
if (d.timestamp >= fromTimestamp && d.timestamp <= toTimestamp) {
|
|
58
|
+
out.push(d);
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
return out;
|
|
63
|
+
}
|
|
64
|
+
function size() {
|
|
65
|
+
return total;
|
|
66
|
+
}
|
|
67
|
+
function clear() {
|
|
68
|
+
chunks.length = 0;
|
|
69
|
+
chunks.push([]);
|
|
70
|
+
total = 0;
|
|
71
|
+
}
|
|
72
|
+
function trim(maxKeep) {
|
|
73
|
+
const target = Math.max(0, Math.floor(maxKeep));
|
|
74
|
+
if (total <= target)
|
|
75
|
+
return;
|
|
76
|
+
let toDrop = total - target;
|
|
77
|
+
// Drop whole oldest chunks first.
|
|
78
|
+
while (toDrop > 0 && chunks.length > 1 && chunks[0].length <= toDrop) {
|
|
79
|
+
toDrop -= chunks[0].length;
|
|
80
|
+
total -= chunks[0].length;
|
|
81
|
+
chunks.shift();
|
|
82
|
+
}
|
|
83
|
+
// Then drop from the head of the first surviving chunk.
|
|
84
|
+
if (toDrop > 0 && chunks.length > 0) {
|
|
85
|
+
const head = chunks[0];
|
|
86
|
+
if (toDrop >= head.length) {
|
|
87
|
+
total -= head.length;
|
|
88
|
+
head.length = 0;
|
|
89
|
+
}
|
|
90
|
+
else {
|
|
91
|
+
head.splice(0, toDrop);
|
|
92
|
+
total -= toDrop;
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
if (chunks.length === 0)
|
|
96
|
+
chunks.push([]);
|
|
97
|
+
}
|
|
98
|
+
return {
|
|
99
|
+
append,
|
|
100
|
+
range,
|
|
101
|
+
size,
|
|
102
|
+
clear,
|
|
103
|
+
trim,
|
|
104
|
+
};
|
|
105
|
+
}
|
|
106
|
+
//# sourceMappingURL=deltaArchive.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"deltaArchive.js","sourceRoot":"","sources":["../../../src/components/orderBookHeatmap/deltaArchive.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAIH,MAAM,UAAU,GAAG,MAAM,CAAA;AAEzB,MAAM,UAAU,kBAAkB,CAAC,IAA0B;IACzD,MAAM,MAAM,GAAuB,CAAC,EAAE,CAAC,CAAA;IACvC,IAAI,KAAK,GAAG,CAAC,CAAA;IACb,IAAI,OAAO,GAAG,IAAI,EAAE,OAAO,KAAK,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAA;IAEhF,SAAS,MAAM,CAAC,KAAqB;QACjC,IAAI,IAAI,GAAG,MAAM,CAAC,MAAM,CAAC,MAAM,GAAG,CAAC,CAAC,CAAA;QACpC,IAAI,IAAI,CAAC,MAAM,IAAI,UAAU,EAAE,CAAC;YAC5B,IAAI,GAAG,EAAE,CAAA;YACT,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;QACrB,CAAC;QACD,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,CAAA;QAChB,KAAK,EAAE,CAAA;QACP,IAAI,MAAM,CAAC,QAAQ,CAAC,OAAO,CAAC,IAAI,KAAK,GAAG,OAAO,EAAE,CAAC;YAC9C,IAAI,CAAC,OAAO,CAAC,CAAA;QACjB,CAAC;IACL,CAAC;IAED,SAAS,KAAK,CACV,aAAqB,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,CAAC,CAAC,CAAC,MAAM,CAAA;YAC1B,KAAK,IAAI,MAAM,CAAC,CAAC,CAAC,CAAC,MAAM,CAAA;YACzB,MAAM,CAAC,KAAK,EAAE,CAAA;QAClB,CAAC;QACD,wDAAwD;QACxD,IAAI,MAAM,GAAG,CAAC,IAAI,MAAM,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YAClC,MAAM,IAAI,GAAG,MAAM,CAAC,CAAC,CAAC,CAAA;YACtB,IAAI,MAAM,IAAI,IAAI,CAAC,MAAM,EAAE,CAAC;gBACxB,KAAK,IAAI,IAAI,CAAC,MAAM,CAAA;gBACpB,IAAI,CAAC,MAAM,GAAG,CAAC,CAAA;YACnB,CAAC;iBAAM,CAAC;gBACJ,IAAI,CAAC,MAAM,CAAC,CAAC,EAAE,MAAM,CAAC,CAAA;gBACtB,KAAK,IAAI,MAAM,CAAA;YACnB,CAAC;QACL,CAAC;QACD,IAAI,MAAM,CAAC,MAAM,KAAK,CAAC;YAAE,MAAM,CAAC,IAAI,CAAC,EAAE,CAAC,CAAA;IAC5C,CAAC;IAED,OAAO;QACH,MAAM;QACN,KAAK;QACL,IAAI;QACJ,KAAK;QACL,IAAI;KACP,CAAA;AACL,CAAC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Public surface of the order-book heatmap module.
|
|
3
|
+
*
|
|
4
|
+
* Consumers should import from this barrel; nothing here is wired into
|
|
5
|
+
* `packages/core/src/index.ts` yet (the renderer integration lands in P1).
|
|
6
|
+
*/
|
|
7
|
+
export { createOrderBookState } from './createOrderBookState';
|
|
8
|
+
export { createSnapshotRing } from './snapshotRing';
|
|
9
|
+
export { createDeltaArchive } from './deltaArchive';
|
|
10
|
+
export { createLogColorScale } from './logColorScale';
|
|
11
|
+
export { createHeatmapController } from './createHeatmapController';
|
|
12
|
+
export type { BookSnapshot, DeltaArchive, DeltaArchiveOptions, HeatmapController, HeatmapControllerConfig, HeatmapState, LogColorScale, OrderBookDelta, OrderBookState, OrderBookStateOptions, SnapshotRing, } from './types';
|
|
13
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/orderBookHeatmap/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAA;AAC7D,OAAO,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAA;AACnD,OAAO,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAA;AACnD,OAAO,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAA;AACrD,OAAO,EAAE,uBAAuB,EAAE,MAAM,2BAA2B,CAAA;AACnE,YAAY,EACR,YAAY,EACZ,YAAY,EACZ,mBAAmB,EACnB,iBAAiB,EACjB,uBAAuB,EACvB,YAAY,EACZ,aAAa,EACb,cAAc,EACd,cAAc,EACd,qBAAqB,EACrB,YAAY,GACf,MAAM,SAAS,CAAA"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Public surface of the order-book heatmap module.
|
|
3
|
+
*
|
|
4
|
+
* Consumers should import from this barrel; nothing here is wired into
|
|
5
|
+
* `packages/core/src/index.ts` yet (the renderer integration lands in P1).
|
|
6
|
+
*/
|
|
7
|
+
export { createOrderBookState } from './createOrderBookState';
|
|
8
|
+
export { createSnapshotRing } from './snapshotRing';
|
|
9
|
+
export { createDeltaArchive } from './deltaArchive';
|
|
10
|
+
export { createLogColorScale } from './logColorScale';
|
|
11
|
+
export { createHeatmapController } from './createHeatmapController';
|
|
12
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/components/orderBookHeatmap/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAA;AAC7D,OAAO,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAA;AACnD,OAAO,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAA;AACnD,OAAO,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAA;AACrD,OAAO,EAAE,uBAAuB,EAAE,MAAM,2BAA2B,CAAA"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Logarithmic intensity scale for heatmap coloring.
|
|
3
|
+
*
|
|
4
|
+
* ROADMAP §3.2 calls this out specifically. Order-book size distribution
|
|
5
|
+
* spans several orders of magnitude — a linear color scale washes out the
|
|
6
|
+
* fine structure. The mapping is:
|
|
7
|
+
*
|
|
8
|
+
* intensity = (ln(size) - ln(sizeMin)) / (ln(sizeMax) - ln(sizeMin))
|
|
9
|
+
*
|
|
10
|
+
* Edge cases (all return a value in `[0, 1]`):
|
|
11
|
+
*
|
|
12
|
+
* size ≤ 0 → 0
|
|
13
|
+
* size ≤ sizeMin → 0
|
|
14
|
+
* size ≥ sizeMax → 1
|
|
15
|
+
* sizeMin === sizeMax (degenerate) → 0.5 for any positive size
|
|
16
|
+
* sizeMin or sizeMax not strictly positive → throw at construction
|
|
17
|
+
*/
|
|
18
|
+
import type { LogColorScale } from './types';
|
|
19
|
+
export declare function createLogColorScale(sizeMin: number, sizeMax: number): LogColorScale;
|
|
20
|
+
//# sourceMappingURL=logColorScale.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"logColorScale.d.ts","sourceRoot":"","sources":["../../../src/components/orderBookHeatmap/logColorScale.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,SAAS,CAAA;AAG5C,wBAAgB,mBAAmB,CAC/B,OAAO,EAAE,MAAM,EACf,OAAO,EAAE,MAAM,GAChB,aAAa,CAwCf"}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Logarithmic intensity scale for heatmap coloring.
|
|
3
|
+
*
|
|
4
|
+
* ROADMAP §3.2 calls this out specifically. Order-book size distribution
|
|
5
|
+
* spans several orders of magnitude — a linear color scale washes out the
|
|
6
|
+
* fine structure. The mapping is:
|
|
7
|
+
*
|
|
8
|
+
* intensity = (ln(size) - ln(sizeMin)) / (ln(sizeMax) - ln(sizeMin))
|
|
9
|
+
*
|
|
10
|
+
* Edge cases (all return a value in `[0, 1]`):
|
|
11
|
+
*
|
|
12
|
+
* size ≤ 0 → 0
|
|
13
|
+
* size ≤ sizeMin → 0
|
|
14
|
+
* size ≥ sizeMax → 1
|
|
15
|
+
* sizeMin === sizeMax (degenerate) → 0.5 for any positive size
|
|
16
|
+
* sizeMin or sizeMax not strictly positive → throw at construction
|
|
17
|
+
*/
|
|
18
|
+
import { KLineChartError } from '../../errors';
|
|
19
|
+
export function createLogColorScale(sizeMin, sizeMax) {
|
|
20
|
+
let lo = sizeMin;
|
|
21
|
+
let hi = sizeMax;
|
|
22
|
+
let lnLo = 0;
|
|
23
|
+
let lnHi = 0;
|
|
24
|
+
let lnSpan = 0;
|
|
25
|
+
function recompute() {
|
|
26
|
+
validate(lo, hi);
|
|
27
|
+
lnLo = Math.log(lo);
|
|
28
|
+
lnHi = Math.log(hi);
|
|
29
|
+
lnSpan = lnHi - lnLo;
|
|
30
|
+
}
|
|
31
|
+
function intensity(size) {
|
|
32
|
+
if (!(size > 0))
|
|
33
|
+
return 0;
|
|
34
|
+
if (lnSpan === 0) {
|
|
35
|
+
// Degenerate range: any positive size maps to the midpoint.
|
|
36
|
+
return 0.5;
|
|
37
|
+
}
|
|
38
|
+
if (size <= lo)
|
|
39
|
+
return 0;
|
|
40
|
+
if (size >= hi)
|
|
41
|
+
return 1;
|
|
42
|
+
const t = (Math.log(size) - lnLo) / lnSpan;
|
|
43
|
+
if (t <= 0)
|
|
44
|
+
return 0;
|
|
45
|
+
if (t >= 1)
|
|
46
|
+
return 1;
|
|
47
|
+
return t;
|
|
48
|
+
}
|
|
49
|
+
function setRange(nextMin, nextMax) {
|
|
50
|
+
lo = nextMin;
|
|
51
|
+
hi = nextMax;
|
|
52
|
+
recompute();
|
|
53
|
+
}
|
|
54
|
+
function range() {
|
|
55
|
+
return { sizeMin: lo, sizeMax: hi };
|
|
56
|
+
}
|
|
57
|
+
recompute();
|
|
58
|
+
return { intensity, setRange, range };
|
|
59
|
+
}
|
|
60
|
+
function validate(lo, hi) {
|
|
61
|
+
if (!(lo > 0) || !Number.isFinite(lo)) {
|
|
62
|
+
throw new KLineChartError('HEATMAP_CONFIG_INVALID', 'createLogColorScale: sizeMin must be a positive finite number');
|
|
63
|
+
}
|
|
64
|
+
if (!(hi > 0) || !Number.isFinite(hi)) {
|
|
65
|
+
throw new KLineChartError('HEATMAP_CONFIG_INVALID', 'createLogColorScale: sizeMax must be a positive finite number');
|
|
66
|
+
}
|
|
67
|
+
if (hi < lo) {
|
|
68
|
+
throw new KLineChartError('HEATMAP_CONFIG_INVALID', 'createLogColorScale: sizeMax must be ≥ sizeMin');
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
//# sourceMappingURL=logColorScale.js.map
|