Commit da74cddc authored by Ahmad Nemati's avatar Ahmad Nemati

git pull

parent 922ad2c9
...@@ -17,8 +17,9 @@ async function init() { ...@@ -17,8 +17,9 @@ async function init() {
for (let i = 0; i < 100; i++) { for (let i = 0; i < 100; i++) {
let closeDate = com[i].closeDate.split('_') let closeDate = com[i].closeDate.split('_')
let profits = com[i].profitLossString.split('_') let profits = com[i].profitLossString.split('_')
let side = com[i].sideString.split('_')
for (let j = 0; j < closeDate.length - 1; j++) for (let j = 0; j < closeDate.length - 1; j++)
add(closeDate[j], parseFloat(profits[j])-0.1) add(closeDate[j], parseFloat(profits[j])-0.1,side[j])
} }
...@@ -48,18 +49,26 @@ let arrNew=[] ...@@ -48,18 +49,26 @@ let arrNew=[]
arrNew = _.orderBy(arrNew, ['sum']) arrNew = _.orderBy(arrNew, ['sum'])
console.log(arr) console.log(arr)
console.log('Balance ->',balance) console.log('Balance ->',balance)
console.log('Max reserve ->',arrNew[0].sum,'date ->',arrNew[0].date) console.log('Worth ->',arrNew[0])
} }
function add(date, profit) { function add(date, profit,side) {
for (let i = 0; i < arr.length; i++) for (let i = 0; i < arr.length; i++)
if (arr[i].date === date) { if (arr[i].date === date) {
arr[i].profit = arr[i].profit + profit arr[i].profit = arr[i].profit + profit
if ( side ==='LONG')
arr[i].longCount++
else
arr[i].shortCount++
return return
} }
arr.push({date: date, profit: profit}) if ( side ==='LONG')
arr.push({date: date, profit: profit,count:1,longCount:1,shortCount:0})
else
arr.push({date: date, profit: profit,count:1,longCount:1,shortCount:1})
} }
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