Commit f7a1eff7 authored by Ahmad Nemati's avatar Ahmad Nemati

init

parent 1de3824c
......@@ -41,6 +41,7 @@ async function format(name) {
}
}
res=newArrr
console.log(res)
// console.log(res)
let start = parseFloat(res[1].split(',')[0])
let timeFrame = parseFloat(res[2].split(',')[0]) - start
......@@ -49,41 +50,45 @@ async function format(name) {
let header = 'time,open,high,low,close'
let arr = []
for (let i = start; i < lastTimestamp; i = i + timeFrame) {
console.log(i + '/' + lastTimestamp)
let d = founder(res, i)
for (let i = start; i <= lastTimestamp; i = i + timeFrame) {
if (lastTimestamp %1000 ===0)
console.log(i + '/' + lastTimestamp)
arr.push(founder(res, i))
// console.log(d)
if (d === null)
d = i + ',0,0,0,0'
arr.push(d)
// if (d === null)
// d = i + ',0,0,0,0'
// arr.push(d)
// console.log(temp[6])
}
arr= await Promise.all(arr)
//console.log(arr)
let t = header + '\n'
for (let i = 0; i < arr.length; i++) {
t = t + arr[i]
if (i <arr.length-1)
t=t+'\n'
}
//let t = ''
// for (let i = 0; i < res.length; i++)
// t = t + res[i]
await createFile(name, t)
console.log('done')
}
function founder(res, timestamp) {
async function founder(res, timestamp) {
for (let i = 0; i < res.length; i++) {
let time = parseFloat(res[i].split(',')[0])
if (timestamp === time)
return res[i]
if (time >timestamp)
break
}
return null
return timestamp + ',0,0,0,0'
}
function createFile(name, body) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment