Commit a9b70be6 authored by Ahmad Nemati's avatar Ahmad Nemati

init

parent 2680ec32
...@@ -3,6 +3,7 @@ let moment = require('moment-timezone') ...@@ -3,6 +3,7 @@ let moment = require('moment-timezone')
let plus = 'plus' let plus = 'plus'
let zarib = 'zarib' let zarib = 'zarib'
let base='base'
function run(data, config) { function run(data, config) {
...@@ -18,12 +19,15 @@ function run(data, config) { ...@@ -18,12 +19,15 @@ function run(data, config) {
let reserv = 0 let reserv = 0
let profit = 0 let profit = 0
let lastCom = 0 let lastCom = 0
let lastMoney=0
for (let i = 0; i < data.length; i++) { for (let i = 0; i < data.length; i++) {
if (step === 0) if (step === 0)
money = config.base money = config.base
else { else {
if (config.type === zarib) if (config.type === zarib)
money=lastMoney * config.param
if (config.type === base)
money = config.base * config.param * step money = config.base * config.param * step
else if (config.type === plus) else if (config.type === plus)
money = config.base + (config.param * step) money = config.base + (config.param * step)
...@@ -34,6 +38,8 @@ function run(data, config) { ...@@ -34,6 +38,8 @@ function run(data, config) {
if (Math.abs(d.reserve) > Math.abs(maxReserve)) if (Math.abs(d.reserve) > Math.abs(maxReserve))
maxReserve = d.reserve maxReserve = d.reserve
// console.log(maxAllocatedMoney)
if (money > maxAllocatedMoney) if (money > maxAllocatedMoney)
maxAllocatedMoney = money maxAllocatedMoney = money
...@@ -48,11 +54,13 @@ function run(data, config) { ...@@ -48,11 +54,13 @@ function run(data, config) {
reserv = 0 reserv = 0
profit = 0 profit = 0
lastCom = 0 lastCom = 0
lastMoney=0
total++ total++
} else { } else {
step++ step++
profit = profit + d.profit profit = profit + d.profit
lastMoney=d.lastMoney
lastCom = lastCom + d.com lastCom = lastCom + d.com
} }
...@@ -130,7 +138,7 @@ function inlineCheck(money, com, data, profit, lastCom) { ...@@ -130,7 +138,7 @@ function inlineCheck(money, com, data, profit, lastCom) {
if (percentage(money, data.runUp) > target) if (percentage(money, data.runUp) > target)
return {done: true, reserve: diff} return {done: true, reserve: diff}
else else
return {done: false, reserve: diff, profit: profitMoney, com: com} return {done: false, reserve: diff, profit: profitMoney, com: com,lastMoney:money}
} }
......
...@@ -12,6 +12,12 @@ ...@@ -12,6 +12,12 @@
"commision": 0.0008, "commision": 0.0008,
"base": 100, "base": 100,
"param": 2 "param": 2
},
{
"type": "base",
"commision": 0.0008,
"base": 100,
"param": 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