UNPKG

trading-signals

Version:

Technical indicators to run technical analysis with JavaScript / TypeScript.

21 lines 667 B
export function getGrid({ levels, lower, spacing, tickSize, upper }) { const prices = []; if (spacing === 'arithmetic') { const step = (upper - lower) / (levels - 1); for (let i = 0; i < levels; i++) { prices.push(lower + step * i); } } else { const ratio = Math.pow(upper / lower, 1 / (levels - 1)); for (let i = 0; i < levels; i++) { prices.push(lower * Math.pow(ratio, i)); } } if (tickSize) { const roundToTick = (x) => Math.round(x / tickSize) * tickSize; return prices.map(roundToTick); } return prices; } //# sourceMappingURL=getGrid.js.map