Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
calcHACandle = function(candle) {
xcloseprev = result.xclose;
xopenprev = result.xopen;
// Calculate new Heikin-Ashi candles
result.xclose = (candle.open + candle.close + candle.high + candle.low)/4;
// xOpen = [xOpen(Previous Bar) + xClose(Previous Bar)]/2
result.xopen = (xopenprev + xcloseprev)/2;
// xHigh = Max(High, xOpen, xClose)
result.xhigh = math.max(candle.high, result.xopen, result.xclose);
// xLow = Min(Low, xOpen, xClose)
result.xlow = math.min(candle.low, result.xopen, result.xclose);
return result;
} ; //calculo de velas
function winsor(percentile, arr) {
let rv = arr.slice();
const len = rv.length;
const mean = m.mean(rv);
const std = m.std(rv);
rv = rv.map(v => (v - mean) / std);
const percentage = percentile / 100 / 2;
const min = m.min(rv);
// const min = m.quantileSeq(rv, percentage);
const max = m.max(rv);
// const max = m.quantileSeq(rv, 1 - percentage);
for (let i = 0; i < len; i++) {
if (rv[i] < min) rv[i] = min;
else if (rv[i] > max) rv[i] = max;
// rv[i] = normalize(min, max, rv[i]);
}
return rv;
}
.then(scores => {
scores = scores.map(score => score ? score : 9999)
console.log('scores', scores)
const indexOfMin = scores.indexOf(math.min(scores))
const winner = lowScore < scores[indexOfMin] ? [centroid, lowScore] : [cands[indexOfMin], scores[indexOfMin]]
return winner
})
.catch(console.error.bind(console))
.then(scores => {
scores = scores.map(score => score ? score : 9999)
const indexOfMin = scores.indexOf(math.min(scores))
const winner = lowScore < scores[indexOfMin] ? [centroid, lowScore] : [cands[indexOfMin], scores[indexOfMin]]
console.log(winner, counter)
return winner
})
.catch(console.error.bind(console))
return produce(fractal, draft => {
const { width, height } = getCanvasSize(canvas);
const factor = min(
width / draft.parent.width,
height / draft.parent.height
);
draft.parent = scale(draft.parent, factor);
draft.children = draft.children.map(child => scale(child, factor));
});
}
if (result.errors[error]) {
result.errors[error] += count;
} else {
result.errors[error] = count;
}
});
result.rps.count += stats.rps.count;
result.requestsCompleted += stats.requestsCompleted;
result.pendingRequests += stats.pendingRequests;
});
result.rps.mean = result.rps.count / STATS_INTERVAL;
result.latency.median = math.median(medians);
result.latency.min = math.min(mins);
result.latency.max = math.max(maxs);
result.latency.p95 = math.sum(request95) / result.requestsCompleted;
result.latency.p99 = math.sum(request99) / result.requestsCompleted;
result.scenarioDuration.p95 = math.sum(scenario95) / result.scenariosCompleted;
result.scenarioDuration.p99 = math.sum(scenario99) / result.scenariosCompleted;
return result;
}
function min(ary) {
return math.min(ary);
}
get topmost() {
return min(this.topLeft.y, this.topRight.y);
}
if (result.errors[error]) {
result.errors[error] += count;
} else {
result.errors[error] = count;
}
});
});
result.latency.median = math.median(requestMedians);
result.latency.min = math.min(requestMins);
result.latency.max = math.max(requestMaxs);
result.latency.p95 = math.sum(request95) / result.requestsCompleted;
result.latency.p99 = math.sum(request99) / result.requestsCompleted;
result.scenarioDuration.median = math.median(scenarioMedians);
result.scenarioDuration.min = math.min(scenarioMins);
result.scenarioDuration.max = math.max(scenarioMaxs);
result.scenarioDuration.p95 = math.sum(scenario95) / result.scenariosCompleted;
result.scenarioDuration.p99 = math.sum(scenario99) / result.scenariosCompleted;
return result;
}