Commit 1d4c69b9 authored by Ahmad Nemati's avatar Ahmad Nemati

git pu

parent a3158e27
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
......@@ -10,25 +10,22 @@ let dir
work()
async function work() {
let arr=[]
let arr = []
try {
await fs.mkdirSync('end')
}
catch (e)
{
} catch (e) {
}
let configs = await fs.readdirSync('last1000/')
for (let z=0;z<configs.length;z++)
{
let directory = await fs.readdirSync('last1000/'+configs[z])
for (let z = 0; z < configs.length; z++) {
let directory = await fs.readdirSync('last1000/' + configs[z])
for (let i = 0; i < directory.length; i = i + 1000) {
// console.log('hi')
for (let j = 0; j < 1000; j++) {
try {
if ((j + i) < directory.length)
arr.push(configs[z]+'/'+directory[j + i])
arr.push(configs[z] + '/' + directory[j + i])
} catch (e) {
}
......@@ -37,11 +34,6 @@ async function work() {
}
}
......@@ -50,34 +42,28 @@ async function work() {
if (arr.length !== 0) {
let timestamp = Date.now()
try {
await fs.mkdirSync('end' +'/'+ timestamp)
await fs.mkdirSync('end' +'/' + timestamp+'/default')
await fs.mkdirSync('end' + '/' + timestamp)
await fs.mkdirSync('end' + '/' + timestamp + '/default')
// for (let z=0;z<drawDown.length;z++)
// await fs.mkdirSync('final1000/' + timestamp+'/drawDown'+drawDown[z])
} catch (e) {
}
await run('default','compound1000', arr, timestamp)
// run('default','compound1000Start', arr, timestamp)
// run('default','profitPerMonth1000', arr, timestamp)
await run('default', 'compound1000', arr, timestamp)
// run('default','compound1000Start', arr, timestamp)
// run('default','profitPerMonth1000', arr, timestamp)
// generateByDrawDown(timestamp,arr)
// await run('default','profitPerMonth1000Start', arr, timestamp)
// await run('default','profitPerMonth1000Start', arr, timestamp)
}
}
async function run(root,name, directory, timestamp) {
async function run(root, name, directory, timestamp) {
// let directory = await fs.readdirSync('last1000')
let arr2 = []
let arrFinal = []
......@@ -87,7 +73,7 @@ async function run(root,name, directory, timestamp) {
if (typeof directory[f] === "undefined")
continue
console.log(directory[f])
arrFinal.push(readFile(root,name, directory[f]))
arrFinal.push(readFile(root, name, directory[f]))
}
......@@ -106,7 +92,7 @@ async function run(root,name, directory, timestamp) {
// console.log(arr2)
let t=name.toLowerCase()
let t = name.toLowerCase()
if (t.includes('per') || name === 'profitPerMonth1000' || name === 'allocatedReservePerMonthUnder3' || name === 'allocatedReservePerMonthUnder2' || name === 'profitPerMonth1000Start')
last = _.orderBy(arr2, ['profitPerMonthDrawDown'], ['desc']);
......@@ -117,25 +103,26 @@ async function run(root,name, directory, timestamp) {
last = _.orderBy(arr2, ['maxLevel'], ['asc']);
let las = []
for (let i = 0; i < last.length; i++) {
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))
var oldJSON = JSON;
JSON = undefined;
require('./json2');
JSON.stringify = oldJSON.stringify;
createfileADV(root, timestamp, name, JSON.stringify(las, null, 2))
last = []
}
async function readFile(root,name, directory,conf) {
async function readFile(root, name, directory, conf) {
let sortByProfit = []
let file = await fs.readFileSync('./last1000/' + directory + '/'+root+'/' + name + '.json', 'utf8')
let file = await fs.readFileSync('./last1000/' + directory + '/' + root + '/' + name + '.json', 'utf8')
file = JSON.parse(file)
// file = _.orderBy(file, sort, ['desc']);
......@@ -145,15 +132,12 @@ async function readFile(root,name, directory,conf) {
}
return file
}
function createfileADV(root,timestamp, filename, data) {
function createfileADV(root, timestamp, filename, data) {
return new Promise(function (resolve, reject) {
fs.writeFile('end'+'/' + timestamp + '/'+root+'/' + filename + '.json', data, 'utf8', function (err) {
fs.writeFile('end' + '/' + timestamp + '/' + root + '/' + filename + '.json', data, 'utf8', function (err) {
if (err) reject(err);
else resolve(data);
});
......
......@@ -124,6 +124,13 @@ async function run(root, name, directory, timestamp) {
}
var oldJSON = JSON;
JSON = undefined;
require('./json2');
JSON.stringify = oldJSON.stringify;
createfileADV(root, timestamp, name, JSON.stringify(las, null, 2))
last = []
......
......@@ -125,10 +125,17 @@ 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])
}
var oldJSON = JSON;
JSON = undefined;
require('./json2');
JSON.stringify = oldJSON.stringify;
createfileADV(root,timestamp, name, JSON.stringify(las, null, 2))
last = []
......
This diff is collapsed.
......@@ -24,5 +24,10 @@
"shelljs": "^0.8.4",
"stringify-object": "^4.0.1",
"unzip": "^0.1.11"
},
"devDependencies": {
"@babel/core": "^7.17.9",
"@babel/preset-env": "^7.16.11",
"@babel/register": "^7.17.7"
}
}
let stringifyObject =require('stringify-object')
var oldJSON = JSON;
JSON = undefined;
require('./json2');
JSON.stringify = oldJSON.stringify;
const object = {
foo: 'bar',
'arr': [1, 2, 3],
nested: {
hello: "world"
}
};
const pretty = stringifyObject(object, {
indent: ' ',
singleQuotes: false
});
let arr=[{hi:1}]
console.log(pretty);
\ No newline at end of file
console.log(JSON.stringify(arr, null, 2))
\ 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