Commit 7d7c306d authored by Ahmad Nemati's avatar Ahmad Nemati

init

parent aa55d60d
node --max-old-space-size=4096 result.js
\ No newline at end of file
let fs=require('fs')
let _ = require('lodash')
let sort='profitPerMonth'
let alocatedReserve=2
let alocatedReserveCompound=3
run()
async function run()
{
let directory =await fs.readdirSync('result')
let arr2=[]
let arr3 = []
for (let i=0;i<directory.length;i++)
{
let file = await fs.readFileSync('./result/'+directory[i]+'/allDataSortedByProfit.json', 'utf8')
file=JSON.parse(file)
for (let j=0;j<file.length;j++)
arr2.push(file[j])
}
arr2 = _.orderBy(arr2, sort, ['desc']);
let arr20Max = []
let arr1000Compound = []
let arrReserv = _.orderBy(arr2, ['percentage'], ['asc']);
let arrCompound = _.orderBy(arr2, ['compoundPerMonth'], ['desc']);
let arrResrv200 = []
let arrReservCompound = []
for (let i = 0; i < 1000; i++) {
arr3.push(arr2[i])
arrResrv200.push(arrReserv[i])
arr1000Compound.push(arrCompound[i])
}
for (let i = 0; i < arr3.length; i++) {
if (arr3[i].allocatedReserve < alocatedReserve)
arr20Max.push(arr3[i])
}
for (let i = 0; i < arrCompound.length; i++) {
if (arrCompound[i].allocatedReserve < alocatedReserveCompound)
arrReservCompound.push(arrCompound[i])
}
createfileADV('profitPerMonth1000', JSON.stringify(arr3, null, 2))
createfileADV('percentage1000', JSON.stringify(arrResrv200, null, 2))
createfileADV('compound1000', JSON.stringify(arr1000Compound, null, 2))
// createfileADV('allocatedReservePerMonthUnder' + alocatedReserve, JSON.stringify(arr20Max, null, 2))
// createfileADV('allocatedReserveCompoundUnder' + alocatedReserveCompound, JSON.stringify(arrReservCompound, null, 2))
}
function createfileADV(filename, data) {
return new Promise(function (resolve, reject) {
fs.writeFile('final/'+ filename + '.json', data, 'utf8', function (err) {
if (err) reject(err);
else resolve(data);
});
});
}
\ No newline at end of file
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