Commit f7f48a40 authored by Ahmad Nemati's avatar Ahmad Nemati

init

parent 7d7c306d
let fs = require('fs')
let fs=require('fs')
let _ = require('lodash') let _ = require('lodash')
let sort = 'profitPerMonth'
let alocatedReserve = 2
let sort='profitPerMonth' let alocatedReserveCompound = 3
let alocatedReserve=2
let alocatedReserveCompound=3
run() run()
async function run() async function run() {
{ let directory = await fs.readdirSync('result')
let directory =await fs.readdirSync('result') let arr2 = []
let arr2=[]
let arr3 = [] let arr3 = []
for (let i=0;i<directory.length;i++) for (let i = 0; i < directory.length; i++) {
{ let file = await fs.readFileSync('./result/' + directory[i] + '/allDataSortedByProfit.json', 'utf8')
let file = await fs.readFileSync('./result/'+directory[i]+'/allDataSortedByProfit.json', 'utf8') file = JSON.parse(file)
file=JSON.parse(file) for (let j = 0; j < file.length; j++)
for (let j=0;j<file.length;j++)
arr2.push(file[j]) arr2.push(file[j])
} }
arr2 = _.orderBy(arr2, sort, ['desc']); arr2 = _.orderBy(arr2, sort, ['desc']);
let arr20Max = [] let arr20Max = []
let arr1000Compound = [] let arr1000Compound = []
...@@ -54,23 +47,26 @@ async function run() ...@@ -54,23 +47,26 @@ async function run()
} }
let alocated100 = []
let allocated1000compond = []
for (let i = 0; i < 1000; i++) {
alocated100.push(arr20Max[i])
allocated1000compond.push(arrReservCompound[i])
}
createfileADV('profitPerMonth1000', JSON.stringify(arr3, null, 2)) createfileADV('profitPerMonth1000', JSON.stringify(arr3, null, 2))
createfileADV('percentage1000', JSON.stringify(arrResrv200, null, 2)) createfileADV('percentage1000', JSON.stringify(arrResrv200, null, 2))
createfileADV('compound1000', JSON.stringify(arr1000Compound, null, 2)) createfileADV('compound1000', JSON.stringify(arr1000Compound, null, 2))
// createfileADV('allocatedReservePerMonthUnder' + alocatedReserve, JSON.stringify(arr20Max, null, 2)) createfileADV('allocatedReservePerMonthUnder' + alocated100, JSON.stringify(arr20Max, null, 2))
// createfileADV('allocatedReserveCompoundUnder' + alocatedReserveCompound, JSON.stringify(arrReservCompound, null, 2)) createfileADV('allocatedReserveCompoundUnder' + allocated1000compond, JSON.stringify(arrReservCompound, null, 2))
} }
function createfileADV(filename, data) { function createfileADV(filename, data) {
return new Promise(function (resolve, reject) { return new Promise(function (resolve, reject) {
fs.writeFile('final/'+ filename + '.json', data, 'utf8', function (err) { fs.writeFile('final/' + 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