Commit 26245ef8 authored by Ahmad Nemati's avatar Ahmad Nemati

init

parent 90533bd8
......@@ -8,7 +8,7 @@ let dynamic = 'dynamic'
let elsa = 'elsa'
function run(data, config, risk, pfTrade, riskFreeLevel, detail, loss,durs) {
function run(data, config, risk, pfTrade, riskFreeLevel, detail, loss, durs) {
let type = config.type + ' param:' + config.param + ' base:' + config.base + ' target:' + config.target
let saveData = []
let needPrintData = shouldPrint(detail, data[0].signal + '&' + type)
......@@ -17,6 +17,8 @@ function run(data, config, risk, pfTrade, riskFreeLevel, detail, loss,durs) {
let commision = config.commision
let money = config.base
let total = 0
let days = 0
let maxDays = 0
let allTotal = 0
let maxReserve = 0
let maxMeta = 0
......@@ -67,14 +69,13 @@ function run(data, config, risk, pfTrade, riskFreeLevel, detail, loss,durs) {
else {
money = percentage2(lastMoney, config.param * curDrawDown)
}
}
else if (config.type === elsa) {
} else if (config.type === elsa) {
if (curDrawDown <= 0)
money = lastMoney
else {
let b=curDrawDown/10
let b = curDrawDown / 10
b=b+ Math.abs(config.param)
b = b + Math.abs(config.param)
money = lastMoney * (b)
......@@ -86,7 +87,11 @@ function run(data, config, risk, pfTrade, riskFreeLevel, detail, loss,durs) {
if (step > riskFreeLevel)
riskfree = true
let d = inlineCheck(money, commision, data[i], profit, lastCom, config.target, riskfree)
let tempDay = getMinDiff(data[i].openDate, data[i].closeDate)
days = days + tempDay
if (days > maxDays)
maxDays = days
if (d.reserve < 0 && Math.abs(d.reserve) > Math.abs(maxReserve))
maxReserve = d.reserve
......@@ -121,6 +126,8 @@ function run(data, config, risk, pfTrade, riskFreeLevel, detail, loss,durs) {
obj.maxAllocatedMoney = maxAllocatedMoney
obj.maxLevel = maxLevel
obj.step = step
obj.days = days
obj.maxDays = maxDays
}
......@@ -142,12 +149,15 @@ function run(data, config, risk, pfTrade, riskFreeLevel, detail, loss,durs) {
}
if (d.done === true) {
days = 0
levels.push(step)
step = 0
reserv = 0
profit = 0
lastCom = 0
curDrawDown=0
curDrawDown = 0
lastMoney = 0
allTotal++
if (!d.riskFree)
......
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