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