Commit f7a1eff7 authored by Ahmad Nemati's avatar Ahmad Nemati

init

parent 1de3824c
...@@ -41,6 +41,7 @@ async function format(name) { ...@@ -41,6 +41,7 @@ async function format(name) {
} }
} }
res=newArrr res=newArrr
console.log(res)
// console.log(res) // console.log(res)
let start = parseFloat(res[1].split(',')[0]) let start = parseFloat(res[1].split(',')[0])
let timeFrame = parseFloat(res[2].split(',')[0]) - start let timeFrame = parseFloat(res[2].split(',')[0]) - start
...@@ -49,41 +50,45 @@ async function format(name) { ...@@ -49,41 +50,45 @@ async function format(name) {
let header = 'time,open,high,low,close' let header = 'time,open,high,low,close'
let arr = [] let arr = []
for (let i = start; i < lastTimestamp; i = i + timeFrame) { for (let i = start; i <= lastTimestamp; i = i + timeFrame) {
if (lastTimestamp %1000 ===0)
console.log(i + '/' + lastTimestamp) console.log(i + '/' + lastTimestamp)
let d = founder(res, i) arr.push(founder(res, i))
// console.log(d) // console.log(d)
if (d === null) // if (d === null)
d = i + ',0,0,0,0' // d = i + ',0,0,0,0'
arr.push(d) // arr.push(d)
// console.log(temp[6]) // console.log(temp[6])
} }
arr= await Promise.all(arr)
//console.log(arr)
let t = header + '\n' let t = header + '\n'
for (let i = 0; i < arr.length; i++) { for (let i = 0; i < arr.length; i++) {
t = t + arr[i] t = t + arr[i]
if (i <arr.length-1) if (i <arr.length-1)
t=t+'\n' t=t+'\n'
} }
//let t = ''
// for (let i = 0; i < res.length; i++)
// t = t + res[i]
await createFile(name, t) await createFile(name, t)
console.log('done') console.log('done')
} }
function founder(res, timestamp) { async function founder(res, timestamp) {
for (let i = 0; i < res.length; i++) { for (let i = 0; i < res.length; i++) {
let time = parseFloat(res[i].split(',')[0]) let time = parseFloat(res[i].split(',')[0])
if (timestamp === time) if (timestamp === time)
return res[i] return res[i]
if (time >timestamp)
break
} }
return null return timestamp + ',0,0,0,0'
} }
function createFile(name, body) { 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