velo-plot 1.12.0 → 1.19.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/README.md +14 -0
- package/dist/{index.core-xiNcuFfJ.js → ChartCore-DQ691eXH.js} +1807 -1287
- package/dist/ChartCore-DQ691eXH.js.map +1 -0
- package/dist/assets/downsample.worker-C70QJ04y.js +2 -0
- package/dist/assets/downsample.worker-C70QJ04y.js.map +1 -0
- package/dist/assets/indicator.worker-bv0zC4EX.js +2 -0
- package/dist/assets/indicator.worker-bv0zC4EX.js.map +1 -0
- package/dist/core/OverlayRenderer.d.ts +2 -0
- package/dist/core/chart/ChartAlerts.d.ts +42 -0
- package/dist/core/chart/ChartCore.d.ts +20 -1
- package/dist/core/chart/ChartRenderLoop.d.ts +4 -2
- package/dist/core/chart/ChartRenderer.d.ts +3 -2
- package/dist/core/chart/candlestickMarkers.d.ts +23 -0
- package/dist/core/chart/exporter/SVGExporter.d.ts +7 -2
- package/dist/core/chart/heikinAshi.d.ts +10 -0
- package/dist/core/chart/series/types.d.ts +2 -2
- package/dist/core/chart/types.d.ts +9 -0
- package/dist/core/indicator/addIndicator.d.ts +36 -0
- package/dist/core/indicator/index.d.ts +2 -0
- package/dist/core/indicator/indicatorPresets.d.ts +37 -0
- package/dist/core/render/pixelSnap.d.ts +8 -0
- package/dist/core/series/Series.d.ts +3 -0
- package/dist/core/stacked/index.d.ts +3 -1
- package/dist/core/stacked/paneResize.d.ts +15 -18
- package/dist/core/stacked/stackExport.d.ts +18 -0
- package/dist/core/stacked/types.d.ts +42 -5
- package/dist/core/time/TimeScale.d.ts +31 -0
- package/dist/createStackedChart-BPooTQ9z.js +1164 -0
- package/dist/createStackedChart-BPooTQ9z.js.map +1 -0
- package/dist/gpu/adapter/gpuRenderer.d.ts +21 -0
- package/dist/gpu/backends/webgpu/WebGPUBackend.d.ts +2 -1
- package/dist/gpuRenderer-BpaMYz-k.js +1848 -0
- package/dist/gpuRenderer-BpaMYz-k.js.map +1 -0
- package/dist/index-CUGS98p4.js +277 -0
- package/dist/index-CUGS98p4.js.map +1 -0
- package/dist/index-D7dTq6VB.js +503 -0
- package/dist/index-D7dTq6VB.js.map +1 -0
- package/dist/{index-Ce2JgkH_.js → index-DoYxf1cV.js} +86 -43
- package/dist/{index-Ce2JgkH_.js.map → index-DoYxf1cV.js.map} +1 -1
- package/dist/index.core-BtGFYMOu.js +167 -0
- package/dist/index.core-BtGFYMOu.js.map +1 -0
- package/dist/index.d.ts +12 -4
- package/dist/indicators--eJGmVox.js +302 -0
- package/dist/indicators--eJGmVox.js.map +1 -0
- package/dist/math-Ddm2EZjj.js +85 -0
- package/dist/math-Ddm2EZjj.js.map +1 -0
- package/dist/plugins/analysis.js +543 -818
- package/dist/plugins/analysis.js.map +1 -1
- package/dist/plugins/anomaly-detection.d.ts +1 -0
- package/dist/plugins/anomaly-detection.js +221 -0
- package/dist/plugins/anomaly-detection.js.map +1 -0
- package/dist/plugins/broken-axis.d.ts +3 -0
- package/dist/plugins/broken-axis.js +262 -0
- package/dist/plugins/broken-axis.js.map +1 -0
- package/dist/plugins/caching.d.ts +3 -0
- package/dist/plugins/caching.js +187 -0
- package/dist/plugins/caching.js.map +1 -0
- package/dist/plugins/data-transform.d.ts +3 -0
- package/dist/plugins/data-transform.js +146 -0
- package/dist/plugins/data-transform.js.map +1 -0
- package/dist/plugins/debug.js +12 -11
- package/dist/plugins/debug.js.map +1 -1
- package/dist/plugins/drawing-tools/index.d.ts +16 -0
- package/dist/plugins/forecasting.d.ts +1 -0
- package/dist/plugins/forecasting.js +236 -0
- package/dist/plugins/forecasting.js.map +1 -0
- package/dist/plugins/gpu.js +202 -1895
- package/dist/plugins/gpu.js.map +1 -1
- package/dist/plugins/index.d.ts +2 -0
- package/dist/plugins/keyboard/index.d.ts +1 -7
- package/dist/plugins/keyboard.js +1 -1
- package/dist/plugins/latex.d.ts +1 -0
- package/dist/plugins/latex.js +454 -0
- package/dist/plugins/latex.js.map +1 -0
- package/dist/plugins/lazy-load/types.d.ts +7 -0
- package/dist/plugins/lazy-load.d.ts +3 -0
- package/dist/plugins/lazy-load.js +212 -0
- package/dist/plugins/lazy-load.js.map +1 -0
- package/dist/plugins/ml-integration.d.ts +3 -0
- package/dist/plugins/ml-integration.js +355 -0
- package/dist/plugins/ml-integration.js.map +1 -0
- package/dist/plugins/offscreen.d.ts +3 -0
- package/dist/plugins/offscreen.js +169 -0
- package/dist/plugins/offscreen.js.map +1 -0
- package/dist/plugins/pattern-recognition.d.ts +3 -0
- package/dist/plugins/pattern-recognition.js +690 -0
- package/dist/plugins/pattern-recognition.js.map +1 -0
- package/dist/plugins/radar.d.ts +3 -0
- package/dist/plugins/radar.js +103 -0
- package/dist/plugins/radar.js.map +1 -0
- package/dist/plugins/regression.d.ts +3 -0
- package/dist/plugins/regression.js +634 -0
- package/dist/plugins/regression.js.map +1 -0
- package/dist/plugins/replay/index.d.ts +19 -0
- package/dist/plugins/roi.d.ts +1 -0
- package/dist/plugins/roi.js +223 -0
- package/dist/plugins/roi.js.map +1 -0
- package/dist/plugins/snapshot/types.d.ts +1 -1
- package/dist/plugins/snapshot.d.ts +3 -0
- package/dist/plugins/snapshot.js +90 -0
- package/dist/plugins/snapshot.js.map +1 -0
- package/dist/plugins/sync/index.d.ts +2 -1
- package/dist/plugins/sync.js +13 -269
- package/dist/plugins/sync.js.map +1 -1
- package/dist/plugins/video-recorder.d.ts +3 -0
- package/dist/plugins/video-recorder.js +104 -0
- package/dist/plugins/video-recorder.js.map +1 -0
- package/dist/plugins/virtualization/types.d.ts +12 -0
- package/dist/plugins/virtualization.d.ts +3 -0
- package/dist/plugins/virtualization.js +6 -0
- package/dist/plugins/virtualization.js.map +1 -0
- package/dist/pool-15HMCNv8.js +88 -0
- package/dist/pool-15HMCNv8.js.map +1 -0
- package/dist/react.d.ts +1 -0
- package/dist/react.js +31 -0
- package/dist/react.js.map +1 -0
- package/dist/renderer/CandlestickRenderer.d.ts +1 -1
- package/dist/renderer/ChartSeriesRenderer.d.ts +6 -0
- package/dist/renderer/GpuChartRenderer.d.ts +23 -0
- package/dist/renderer/index.d.ts +3 -0
- package/dist/renderer/spike/WebGLGridSpike.d.ts +40 -0
- package/dist/testing/baselines/v1.15.0.json.d.ts +51 -0
- package/dist/testing/gridSpikeBenchmark.d.ts +49 -0
- package/dist/testing/index.d.ts +5 -0
- package/dist/testing/rendererBenchmark.d.ts +13 -0
- package/dist/testing/stage1BrowserBench.d.ts +42 -0
- package/dist/types.d.ts +21 -1
- package/dist/utils-BK5UUXxj.js +172 -0
- package/dist/utils-BK5UUXxj.js.map +1 -0
- package/dist/velo-plot.full.js +1382 -5932
- package/dist/velo-plot.full.js.map +1 -1
- package/dist/velo-plot.js +26 -25
- package/dist/velo-plot.js.map +1 -1
- package/dist/workers/downsample.d.ts +38 -0
- package/dist/workers/downsampleAsync.d.ts +6 -0
- package/dist/workers/indicator.worker.d.ts +32 -0
- package/dist/workers/indicatorsAsync.d.ts +26 -0
- package/dist/workers/pool.d.ts +36 -0
- package/package.json +19 -2
- package/dist/core/OverlayRenderer.test.d.ts +0 -1
- package/dist/core/chart/ChartScaling.test.d.ts +0 -1
- package/dist/core/chart/NavigationUtils.test.d.ts +0 -1
- package/dist/core/format/axisFormat.test.d.ts +0 -1
- package/dist/core/indicator/buildIndicatorSeries.test.d.ts +0 -1
- package/dist/core/series/SeriesBounds.test.d.ts +0 -1
- package/dist/core/stacked/createStackedChart.test.d.ts +0 -1
- package/dist/core/stacked/paneAxis.test.d.ts +0 -1
- package/dist/core/stacked/paneResize.test.d.ts +0 -1
- package/dist/core/sync/index.test.d.ts +0 -1
- package/dist/index.core-xiNcuFfJ.js.map +0 -1
- package/dist/plugins/tools/tooltip/format.test.d.ts +0 -1
- package/dist/utils-Dbro9-qM.js +0 -254
- package/dist/utils-Dbro9-qM.js.map +0 -1
package/dist/index.d.ts
CHANGED
|
@@ -31,7 +31,11 @@ export { SERIALIZATION_VERSION, encodeFloat32Array, decodeFloat32Array, compress
|
|
|
31
31
|
export type { PlotArea, CursorState, } from './types';
|
|
32
32
|
export { TooltipManager, TOOLTIP_THEMES, getTooltipThemeForChartTheme, } from './plugins/tools/tooltip';
|
|
33
33
|
export type { TooltipData, TooltipType, TooltipTheme, TooltipOptions, TooltipTemplate, DataPointTooltip, CrosshairTooltip, HeatmapTooltip, } from './plugins/tools/tooltip';
|
|
34
|
-
export { lttbDownsample, minMaxDownsample, calculateTargetPoints, } from './workers/downsample';
|
|
34
|
+
export { lttbDownsample, minMaxDownsample, ohlcMinMaxDownsample, calculateTargetPoints, sliceSeriesToViewport, lowerBoundX, upperBoundX, } from './workers/downsample';
|
|
35
|
+
export { downsampleAsync, ohlcDownsampleAsync, destroyDownsamplePool, getDownsamplePoolSize, } from './workers/downsampleAsync';
|
|
36
|
+
export { rsiAsync, smaAsync, emaAsync, macdAsync, bollingerBandsAsync, destroyIndicatorPool, } from './workers/indicatorsAsync';
|
|
37
|
+
export { WorkerPool, nextTaskId } from './workers/pool';
|
|
38
|
+
export type { WorkerPoolOptions } from './workers/pool';
|
|
35
39
|
export { formatWithPrefix, formatValue, formatScientific, getBestPrefix, detectCycles, generateCycleColors, detectPeaks, validateData, calculateStats, movingAverage, downsampleLTTB, subtractBaseline, integrate, derivative, cumulativeIntegral, calculateR2, solveLinearSystem, fft, ifft, analyzeSpectrum, powerSpectrum, dominantFrequency, analyzeComplexSpectrum, fftFromComplexInput, hanningWindow, hammingWindow, blackmanWindow, nextPowerOf2, complexToArrays, arraysToComplex, ifftFromArrays, ifftComplex, getPositiveFrequencies, lowPassFilter, highPassFilter, bandPassFilter, bandStopFilter, butterworth, exponentialMovingAverage, gaussianSmooth, savitzkyGolay, medianFilter, singleFrequencyFilter, crossCorrelation, autoCorrelation, detectAnomalies, trapezoidalIntegration, simpsonsIntegration, tTest, type CycleInfo, type Peak, type PrefixInfo, type ValidationResult, type DataStats, type FFTResult, type ComplexFFTResult, type PowerSpectrumResult, type FilterOptions, type ButterworthOptions, type SingleFrequencyFilterOptions, } from './plugins/analysis';
|
|
36
40
|
export { createWebSocketStream, connectStreamToChart, createMessageParser, createMockStream, type WebSocketStream, type WebSocketStreamConfig, type DataPoint, type StreamStats, type WebSocketState, } from './streaming';
|
|
37
41
|
export { SciPlot, useSciPlot, type SciPlotProps, type SciPlotRef, type SciPlotSeries, type UseSciPlotOptions, type UseSciPlotReturn, } from './react';
|
|
@@ -42,12 +46,16 @@ export { KeyBindingManager, DEFAULT_KEY_BINDINGS, createKeyBinding, parseShortcu
|
|
|
42
46
|
export { ClipboardManager, getClipboardManager, copyToClipboard, formatData, type ClipboardFormat, type ClipboardOptions, type ClipboardDataPoint, type ClipboardResult, } from './core/clipboard';
|
|
43
47
|
export { DebugOverlay, createDebugOverlay, enableDebugMode, type DebugStats, type DebugOverlayOptions, } from './core/debug';
|
|
44
48
|
export { LoadingIndicator, createLoadingIndicator, showLoading, showProgress, type LoadingIndicatorType, type LoadingIndicatorOptions, type LoadingState, } from './core/loading';
|
|
45
|
-
export { generateSineWave, generateSquareWave, generateSawtoothWave, generateTriangleWave, generateRandomData, generateCVData, generateNyquistData, benchmarkRender, assertPerformance, createSnapshot, compareSnapshots, waitForFrames, waitFor, type MockChartOptions, type WaveformOptions, type RandomDataOptions, type BenchmarkResult as TestBenchmarkResult, type BenchmarkOptions as TestBenchmarkOptions, type SnapshotOptions, type ChartSnapshot, } from './testing';
|
|
49
|
+
export { generateSineWave, generateSquareWave, generateSawtoothWave, generateTriangleWave, generateRandomData, generateCVData, generateNyquistData, benchmarkRender, assertPerformance, compareGridBackends, evaluateRendererCompare, benchmarkCanvasGrid, benchmarkWebGLGrid, getBaseline, compareScenarioToBaseline, createSnapshot, compareSnapshots, waitForFrames, waitFor, type MockChartOptions, type WaveformOptions, type RandomDataOptions, type BenchmarkResult as TestBenchmarkResult, type BenchmarkOptions as TestBenchmarkOptions, type SnapshotOptions, type ChartSnapshot, } from './testing';
|
|
46
50
|
export { ChartGroup, createChartGroup, linkCharts, createMasterSlave, type SyncAxis, type SyncOptions, type ChartLike, type SyncEvent, } from './core/sync';
|
|
47
51
|
export { createStackedChart, STACKED_MAX_PANES, STACKED_DEFAULT_MIN_PANE_RATIO, type StackedChart, type StackedChartOptions, type StackedPaneConfig, type StackedSyncOptions, } from './core/stacked';
|
|
48
|
-
export { buildIndicatorSeries, createIndicatorSeries, buildIndicatorPane, detectIndicatorMarkers, type IndicatorData, type IndicatorSeriesOptions, type IndicatorStyle, type IndicatorLineLayer, type IndicatorLineColorZones, type BuildIndicatorPaneOptions, } from './core/indicator';
|
|
52
|
+
export { buildIndicatorSeries, createIndicatorSeries, buildIndicatorPane, buildIndicatorPaneFromPreset, addIndicatorToChart, computeIndicatorFromSeries, computeIndicatorPreset, detectIndicatorMarkers, type IndicatorData, type IndicatorSeriesOptions, type IndicatorStyle, type IndicatorLineLayer, type IndicatorLineColorZones, type BuildIndicatorPaneOptions, type AddIndicatorOptions, type AddIndicatorResult, type IndicatorPresetName, } from './core/indicator';
|
|
53
|
+
export { mapToBusinessDayScale, isBusinessDay, businessDaySpanMs, type TimeScaleOptions, type BusinessDayMapping, } from './core/time/TimeScale';
|
|
54
|
+
export { computeHeikinAshi } from './core/chart/heikinAshi';
|
|
55
|
+
export type { CandlestickMarker, CandlestickMarkerPosition, CandlestickMarkerShape, } from './core/chart/candlestickMarkers';
|
|
56
|
+
export type { PriceAlertOptions } from './core/chart/ChartAlerts';
|
|
49
57
|
export { ThemeEditor, createThemeEditor, getPresetTheme, getPresetNames, THEME_PRESETS, type EditorTheme, type ThemeEditorOptions, type ThemePreset, type ColorGroup, type ColorProperty, } from './core/theme-editor';
|
|
50
58
|
export { BackpressureManager, CircularBuffer, createBackpressureManager, createRealtimeBackpressure, createLosslessBackpressure, type OverflowStrategy, type BackpressureConfig, type PressureStats, type BufferHealth, } from './streaming/backpressure';
|
|
51
59
|
export { sma, ema, wma, dema, tema, rsi, macd, stochastic, roc, momentum, bollingerBands, atr, standardDeviation, vwap, obv, adx, aroon, percentChange, cumsum, normalize, type IndicatorResult, type OHLCData, } from './plugins/analysis';
|
|
52
|
-
export { createPluginContext, PluginManagerImpl, getPluginRegistry, registerPlugin, definePlugin, defineAndRegister, loadPlugin, listPluginsByCategory, validateManifest, checkPluginCompatibility, createPlugin, createConfigurablePlugin, CrosshairPlugin, StatsPlugin, WatermarkPlugin, GridHighlightPlugin, DataLoggerPlugin, DirectionIndicatorPlugin, Plugin3D, PluginGpu, PluginTools, PluginAnalysis, PluginAnnotations, PluginStreaming, PluginThemeEditor, PluginI18n, PluginKeyboard, PluginClipboard, PluginSync, PluginDebug, PluginLoading, PluginDataExport, PluginContextMenu, PluginAnomalyDetection, PluginMLIntegration, PluginPatternRecognition, PluginRegression, PluginRadar, PluginSnapshot, PluginDataTransform, PluginLaTeX, PluginDragEdit, PluginCaching, PluginLazyLoad, PluginBrokenAxis, PluginVideoRecorder, PluginOffscreen, PluginVirtualization, PluginROI, PluginForecasting, BuiltinPlugins, } from './plugins';
|
|
60
|
+
export { createPluginContext, PluginManagerImpl, getPluginRegistry, registerPlugin, definePlugin, defineAndRegister, loadPlugin, listPluginsByCategory, validateManifest, checkPluginCompatibility, createPlugin, createConfigurablePlugin, CrosshairPlugin, StatsPlugin, WatermarkPlugin, GridHighlightPlugin, DataLoggerPlugin, DirectionIndicatorPlugin, Plugin3D, PluginGpu, PluginTools, PluginAnalysis, PluginAnnotations, PluginStreaming, PluginThemeEditor, PluginI18n, PluginKeyboard, PluginClipboard, PluginSync, PluginDebug, PluginLoading, PluginDataExport, PluginContextMenu, PluginAnomalyDetection, PluginMLIntegration, PluginPatternRecognition, PluginRegression, PluginRadar, PluginSnapshot, PluginDataTransform, PluginLaTeX, PluginDragEdit, PluginCaching, PluginLazyLoad, PluginBrokenAxis, PluginVideoRecorder, PluginOffscreen, PluginVirtualization, PluginDrawingTools, PluginReplay, PluginROI, PluginForecasting, BuiltinPlugins, } from './plugins';
|
|
53
61
|
export type { PluginVersion, PluginCapability, PluginManifest, PluginContext, RenderContext, CoordinateContext, DataContext, UIContext as PluginUIContext, EventContext as PluginEventContext, PluginStorage, PluginLogger, OverlayOptions, NotificationOptions, PickResult, BeforeRenderEvent, AfterRenderEvent, InteractionEvent, ViewChangeEvent, SeriesChangeEvent, DataUpdateEvent, ChartPlugin, PluginFactory, TypedPlugin, PluginManager, PluginRegistry, PluginRegistryEntry, ContextDependencies, CrosshairPluginConfig, StatsPluginConfig, WatermarkPluginConfig, GridHighlightConfig, DataLoggerConfig, DirectionIndicatorConfig, Plugin3DConfig, PluginGpuConfig, PluginToolsConfig, PluginAnalysisConfig, PluginAnnotationsConfig, PluginStreamingConfig, PluginThemeEditorConfig, PluginI18nConfig, PluginKeyboardConfig, PluginClipboardConfig, PluginSyncConfig, PluginDebugConfig, PluginLoadingConfig, PluginDataExportConfig, PluginContextMenuConfig, PluginAnomalyDetectionConfig, PluginMLIntegrationConfig, PluginPatternRecognitionConfig, PluginRegressionConfig, PluginRadarConfig, PluginSnapshotConfig, PluginDataTransformConfig, PluginLaTeXConfig, PluginDragEditConfig, PluginCachingConfig, PluginLazyLoadConfig, PluginBrokenAxisConfig, PluginVideoRecorderConfig, PluginOffscreenConfig, PluginVirtualizationConfig, PluginROIConfig, PluginForecastingConfig, RegressionAPI, RegressionResult, RegressionData, MLIntegrationAPI, MLModelAPI, PredictionResult, VisualizationConfig, DataTransformAPI, TransformOp, TransformType, RadarAPI, RadarSeriesData, RadarPoint, LaTeXPluginAPI, LaTeXDimensions, DragEditAPI, DragEditEvent, CachingAPI, CacheStats, LazyLoadAPI, DataProvider, OffscreenAPI, OffscreenStats, OffscreenMode, OffscreenTransferMode, OffscreenFallbackMode, VirtualizationAPI, VirtualizationStats, VirtualizationMode, VirtualizationStrategy, RoiAPI, RoiRegion, RoiPoint, RoiMaskResult, RoiTool, RoiEvent, RoiSelectedEvent, BrokenAxisAPI, AxisBreak, VideoRecorderAPI, VideoRecorderOptions, SnapshotExportAPI as SnapshotAPI, SnapshotExportOptions, SnapshotResolution, SnapshotFormat, AnomalyDetectionResult, AnomalyPoint, AnomalyMethod, PatternRecognitionAPI, PatternMatch, PatternDetectionResult, ForecastingAPI, ForecastingOptions, ForecastingResult, ForecastingParams } from './plugins';
|
|
@@ -0,0 +1,302 @@
|
|
|
1
|
+
function N(s, t) {
|
|
2
|
+
const r = s instanceof Float32Array || s instanceof Float64Array ? s : Float32Array.from(s), o = new Float32Array(r.length);
|
|
3
|
+
if (t < 1 || t > r.length)
|
|
4
|
+
return o.fill(NaN), o;
|
|
5
|
+
for (let n = 0; n < t - 1; n++)
|
|
6
|
+
o[n] = NaN;
|
|
7
|
+
let l = 0;
|
|
8
|
+
for (let n = 0; n < t; n++)
|
|
9
|
+
l += r[n];
|
|
10
|
+
o[t - 1] = l / t;
|
|
11
|
+
for (let n = t; n < r.length; n++)
|
|
12
|
+
l = l - r[n - t] + r[n], o[n] = l / t;
|
|
13
|
+
return o;
|
|
14
|
+
}
|
|
15
|
+
function y(s, t) {
|
|
16
|
+
const r = s instanceof Float32Array || s instanceof Float64Array ? s : Float32Array.from(s), o = new Float32Array(r.length);
|
|
17
|
+
if (t < 1 || t > r.length)
|
|
18
|
+
return o.fill(NaN), o;
|
|
19
|
+
const l = 2 / (t + 1);
|
|
20
|
+
for (let e = 0; e < t - 1; e++)
|
|
21
|
+
o[e] = NaN;
|
|
22
|
+
let n = 0;
|
|
23
|
+
for (let e = 0; e < t; e++)
|
|
24
|
+
n += r[e];
|
|
25
|
+
o[t - 1] = n / t;
|
|
26
|
+
for (let e = t; e < r.length; e++)
|
|
27
|
+
o[e] = (r[e] - o[e - 1]) * l + o[e - 1];
|
|
28
|
+
return o;
|
|
29
|
+
}
|
|
30
|
+
function x(s, t) {
|
|
31
|
+
const r = s instanceof Float32Array || s instanceof Float64Array ? s : Float32Array.from(s), o = new Float32Array(r.length);
|
|
32
|
+
if (t < 1 || t > r.length)
|
|
33
|
+
return o.fill(NaN), o;
|
|
34
|
+
const l = t * (t + 1) / 2;
|
|
35
|
+
for (let n = 0; n < t - 1; n++)
|
|
36
|
+
o[n] = NaN;
|
|
37
|
+
for (let n = t - 1; n < r.length; n++) {
|
|
38
|
+
let e = 0;
|
|
39
|
+
for (let a = 0; a < t; a++)
|
|
40
|
+
e += r[n - t + 1 + a] * (a + 1);
|
|
41
|
+
o[n] = e / l;
|
|
42
|
+
}
|
|
43
|
+
return o;
|
|
44
|
+
}
|
|
45
|
+
function V(s, t) {
|
|
46
|
+
const r = y(s, t), o = y(r, t), l = new Float32Array(s.length);
|
|
47
|
+
for (let n = 0; n < s.length; n++)
|
|
48
|
+
l[n] = 2 * r[n] - o[n];
|
|
49
|
+
return l;
|
|
50
|
+
}
|
|
51
|
+
function D(s, t) {
|
|
52
|
+
const r = y(s, t), o = y(r, t), l = y(o, t), n = new Float32Array(s.length);
|
|
53
|
+
for (let e = 0; e < s.length; e++)
|
|
54
|
+
n[e] = 3 * r[e] - 3 * o[e] + l[e];
|
|
55
|
+
return n;
|
|
56
|
+
}
|
|
57
|
+
function j(s, t = 14) {
|
|
58
|
+
const r = s instanceof Float32Array || s instanceof Float64Array ? s : Float32Array.from(s), o = new Float32Array(r.length);
|
|
59
|
+
if (t < 1 || r.length < t + 1)
|
|
60
|
+
return o.fill(NaN), o;
|
|
61
|
+
for (let e = 0; e < t; e++)
|
|
62
|
+
o[e] = NaN;
|
|
63
|
+
let l = 0, n = 0;
|
|
64
|
+
for (let e = 1; e <= t; e++) {
|
|
65
|
+
const a = r[e] - r[e - 1];
|
|
66
|
+
a > 0 ? l += a : n += Math.abs(a);
|
|
67
|
+
}
|
|
68
|
+
if (l /= t, n /= t, n === 0)
|
|
69
|
+
o[t] = 100;
|
|
70
|
+
else {
|
|
71
|
+
const e = l / n;
|
|
72
|
+
o[t] = 100 - 100 / (1 + e);
|
|
73
|
+
}
|
|
74
|
+
for (let e = t + 1; e < r.length; e++) {
|
|
75
|
+
const a = r[e] - r[e - 1];
|
|
76
|
+
let c = 0, f = 0;
|
|
77
|
+
if (a > 0 ? c = a : f = Math.abs(a), l = (l * (t - 1) + c) / t, n = (n * (t - 1) + f) / t, n === 0)
|
|
78
|
+
o[e] = 100;
|
|
79
|
+
else {
|
|
80
|
+
const u = l / n;
|
|
81
|
+
o[e] = 100 - 100 / (1 + u);
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
return o;
|
|
85
|
+
}
|
|
86
|
+
function q(s, t = 12, r = 26, o = 9) {
|
|
87
|
+
const l = s instanceof Float32Array || s instanceof Float64Array ? s : Float32Array.from(s), n = y(l, t), e = y(l, r), a = new Float32Array(l.length);
|
|
88
|
+
for (let u = 0; u < l.length; u++)
|
|
89
|
+
a[u] = n[u] - e[u];
|
|
90
|
+
const c = y(a, o), f = new Float32Array(l.length);
|
|
91
|
+
for (let u = 0; u < l.length; u++)
|
|
92
|
+
f[u] = a[u] - c[u];
|
|
93
|
+
return {
|
|
94
|
+
values: a,
|
|
95
|
+
signal: c,
|
|
96
|
+
histogram: f
|
|
97
|
+
};
|
|
98
|
+
}
|
|
99
|
+
function S(s, t = 14, r = 3) {
|
|
100
|
+
const { high: o, low: l, close: n } = s, e = n.length, a = new Float32Array(e);
|
|
101
|
+
for (let f = 0; f < e; f++) {
|
|
102
|
+
if (f < t - 1) {
|
|
103
|
+
a[f] = NaN;
|
|
104
|
+
continue;
|
|
105
|
+
}
|
|
106
|
+
let u = -1 / 0, g = 1 / 0;
|
|
107
|
+
for (let h = f - t + 1; h <= f; h++)
|
|
108
|
+
o[h] > u && (u = o[h]), l[h] < g && (g = l[h]);
|
|
109
|
+
const A = u - g;
|
|
110
|
+
A === 0 ? a[f] = 50 : a[f] = (n[f] - g) / A * 100;
|
|
111
|
+
}
|
|
112
|
+
const c = N(a, r);
|
|
113
|
+
return {
|
|
114
|
+
values: a,
|
|
115
|
+
// %K
|
|
116
|
+
signal: c
|
|
117
|
+
// %D
|
|
118
|
+
};
|
|
119
|
+
}
|
|
120
|
+
function E(s, t = 10) {
|
|
121
|
+
const r = s instanceof Float32Array || s instanceof Float64Array ? s : Float32Array.from(s), o = new Float32Array(r.length);
|
|
122
|
+
for (let l = 0; l < t; l++)
|
|
123
|
+
o[l] = NaN;
|
|
124
|
+
for (let l = t; l < r.length; l++) {
|
|
125
|
+
const n = r[l - t];
|
|
126
|
+
n === 0 ? o[l] = NaN : o[l] = (r[l] - n) / n * 100;
|
|
127
|
+
}
|
|
128
|
+
return o;
|
|
129
|
+
}
|
|
130
|
+
function P(s, t = 10) {
|
|
131
|
+
const r = s instanceof Float32Array || s instanceof Float64Array ? s : Float32Array.from(s), o = new Float32Array(r.length);
|
|
132
|
+
for (let l = 0; l < t; l++)
|
|
133
|
+
o[l] = NaN;
|
|
134
|
+
for (let l = t; l < r.length; l++)
|
|
135
|
+
o[l] = r[l] - r[l - t];
|
|
136
|
+
return o;
|
|
137
|
+
}
|
|
138
|
+
function L(s, t = 20, r = 2) {
|
|
139
|
+
const o = s instanceof Float32Array || s instanceof Float64Array ? s : Float32Array.from(s), l = N(o, t), n = new Float32Array(o.length), e = new Float32Array(o.length);
|
|
140
|
+
for (let a = 0; a < o.length; a++) {
|
|
141
|
+
if (a < t - 1) {
|
|
142
|
+
n[a] = NaN, e[a] = NaN;
|
|
143
|
+
continue;
|
|
144
|
+
}
|
|
145
|
+
let c = 0;
|
|
146
|
+
for (let u = a - t + 1; u <= a; u++) {
|
|
147
|
+
const g = o[u] - l[a];
|
|
148
|
+
c += g * g;
|
|
149
|
+
}
|
|
150
|
+
const f = Math.sqrt(c / t);
|
|
151
|
+
n[a] = l[a] + r * f, e[a] = l[a] - r * f;
|
|
152
|
+
}
|
|
153
|
+
return {
|
|
154
|
+
values: l,
|
|
155
|
+
upper: n,
|
|
156
|
+
lower: e
|
|
157
|
+
};
|
|
158
|
+
}
|
|
159
|
+
function T(s, t = 14) {
|
|
160
|
+
const { high: r, low: o, close: l } = s, n = l.length, e = new Float32Array(n);
|
|
161
|
+
e[0] = r[0] - o[0];
|
|
162
|
+
for (let a = 1; a < n; a++) {
|
|
163
|
+
const c = r[a] - o[a], f = Math.abs(r[a] - l[a - 1]), u = Math.abs(o[a] - l[a - 1]);
|
|
164
|
+
e[a] = Math.max(c, f, u);
|
|
165
|
+
}
|
|
166
|
+
return y(e, t);
|
|
167
|
+
}
|
|
168
|
+
function k(s, t = 20) {
|
|
169
|
+
const r = s instanceof Float32Array || s instanceof Float64Array ? s : Float32Array.from(s), o = new Float32Array(r.length), l = N(r, t);
|
|
170
|
+
for (let n = 0; n < r.length; n++) {
|
|
171
|
+
if (n < t - 1) {
|
|
172
|
+
o[n] = NaN;
|
|
173
|
+
continue;
|
|
174
|
+
}
|
|
175
|
+
let e = 0;
|
|
176
|
+
for (let a = n - t + 1; a <= n; a++) {
|
|
177
|
+
const c = r[a] - l[n];
|
|
178
|
+
e += c * c;
|
|
179
|
+
}
|
|
180
|
+
o[n] = Math.sqrt(e / t);
|
|
181
|
+
}
|
|
182
|
+
return o;
|
|
183
|
+
}
|
|
184
|
+
function z(s) {
|
|
185
|
+
const { high: t, low: r, close: o, volume: l } = s;
|
|
186
|
+
if (!l)
|
|
187
|
+
throw new Error("VWAP requires volume data");
|
|
188
|
+
const n = o.length, e = new Float32Array(n);
|
|
189
|
+
let a = 0, c = 0;
|
|
190
|
+
for (let f = 0; f < n; f++) {
|
|
191
|
+
const u = (t[f] + r[f] + o[f]) / 3;
|
|
192
|
+
a += u * l[f], c += l[f], c === 0 ? e[f] = u : e[f] = a / c;
|
|
193
|
+
}
|
|
194
|
+
return e;
|
|
195
|
+
}
|
|
196
|
+
function B(s, t) {
|
|
197
|
+
const r = s instanceof Float32Array || s instanceof Float64Array ? s : Float32Array.from(s), o = t instanceof Float32Array || t instanceof Float64Array ? t : Float32Array.from(t), l = new Float32Array(r.length);
|
|
198
|
+
l[0] = o[0];
|
|
199
|
+
for (let n = 1; n < r.length; n++)
|
|
200
|
+
r[n] > r[n - 1] ? l[n] = l[n - 1] + o[n] : r[n] < r[n - 1] ? l[n] = l[n - 1] - o[n] : l[n] = l[n - 1];
|
|
201
|
+
return l;
|
|
202
|
+
}
|
|
203
|
+
function C(s, t = 14) {
|
|
204
|
+
const { high: r, low: o, close: l } = s, n = l.length, e = new Float32Array(n), a = new Float32Array(n), c = new Float32Array(n);
|
|
205
|
+
c[0] = r[0] - o[0], e[0] = 0, a[0] = 0;
|
|
206
|
+
for (let i = 1; i < n; i++) {
|
|
207
|
+
const F = r[i] - r[i - 1], m = o[i - 1] - o[i];
|
|
208
|
+
e[i] = F > m && F > 0 ? F : 0, a[i] = m > F && m > 0 ? m : 0;
|
|
209
|
+
const M = r[i] - o[i], v = Math.abs(r[i] - l[i - 1]), I = Math.abs(o[i] - l[i - 1]);
|
|
210
|
+
c[i] = Math.max(M, v, I);
|
|
211
|
+
}
|
|
212
|
+
const f = y(c, t), u = y(e, t), g = y(a, t), A = new Float32Array(n), h = new Float32Array(n), w = new Float32Array(n);
|
|
213
|
+
for (let i = 0; i < n; i++)
|
|
214
|
+
if (f[i] === 0 || isNaN(f[i]))
|
|
215
|
+
A[i] = NaN, h[i] = NaN, w[i] = NaN;
|
|
216
|
+
else {
|
|
217
|
+
A[i] = u[i] / f[i] * 100, h[i] = g[i] / f[i] * 100;
|
|
218
|
+
const F = A[i] + h[i];
|
|
219
|
+
w[i] = F === 0 ? 0 : Math.abs(A[i] - h[i]) / F * 100;
|
|
220
|
+
}
|
|
221
|
+
return {
|
|
222
|
+
values: y(w, t),
|
|
223
|
+
upper: A,
|
|
224
|
+
// +DI
|
|
225
|
+
lower: h
|
|
226
|
+
// -DI
|
|
227
|
+
};
|
|
228
|
+
}
|
|
229
|
+
function G(s, t = 25) {
|
|
230
|
+
const { high: r, low: o } = s, l = r.length, n = new Float32Array(l), e = new Float32Array(l);
|
|
231
|
+
for (let c = 0; c < l; c++) {
|
|
232
|
+
if (c < t) {
|
|
233
|
+
n[c] = NaN, e[c] = NaN;
|
|
234
|
+
continue;
|
|
235
|
+
}
|
|
236
|
+
let f = c, u = c, g = -1 / 0, A = 1 / 0;
|
|
237
|
+
for (let h = c - t; h <= c; h++)
|
|
238
|
+
r[h] > g && (g = r[h], f = h), o[h] < A && (A = o[h], u = h);
|
|
239
|
+
n[c] = (t - (c - f)) / t * 100, e[c] = (t - (c - u)) / t * 100;
|
|
240
|
+
}
|
|
241
|
+
const a = new Float32Array(l);
|
|
242
|
+
for (let c = 0; c < l; c++)
|
|
243
|
+
a[c] = n[c] - e[c];
|
|
244
|
+
return {
|
|
245
|
+
values: a,
|
|
246
|
+
upper: n,
|
|
247
|
+
lower: e
|
|
248
|
+
};
|
|
249
|
+
}
|
|
250
|
+
function R(s, t = 1) {
|
|
251
|
+
const r = s instanceof Float32Array || s instanceof Float64Array ? s : Float32Array.from(s), o = new Float32Array(r.length);
|
|
252
|
+
for (let l = 0; l < t; l++)
|
|
253
|
+
o[l] = NaN;
|
|
254
|
+
for (let l = t; l < r.length; l++) {
|
|
255
|
+
const n = r[l - t];
|
|
256
|
+
n === 0 ? o[l] = NaN : o[l] = (r[l] - n) / n * 100;
|
|
257
|
+
}
|
|
258
|
+
return o;
|
|
259
|
+
}
|
|
260
|
+
function U(s) {
|
|
261
|
+
const t = s instanceof Float32Array || s instanceof Float64Array ? s : Float32Array.from(s), r = new Float32Array(t.length);
|
|
262
|
+
r[0] = t[0];
|
|
263
|
+
for (let o = 1; o < t.length; o++)
|
|
264
|
+
r[o] = r[o - 1] + t[o];
|
|
265
|
+
return r;
|
|
266
|
+
}
|
|
267
|
+
function W(s) {
|
|
268
|
+
const t = s instanceof Float32Array || s instanceof Float64Array ? s : Float32Array.from(s), r = new Float32Array(t.length);
|
|
269
|
+
let o = 1 / 0, l = -1 / 0;
|
|
270
|
+
for (let e = 0; e < t.length; e++)
|
|
271
|
+
isNaN(t[e]) || (t[e] < o && (o = t[e]), t[e] > l && (l = t[e]));
|
|
272
|
+
const n = l - o;
|
|
273
|
+
if (n === 0)
|
|
274
|
+
r.fill(50);
|
|
275
|
+
else
|
|
276
|
+
for (let e = 0; e < t.length; e++)
|
|
277
|
+
r[e] = (t[e] - o) / n * 100;
|
|
278
|
+
return r;
|
|
279
|
+
}
|
|
280
|
+
export {
|
|
281
|
+
S as a,
|
|
282
|
+
E as b,
|
|
283
|
+
P as c,
|
|
284
|
+
V as d,
|
|
285
|
+
y as e,
|
|
286
|
+
L as f,
|
|
287
|
+
T as g,
|
|
288
|
+
k as h,
|
|
289
|
+
C as i,
|
|
290
|
+
G as j,
|
|
291
|
+
U as k,
|
|
292
|
+
q as m,
|
|
293
|
+
W as n,
|
|
294
|
+
B as o,
|
|
295
|
+
R as p,
|
|
296
|
+
j as r,
|
|
297
|
+
N as s,
|
|
298
|
+
D as t,
|
|
299
|
+
z as v,
|
|
300
|
+
x as w
|
|
301
|
+
};
|
|
302
|
+
//# sourceMappingURL=indicators--eJGmVox.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"indicators--eJGmVox.js","sources":["../src/plugins/analysis/indicators.ts"],"sourcesContent":["/**\n * Sci Plot - Financial/Technical Indicators Module\n * \n * Provides common financial and technical analysis indicators:\n * - Moving Averages (SMA, EMA, WMA)\n * - Momentum Indicators (RSI, MACD, Stochastic)\n * - Volatility (Bollinger Bands, ATR)\n * - Volume (VWAP, OBV)\n * - Trend (ADX, Aroon)\n * \n * @module indicators\n */\n\n// ============================================\n// Types\n// ============================================\n\nexport interface IndicatorResult {\n /** Indicator values (NaN for insufficient data) */\n values: Float32Array;\n /** Additional line (e.g., signal line for MACD) */\n signal?: Float32Array;\n /** Upper band (e.g., Bollinger upper) */\n upper?: Float32Array;\n /** Lower band (e.g., Bollinger lower) */\n lower?: Float32Array;\n /** Histogram (e.g., MACD histogram) */\n histogram?: Float32Array;\n}\n\nexport interface OHLCData {\n open: Float32Array | Float64Array;\n high: Float32Array | Float64Array;\n low: Float32Array | Float64Array;\n close: Float32Array | Float64Array;\n volume?: Float32Array | Float64Array;\n}\n\n// ============================================\n// Moving Averages\n// ============================================\n\n/**\n * Simple Moving Average (SMA)\n * @param data Input data array\n * @param period Number of periods\n */\nexport function sma(data: Float32Array | Float64Array | number[], period: number): Float32Array {\n const input = data instanceof Float32Array || data instanceof Float64Array ? data : Float32Array.from(data);\n const result = new Float32Array(input.length);\n \n if (period < 1 || period > input.length) {\n result.fill(NaN);\n return result;\n }\n\n // Fill initial values with NaN\n for (let i = 0; i < period - 1; i++) {\n result[i] = NaN;\n }\n\n // Calculate first SMA\n let sum = 0;\n for (let i = 0; i < period; i++) {\n sum += input[i];\n }\n result[period - 1] = sum / period;\n\n // Calculate remaining SMAs using sliding window\n for (let i = period; i < input.length; i++) {\n sum = sum - input[i - period] + input[i];\n result[i] = sum / period;\n }\n\n return result;\n}\n\n/**\n * Exponential Moving Average (EMA)\n * @param data Input data array\n * @param period Number of periods\n */\nexport function ema(data: Float32Array | Float64Array | number[], period: number): Float32Array {\n const input = data instanceof Float32Array || data instanceof Float64Array ? data : Float32Array.from(data);\n const result = new Float32Array(input.length);\n \n if (period < 1 || period > input.length) {\n result.fill(NaN);\n return result;\n }\n\n const multiplier = 2 / (period + 1);\n\n // Fill initial values with NaN\n for (let i = 0; i < period - 1; i++) {\n result[i] = NaN;\n }\n\n // First EMA is SMA\n let sum = 0;\n for (let i = 0; i < period; i++) {\n sum += input[i];\n }\n result[period - 1] = sum / period;\n\n // Calculate remaining EMAs\n for (let i = period; i < input.length; i++) {\n result[i] = (input[i] - result[i - 1]) * multiplier + result[i - 1];\n }\n\n return result;\n}\n\n/**\n * Weighted Moving Average (WMA)\n * @param data Input data array\n * @param period Number of periods\n */\nexport function wma(data: Float32Array | Float64Array | number[], period: number): Float32Array {\n const input = data instanceof Float32Array || data instanceof Float64Array ? data : Float32Array.from(data);\n const result = new Float32Array(input.length);\n \n if (period < 1 || period > input.length) {\n result.fill(NaN);\n return result;\n }\n\n const weightSum = (period * (period + 1)) / 2;\n\n // Fill initial values with NaN\n for (let i = 0; i < period - 1; i++) {\n result[i] = NaN;\n }\n\n // Calculate WMAs\n for (let i = period - 1; i < input.length; i++) {\n let weightedSum = 0;\n for (let j = 0; j < period; j++) {\n weightedSum += input[i - period + 1 + j] * (j + 1);\n }\n result[i] = weightedSum / weightSum;\n }\n\n return result;\n}\n\n/**\n * Double Exponential Moving Average (DEMA)\n * @param data Input data array\n * @param period Number of periods\n */\nexport function dema(data: Float32Array | Float64Array | number[], period: number): Float32Array {\n const ema1 = ema(data, period);\n const ema2 = ema(ema1, period);\n const result = new Float32Array(data.length);\n\n for (let i = 0; i < data.length; i++) {\n result[i] = 2 * ema1[i] - ema2[i];\n }\n\n return result;\n}\n\n/**\n * Triple Exponential Moving Average (TEMA)\n * @param data Input data array\n * @param period Number of periods\n */\nexport function tema(data: Float32Array | Float64Array | number[], period: number): Float32Array {\n const ema1 = ema(data, period);\n const ema2 = ema(ema1, period);\n const ema3 = ema(ema2, period);\n const result = new Float32Array(data.length);\n\n for (let i = 0; i < data.length; i++) {\n result[i] = 3 * ema1[i] - 3 * ema2[i] + ema3[i];\n }\n\n return result;\n}\n\n// ============================================\n// Momentum Indicators\n// ============================================\n\n/**\n * Relative Strength Index (RSI)\n * @param data Close prices\n * @param period RSI period (default: 14)\n */\nexport function rsi(data: Float32Array | Float64Array | number[], period: number = 14): Float32Array {\n const input = data instanceof Float32Array || data instanceof Float64Array ? data : Float32Array.from(data);\n const result = new Float32Array(input.length);\n \n if (period < 1 || input.length < period + 1) {\n result.fill(NaN);\n return result;\n }\n\n // Fill initial values with NaN\n for (let i = 0; i < period; i++) {\n result[i] = NaN;\n }\n\n // Calculate initial average gain/loss\n let avgGain = 0;\n let avgLoss = 0;\n\n for (let i = 1; i <= period; i++) {\n const change = input[i] - input[i - 1];\n if (change > 0) {\n avgGain += change;\n } else {\n avgLoss += Math.abs(change);\n }\n }\n\n avgGain /= period;\n avgLoss /= period;\n\n // First RSI value\n if (avgLoss === 0) {\n result[period] = 100;\n } else {\n const rs = avgGain / avgLoss;\n result[period] = 100 - (100 / (1 + rs));\n }\n\n // Calculate remaining RSI values using smoothed averages\n for (let i = period + 1; i < input.length; i++) {\n const change = input[i] - input[i - 1];\n let gain = 0;\n let loss = 0;\n\n if (change > 0) {\n gain = change;\n } else {\n loss = Math.abs(change);\n }\n\n avgGain = (avgGain * (period - 1) + gain) / period;\n avgLoss = (avgLoss * (period - 1) + loss) / period;\n\n if (avgLoss === 0) {\n result[i] = 100;\n } else {\n const rs = avgGain / avgLoss;\n result[i] = 100 - (100 / (1 + rs));\n }\n }\n\n return result;\n}\n\n/**\n * Moving Average Convergence Divergence (MACD)\n * @param data Close prices\n * @param fastPeriod Fast EMA period (default: 12)\n * @param slowPeriod Slow EMA period (default: 26)\n * @param signalPeriod Signal line period (default: 9)\n */\nexport function macd(\n data: Float32Array | Float64Array | number[],\n fastPeriod: number = 12,\n slowPeriod: number = 26,\n signalPeriod: number = 9\n): IndicatorResult {\n const input = data instanceof Float32Array || data instanceof Float64Array ? data : Float32Array.from(data);\n \n const fastEma = ema(input, fastPeriod);\n const slowEma = ema(input, slowPeriod);\n \n // MACD Line = Fast EMA - Slow EMA\n const macdLine = new Float32Array(input.length);\n for (let i = 0; i < input.length; i++) {\n macdLine[i] = fastEma[i] - slowEma[i];\n }\n \n // Signal Line = EMA of MACD Line\n const signal = ema(macdLine, signalPeriod);\n \n // Histogram = MACD Line - Signal Line\n const histogram = new Float32Array(input.length);\n for (let i = 0; i < input.length; i++) {\n histogram[i] = macdLine[i] - signal[i];\n }\n\n return {\n values: macdLine,\n signal,\n histogram,\n };\n}\n\n/**\n * Stochastic Oscillator\n * @param ohlc OHLC data\n * @param kPeriod %K period (default: 14)\n * @param dPeriod %D smoothing period (default: 3)\n */\nexport function stochastic(\n ohlc: OHLCData,\n kPeriod: number = 14,\n dPeriod: number = 3\n): IndicatorResult {\n const { high, low, close } = ohlc;\n const length = close.length;\n const kValues = new Float32Array(length);\n \n // Calculate %K\n for (let i = 0; i < length; i++) {\n if (i < kPeriod - 1) {\n kValues[i] = NaN;\n continue;\n }\n \n let highest = -Infinity;\n let lowest = Infinity;\n \n for (let j = i - kPeriod + 1; j <= i; j++) {\n if (high[j] > highest) highest = high[j];\n if (low[j] < lowest) lowest = low[j];\n }\n \n const range = highest - lowest;\n if (range === 0) {\n kValues[i] = 50; // Neutral when no range\n } else {\n kValues[i] = ((close[i] - lowest) / range) * 100;\n }\n }\n \n // %D is SMA of %K\n const dValues = sma(kValues, dPeriod);\n\n return {\n values: kValues, // %K\n signal: dValues, // %D\n };\n}\n\n/**\n * Rate of Change (ROC)\n * @param data Close prices\n * @param period ROC period (default: 10)\n */\nexport function roc(data: Float32Array | Float64Array | number[], period: number = 10): Float32Array {\n const input = data instanceof Float32Array || data instanceof Float64Array ? data : Float32Array.from(data);\n const result = new Float32Array(input.length);\n \n for (let i = 0; i < period; i++) {\n result[i] = NaN;\n }\n \n for (let i = period; i < input.length; i++) {\n const pastValue = input[i - period];\n if (pastValue === 0) {\n result[i] = NaN;\n } else {\n result[i] = ((input[i] - pastValue) / pastValue) * 100;\n }\n }\n\n return result;\n}\n\n/**\n * Momentum\n * @param data Close prices\n * @param period Momentum period (default: 10)\n */\nexport function momentum(data: Float32Array | Float64Array | number[], period: number = 10): Float32Array {\n const input = data instanceof Float32Array || data instanceof Float64Array ? data : Float32Array.from(data);\n const result = new Float32Array(input.length);\n \n for (let i = 0; i < period; i++) {\n result[i] = NaN;\n }\n \n for (let i = period; i < input.length; i++) {\n result[i] = input[i] - input[i - period];\n }\n\n return result;\n}\n\n// ============================================\n// Volatility Indicators\n// ============================================\n\n/**\n * Bollinger Bands\n * @param data Close prices\n * @param period SMA period (default: 20)\n * @param stdDev Standard deviation multiplier (default: 2)\n */\nexport function bollingerBands(\n data: Float32Array | Float64Array | number[],\n period: number = 20,\n stdDev: number = 2\n): IndicatorResult {\n const input = data instanceof Float32Array || data instanceof Float64Array ? data : Float32Array.from(data);\n const middle = sma(input, period);\n const upper = new Float32Array(input.length);\n const lower = new Float32Array(input.length);\n\n for (let i = 0; i < input.length; i++) {\n if (i < period - 1) {\n upper[i] = NaN;\n lower[i] = NaN;\n continue;\n }\n\n // Calculate standard deviation\n let sumSquares = 0;\n for (let j = i - period + 1; j <= i; j++) {\n const diff = input[j] - middle[i];\n sumSquares += diff * diff;\n }\n const std = Math.sqrt(sumSquares / period);\n\n upper[i] = middle[i] + stdDev * std;\n lower[i] = middle[i] - stdDev * std;\n }\n\n return {\n values: middle,\n upper,\n lower,\n };\n}\n\n/**\n * Average True Range (ATR)\n * @param ohlc OHLC data\n * @param period ATR period (default: 14)\n */\nexport function atr(ohlc: OHLCData, period: number = 14): Float32Array {\n const { high, low, close } = ohlc;\n const length = close.length;\n const tr = new Float32Array(length);\n \n // True Range calculation\n tr[0] = high[0] - low[0];\n \n for (let i = 1; i < length; i++) {\n const hl = high[i] - low[i];\n const hc = Math.abs(high[i] - close[i - 1]);\n const lc = Math.abs(low[i] - close[i - 1]);\n tr[i] = Math.max(hl, hc, lc);\n }\n\n // ATR is smoothed average of True Range\n return ema(tr, period);\n}\n\n/**\n * Standard Deviation\n * @param data Input data\n * @param period Period for calculation (default: 20)\n */\nexport function standardDeviation(data: Float32Array | Float64Array | number[], period: number = 20): Float32Array {\n const input = data instanceof Float32Array || data instanceof Float64Array ? data : Float32Array.from(data);\n const result = new Float32Array(input.length);\n const avg = sma(input, period);\n\n for (let i = 0; i < input.length; i++) {\n if (i < period - 1) {\n result[i] = NaN;\n continue;\n }\n\n let sumSquares = 0;\n for (let j = i - period + 1; j <= i; j++) {\n const diff = input[j] - avg[i];\n sumSquares += diff * diff;\n }\n result[i] = Math.sqrt(sumSquares / period);\n }\n\n return result;\n}\n\n// ============================================\n// Volume Indicators\n// ============================================\n\n/**\n * Volume Weighted Average Price (VWAP)\n * @param ohlc OHLC data with volume\n */\nexport function vwap(ohlc: OHLCData): Float32Array {\n const { high, low, close, volume } = ohlc;\n \n if (!volume) {\n throw new Error('VWAP requires volume data');\n }\n\n const length = close.length;\n const result = new Float32Array(length);\n \n let cumulativeTPV = 0; // Cumulative Typical Price * Volume\n let cumulativeVolume = 0;\n\n for (let i = 0; i < length; i++) {\n const typicalPrice = (high[i] + low[i] + close[i]) / 3;\n cumulativeTPV += typicalPrice * volume[i];\n cumulativeVolume += volume[i];\n \n if (cumulativeVolume === 0) {\n result[i] = typicalPrice;\n } else {\n result[i] = cumulativeTPV / cumulativeVolume;\n }\n }\n\n return result;\n}\n\n/**\n * On-Balance Volume (OBV)\n * @param close Close prices\n * @param volume Volume data\n */\nexport function obv(\n close: Float32Array | Float64Array | number[],\n volume: Float32Array | Float64Array | number[]\n): Float32Array {\n const closeInput = close instanceof Float32Array || close instanceof Float64Array ? close : Float32Array.from(close);\n const volumeInput = volume instanceof Float32Array || volume instanceof Float64Array ? volume : Float32Array.from(volume);\n \n const result = new Float32Array(closeInput.length);\n result[0] = volumeInput[0];\n\n for (let i = 1; i < closeInput.length; i++) {\n if (closeInput[i] > closeInput[i - 1]) {\n result[i] = result[i - 1] + volumeInput[i];\n } else if (closeInput[i] < closeInput[i - 1]) {\n result[i] = result[i - 1] - volumeInput[i];\n } else {\n result[i] = result[i - 1];\n }\n }\n\n return result;\n}\n\n// ============================================\n// Trend Indicators\n// ============================================\n\n/**\n * Average Directional Index (ADX)\n * @param ohlc OHLC data\n * @param period ADX period (default: 14)\n */\nexport function adx(ohlc: OHLCData, period: number = 14): IndicatorResult {\n const { high, low, close } = ohlc;\n const length = close.length;\n \n const plusDM = new Float32Array(length);\n const minusDM = new Float32Array(length);\n const tr = new Float32Array(length);\n \n // Calculate +DM, -DM, TR\n tr[0] = high[0] - low[0];\n plusDM[0] = 0;\n minusDM[0] = 0;\n\n for (let i = 1; i < length; i++) {\n const upMove = high[i] - high[i - 1];\n const downMove = low[i - 1] - low[i];\n \n plusDM[i] = upMove > downMove && upMove > 0 ? upMove : 0;\n minusDM[i] = downMove > upMove && downMove > 0 ? downMove : 0;\n \n const hl = high[i] - low[i];\n const hc = Math.abs(high[i] - close[i - 1]);\n const lc = Math.abs(low[i] - close[i - 1]);\n tr[i] = Math.max(hl, hc, lc);\n }\n\n // Smooth with EMA\n const smoothedTR = ema(tr, period);\n const smoothedPlusDM = ema(plusDM, period);\n const smoothedMinusDM = ema(minusDM, period);\n\n // Calculate +DI and -DI\n const plusDI = new Float32Array(length);\n const minusDI = new Float32Array(length);\n const dx = new Float32Array(length);\n\n for (let i = 0; i < length; i++) {\n if (smoothedTR[i] === 0 || isNaN(smoothedTR[i])) {\n plusDI[i] = NaN;\n minusDI[i] = NaN;\n dx[i] = NaN;\n } else {\n plusDI[i] = (smoothedPlusDM[i] / smoothedTR[i]) * 100;\n minusDI[i] = (smoothedMinusDM[i] / smoothedTR[i]) * 100;\n \n const diSum = plusDI[i] + minusDI[i];\n dx[i] = diSum === 0 ? 0 : (Math.abs(plusDI[i] - minusDI[i]) / diSum) * 100;\n }\n }\n\n // ADX is smoothed DX\n const adxValues = ema(dx, period);\n\n return {\n values: adxValues,\n upper: plusDI, // +DI\n lower: minusDI, // -DI\n };\n}\n\n/**\n * Aroon Indicator\n * @param ohlc OHLC data\n * @param period Aroon period (default: 25)\n */\nexport function aroon(ohlc: OHLCData, period: number = 25): IndicatorResult {\n const { high, low } = ohlc;\n const length = high.length;\n \n const aroonUp = new Float32Array(length);\n const aroonDown = new Float32Array(length);\n\n for (let i = 0; i < length; i++) {\n if (i < period) {\n aroonUp[i] = NaN;\n aroonDown[i] = NaN;\n continue;\n }\n\n let highestIdx = i;\n let lowestIdx = i;\n let highest = -Infinity;\n let lowest = Infinity;\n\n for (let j = i - period; j <= i; j++) {\n if (high[j] > highest) {\n highest = high[j];\n highestIdx = j;\n }\n if (low[j] < lowest) {\n lowest = low[j];\n lowestIdx = j;\n }\n }\n\n aroonUp[i] = ((period - (i - highestIdx)) / period) * 100;\n aroonDown[i] = ((period - (i - lowestIdx)) / period) * 100;\n }\n\n // Aroon Oscillator = Aroon Up - Aroon Down\n const oscillator = new Float32Array(length);\n for (let i = 0; i < length; i++) {\n oscillator[i] = aroonUp[i] - aroonDown[i];\n }\n\n return {\n values: oscillator,\n upper: aroonUp,\n lower: aroonDown,\n };\n}\n\n// ============================================\n// Utility Functions\n// ============================================\n\n/**\n * Calculate percentage change\n */\nexport function percentChange(data: Float32Array | Float64Array | number[], period: number = 1): Float32Array {\n const input = data instanceof Float32Array || data instanceof Float64Array ? data : Float32Array.from(data);\n const result = new Float32Array(input.length);\n \n for (let i = 0; i < period; i++) {\n result[i] = NaN;\n }\n \n for (let i = period; i < input.length; i++) {\n const prev = input[i - period];\n if (prev === 0) {\n result[i] = NaN;\n } else {\n result[i] = ((input[i] - prev) / prev) * 100;\n }\n }\n\n return result;\n}\n\n/**\n * Calculate cumulative sum\n */\nexport function cumsum(data: Float32Array | Float64Array | number[]): Float32Array {\n const input = data instanceof Float32Array || data instanceof Float64Array ? data : Float32Array.from(data);\n const result = new Float32Array(input.length);\n \n result[0] = input[0];\n for (let i = 1; i < input.length; i++) {\n result[i] = result[i - 1] + input[i];\n }\n\n return result;\n}\n\n/**\n * Normalize data to 0-100 range\n */\nexport function normalize(data: Float32Array | Float64Array | number[]): Float32Array {\n const input = data instanceof Float32Array || data instanceof Float64Array ? data : Float32Array.from(data);\n const result = new Float32Array(input.length);\n \n let min = Infinity;\n let max = -Infinity;\n \n for (let i = 0; i < input.length; i++) {\n if (!isNaN(input[i])) {\n if (input[i] < min) min = input[i];\n if (input[i] > max) max = input[i];\n }\n }\n\n const range = max - min;\n if (range === 0) {\n result.fill(50);\n } else {\n for (let i = 0; i < input.length; i++) {\n result[i] = ((input[i] - min) / range) * 100;\n }\n }\n\n return result;\n}\n"],"names":["sma","data","period","input","result","i","sum","ema","multiplier","wma","weightSum","weightedSum","j","dema","ema1","ema2","tema","ema3","rsi","avgGain","avgLoss","change","rs","gain","loss","macd","fastPeriod","slowPeriod","signalPeriod","fastEma","slowEma","macdLine","signal","histogram","stochastic","ohlc","kPeriod","dPeriod","high","low","close","length","kValues","highest","lowest","range","dValues","roc","pastValue","momentum","bollingerBands","stdDev","middle","upper","lower","sumSquares","diff","std","atr","tr","hl","hc","lc","standardDeviation","avg","vwap","volume","cumulativeTPV","cumulativeVolume","typicalPrice","obv","closeInput","volumeInput","adx","plusDM","minusDM","upMove","downMove","smoothedTR","smoothedPlusDM","smoothedMinusDM","plusDI","minusDI","dx","diSum","aroon","aroonUp","aroonDown","highestIdx","lowestIdx","oscillator","percentChange","prev","cumsum","normalize","min","max"],"mappings":"AA+CO,SAASA,EAAIC,GAA8CC,GAA8B;AAC9F,QAAMC,IAAQF,aAAgB,gBAAgBA,aAAgB,eAAeA,IAAO,aAAa,KAAKA,CAAI,GACpGG,IAAS,IAAI,aAAaD,EAAM,MAAM;AAE5C,MAAID,IAAS,KAAKA,IAASC,EAAM;AAC/B,WAAAC,EAAO,KAAK,GAAG,GACRA;AAIT,WAASC,IAAI,GAAGA,IAAIH,IAAS,GAAGG;AAC9B,IAAAD,EAAOC,CAAC,IAAI;AAId,MAAIC,IAAM;AACV,WAASD,IAAI,GAAGA,IAAIH,GAAQG;AAC1B,IAAAC,KAAOH,EAAME,CAAC;AAEhB,EAAAD,EAAOF,IAAS,CAAC,IAAII,IAAMJ;AAG3B,WAASG,IAAIH,GAAQG,IAAIF,EAAM,QAAQE;AACrC,IAAAC,IAAMA,IAAMH,EAAME,IAAIH,CAAM,IAAIC,EAAME,CAAC,GACvCD,EAAOC,CAAC,IAAIC,IAAMJ;AAGpB,SAAOE;AACT;AAOO,SAASG,EAAIN,GAA8CC,GAA8B;AAC9F,QAAMC,IAAQF,aAAgB,gBAAgBA,aAAgB,eAAeA,IAAO,aAAa,KAAKA,CAAI,GACpGG,IAAS,IAAI,aAAaD,EAAM,MAAM;AAE5C,MAAID,IAAS,KAAKA,IAASC,EAAM;AAC/B,WAAAC,EAAO,KAAK,GAAG,GACRA;AAGT,QAAMI,IAAa,KAAKN,IAAS;AAGjC,WAASG,IAAI,GAAGA,IAAIH,IAAS,GAAGG;AAC9B,IAAAD,EAAOC,CAAC,IAAI;AAId,MAAIC,IAAM;AACV,WAASD,IA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A,IAAM7F,EAAME,CAAC;AAIrC,QAAMwC,IAAQmD,IAAMD;AACpB,MAAIlD,MAAU;AACZ,IAAAzC,EAAO,KAAK,EAAE;AAAA;AAEd,aAASC,IAAI,GAAGA,IAAIF,EAAM,QAAQE;AAChC,MAAAD,EAAOC,CAAC,KAAMF,EAAME,CAAC,IAAI0F,KAAOlD,IAAS;AAI7C,SAAOzC;AACT;"}
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
function d(a, i) {
|
|
2
|
+
const e = i.length, n = a.map((t, c) => [...t, i[c]]);
|
|
3
|
+
for (let t = 0; t < e; t++) {
|
|
4
|
+
let c = t;
|
|
5
|
+
for (let s = t + 1; s < e; s++)
|
|
6
|
+
Math.abs(n[s][t]) > Math.abs(n[c][t]) && (c = s);
|
|
7
|
+
const l = n[t];
|
|
8
|
+
n[t] = n[c], n[c] = l;
|
|
9
|
+
const o = n[t][t];
|
|
10
|
+
if (Math.abs(o) < 1e-12)
|
|
11
|
+
throw new Error("Matrix is singular or near-singular");
|
|
12
|
+
for (let s = t + 1; s < e; s++) {
|
|
13
|
+
const f = n[s][t] / o;
|
|
14
|
+
for (let u = t; u <= e; u++)
|
|
15
|
+
n[s][u] -= f * n[t][u];
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
const r = new Array(e).fill(0);
|
|
19
|
+
for (let t = e - 1; t >= 0; t--) {
|
|
20
|
+
let c = 0;
|
|
21
|
+
for (let l = t + 1; l < e; l++)
|
|
22
|
+
c += n[t][l] * r[l];
|
|
23
|
+
r[t] = (n[t][e] - c) / n[t][t];
|
|
24
|
+
}
|
|
25
|
+
return r;
|
|
26
|
+
}
|
|
27
|
+
function w(a, i, e) {
|
|
28
|
+
const n = a.length;
|
|
29
|
+
if (n === 0) return 0;
|
|
30
|
+
let r = 0;
|
|
31
|
+
for (let o = 0; o < n; o++) r += i[o];
|
|
32
|
+
const t = r / n;
|
|
33
|
+
let c = 0, l = 0;
|
|
34
|
+
for (let o = 0; o < n; o++) {
|
|
35
|
+
const s = i[o], f = e(a[o]);
|
|
36
|
+
c += (s - t) * (s - t), l += (s - f) * (s - f);
|
|
37
|
+
}
|
|
38
|
+
return c === 0 ? 1 : 1 - l / c;
|
|
39
|
+
}
|
|
40
|
+
function v(a, i, e, n) {
|
|
41
|
+
const r = a.length;
|
|
42
|
+
if (r < 2) return 0;
|
|
43
|
+
let t = 0;
|
|
44
|
+
const c = e !== void 0 ? e : a[0], l = n !== void 0 ? n : a[r - 1];
|
|
45
|
+
for (let o = 0; o < r - 1; o++) {
|
|
46
|
+
const s = a[o], f = a[o + 1];
|
|
47
|
+
if (f < c) continue;
|
|
48
|
+
if (s > l) break;
|
|
49
|
+
const u = Math.max(s, c), h = Math.min(f, l);
|
|
50
|
+
if (u < h) {
|
|
51
|
+
const m = i[o] + (i[o + 1] - i[o]) * ((u - s) / (f - s)), g = i[o] + (i[o + 1] - i[o]) * ((h - s) / (f - s));
|
|
52
|
+
t += (h - u) * (m + g) / 2;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
return t;
|
|
56
|
+
}
|
|
57
|
+
function b(a, i) {
|
|
58
|
+
const e = a.length;
|
|
59
|
+
if (e < 2) return new Float32Array(0);
|
|
60
|
+
const n = new Float32Array(e);
|
|
61
|
+
for (let r = 0; r < e - 1; r++) {
|
|
62
|
+
const t = a[r + 1] - a[r];
|
|
63
|
+
n[r] = t !== 0 ? (i[r + 1] - i[r]) / t : 0;
|
|
64
|
+
}
|
|
65
|
+
return n[e - 1] = n[e - 2], n;
|
|
66
|
+
}
|
|
67
|
+
function A(a, i) {
|
|
68
|
+
const e = a.length;
|
|
69
|
+
if (e < 1) return new Float32Array(0);
|
|
70
|
+
const n = new Float32Array(e);
|
|
71
|
+
n[0] = 0;
|
|
72
|
+
for (let r = 0; r < e - 1; r++) {
|
|
73
|
+
const c = (a[r + 1] - a[r]) * (i[r] + i[r + 1]) / 2;
|
|
74
|
+
n[r + 1] = n[r] + c;
|
|
75
|
+
}
|
|
76
|
+
return n;
|
|
77
|
+
}
|
|
78
|
+
export {
|
|
79
|
+
w as a,
|
|
80
|
+
A as c,
|
|
81
|
+
b as d,
|
|
82
|
+
v as i,
|
|
83
|
+
d as s
|
|
84
|
+
};
|
|
85
|
+
//# sourceMappingURL=math-Ddm2EZjj.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"math-Ddm2EZjj.js","sources":["../src/plugins/analysis/math.ts"],"sourcesContent":["/**\n * Mathematical utilities for numerical analysis and regression.\n */\n\n/**\n * Solve a system of linear equations Ax = B using Gaussian elimination with partial pivoting.\n * \n * @param A - Matrix coefficients\n * @param B - Right hand side vector\n * @returns Solution vector x\n */\nexport function solveLinearSystem(A: number[][], B: number[]): number[] {\n const n = B.length;\n const matrix = A.map((row, i) => [...row, B[i]]);\n\n for (let i = 0; i < n; i++) {\n // Partial pivoting\n let maxRow = i;\n for (let k = i + 1; k < n; k++) {\n if (Math.abs(matrix[k][i]) > Math.abs(matrix[maxRow][i])) {\n maxRow = k;\n }\n }\n\n // Swap rows\n const temp = matrix[i];\n matrix[i] = matrix[maxRow];\n matrix[maxRow] = temp;\n\n // Pivot must be non-zero\n const pivot = matrix[i][i];\n if (Math.abs(pivot) < 1e-12) {\n throw new Error(\"Matrix is singular or near-singular\");\n }\n\n // Eliminate below\n for (let k = i + 1; k < n; k++) {\n const factor = matrix[k][i] / pivot;\n for (let j = i; j <= n; j++) {\n matrix[k][j] -= factor * matrix[i][j];\n }\n }\n }\n\n // Back substitution\n const x = new Array(n).fill(0);\n for (let i = n - 1; i >= 0; i--) {\n let sum = 0;\n for (let j = i + 1; j < n; j++) {\n sum += matrix[i][j] * x[j];\n }\n x[i] = (matrix[i][n] - sum) / matrix[i][i];\n }\n\n return x;\n}\n\n/**\n * Calculate R² (coefficient of determination)\n */\nexport function calculateR2(\n x: number[] | Float32Array,\n y: number[] | Float32Array,\n fitFn: (x: number) => number\n): number {\n const n = x.length;\n if (n === 0) return 0;\n\n let sumY = 0;\n for (let i = 0; i < n; i++) sumY += y[i];\n const meanY = sumY / n;\n\n let ssTot = 0; // Total sum of squares\n let ssRes = 0; // Residual sum of squares\n\n for (let i = 0; i < n; i++) {\n const yi = y[i];\n const fi = fitFn(x[i]);\n ssTot += (yi - meanY) * (yi - meanY);\n ssRes += (yi - fi) * (yi - fi);\n }\n\n return ssTot === 0 ? 1 : 1 - ssRes / ssTot;\n}\n\n/**\n * Numerical integration using the trapezoidal rule.\n * \n * @param x - X values (must be sorted)\n * @param y - Y values\n * @param xMin - Optional start of integration range\n * @param xMax - Optional end of integration range\n */\nexport function integrate(\n x: number[] | Float32Array,\n y: number[] | Float32Array,\n xMin?: number,\n xMax?: number\n): number {\n const n = x.length;\n if (n < 2) return 0;\n\n let area = 0;\n const start = xMin !== undefined ? xMin : x[0];\n const end = xMax !== undefined ? xMax : x[n - 1];\n\n for (let i = 0; i < n - 1; i++) {\n const x1 = x[i];\n const x2 = x[i + 1];\n \n // Skip if outside range\n if (x2 < start) continue;\n if (x1 > end) break;\n\n // Handle partial intervals at boundaries\n const ia = Math.max(x1, start);\n const ib = Math.min(x2, end);\n\n if (ia < ib) {\n // Linear interpolation for y values at boundaries if needed\n const y1 = y[i] + (y[i + 1] - y[i]) * ((ia - x1) / (x2 - x1));\n const y2 = y[i] + (y[i + 1] - y[i]) * ((ib - x1) / (x2 - x1));\n \n area += (ib - ia) * (y1 + y2) / 2;\n }\n }\n\n return area;\n}\n\n/**\n * Calculate numerical derivative dy/dx\n */\nexport function derivative(\n x: number[] | Float32Array,\n y: number[] | Float32Array\n): Float32Array {\n const n = x.length;\n if (n < 2) return new Float32Array(0);\n\n const result = new Float32Array(n);\n for (let i = 0; i < n - 1; i++) {\n const dx = x[i + 1] - x[i];\n result[i] = dx !== 0 ? (y[i + 1] - y[i]) / dx : 0;\n }\n // Last point same as previous for length matching\n result[n - 1] = result[n - 2];\n return result;\n}\n\n/**\n * Calculate cumulative integral (area array)\n */\nexport function cumulativeIntegral(\n x: number[] | Float32Array,\n y: number[] | Float32Array\n): Float32Array {\n const n = x.length;\n if (n < 1) return new Float32Array(0);\n\n const result = new Float32Array(n);\n result[0] = 0;\n \n for (let i = 0; i < n - 1; i++) {\n const dx = x[i + 1] - x[i];\n const area = dx * (y[i] + y[i + 1]) / 2;\n result[i + 1] = result[i] + area;\n }\n \n return result;\n}\n"],"names":["solveLinearSystem","A","B","n","matrix","row","i","maxRow","k","temp","pivot","factor","j","x","sum","calculateR2","y","fitFn","sumY","meanY","ssTot","ssRes","yi","fi","integrate","xMin","xMax","area","start","end","x1","x2","ia","ib","y1","y2","derivative","result","dx","cumulativeIntegral"],"mappings":"AAWO,SAASA,EAAkBC,GAAeC,GAAuB;AACtE,QAAMC,IAAID,EAAE,QACNE,IAASH,EAAE,IAAI,CAACI,GAAKC,MAAM,CAAC,GAAGD,GAAKH,EAAEI,CAAC,CAAC,CAAC;AAE/C,WAASA,IAAI,GAAGA,IAAIH,GAAGG,KAAK;AAE1B,QAAIC,IAASD;AACb,aAASE,IAAIF,IAAI,GAAGE,IAAIL,GAAGK;AACzB,MAAI,KAAK,IAAIJ,EAAOI,CAAC,EAAEF,CAAC,CAAC,IAAI,KAAK,IAAIF,EAAOG,CAAM,EAAED,CAAC,CAAC,MACrDC,IAASC;AAKb,UAAMC,IAAOL,EAAOE,CAAC;AACrB,IAAAF,EAAOE,CAAC,IAAIF,EAAOG,CAAM,GACzBH,EAAOG,CAAM,IAAIE;AAGjB,UAAMC,IAAQN,EAAOE,CAAC,EAAEA,CAAC;AACzB,QAAI,KAAK,IAAII,CAAK,IAAI;AACpB,YAAM,IAAI,MAAM,qCAAqC;AAIvD,aAASF,IAAIF,IAAI,GAAGE,IAAIL,GAAGK,KAAK;AAC9B,YAAMG,IAASP,EAAOI,CAAC,EAAEF,CAAC,IAAII;AAC9B,eAASE,IAAIN,GAAGM,KAAKT,GAAGS;AACtB,QAAAR,EAAOI,CAAC,EAAEI,CAAC,KAAKD,IAASP,EAAOE,CA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