Commit d5a1ef0f authored by Ahmad Nemati's avatar Ahmad Nemati

init

parent cf9b80f9
...@@ -9,7 +9,7 @@ async function copyAllFiles() ...@@ -9,7 +9,7 @@ async function copyAllFiles()
for (let z=0;z<configs.length;z++) for (let z=0;z<configs.length;z++)
{ {
try { try {
await fs.mkdirSync('final/' + configs[z]) await fs.mkdirSync('final1000/' + configs[z])
} }
catch (e) catch (e)
......
var shell = require('shelljs');
let fs = require('fs')
copyAllFiles()
async function copyAllFiles()
{
let configs = await fs.readdirSync('configs')
for (let z=0;z<configs.length;z++)
{
shell.exec('node --max-old-space-size=9999999999 final1000.js ' + configs[z] , {async: true});
}
}
\ No newline at end of file
node --max-old-space-size=9999999999 final1000.js node --max-old-space-size=9999999999 beforeFinal1000.js
\ No newline at end of file \ No newline at end of file
...@@ -5,12 +5,14 @@ let drawDown=[30,40,50] ...@@ -5,12 +5,14 @@ let drawDown=[30,40,50]
let sort = 'profitPerMonth' let sort = 'profitPerMonth'
let alocatedReserve = 3 let alocatedReserve = 3
let alocatedReserveCompound = 3 let alocatedReserveCompound = 3
let dir
work() work()
async function work() { async function work() {
let directory = await fs.readdirSync('last1000') var args = process.argv.slice(2);
dir = args[0]
let directory = await fs.readdirSync('last1000/'+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 = []
...@@ -29,8 +31,8 @@ async function work() { ...@@ -29,8 +31,8 @@ async function work() {
if (arr.length !== 0) { if (arr.length !== 0) {
let timestamp = Date.now() let timestamp = Date.now()
try { try {
await fs.mkdirSync('final1000/' + timestamp) await fs.mkdirSync('final1000/' +dir+'/'+ timestamp)
await fs.mkdirSync('final1000/' + timestamp+'/default') await fs.mkdirSync('final1000/' +dir+'/' + timestamp+'/default')
// for (let z=0;z<drawDown.length;z++) // for (let z=0;z<drawDown.length;z++)
// await fs.mkdirSync('final1000/' + timestamp+'/drawDown'+drawDown[z]) // await fs.mkdirSync('final1000/' + timestamp+'/drawDown'+drawDown[z])
} catch (e) { } catch (e) {
...@@ -40,7 +42,7 @@ async function work() { ...@@ -40,7 +42,7 @@ async function work() {
run('default','compound1000', arr, timestamp) 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)
// generateByDrawDown(timestamp,arr) // generateByDrawDown(timestamp,arr)
await run('default','profitPerMonth1000Start', arr, timestamp) await run('default','profitPerMonth1000Start', arr, timestamp)
...@@ -83,7 +85,7 @@ async function run(root,name, directory, timestamp) { ...@@ -83,7 +85,7 @@ async function run(root,name, directory, timestamp) {
for (let f = 0; f < directory.length; f++) { for (let f = 0; f < directory.length; f++) {
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]))
} }
...@@ -115,36 +117,6 @@ async function run(root,name, directory, timestamp) { ...@@ -115,36 +117,6 @@ async function run(root,name, directory, timestamp) {
// if (name === 'allocatedReservePerMonthUnder2' || name === 'allocatedReservePerMonthUnder3') {
// let arr20Max = []
// for (let i = 0; i < last.length; i++) {
// if (name === 'allocatedReservePerMonthUnder2')
// alocatedReserve = 2
// else
// alocatedReserve = 3
//
// if (last[i].allocatedReserve < alocatedReserve)
// arr20Max.push(last[i])
// }
//
// last = arr20Max
// }
//
// if (name === 'allocatedReserveCompoundUnder2' || name === 'allocatedReserveCompoundUnder3') {
// let arr20Max = []
// for (let i = 0; i < last.length; i++) {
// if (name === 'allocatedReserveCompoundUnder2')
// alocatedReserve = 2
// else
// alocatedReserve = 3
//
// if (last[i].allocatedReserve < alocatedReserve)
// arr20Max.push(last[i])
// }
//
// last = arr20Max
// }
//
let las = [] let las = []
for (let i = 0; i < 1000; i++) { for (let i = 0; i < 1000; i++) {
...@@ -161,7 +133,7 @@ async function run(root,name, directory, timestamp) { ...@@ -161,7 +133,7 @@ async function run(root,name, directory, timestamp) {
async function readFile(root,name, directory) { async function readFile(root,name, directory) {
let sortByProfit = [] let sortByProfit = []
let file = await fs.readFileSync('./last1000/' + directory + '/'+root+'/' + name + '.json', 'utf8') let file = await fs.readFileSync('./last1000/'+dir+'/' + directory + '/'+root+'/' + name + '.json', 'utf8')
file = JSON.parse(file) file = JSON.parse(file)
// file = _.orderBy(file, sort, ['desc']); // file = _.orderBy(file, sort, ['desc']);
...@@ -179,7 +151,7 @@ async function readFile(root,name, directory) { ...@@ -179,7 +151,7 @@ async function readFile(root,name, directory) {
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('final1000/' + timestamp + '/'+root+'/' + filename + '.json', data, 'utf8', function (err) { fs.writeFile('final1000/'+dir+'/' + timestamp + '/'+root+'/' + filename + '.json', data, 'utf8', function (err) {
if (err) reject(err); if (err) reject(err);
else resolve(data); else resolve(data);
}); });
......
...@@ -5,12 +5,14 @@ let drawDown=[30,40,50] ...@@ -5,12 +5,14 @@ let drawDown=[30,40,50]
let sort = 'profitPerMonth' let sort = 'profitPerMonth'
let alocatedReserve = 3 let alocatedReserve = 3
let alocatedReserveCompound = 3 let alocatedReserveCompound = 3
let dir
work() work()
async function work() { async function work() {
let directory = await fs.readdirSync('last1000') var args = process.argv.slice(2);
dir = args[0]
let directory = await fs.readdirSync('last1000/'+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 = []
...@@ -29,10 +31,10 @@ async function work() { ...@@ -29,10 +31,10 @@ async function work() {
if (arr.length !== 0) { if (arr.length !== 0) {
let timestamp = Date.now() let timestamp = Date.now()
try { try {
await fs.mkdirSync('final1000/' + timestamp) await fs.mkdirSync('final1000/' +dir+'/'+ timestamp)
await fs.mkdirSync('final1000/' + timestamp+'/default') await fs.mkdirSync('final1000/' +dir+'/' + timestamp+'/default')
for (let z=0;i<drawDown.length;z++) // for (let z=0;z<drawDown.length;z++)
await fs.mkdirSync('final1000/' + timestamp+'/drawDown'+drawDown[z]) // await fs.mkdirSync('final1000/' + timestamp+'/drawDown'+drawDown[z])
} catch (e) { } catch (e) {
} }
...@@ -40,7 +42,7 @@ async function work() { ...@@ -40,7 +42,7 @@ async function work() {
run('default','compound1000', arr, timestamp) 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)
generateByDrawDown(timestamp,arr) // generateByDrawDown(timestamp,arr)
await run('default','profitPerMonth1000Start', arr, timestamp) await run('default','profitPerMonth1000Start', arr, timestamp)
...@@ -115,36 +117,6 @@ async function run(root,name, directory, timestamp) { ...@@ -115,36 +117,6 @@ async function run(root,name, directory, timestamp) {
// if (name === 'allocatedReservePerMonthUnder2' || name === 'allocatedReservePerMonthUnder3') {
// let arr20Max = []
// for (let i = 0; i < last.length; i++) {
// if (name === 'allocatedReservePerMonthUnder2')
// alocatedReserve = 2
// else
// alocatedReserve = 3
//
// if (last[i].allocatedReserve < alocatedReserve)
// arr20Max.push(last[i])
// }
//
// last = arr20Max
// }
//
// if (name === 'allocatedReserveCompoundUnder2' || name === 'allocatedReserveCompoundUnder3') {
// let arr20Max = []
// for (let i = 0; i < last.length; i++) {
// if (name === 'allocatedReserveCompoundUnder2')
// alocatedReserve = 2
// else
// alocatedReserve = 3
//
// if (last[i].allocatedReserve < alocatedReserve)
// arr20Max.push(last[i])
// }
//
// last = arr20Max
// }
//
let las = [] let las = []
for (let i = 0; i < 1000; i++) { for (let i = 0; i < 1000; i++) {
...@@ -161,7 +133,7 @@ async function run(root,name, directory, timestamp) { ...@@ -161,7 +133,7 @@ async function run(root,name, directory, timestamp) {
async function readFile(root,name, directory) { async function readFile(root,name, directory) {
let sortByProfit = [] let sortByProfit = []
let file = await fs.readFileSync('./last1000/' + directory + '/'+root+'/' + name + '.json', 'utf8') let file = await fs.readFileSync('./last1000/'+dir+'/' + directory + '/'+root+'/' + name + '.json', 'utf8')
file = JSON.parse(file) file = JSON.parse(file)
// file = _.orderBy(file, sort, ['desc']); // file = _.orderBy(file, sort, ['desc']);
...@@ -179,7 +151,7 @@ async function readFile(root,name, directory) { ...@@ -179,7 +151,7 @@ async function readFile(root,name, directory) {
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('final1000/' + timestamp + '/'+root+'/' + filename + '.json', data, 'utf8', function (err) { fs.writeFile('final1000/'+dir+'/' + timestamp + '/'+root+'/' + 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