Commit 7dc79602 authored by Ahmad Nemati's avatar Ahmad Nemati

init

parent c8ab29f0
......@@ -22,15 +22,16 @@ function run(data, config, risk, pfTrade, riskFreeLevel) {
let lastCom = 0
let lastMoney = 0
let levels = []
let dur = getMinDiff(data[0].openDate, data[data.length - 1].closeDate)
// try {
// dur
// }
// catch (e)
// {
// fs.appendFileSync('error.txt', JSON.stringify(data)+'\n');
//
// }
let dur
try {
dur =getMinDiff(data[0].openDate, data[data.length - 1].closeDate)
}
catch (e)
{
return null
}
let newP = dur / data.length
// console.log(data.length)
......
......@@ -39,7 +39,9 @@ function initData(data, config, name, risk, pfTrade, side, riskFreeLevel) {
let arr = []
if (t.includes('Open_Time')) {
data = _.sortBy(data, function(o) { return new moment(o.Open_Time, 'YYYY.MM.DD HH:mm:ss').format('YYYY-MM-DD HH:mm:ss') });
data = _.sortBy(data, function (o) {
return new moment(o.Open_Time, 'YYYY.MM.DD HH:mm:ss').format('YYYY-MM-DD HH:mm:ss')
});
for (let i = 0; i < data.length; i++) {
if (data.length - 1 === i)
continue
......@@ -109,10 +111,11 @@ function initData(data, config, name, risk, pfTrade, side, riskFreeLevel) {
// console.log(arr)
let cz = []
for (let i = 0; i < config.length; i++) {
cz.push(ai.run(arr, config[i], risk, pfTrade, riskFreeLevel))
let d = ai.run(arr, config[i], risk, pfTrade, riskFreeLevel)
if (d !== null)
cz.push(d)
}
return cz
......
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