Commit d2e33544 authored by Ahmad Nemati's avatar Ahmad Nemati

init

parent 6072241f
......@@ -39,7 +39,7 @@ function run(data, config, risk, pfTrade, riskFreeLevel, detail, loss, durs,maxT
let dur
try {
dur = getMinDiff(data[0].openDate, data[data.length - 1].closeDate)
dur = getNewMinDiff(data[0].openDate, data[data.length - 1].closeDate)
} catch (e) {
return null
......@@ -454,12 +454,12 @@ function getMinDiff(start, closed) {
}
function getNewMinDiff(start, closed) {
//2019-05-25T05:34:27+04:30
var now = moment(closed);
var end = moment.duration(now.diff(moment(start)));
// console.log(parseInt(end.asDays()))
return parseInt(end.asDays())
function getNewMinDiff(s, c) {
const diffInMs = new Date(c) - new Date(s)
return diffInMs / (1000 * 60 * 60 * 24);
}
......
const fs = require('fs');
let moment=require('moment-timezone')
tesT()
let closeTime=1611750600000
let openTime=1611304200000
function tesT()
{
const startDate = '2021-01-22 12:00:00';
const endDate = '2021-01-26 12:00:00';
fs.appendFileSync('error.txt', 'test new line\n');
\ No newline at end of file
const diffInMs = new Date(endDate) - new Date(startDate)
const diffInDays = diffInMs / (1000 * 60 * 60 * 24);
console.log(diffInDays)
}
//fs.appendFileSync('error.txt', 'test new line\n');
\ No newline at end of file
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