Commit 87ba2529 authored by Ahmad Nemati's avatar Ahmad Nemati

init

parent 94fc4423
...@@ -87,10 +87,20 @@ function run(data, config) { ...@@ -87,10 +87,20 @@ function run(data, config) {
// percentage2 = maxAllocatedMoney / percentage2 // percentage2 = maxAllocatedMoney / percentage2
// let minus2 = 0 // let minus2 = 0
// if (percentage2 < 0) { // if (percentage2 < 0) {
// minus2 = percentage2 // minus2 = percentage2
// percentage2 = null // percentage2 = null
// } // }
let perp=(config.target * 100)/Math.abs(maxReserve)
perp=perp/100
let sum=Math.abs(maxReserve)
for (let i=0;i<total;i++)
sum = sum + (sum* perp)
let newCompund=sum/dur
let compoundPerMonth=(newCompund * 30 * 100)/maxReserve
let opt = { let opt = {
platform: data[0].signal, platform: data[0].signal,
type: config.type + ' param:' + config.param + ' base:' + config.base +' target:'+config.target, type: config.type + ' param:' + config.param + ' base:' + config.base +' target:'+config.target,
...@@ -99,8 +109,9 @@ function run(data, config) { ...@@ -99,8 +109,9 @@ function run(data, config) {
maxLevel: maxLevel, maxLevel: maxLevel,
dur:dur, dur:dur,
totalFinal:totalFinal, totalFinal:totalFinal,
totalCompound:sum,
profitPerMonth:Math.abs(profitPerMonth), profitPerMonth:Math.abs(profitPerMonth),
compoundPerMonth:compoundPerMonth,
maxAllocatedMoney: maxAllocatedMoney, maxAllocatedMoney: maxAllocatedMoney,
avgAllocatedMoney: maxAllocatedMoney / total, avgAllocatedMoney: maxAllocatedMoney / total,
...@@ -122,6 +133,15 @@ function run(data, config) { ...@@ -122,6 +133,15 @@ function run(data, config) {
// console.log(data) // console.log(data)
} }
function percentage2(base, per) {
base = parseFloat(base)
per = parseFloat(per)
let percentager = per / 100
let temp = base * percentager
return base + temp
}
function inlineCheck(money, com, data, profit, lastCom,tar) { function inlineCheck(money, com, data, profit, lastCom,tar) {
// console.log(profit) // console.log(profit)
......
...@@ -20,7 +20,7 @@ run() ...@@ -20,7 +20,7 @@ run()
async function run() async function run()
{ {
let obj={sort:'profitPerMonth',alocatedReserve:20} let obj={sort:'profitPerMonth',alocatedReserve:10}
let all=[] let all=[]
for (let i=0;i<arr.length;i++) for (let i=0;i<arr.length;i++)
all.push(add(arr[i])) all.push(add(arr[i]))
......
...@@ -33,11 +33,14 @@ async function run() { ...@@ -33,11 +33,14 @@ async function run() {
arr2 = _.orderBy(arr2, [configs.sort], ['desc']); arr2 = _.orderBy(arr2, [configs.sort], ['desc']);
let arr20Max=[] let arr20Max=[]
let arr1000Compound=[]
let arrReserv=_.orderBy(arr2, ['percentage'], ['asc']); let arrReserv=_.orderBy(arr2, ['percentage'], ['asc']);
let arrCompound=_.orderBy(arr2, ['compoundPerMonth'], ['asc']);
let arrResrv200=[] let arrResrv200=[]
for (let i = 0; i < 200; i++) { for (let i = 0; i < 1000; i++) {
arr3.push(arr2[i]) arr3.push(arr2[i])
arrResrv200.push(arrReserv[i]) arrResrv200.push(arrReserv[i])
arr1000Compound.push(arrCompound[i])
} }
for (let i=0;i<arrReserv.length;i++) for (let i=0;i<arrReserv.length;i++)
...@@ -53,8 +56,9 @@ async function run() { ...@@ -53,8 +56,9 @@ async function run() {
// createfile(JSON.stringify(arr2, null, 2)) // createfile(JSON.stringify(arr2, null, 2))
createfile2(JSON.stringify(arr3, null, 2)) createfile2(JSON.stringify(arr3, null, 2))
// createfileADV('percentage',JSON.stringify(arrReserv, null, 2)) // createfileADV('percentage',JSON.stringify(arrReserv, null, 2))
createfileADV('percentage200',JSON.stringify(arrResrv200, null, 2)) createfileADV('percentage1000',JSON.stringify(arrResrv200, null, 2))
// createfileADV('allocatedReserve',JSON.stringify(arr20Max, null, 2)) createfileADV('compound1000',JSON.stringify(arr1000Compound, null, 2))
createfileADV('allocatedReserve',JSON.stringify(arr20Max, null, 2))
// console.log(perf.stop()) // console.log(perf.stop())
console.log('Done') console.log('Done')
// process.exit(0) // process.exit(0)
...@@ -82,7 +86,7 @@ function createfileADV(filename,data) { ...@@ -82,7 +86,7 @@ function createfileADV(filename,data) {
function createfile2(data) { function createfile2(data) {
return new Promise(function (resolve, reject) { return new Promise(function (resolve, reject) {
fs.writeFile('work/result2.json', data, 'utf8', function (err) { fs.writeFile('work/profitPerMonth1000.json', data, 'utf8', function (err) {
if (err) reject(err); if (err) reject(err);
else resolve(data); else resolve(data);
}); });
......
let arr=[1,2,3,4,5,6,7,8,9,10] let target = 20
let arr2=[1,2,3,4,5,6,7,8,9,10] let maxReserve = 300
let total = 2
let t=0 let perp = (target * 100) / Math.abs(maxReserve)
perp=perp/100
for (let i=0;i<arr.length;i++) let sum = Math.abs(maxReserve)
for (let j=0;j<arr2.length;j++)
for (let z=0;z<arr2.length;z++)
t++
for (let i = 0; i < total; i++)
sum = sum + (sum* perp)
console.log(sum)
console.log(t) function percentage2(base, per) {
\ No newline at end of file
base = parseFloat(base)
per = parseFloat(per)
let percentager = per / 100
let temp = base * percentager
return base + temp
}
\ 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