Commit ffde763f authored by Ahmad Nemati's avatar Ahmad Nemati

git pu

parent 32594ab7
......@@ -122,6 +122,7 @@ async function run(root,name, directory, timestamp) {
let las = []
for (let i = 0; i < last.length; i++) {
if (i < last.length)
if (last[i].total > 0)
las.push(last[i])
}
......
let fs = require('fs')
let _ = require('lodash')
let drawDown=[30,40,50]
let drawDown = [30, 40, 50]
let sort = 'profitPerMonth'
let alocatedReserve = 3
let alocatedReserveCompound = 3
......@@ -12,7 +12,7 @@ work()
async function work() {
var args = process.argv.slice(2);
dir = args[0]
let directory = await fs.readdirSync('result/'+dir)
let directory = await fs.readdirSync('result/' + dir)
for (let i = 0; i < directory.length; i = i + 1000) {
// console.log('hi')
let arr = []
......@@ -31,63 +31,59 @@ async function work() {
if (arr.length !== 0) {
let timestamp = Date.now()
try {
await fs.mkdirSync('last1000/' +dir+'/'+ timestamp)
await fs.mkdirSync('last1000/' +dir+'/' + timestamp+'/default')
await fs.mkdirSync('last1000/' + dir + '/' + timestamp)
await fs.mkdirSync('last1000/' + dir + '/' + timestamp + '/default')
// for (let z=0;z<drawDown.length;z++)
// await fs.mkdirSync('last1000/' + timestamp+'/drawDown'+drawDown[z])
} catch (e) {
}
await run('default','compound1000', arr, timestamp)
// run('default','compound1000Start', arr, timestamp)
// run('default','profitPerMonth1000', arr, timestamp)
// run('default','maxtime1000', arr, timestamp)
// generateByDrawDown(timestamp,arr)
// await run('default','profitPerMonth1000Start', arr, timestamp)
// run('profitPerMonth1000', arr, timestamp)
//
//
// // run('percentage1000', arr, timestamp)
// run('compound1000', arr, timestamp)
// run('profitPerMonth1000Start', arr, timestamp)
// await run('compound1000Start', arr, timestamp)
// run('allocatedReservePerMonthUnder2', arr, timestamp)
// await run('allocatedReserveCompoundUnder2', arr, timestamp)
await run('default', 'compound1000', arr, timestamp)
// run('default','compound1000Start', arr, timestamp)
// run('default','profitPerMonth1000', arr, timestamp)
// run('default','maxtime1000', arr, timestamp)
// generateByDrawDown(timestamp,arr)
// await run('default','profitPerMonth1000Start', arr, timestamp)
// run('profitPerMonth1000', arr, timestamp)
//
//
// // run('percentage1000', arr, timestamp)
// run('compound1000', arr, timestamp)
// run('profitPerMonth1000Start', arr, timestamp)
// await run('compound1000Start', arr, timestamp)
// run('allocatedReservePerMonthUnder2', arr, timestamp)
// await run('allocatedReserveCompoundUnder2', arr, timestamp)
}
}
}
async function generateByDrawDown(timestamp,arr)
{
for (let i=0;i<drawDown.length;i++)
{
run('drawDown'+drawDown[i],'compound1000DrawDown'+drawDown[i], arr, timestamp)
run('drawDown'+drawDown[i],'compound1000StartDrawDown'+drawDown[i], arr, timestamp)
run('drawDown'+drawDown[i],'profitPerMonth1000DrawDown'+drawDown[i], arr, timestamp)
await run('drawDown'+drawDown[i],'profitPerMonth1000StartDrawDown'+drawDown[i], arr, timestamp)
async function generateByDrawDown(timestamp, arr) {
for (let i = 0; i < drawDown.length; i++) {
run('drawDown' + drawDown[i], 'compound1000DrawDown' + drawDown[i], arr, timestamp)
run('drawDown' + drawDown[i], 'compound1000StartDrawDown' + drawDown[i], arr, timestamp)
run('drawDown' + drawDown[i], 'profitPerMonth1000DrawDown' + drawDown[i], arr, timestamp)
await run('drawDown' + drawDown[i], 'profitPerMonth1000StartDrawDown' + drawDown[i], arr, timestamp)
}
}
async function run(root,name, directory, timestamp) {
async function run(root, name, directory, timestamp) {
// let directory = await fs.readdirSync('result')
let arr2 = []
let arrFinal = []
let last = []
// console.log(directory)
// console.log(directory)
for (let f = 0; f < directory.length; f++) {
if (typeof directory[f] === "undefined")
continue
console.log(directory[f])
arrFinal.push(readFile(root,name, directory[f]))
arrFinal.push(readFile(root, name, directory[f]))
}
......@@ -96,7 +92,7 @@ async function run(root,name, directory, timestamp) {
for (let i = 0; i < arrFinal.length; i++) {
let inline = arrFinal[i]
// console.log(inline)
// console.log(inline)
for (let z = 0; z < inline.length; z++)
......@@ -105,8 +101,8 @@ async function run(root,name, directory, timestamp) {
}
// console.log(arr2)
let t=name.toLowerCase()
// console.log(arr2)
let t = name.toLowerCase()
if (t.includes('per') || name === 'profitPerMonth1000' || name === 'allocatedReservePerMonthUnder3' || name === 'allocatedReservePerMonthUnder2' || name === 'profitPerMonth1000Start')
last = _.orderBy(arr2, ['profitPerMonthDrawDown'], ['desc']);
......@@ -116,28 +112,27 @@ let t=name.toLowerCase()
if (t.includes('compound') || name === 'compound1000' || name === 'allocatedReserveCompoundUnder3' || name === 'allocatedReserveCompoundUnder2' || name === 'compound1000Start')
last = _.orderBy(arr2, ['maxLevel'], ['asc']);
if ( name === 'maxtime1000')
if (name === 'maxtime1000')
last = _.orderBy(arr2, ['maxRuntime']);
let las = []
for (let i = 0; i < last.length; i++) {
if (i < last.length)
las.push(last[i])
if (last[i].total > 0)
las.push(last[i])
}
createfileADV(root,timestamp, name, JSON.stringify(las, null, 2))
createfileADV(root, timestamp, name, JSON.stringify(las, null, 2))
last = []
}
async function readFile(root,name, directory) {
async function readFile(root, name, directory) {
let sortByProfit = []
let file = await fs.readFileSync('./result/'+dir+'/' + directory + '/'+root+'/' + name + '.json', 'utf8')
let file = await fs.readFileSync('./result/' + dir + '/' + directory + '/' + root + '/' + name + '.json', 'utf8')
file = JSON.parse(file)
// file = _.orderBy(file, sort, ['desc']);
......@@ -147,15 +142,12 @@ async function readFile(root,name, directory) {
}
return file
}
function createfileADV(root,timestamp, filename, data) {
function createfileADV(root, timestamp, filename, data) {
return new Promise(function (resolve, reject) {
fs.writeFile('last1000/'+dir+'/' + timestamp + '/'+root+'/' + filename + '.json', data, 'utf8', function (err) {
fs.writeFile('last1000/' + dir + '/' + timestamp + '/' + root + '/' + filename + '.json', data, 'utf8', function (err) {
if (err) reject(err);
else resolve(data);
});
......
......@@ -125,6 +125,7 @@ async function run(root,name, directory, timestamp) {
let las = []
for (let i = 0; i < last.length; i++) {
if (i < last.length)
if (last[i].total > 0)
las.push(last[i])
}
......
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