Commit 59c40a1f authored by Ahmad Nemati's avatar Ahmad Nemati

init

parent eadbcf9d
...@@ -7,22 +7,18 @@ let alocatedReserve = 3 ...@@ -7,22 +7,18 @@ let alocatedReserve = 3
let alocatedReserveCompound = 3 let alocatedReserveCompound = 3
work() work()
async function work()
{ async function work() {
let directory = await fs.readdirSync('result') let directory = await fs.readdirSync('result')
for (let i=0;i<directory.length ;i=i+1000) for (let i = 0; i < directory.length; i = i + 1000) {
{ // console.log('hi')
console.log('hi') let arr = []
let arr=[] for (let j = 0; j < 1000; j++) {
for (let j=0;j<1000;j++)
{
try { try {
arr.push(directory[j+i]) if ((j + i) < directory.length)
} arr.push(directory[j + i])
catch (e) } catch (e) {
{
} }
...@@ -30,37 +26,36 @@ async function work() ...@@ -30,37 +26,36 @@ async function work()
} }
if (arr.length !==0) if (arr.length !== 0) {
{
let timestamp = Date.now() let timestamp = Date.now()
try { try {
await fs.mkdirSync('last1000/' + timestamp) await fs.mkdirSync('last1000/' + timestamp)
} catch (e) { } catch (e) {
} }
run('profitPerMonth1000',arr,timestamp) run('profitPerMonth1000', arr, timestamp)
run('percentage1000',arr,timestamp) run('percentage1000', arr, timestamp)
run('compound1000',arr,timestamp) run('compound1000', arr, timestamp)
run('allocatedReservePerMonthUnder3',arr,timestamp) run('allocatedReservePerMonthUnder3', arr, timestamp)
run('allocatedReserveCompoundUnder3',arr,timestamp) run('allocatedReserveCompoundUnder3', arr, timestamp)
run('allocatedReservePerMonthUnder2',arr,timestamp) run('allocatedReservePerMonthUnder2', arr, timestamp)
await run('allocatedReserveCompoundUnder2',arr,timestamp) await run('allocatedReserveCompoundUnder2', arr, timestamp)
} }
} }
} }
async function run(name,directory,timestamp) { async function run(name, directory, timestamp) {
// let directory = await fs.readdirSync('result') // let directory = await fs.readdirSync('result')
let arr2 = [] let arr2 = []
let arrFinal = [] let arrFinal = []
let last = [] let last = []
for (let f = 0; f < directory.length; f++) console.log(directory)
{ for (let f = 0; f < directory.length; f++) {
if (typeof directory[f] ==="undefined") if (typeof directory[f] === "undefined")
continue continue
console.log(directory[f])
arrFinal.push(readFile(name, directory[f])) arrFinal.push(readFile(name, directory[f]))
} }
...@@ -115,9 +110,9 @@ async function run(name,directory,timestamp) { ...@@ -115,9 +110,9 @@ async function run(name,directory,timestamp) {
las.push(last[i]) las.push(last[i])
createfileADV(timestamp,name, JSON.stringify(las, null, 2)) createfileADV(timestamp, name, JSON.stringify(las, null, 2))
last=[] last = []
} }
...@@ -148,9 +143,9 @@ async function readFile(name, directory) { ...@@ -148,9 +143,9 @@ async function readFile(name, directory) {
return file return file
} }
function createfileADV(timestamp,filename, data) { function createfileADV(timestamp, filename, data) {
return new Promise(function (resolve, reject) { return new Promise(function (resolve, reject) {
fs.writeFile('last1000/' +timestamp+'/'+ filename + '.json', data, 'utf8', function (err) { fs.writeFile('last1000/' + timestamp + '/' + filename + '.json', data, 'utf8', function (err) {
if (err) reject(err); if (err) reject(err);
else resolve(data); else resolve(data);
}); });
......
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