mgilliland23 / quantla

Quantla is a node powered crypto currency trading bot
5 stars 2 forks source link

review function MergeHistoricData(data, mergecutoff) #62

Closed costargc closed 5 years ago

costargc commented 5 years ago

Need to review this function. I don't think its working as it should. This function should receive a data and concatenate to each line a mergecutoff number of arrays.

ex.:

data = [
[1,2],
[3,4],
[5,6],
[7,8],
[9,10]
]

mergecutoff = 2

should return:

return = [
  [ 1, 2 ],
  [ 3, 4 ],
  [ 5, 6, 3, 4, 1, 2 ],
  [ 7, 8, 5, 6, 3, 4 ],
  [ 9, 10, 7, 8, 5, 6 ]
]
function MergeHistoricData(data, mergecutoff) {
  for (i = 0; i < data.length - mergecutoff; i++) {
    for (j = 0; j < mergecutoff; j++) {
      for (k = 0; k < data[data.length - i - 1 - j - 1].length; k++) {
        data[data.length - i - 1].push(data[data.length - i - 1 - j - 1][k]);
      }
    }
  }
  return data;
}
costargc commented 5 years ago

bottom of the data has the most recent information... the function works perfectly! Even in the case where data < mengecutoff... this still works. So I did a great job in the first deploy 🤣