Commit a6dde5c3 authored by Ahmad Nemati's avatar Ahmad Nemati

init

parent 2b6bad13
......@@ -11,8 +11,8 @@ let candles = []
let timeFrame = 0
function run(data, config, risk, pfTrade, riskFreeLevel, detail, loss, durs, maxTradeDays, targetPercentage, candlesData,fft) {
let type = config.type + ' param:' + config.param + ' base:' + config.base + ' target:' + config.target + ' targetPercentage:' + targetPercentage.enable + ' fft:' + fft
function run(data, config, risk, pfTrade, riskFreeLevel, detail, loss, durs, maxTradeDays, targetPercentage, candlesData,fft,fftPercent) {
let type = config.type + ' param:' + config.param + ' base:' + config.base + ' target:' + config.target + ' targetPercentage:' + targetPercentage.enable + ' fft:' + fft + ' fftPercent:' + fftPercent
let saveData = []
candles = candlesData
timeFrame = candles[1].t - candles[0].t
......@@ -52,6 +52,7 @@ function run(data, config, risk, pfTrade, riskFreeLevel, detail, loss, durs, max
let durDetail = []
let runBefore=false
let countDrop=0
let allLossProfit=0
let dur
try {
......@@ -75,14 +76,20 @@ function run(data, config, risk, pfTrade, riskFreeLevel, detail, loss, durs, max
return null
if (data[i].profit <0)
if (data[i].profit <0) {
allLossProfit=allLossProfit+data[i].profit
countDrop++
else
countDrop=0
}
else {
allLossProfit=0
countDrop = 0
}
if (runBefore ===false)
{
if (countDrop <fft)
// if (countDrop <fft)
// continue
if (allLossProfit> fftPercent)
continue
}
runBefore=true
......
......@@ -36,6 +36,7 @@ async function format(name) {
let list=[]
let pluser=0
let allProfit=0
let con=0
for (let i = 1; i <(res.length-1); i ++) {
let d=res[i].split(',')
try {
......@@ -44,6 +45,7 @@ let d=res[i].split(',')
{
allProfit=allProfit+profit
pluser++
con++
}
else
{
......@@ -72,7 +74,8 @@ let d=res[i].split(',')
arr.push({number:arr2[i],count:counter})
}
console.log('Avg Profit:'+(allProfit/list.length))
console.log('Count Profit<0:'+con , 'Sum profit<0:'+allProfit,'Avg Profit:'+(allProfit/con))
console.log(arr)
// arr= await Promise.all(arr)
// //console.log(arr)
......
......@@ -6,7 +6,7 @@ let moment = require('moment-timezone')
let ai = require('./ai')
async function parse(directory, name, configs, risk, pfTrade, side, riskFreeLevel,detail,onlyShortLong,loss,dur,maxTradeDays,targetPercentage,candles,fft) {
async function parse(directory, name, configs, risk, pfTrade, side, riskFreeLevel,detail,onlyShortLong,loss,dur,maxTradeDays,targetPercentage,candles,fft,fftPercent) {
return new Promise(function (resolve, reject) {
let arr = []
......@@ -15,12 +15,12 @@ async function parse(directory, name, configs, risk, pfTrade, side, riskFreeLeve
.pipe(csv.parse({headers: true}))
.on('error', error => reject(error))
.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)));
.on('end', rowCount => resolve(initData(arr, configs, 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) {
function initData(data, config, name, risk, pfTrade, side, riskFreeLevel,detail,onlyShortLong,loss,dur,maxTradeDays,targetPercentage,candles,fft,fftPercent) {
data = JSON.stringify(data)
......@@ -140,7 +140,7 @@ function initData(data, config, name, risk, pfTrade, side, riskFreeLevel,detail,
let cz = []
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)
let d = ai.run(arr, config[i], risk, pfTrade, riskFreeLevel,detail,loss,dur,maxTradeDays,targetPercentage,candles,fft,fftPercent)
if (d !== null)
cz.push(d)
}
......
......@@ -20,7 +20,7 @@ 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}
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 detail=['configs2.json-211021092159_O1_BNC_BTCUSD_Lp1_Y211020a - Copy_Mn.csv&zarib param:1.1 base:200 target:1']
obj.detail=detail
let all=[]
......
......@@ -44,7 +44,7 @@ async function run() {
for (let i = 0; i < files.length; i++)
if (files[i].includes('.csv')) {
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))
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 = 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