Commit 6390824b authored by Ahmad Nemati's avatar Ahmad Nemati

git pu

parent a085766f
...@@ -11,22 +11,22 @@ let candles = [] ...@@ -11,22 +11,22 @@ let candles = []
let timeFrame = 0 let timeFrame = 0
function run(data, config, risk, pfTrade, riskFreeLevel, detail, loss, durs, maxTradeDays, targetPercentage, candlesData, fft, fftPercent, fftRunup, fftPercentRunup, fftDiffDrawDownProfit,fftDrawDown, usage) { function run(data, config, risk, pfTrade, riskFreeLevel, detail, loss, durs, maxTradeDays, targetPercentage, candlesData, fft, fftPercent, fftRunup, fftPercentRunup, fftDiffDrawDownProfit, fftDrawDown, ddPlusRunCount, usage) {
let type = config.type + ' param:' + config.param + ' base:' + config.base + ' target:' + config.target + ' targetPercentage:' + targetPercentage.enable let type = config.type + ' param:' + config.param + ' base:' + config.base + ' target:' + config.target + ' targetPercentage:' + targetPercentage.enable
if (usage === 'fft') { if (usage === 'fft') {
type = type + ' ' + usage + ' ' + fft type = type + ' ' + usage + ' ' + fft
} else if (usage === 'fftPercent') { } else if (usage === 'fftPercent') {
type = type + ' ' + usage + ' ' + fftPercent type = type + ' ' + usage + ' ' + fftPercent
} else if (usage === 'fftRunup') { } else if (usage === 'fftRunup') {
type = type + ' ' + usage + ' ' + fftRunup type = type + ' ' + usage + ' ' + fftRunup
} else if (usage ==='fftDiffDrawDownProfit') { } else if (usage === 'fftDiffDrawDownProfit') {
type = type + ' ' + usage + ' ' + fftDiffDrawDownProfit type = type + ' ' + usage + ' ' + fftDiffDrawDownProfit
} } else if (usage === 'fftPercentRunup') {
else if (usage ==='fftPercentRunup') { type = type + ' ' + usage + ' Count:' + fftPercentRunup.count + ' Percent:' + fftPercentRunup.percent
type = type + ' ' + usage + ' Count:' + fftPercentRunup.count +' Percent:'+fftPercentRunup.percent } else if (usage === 'fftDrawDown') {
}
else if (usage ==='fftDrawDown') {
type = type + ' ' + usage + ' ' + fftDrawDown type = type + ' ' + usage + ' ' + fftDrawDown
} else if (usage === 'ddPlusRunCount') {
type = type + ' ' + usage + ' ' + ddPlusRunCount
} }
...@@ -53,7 +53,7 @@ function run(data, config, risk, pfTrade, riskFreeLevel, detail, loss, durs, max ...@@ -53,7 +53,7 @@ function run(data, config, risk, pfTrade, riskFreeLevel, detail, loss, durs, max
let maxLevel = 0 let maxLevel = 0
let maxRuntime = 0 let maxRuntime = 0
let realProfit = 0 let realProfit = 0
let dateString='' let dateString = ''
// console.log(data) // console.log(data)
...@@ -69,13 +69,13 @@ function run(data, config, risk, pfTrade, riskFreeLevel, detail, loss, durs, max ...@@ -69,13 +69,13 @@ function run(data, config, risk, pfTrade, riskFreeLevel, detail, loss, durs, max
let detailLevel = [] let detailLevel = []
let durDetail = [] let durDetail = []
let runBefore = false let runBefore = false
let canCreateRunupPercent=false let canCreateRunupPercent = false
let countDrop = 0 let countDrop = 0
let allLossProfit = 0 let allLossProfit = 0
let drawDownPlusRunUpCount = 0
let countDropRunup = 0 let countDropRunup = 0
let fftDrawDownPercent=0 let fftDrawDownPercent = 0
let allLossProfitRunup = 0 let allLossProfitRunup = 0
let diffDrawdownProfitAll = 0 let diffDrawdownProfitAll = 0
...@@ -106,51 +106,63 @@ function run(data, config, risk, pfTrade, riskFreeLevel, detail, loss, durs, max ...@@ -106,51 +106,63 @@ function run(data, config, risk, pfTrade, riskFreeLevel, detail, loss, durs, max
if (usage === 'fft') { if (usage === 'fft') {
if (countDrop < fft) if (countDrop < fft)
runBefore=false runBefore = false
else else
runBefore=true runBefore = true
} else if (usage === 'drawDownPlusRunUpCount') {
if (drawDownPlusRunUpCount < ddPlusRunCount)
runBefore = false
else
runBefore = true
} else if (usage === 'fftPercent') { } else if (usage === 'fftPercent') {
if (allLossProfit > fftPercent) if (allLossProfit > fftPercent)
runBefore=false runBefore = false
else else
runBefore=true runBefore = true
}else if (usage === 'fftDrawDown') { } else if (usage === 'fftDrawDown') {
if (fftDrawDownPercent > fftDrawDown) if (fftDrawDownPercent > fftDrawDown)
runBefore=false runBefore = false
else else
runBefore=true runBefore = true
} } else if (usage === 'fftRunup') {
else if (usage === 'fftRunup') {
if (countDropRunup < fftRunup) if (countDropRunup < fftRunup)
runBefore=false runBefore = false
else else
runBefore=true runBefore = true
} else if (usage ==='fftDiffDrawDownProfit') { } else if (usage === 'fftDiffDrawDownProfit') {
if (diffDrawdownProfitAll > fftDiffDrawDownProfit) if (diffDrawdownProfitAll > fftDiffDrawDownProfit)
runBefore=false runBefore = false
else else
runBefore=true runBefore = true
} } else if (usage === 'fftPercentRunup') {
else if (usage ==='fftPercentRunup') { if (canCreateRunupPercent === false)
if (canCreateRunupPercent ===false) runBefore = false
runBefore=false
else else
runBefore=true runBefore = true
} }
} }
if ((data[i].runUp + data[i].drawDown) <0)
{
drawDownPlusRunUpCount++
}
else
{
drawDownPlusRunUpCount=0
}
if (data[i].profit < 0) { if (data[i].profit < 0) {
allLossProfit = allLossProfit + data[i].profit allLossProfit = allLossProfit + data[i].profit
diffDrawdownProfitAll = diffDrawdownProfitAll + (data[i].drawDown - data[i].profit) diffDrawdownProfitAll = diffDrawdownProfitAll + (data[i].drawDown - data[i].profit)
fftDrawDownPercent=fftDrawDownPercent+data[i].drawDown fftDrawDownPercent = fftDrawDownPercent + data[i].drawDown
countDrop++ countDrop++
} else { } else {
allLossProfit = 0 allLossProfit = 0
diffDrawdownProfitAll = 0 diffDrawdownProfitAll = 0
countDrop = 0 countDrop = 0
fftDrawDownPercent=0 fftDrawDownPercent = 0
} }
if (data[i].runUp < config.target) { if (data[i].runUp < config.target) {
allLossProfitRunup = allLossProfitRunup + data[i].runUp allLossProfitRunup = allLossProfitRunup + data[i].runUp
...@@ -160,39 +172,33 @@ function run(data, config, risk, pfTrade, riskFreeLevel, detail, loss, durs, max ...@@ -160,39 +172,33 @@ function run(data, config, risk, pfTrade, riskFreeLevel, detail, loss, durs, max
countDropRunup = 0 countDropRunup = 0
} }
if (usage ==='fftPercentRunup') if (usage === 'fftPercentRunup') {
{
let temp = 0 let temp = 0
for (let z = i + 1; z <= (i + fftPercentRunup.count); z++) { for (let z = i + 1; z <= (i + fftPercentRunup.count); z++) {
try { try {
let runup = data[z].runUp let runup = data[z].runUp
temp = temp + runup temp = temp + runup
} } catch (e) {
catch (e)
{
} }
} }
if (temp <= fftPercentRunup.percent) { if (temp <= fftPercentRunup.percent) {
canCreateRunupPercent=true canCreateRunupPercent = true
} }
} }
if (runBefore === false)
if (runBefore ===false)
continue continue
if (step ===0) if (step === 0)
dateString=dateString+data[i].openDate.split(' ')[0]+'_' dateString = dateString + data[i].openDate.split(' ')[0] + '_'
canCreateRunupPercent=false canCreateRunupPercent = false
runBefore = true runBefore = true
let obj let obj
if (step === 0) { if (step === 0) {
// unixStart = data[i].unixOpen // unixStart = data[i].unixOpen
startDays = data[i].openDate startDays = data[i].openDate
money = config.base money = config.base
} else { } else {
...@@ -256,8 +262,8 @@ function run(data, config, risk, pfTrade, riskFreeLevel, detail, loss, durs, max ...@@ -256,8 +262,8 @@ function run(data, config, risk, pfTrade, riskFreeLevel, detail, loss, durs, max
obj = d obj = d
obj.signal = data[i] obj.signal = data[i]
// obj.signal.openTimeStamp = data[i].unixOpen // obj.signal.openTimeStamp = data[i].unixOpen
// obj.signal.closeTimeStamp = data[i].unixClose // obj.signal.closeTimeStamp = data[i].unixClose
if (d.meta < 0) if (d.meta < 0)
...@@ -341,7 +347,7 @@ function run(data, config, risk, pfTrade, riskFreeLevel, detail, loss, durs, max ...@@ -341,7 +347,7 @@ function run(data, config, risk, pfTrade, riskFreeLevel, detail, loss, durs, max
total++ total++
} else { } else {
// unixMid = data[i].unixClose // unixMid = data[i].unixClose
step++ step++
profit = profit + d.profit profit = profit + d.profit
lastMoney = d.lastMoney lastMoney = d.lastMoney
...@@ -490,7 +496,7 @@ function run(data, config, risk, pfTrade, riskFreeLevel, detail, loss, durs, max ...@@ -490,7 +496,7 @@ function run(data, config, risk, pfTrade, riskFreeLevel, detail, loss, durs, max
totalCompound: sum, totalCompound: sum,
profitPerMonth: Math.abs(profitPerMonth), profitPerMonth: Math.abs(profitPerMonth),
compoundPerMonth: compoundPerMonth, compoundPerMonth: compoundPerMonth,
dateString:dateString, dateString: dateString,
firstMaxAllocatedMoney: firstMaxAllocatedMoney, firstMaxAllocatedMoney: firstMaxAllocatedMoney,
maxAllocatedMoney: maxAllocatedMoney, maxAllocatedMoney: maxAllocatedMoney,
......
...@@ -64,6 +64,7 @@ async function run() { ...@@ -64,6 +64,7 @@ async function run() {
i.fftPercentRunup= config.fftPercentRunup i.fftPercentRunup= config.fftPercentRunup
i.fftDiffDrawDownProfit=config.fftDiffDrawDownProfit i.fftDiffDrawDownProfit=config.fftDiffDrawDownProfit
i.fftDrawDown=config.fftDrawDown i.fftDrawDown=config.fftDrawDown
i.ddPlusRunCount=config.ddPlusRunCount
i.usage= config.usage i.usage= config.usage
i.detail=config.detail i.detail=config.detail
......
...@@ -140,7 +140,7 @@ function initData(data, config, name, risk, pfTrade, side, riskFreeLevel,detail, ...@@ -140,7 +140,7 @@ function initData(data, config, name, risk, pfTrade, side, riskFreeLevel,detail,
let cz = [] let cz = []
for (let i = 0; i < config.length; i++) { for (let i = 0; i < config.length; i++) {
let d = ai.run(arr, config[i], config[i].risk, config[i].pfTrade, config[i].riskFreeLevel,config[i].detail,config[i].loss,config[i].dur,config[i].maxTradeDays,config[i].targetPercentage,candles,config[i].fft,config[i].fftPercent,config[i].fftRunup,config[i].fftPercentRunup,config[i].fftDiffDrawDownProfit,config[i].fftDrawDown,config[i].usage) let d = ai.run(arr, config[i], config[i].risk, config[i].pfTrade, config[i].riskFreeLevel,config[i].detail,config[i].loss,config[i].dur,config[i].maxTradeDays,config[i].targetPercentage,candles,config[i].fft,config[i].fftPercent,config[i].fftRunup,config[i].fftPercentRunup,config[i].fftDiffDrawDownProfit,config[i].fftDrawDown,config[i].ddPlusRunCount,config[i].usage)
if (d !== null) if (d !== null)
cz.push(d) cz.push(d)
} }
......
...@@ -20,7 +20,7 @@ run() ...@@ -20,7 +20,7 @@ run()
async function run() async function run()
{ {
let obj={sort:'profitPerMonthDrawDown',alocatedReserve:3,alocatedReserveCompound:3,risk:0,start:10000,pfTrade:2,side:'both',riskFreeLevel:100,onlyShortLong:false,loss:0,level:200,dur:1500,maxTradeDays:40,targetPercentage:{enable:true},fft:1,fftPercent:-2,fftRunup:2,fftPercentRunup:{count:7,percent:15},fftDiffDrawDownProfit:-0.5,fftDrawDown:-1,usage:'fft'} let obj={sort:'profitPerMonthDrawDown',alocatedReserve:3,alocatedReserveCompound:3,risk:0,start:10000,pfTrade:2,side:'both',riskFreeLevel:100,onlyShortLong:false,loss:0,level:200,dur:1500,maxTradeDays:40,targetPercentage:{enable:true},fft:1,fftPercent:-2,fftRunup:2,fftPercentRunup:{count:7,percent:15},fftDiffDrawDownProfit:-0.5,fftDrawDown:-1,ddPlusRunCount:4,usage:'fft'}
let detail=['configs2.json-211021092159_O1_BNC_BTCUSD_Lp1_Y211020a - Copy_Mn.csv&zarib param:1.1 base:200 target:1'] let detail=['configs2.json-211021092159_O1_BNC_BTCUSD_Lp1_Y211020a - Copy_Mn.csv&zarib param:1.1 base:200 target:1']
obj.detail=detail obj.detail=detail
let all=[] let all=[]
......
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