pricehistory
Version:
Series data with technical indicators.
33 lines (32 loc) • 1.01 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
const simpul_1 = require("simpul");
function getVolumeRate(option, series) {
if (option.volumeFill !== true ||
!option.low ||
!option.high ||
!option.volume)
return;
let totalVolume = 0;
let totalRange = 0;
for (const curr of series) {
const low = curr[option.low];
const high = curr[option.high];
const volume = curr[option.volume];
if (typeof low !== "number")
continue;
if (typeof high !== "number")
continue;
if (typeof volume !== "number" || volume === 0)
continue;
const range = simpul_1.math.change.percent(low, high);
if (typeof range === "number") {
totalVolume += volume;
totalRange += range;
}
}
if (totalVolume > 0 && totalRange > 0) {
return simpul_1.math.num(totalVolume / totalRange);
}
}
exports.default = getVolumeRate;