Commit 25c75559 authored by Ahmad Nemati's avatar Ahmad Nemati

git pu

parent fb3b3a22
let t='dynamic param:48.0 base:200 target:1 targetPercentage:true fft 1' let _=require('lodash')
let arr=[2,3,5,1,2,2]
console.log(_.orderBy(arr))
console.log(t.split('targetPercentage:true')) \ No newline at end of file
\ No newline at end of file
...@@ -43,6 +43,7 @@ async function run() { ...@@ -43,6 +43,7 @@ async function run() {
add(config[j].total, arrDate, config[j].type.split('targetPercentage:false')[1]) add(config[j].total, arrDate, config[j].type.split('targetPercentage:false')[1])
addShortLong(config[j].total, countOfshort, countOfLong) addShortLong(config[j].total, countOfshort, countOfLong)
addPoftrade(config[j].total,config[j].pftrade)
} }
...@@ -77,6 +78,15 @@ async function run() { ...@@ -77,6 +78,15 @@ async function run() {
} }
} }
for (let i = 0; i < adder.length; i++) {
for (let z = i + 1; z < adder.length; z++) {
let pfTrade = adder[z].pfTrade
for (let l = 0; l < pfTrade.length; l++)
addPoftrade(adder[i].total, pfTrade[l])
}
}
var endTime = performance.now() var endTime = performance.now()
console.log(`Call to doSomething took ${endTime - startTime} milliseconds`) console.log(`Call to doSomething took ${endTime - startTime} milliseconds`)
...@@ -89,6 +99,24 @@ async function run() { ...@@ -89,6 +99,24 @@ async function run() {
for (let i = 0; i < adder.length; i++) { for (let i = 0; i < adder.length; i++) {
adder[i].type = _.uniq(adder[i].type) adder[i].type = _.uniq(adder[i].type)
adder[i].type = _.orderBy(adder[i].type) adder[i].type = _.orderBy(adder[i].type)
adder[i].pfTrade = _.orderBy(adder[i].pfTrade)
}
for (let i = 0; i < adder.length; i++) {
let dates = adder[i].dates
let maxDiff = 0
for (let z = 0; z < dates.length - 1; z++) {
let diff = getDaysDiff(dates[z], dates[z + 1])
if (diff > maxDiff)
maxDiff = diff
}
adder[i].diffDay = maxDiff
} }
for (let i = 0; i < adder.length; i++) { for (let i = 0; i < adder.length; i++) {
...@@ -133,7 +161,7 @@ function add(total, dates, type) { ...@@ -133,7 +161,7 @@ function add(total, dates, type) {
if (found) if (found)
return return
adder.push({total: total, dates: dates, countDay: dates.length, type: [type]}) adder.push({total: total, dates: dates, countDay: dates.length, type: [type],pfTrade:[]})
} }
...@@ -147,6 +175,15 @@ function addShortLong(total, short, long) { ...@@ -147,6 +175,15 @@ function addShortLong(total, short, long) {
} }
} }
function addPoftrade(total, pfTrade) {
for (let i = 0; i < adder.length; i++)
if (adder[i].total === total) {
adder[i].pfTrade.push(pfTrade)
}
}
function getDaysDiff(start, closed) { function getDaysDiff(start, closed) {
//2019-05-25T05:34:27+04:30 //2019-05-25T05:34:27+04:30
var now = moment(moment(closed, 'YYYY-MM-DD').format()); var now = moment(moment(closed, 'YYYY-MM-DD').format());
......
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