efcd6216c1
The rolling-window VWAP indicator (`wickra_core::RollingVwap`) was only available in the Rust crate, even though the README's Volume-family table already advertised "VWAP (cumulative + rolling)" as a cross- language feature. Users on Python, Node or in the browser had to fall back to the cumulative `VWAP` or re-implement the rolling variant themselves. This commit closes the gap end-to-end: - Python: `wickra.RollingVWAP(period)` — same constructor / `update` / `batch` / `reset` / `is_ready` / `warmup_period` surface as `VWAP`, plus a `period` property and a typed `__repr__`. The `__init__.py` re-exports it and `__all__` lists it; the `.pyi` stub matches. - Node: `RollingVWAP(period)` — napi class with the same lifecycle, exported from `index.js` and declared in `index.d.ts`. - WASM: `RollingVWAP(period)` — wasm-bindgen class with the same `Float64Array` I/O as `VWAP`. Tests added: - Python: `test_rolling_vwap_streaming_matches_batch` — exercises `update == batch` plus the full lifecycle on the shared OHLC fixture. - Node: `RollingVWAP` row in the `candleScalar` parity table — covered by the generic streaming-vs-batch + lifecycle harness. - WASM: dedicated `wasm-bindgen-test` mirrors the Python test. The wiki page `Indicator-Vwap.md` drops the "Rust-only" caveat and gains Python / Node / WASM examples.
388 lines
12 KiB
JavaScript
388 lines
12 KiB
JavaScript
/* tslint:disable */
|
|
/* eslint-disable */
|
|
/* prettier-ignore */
|
|
|
|
/* auto-generated by NAPI-RS */
|
|
|
|
const { existsSync, readFileSync } = require('fs')
|
|
const { join } = require('path')
|
|
|
|
const { platform, arch } = process
|
|
|
|
let nativeBinding = null
|
|
let localFileExisted = false
|
|
let loadError = null
|
|
|
|
function isMusl() {
|
|
// For Node 10
|
|
if (!process.report || typeof process.report.getReport !== 'function') {
|
|
try {
|
|
const lddPath = require('child_process').execSync('which ldd').toString().trim()
|
|
return readFileSync(lddPath, 'utf8').includes('musl')
|
|
} catch (e) {
|
|
return true
|
|
}
|
|
} else {
|
|
const { glibcVersionRuntime } = process.report.getReport().header
|
|
return !glibcVersionRuntime
|
|
}
|
|
}
|
|
|
|
switch (platform) {
|
|
case 'android':
|
|
switch (arch) {
|
|
case 'arm64':
|
|
localFileExisted = existsSync(join(__dirname, 'wickra.android-arm64.node'))
|
|
try {
|
|
if (localFileExisted) {
|
|
nativeBinding = require('./wickra.android-arm64.node')
|
|
} else {
|
|
nativeBinding = require('wickra-android-arm64')
|
|
}
|
|
} catch (e) {
|
|
loadError = e
|
|
}
|
|
break
|
|
case 'arm':
|
|
localFileExisted = existsSync(join(__dirname, 'wickra.android-arm-eabi.node'))
|
|
try {
|
|
if (localFileExisted) {
|
|
nativeBinding = require('./wickra.android-arm-eabi.node')
|
|
} else {
|
|
nativeBinding = require('wickra-android-arm-eabi')
|
|
}
|
|
} catch (e) {
|
|
loadError = e
|
|
}
|
|
break
|
|
default:
|
|
throw new Error(`Unsupported architecture on Android ${arch}`)
|
|
}
|
|
break
|
|
case 'win32':
|
|
switch (arch) {
|
|
case 'x64':
|
|
localFileExisted = existsSync(
|
|
join(__dirname, 'wickra.win32-x64-msvc.node')
|
|
)
|
|
try {
|
|
if (localFileExisted) {
|
|
nativeBinding = require('./wickra.win32-x64-msvc.node')
|
|
} else {
|
|
nativeBinding = require('wickra-win32-x64-msvc')
|
|
}
|
|
} catch (e) {
|
|
loadError = e
|
|
}
|
|
break
|
|
case 'ia32':
|
|
localFileExisted = existsSync(
|
|
join(__dirname, 'wickra.win32-ia32-msvc.node')
|
|
)
|
|
try {
|
|
if (localFileExisted) {
|
|
nativeBinding = require('./wickra.win32-ia32-msvc.node')
|
|
} else {
|
|
nativeBinding = require('wickra-win32-ia32-msvc')
|
|
}
|
|
} catch (e) {
|
|
loadError = e
|
|
}
|
|
break
|
|
case 'arm64':
|
|
localFileExisted = existsSync(
|
|
join(__dirname, 'wickra.win32-arm64-msvc.node')
|
|
)
|
|
try {
|
|
if (localFileExisted) {
|
|
nativeBinding = require('./wickra.win32-arm64-msvc.node')
|
|
} else {
|
|
nativeBinding = require('wickra-win32-arm64-msvc')
|
|
}
|
|
} catch (e) {
|
|
loadError = e
|
|
}
|
|
break
|
|
default:
|
|
throw new Error(`Unsupported architecture on Windows: ${arch}`)
|
|
}
|
|
break
|
|
case 'darwin':
|
|
localFileExisted = existsSync(join(__dirname, 'wickra.darwin-universal.node'))
|
|
try {
|
|
if (localFileExisted) {
|
|
nativeBinding = require('./wickra.darwin-universal.node')
|
|
} else {
|
|
nativeBinding = require('wickra-darwin-universal')
|
|
}
|
|
break
|
|
} catch {}
|
|
switch (arch) {
|
|
case 'x64':
|
|
localFileExisted = existsSync(join(__dirname, 'wickra.darwin-x64.node'))
|
|
try {
|
|
if (localFileExisted) {
|
|
nativeBinding = require('./wickra.darwin-x64.node')
|
|
} else {
|
|
nativeBinding = require('wickra-darwin-x64')
|
|
}
|
|
} catch (e) {
|
|
loadError = e
|
|
}
|
|
break
|
|
case 'arm64':
|
|
localFileExisted = existsSync(
|
|
join(__dirname, 'wickra.darwin-arm64.node')
|
|
)
|
|
try {
|
|
if (localFileExisted) {
|
|
nativeBinding = require('./wickra.darwin-arm64.node')
|
|
} else {
|
|
nativeBinding = require('wickra-darwin-arm64')
|
|
}
|
|
} catch (e) {
|
|
loadError = e
|
|
}
|
|
break
|
|
default:
|
|
throw new Error(`Unsupported architecture on macOS: ${arch}`)
|
|
}
|
|
break
|
|
case 'freebsd':
|
|
if (arch !== 'x64') {
|
|
throw new Error(`Unsupported architecture on FreeBSD: ${arch}`)
|
|
}
|
|
localFileExisted = existsSync(join(__dirname, 'wickra.freebsd-x64.node'))
|
|
try {
|
|
if (localFileExisted) {
|
|
nativeBinding = require('./wickra.freebsd-x64.node')
|
|
} else {
|
|
nativeBinding = require('wickra-freebsd-x64')
|
|
}
|
|
} catch (e) {
|
|
loadError = e
|
|
}
|
|
break
|
|
case 'linux':
|
|
switch (arch) {
|
|
case 'x64':
|
|
if (isMusl()) {
|
|
localFileExisted = existsSync(
|
|
join(__dirname, 'wickra.linux-x64-musl.node')
|
|
)
|
|
try {
|
|
if (localFileExisted) {
|
|
nativeBinding = require('./wickra.linux-x64-musl.node')
|
|
} else {
|
|
nativeBinding = require('wickra-linux-x64-musl')
|
|
}
|
|
} catch (e) {
|
|
loadError = e
|
|
}
|
|
} else {
|
|
localFileExisted = existsSync(
|
|
join(__dirname, 'wickra.linux-x64-gnu.node')
|
|
)
|
|
try {
|
|
if (localFileExisted) {
|
|
nativeBinding = require('./wickra.linux-x64-gnu.node')
|
|
} else {
|
|
nativeBinding = require('wickra-linux-x64-gnu')
|
|
}
|
|
} catch (e) {
|
|
loadError = e
|
|
}
|
|
}
|
|
break
|
|
case 'arm64':
|
|
if (isMusl()) {
|
|
localFileExisted = existsSync(
|
|
join(__dirname, 'wickra.linux-arm64-musl.node')
|
|
)
|
|
try {
|
|
if (localFileExisted) {
|
|
nativeBinding = require('./wickra.linux-arm64-musl.node')
|
|
} else {
|
|
nativeBinding = require('wickra-linux-arm64-musl')
|
|
}
|
|
} catch (e) {
|
|
loadError = e
|
|
}
|
|
} else {
|
|
localFileExisted = existsSync(
|
|
join(__dirname, 'wickra.linux-arm64-gnu.node')
|
|
)
|
|
try {
|
|
if (localFileExisted) {
|
|
nativeBinding = require('./wickra.linux-arm64-gnu.node')
|
|
} else {
|
|
nativeBinding = require('wickra-linux-arm64-gnu')
|
|
}
|
|
} catch (e) {
|
|
loadError = e
|
|
}
|
|
}
|
|
break
|
|
case 'arm':
|
|
if (isMusl()) {
|
|
localFileExisted = existsSync(
|
|
join(__dirname, 'wickra.linux-arm-musleabihf.node')
|
|
)
|
|
try {
|
|
if (localFileExisted) {
|
|
nativeBinding = require('./wickra.linux-arm-musleabihf.node')
|
|
} else {
|
|
nativeBinding = require('wickra-linux-arm-musleabihf')
|
|
}
|
|
} catch (e) {
|
|
loadError = e
|
|
}
|
|
} else {
|
|
localFileExisted = existsSync(
|
|
join(__dirname, 'wickra.linux-arm-gnueabihf.node')
|
|
)
|
|
try {
|
|
if (localFileExisted) {
|
|
nativeBinding = require('./wickra.linux-arm-gnueabihf.node')
|
|
} else {
|
|
nativeBinding = require('wickra-linux-arm-gnueabihf')
|
|
}
|
|
} catch (e) {
|
|
loadError = e
|
|
}
|
|
}
|
|
break
|
|
case 'riscv64':
|
|
if (isMusl()) {
|
|
localFileExisted = existsSync(
|
|
join(__dirname, 'wickra.linux-riscv64-musl.node')
|
|
)
|
|
try {
|
|
if (localFileExisted) {
|
|
nativeBinding = require('./wickra.linux-riscv64-musl.node')
|
|
} else {
|
|
nativeBinding = require('wickra-linux-riscv64-musl')
|
|
}
|
|
} catch (e) {
|
|
loadError = e
|
|
}
|
|
} else {
|
|
localFileExisted = existsSync(
|
|
join(__dirname, 'wickra.linux-riscv64-gnu.node')
|
|
)
|
|
try {
|
|
if (localFileExisted) {
|
|
nativeBinding = require('./wickra.linux-riscv64-gnu.node')
|
|
} else {
|
|
nativeBinding = require('wickra-linux-riscv64-gnu')
|
|
}
|
|
} catch (e) {
|
|
loadError = e
|
|
}
|
|
}
|
|
break
|
|
case 's390x':
|
|
localFileExisted = existsSync(
|
|
join(__dirname, 'wickra.linux-s390x-gnu.node')
|
|
)
|
|
try {
|
|
if (localFileExisted) {
|
|
nativeBinding = require('./wickra.linux-s390x-gnu.node')
|
|
} else {
|
|
nativeBinding = require('wickra-linux-s390x-gnu')
|
|
}
|
|
} catch (e) {
|
|
loadError = e
|
|
}
|
|
break
|
|
default:
|
|
throw new Error(`Unsupported architecture on Linux: ${arch}`)
|
|
}
|
|
break
|
|
default:
|
|
throw new Error(`Unsupported OS: ${platform}, architecture: ${arch}`)
|
|
}
|
|
|
|
if (!nativeBinding) {
|
|
if (loadError) {
|
|
throw loadError
|
|
}
|
|
throw new Error(`Failed to load native binding`)
|
|
}
|
|
|
|
const { version, SMA, EMA, WMA, RSI, DEMA, TEMA, HMA, ROC, TRIX, SMMA, TRIMA, ZLEMA, MOM, CMO, DPO, StdDev, UlcerIndex, VerticalHorizontalFilter, ZScore, MACD, BollingerBands, ATR, Stochastic, OBV, ADX, CCI, WilliamsR, MFI, PSAR, Keltner, Donchian, VWAP, RollingVWAP, AwesomeOscillator, Aroon, KAMA, T3, TSI, PMO, ADL, VolumePriceTrend, ChaikinMoneyFlow, ChaikinOscillator, ForceIndex, EaseOfMovement, SuperTrend, ChandelierExit, ChandeKrollStop, AtrTrailingStop, TypicalPrice, MedianPrice, WeightedClose, LinearRegression, LinRegSlope, AcceleratorOscillator, BalanceOfPower, ChoppinessIndex, TrueRange, ChaikinVolatility, LinRegAngle, BollingerBandwidth, PercentB, NATR, HistoricalVolatility, AroonOscillator, Vortex, MassIndex, StochRSI, UltimateOscillator, PPO, Coppock, VWMA } = nativeBinding
|
|
|
|
module.exports.version = version
|
|
module.exports.SMA = SMA
|
|
module.exports.EMA = EMA
|
|
module.exports.WMA = WMA
|
|
module.exports.RSI = RSI
|
|
module.exports.DEMA = DEMA
|
|
module.exports.TEMA = TEMA
|
|
module.exports.HMA = HMA
|
|
module.exports.ROC = ROC
|
|
module.exports.TRIX = TRIX
|
|
module.exports.SMMA = SMMA
|
|
module.exports.TRIMA = TRIMA
|
|
module.exports.ZLEMA = ZLEMA
|
|
module.exports.MOM = MOM
|
|
module.exports.CMO = CMO
|
|
module.exports.DPO = DPO
|
|
module.exports.StdDev = StdDev
|
|
module.exports.UlcerIndex = UlcerIndex
|
|
module.exports.VerticalHorizontalFilter = VerticalHorizontalFilter
|
|
module.exports.ZScore = ZScore
|
|
module.exports.MACD = MACD
|
|
module.exports.BollingerBands = BollingerBands
|
|
module.exports.ATR = ATR
|
|
module.exports.Stochastic = Stochastic
|
|
module.exports.OBV = OBV
|
|
module.exports.ADX = ADX
|
|
module.exports.CCI = CCI
|
|
module.exports.WilliamsR = WilliamsR
|
|
module.exports.MFI = MFI
|
|
module.exports.PSAR = PSAR
|
|
module.exports.Keltner = Keltner
|
|
module.exports.Donchian = Donchian
|
|
module.exports.VWAP = VWAP
|
|
module.exports.RollingVWAP = RollingVWAP
|
|
module.exports.AwesomeOscillator = AwesomeOscillator
|
|
module.exports.Aroon = Aroon
|
|
module.exports.KAMA = KAMA
|
|
module.exports.T3 = T3
|
|
module.exports.TSI = TSI
|
|
module.exports.PMO = PMO
|
|
module.exports.ADL = ADL
|
|
module.exports.VolumePriceTrend = VolumePriceTrend
|
|
module.exports.ChaikinMoneyFlow = ChaikinMoneyFlow
|
|
module.exports.ChaikinOscillator = ChaikinOscillator
|
|
module.exports.ForceIndex = ForceIndex
|
|
module.exports.EaseOfMovement = EaseOfMovement
|
|
module.exports.SuperTrend = SuperTrend
|
|
module.exports.ChandelierExit = ChandelierExit
|
|
module.exports.ChandeKrollStop = ChandeKrollStop
|
|
module.exports.AtrTrailingStop = AtrTrailingStop
|
|
module.exports.TypicalPrice = TypicalPrice
|
|
module.exports.MedianPrice = MedianPrice
|
|
module.exports.WeightedClose = WeightedClose
|
|
module.exports.LinearRegression = LinearRegression
|
|
module.exports.LinRegSlope = LinRegSlope
|
|
module.exports.AcceleratorOscillator = AcceleratorOscillator
|
|
module.exports.BalanceOfPower = BalanceOfPower
|
|
module.exports.ChoppinessIndex = ChoppinessIndex
|
|
module.exports.TrueRange = TrueRange
|
|
module.exports.ChaikinVolatility = ChaikinVolatility
|
|
module.exports.LinRegAngle = LinRegAngle
|
|
module.exports.BollingerBandwidth = BollingerBandwidth
|
|
module.exports.PercentB = PercentB
|
|
module.exports.NATR = NATR
|
|
module.exports.HistoricalVolatility = HistoricalVolatility
|
|
module.exports.AroonOscillator = AroonOscillator
|
|
module.exports.Vortex = Vortex
|
|
module.exports.MassIndex = MassIndex
|
|
module.exports.StochRSI = StochRSI
|
|
module.exports.UltimateOscillator = UltimateOscillator
|
|
module.exports.PPO = PPO
|
|
module.exports.Coppock = Coppock
|
|
module.exports.VWMA = VWMA
|