Commit 38ec2bb5 authored by Ahmad Nemati's avatar Ahmad Nemati

init

parent e98bf3a6
...@@ -11,7 +11,7 @@ let candles = [] ...@@ -11,7 +11,7 @@ let candles = []
let timeFrame = 0 let timeFrame = 0
function run(data, config, risk, pfTrade, riskFreeLevel, detail, loss, durs, maxTradeDays, targetPercentage, candlesData,fft,fftPercent) { function run(data, config, risk, pfTrade, riskFreeLevel, detail, loss, durs, maxTradeDays, targetPercentage, candlesData,fft,fftPercent,fftRunup,fftPercentRunup) {
let type = config.type + ' param:' + config.param + ' base:' + config.base + ' target:' + config.target + ' targetPercentage:' + targetPercentage.enable + ' fft:' + fft + ' fftPercent:' + fftPercent let type = config.type + ' param:' + config.param + ' base:' + config.base + ' target:' + config.target + ' targetPercentage:' + targetPercentage.enable + ' fft:' + fft + ' fftPercent:' + fftPercent
let saveData = [] let saveData = []
candles = candlesData candles = candlesData
...@@ -54,6 +54,10 @@ function run(data, config, risk, pfTrade, riskFreeLevel, detail, loss, durs, max ...@@ -54,6 +54,10 @@ function run(data, config, risk, pfTrade, riskFreeLevel, detail, loss, durs, max
let countDrop=0 let countDrop=0
let allLossProfit=0 let allLossProfit=0
let countDropRunup=0
let allLossProfitRunup=0
let dur let dur
try { try {
dur = getNewMinDiff(data[0].openDate, data[data.length - 1].closeDate) dur = getNewMinDiff(data[0].openDate, data[data.length - 1].closeDate)
...@@ -87,13 +91,29 @@ function run(data, config, risk, pfTrade, riskFreeLevel, detail, loss, durs, max ...@@ -87,13 +91,29 @@ function run(data, config, risk, pfTrade, riskFreeLevel, detail, loss, durs, max
allLossProfit=0 allLossProfit=0
countDrop = 0 countDrop = 0
} }
if (data[i].runUp >=config.target) {
allLossProfitRunup=allLossProfitRunup+data[i].runUp
countDropRunup++
}
else {
allLossProfitRunup=0
countDropRunup = 0
}
if (runBefore ===false) if (runBefore ===false)
{ {
// if (countDrop <fft) // if (countDrop <fft)
// continue // continue
if (allLossProfit> fftPercent) // if (allLossProfit> fftPercent)
// continue
if (countDropRunup < fftRunup)
continue continue
} }
runBefore=true runBefore=true
......
...@@ -6,7 +6,7 @@ let moment = require('moment-timezone') ...@@ -6,7 +6,7 @@ let moment = require('moment-timezone')
let ai = require('./ai') let ai = require('./ai')
async function parse(directory, name, configs, risk, pfTrade, side, riskFreeLevel,detail,onlyShortLong,loss,dur,maxTradeDays,targetPercentage,candles,fft,fftPercent) { async function parse(directory, name, configs, risk, pfTrade, side, riskFreeLevel,detail,onlyShortLong,loss,dur,maxTradeDays,targetPercentage,candles,fft,fftPercent,fftRunup,fftPercentRunup) {
return new Promise(function (resolve, reject) { return new Promise(function (resolve, reject) {
let arr = [] let arr = []
...@@ -15,12 +15,12 @@ async function parse(directory, name, configs, risk, pfTrade, side, riskFreeLeve ...@@ -15,12 +15,12 @@ async function parse(directory, name, configs, risk, pfTrade, side, riskFreeLeve
.pipe(csv.parse({headers: true})) .pipe(csv.parse({headers: true}))
.on('error', error => reject(error)) .on('error', error => reject(error))
.on('data', row => arr.push(row)) .on('data', row => arr.push(row))
.on('end', rowCount => resolve(initData(arr, configs, name, risk, pfTrade, side, riskFreeLevel,detail,onlyShortLong,loss,dur,maxTradeDays,targetPercentage,candles,fft,fftPercent))); .on('end', rowCount => resolve(initData(arr, configs, name, risk, pfTrade, side, riskFreeLevel,detail,onlyShortLong,loss,dur,maxTradeDays,targetPercentage,candles,fft,fftPercent,fftRunup,fftPercentRunup)));
}); });
} }
function initData(data, config, name, risk, pfTrade, side, riskFreeLevel,detail,onlyShortLong,loss,dur,maxTradeDays,targetPercentage,candles,fft,fftPercent) { function initData(data, config, name, risk, pfTrade, side, riskFreeLevel,detail,onlyShortLong,loss,dur,maxTradeDays,targetPercentage,candles,fft,fftPercent,fftRunup,fftPercentRunup) {
data = JSON.stringify(data) data = JSON.stringify(data)
...@@ -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], risk, pfTrade, riskFreeLevel,detail,loss,dur,maxTradeDays,targetPercentage,candles,fft,fftPercent) let d = ai.run(arr, config[i], risk, pfTrade, riskFreeLevel,detail,loss,dur,maxTradeDays,targetPercentage,candles,fft,fftPercent,fftRunup,fftPercentRunup)
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} 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:-2}
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=[]
......
...@@ -44,7 +44,7 @@ async function run() { ...@@ -44,7 +44,7 @@ async function run() {
for (let i = 0; i < files.length; i++) for (let i = 0; i < files.length; i++)
if (files[i].includes('.csv')) { if (files[i].includes('.csv')) {
csvFile = files[i] csvFile = files[i]
arr.push(csv.parse(directory, files[i], configs.data, configs.risk, configs.pfTrade, configs.side, configs.riskFreeLevel, JSON.parse(checks), configs.onlyShortLong, configs.loss,configs.dur,configs.maxTradeDays,configs.targetPercentage,arr5,configs.fft,configs.fftPercent)) arr.push(csv.parse(directory, files[i], configs.data, configs.risk, configs.pfTrade, configs.side, configs.riskFreeLevel, JSON.parse(checks), configs.onlyShortLong, configs.loss,configs.dur,configs.maxTradeDays,configs.targetPercentage,arr5,configs.fft,configs.fftPercent,configs.fftRunup,configs.fftPercentRunup))
} }
arr = await Promise.all(arr) arr = await Promise.all(arr)
......
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