mirror of
https://github.com/freqtrade/frequi.git
synced 2024-11-13 03:33:50 +00:00
refactor: do processing in one loop
This commit is contained in:
parent
7362e8d5e2
commit
910768f531
|
@ -4,10 +4,10 @@ export default function heikinAshiDataset(columns: string[], data: Array<number[
|
||||||
const highIdx = columns.indexOf('high');
|
const highIdx = columns.indexOf('high');
|
||||||
const lowIdx = columns.indexOf('low');
|
const lowIdx = columns.indexOf('low');
|
||||||
|
|
||||||
|
return data.map((original, idx, candles) => {
|
||||||
// Prevent mutation of original data
|
// Prevent mutation of original data
|
||||||
const dataCopy = data.map((original) => original.slice());
|
const candle = original.slice();
|
||||||
|
|
||||||
return dataCopy.map((candle, idx, candles) => {
|
|
||||||
if (idx === 0) {
|
if (idx === 0) {
|
||||||
const close = (candle[openIdx] + candle[highIdx] + candle[lowIdx] + candle[closeIdx]) / 4;
|
const close = (candle[openIdx] + candle[highIdx] + candle[lowIdx] + candle[closeIdx]) / 4;
|
||||||
const open = (candle[openIdx] + candle[closeIdx]) / 2;
|
const open = (candle[openIdx] + candle[closeIdx]) / 2;
|
||||||
|
|
Loading…
Reference in New Issue
Block a user