mirror of
https://github.com/freqtrade/frequi.git
synced 2024-11-10 18:23: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 lowIdx = columns.indexOf('low');
|
||||
|
||||
// Prevent mutation of original data
|
||||
const dataCopy = data.map((original) => original.slice());
|
||||
return data.map((original, idx, candles) => {
|
||||
// Prevent mutation of original data
|
||||
const candle = original.slice();
|
||||
|
||||
return dataCopy.map((candle, idx, candles) => {
|
||||
if (idx === 0) {
|
||||
const close = (candle[openIdx] + candle[highIdx] + candle[lowIdx] + candle[closeIdx]) / 4;
|
||||
const open = (candle[openIdx] + candle[closeIdx]) / 2;
|
||||
|
|
Loading…
Reference in New Issue
Block a user