Commit 0d69cb93 authored by Ahmad Nemati's avatar Ahmad Nemati

git pull

parent 18567aac
......@@ -5,7 +5,7 @@ const uuid = require('uniqid')
let pair = 'BNB'
let res
let arr = []
let balance =10000
let balance = 10000
init()
//profitLossString
......@@ -19,96 +19,114 @@ async function init() {
let profits = com[i].profitLossString.split('_')
let side = com[i].sideString.split('_')
for (let j = 0; j < closeDate.length - 1; j++)
add(closeDate[j], parseFloat(profits[j])-0.1,side[j])
add(closeDate[j], parseFloat(profits[j]) - 0.1, side[j])
}
arr=_.orderBy(arr,['date'])
arr = _.orderBy(arr, ['date'])
for (let i=0;i<arr.length;i++)
{
balance=balance+arr[i].profit
arr[i].balance=balance
for (let i = 0; i < arr.length; i++) {
balance = balance + arr[i].profit
arr[i].balance = balance
}
let arrNew=[]
let arrNew = []
for (let i = 0; i < arr.length; i++) {
let sums = 0
for (let j = i + 1; j < arr.length ; j++) {
for (let j = i + 1; j < arr.length; j++) {
sums = sums + parseFloat(arr[j].profit)
if (arrNew.length ===0)
arrNew.push({sum: sums, index: i,date:arr[j].date})
else if (arrNew[arrNew.length-1].sum > sums)
arrNew.push({sum: sums, index: i,date:arr[j].date})
if (arrNew.length === 0)
arrNew.push({sum: sums, index: i, date: arr[j].date})
else if (arrNew[arrNew.length - 1].sum > sums)
arrNew.push({sum: sums, index: i, date: arr[j].date})
}
}
arrNew = _.orderBy(arrNew, ['sum'])
// console.log(arr)
console.log('Balance ->',balance)
console.log('Worth ->',arrNew[0])
let worth=arrNew[0].sum
console.log('Detail ->',get(arrNew[0].date))
let index=arrNew[0].index
console.log('index',index)
arrNew=[]
// console.log(arr)
console.log('Balance ->', balance)
console.log('Worth ->', arrNew[0])
let worth = arrNew[0].date
console.log('Detail ->', get(arrNew[0].date))
let index = arrNew[0].index
console.log('index', index)
arrNew = []
let sums = 0
for (let i = index; i < arr.length; i++) {
if (i ===index)
console.log(arr[i])
let start = false
for (let i = 0; i < arr.length; i++) {
if (arr[i].date === worth)
start = true
else {
if (!start)
continue
}
sums = sums + parseFloat(arr[i].profit)
// if (arrNew.length ===0)
// arrNew.push({sum: sums, index: i,date:arr[j].date})
// else if (arrNew[arrNew.length-1].sum > sums)
arrNew.push({sum: sums, index: i,date:arr[i].date})
arrNew.push({sum: sums, index: i, date: arr[i].date})
}
let t=''
for (let i=0;i<arrNew.length;i++)
{
let det=get(arrNew[i].date)
let t = ''
for (let i = 0; i < arrNew.length; i++) {
let det = get(arrNew[i].date)
if (worth ===arrNew[i].sum)
t='****Worth**** ->'
if (worth === arrNew[i].sum)
t = '****Worth**** ->'
t=t+arrNew[i].date
t=t+' '+' Profits-> '+arrNew[i].sum +' Count-> '+det.count +' Longs-> '+det.longCount+' Long Profit-> '+det.longProfit+' Shorts-> '+det.shortCount+' Short Profit=> '+det.shortProfit+'\n'
t = t + arrNew[i].date
t = t + ' ' + ' Profits-> ' + arrNew[i].sum + ' Count-> ' + det.count + ' Longs-> ' + det.longCount + ' Long Profit-> ' + det.longProfit + ' Shorts-> ' + det.shortCount + ' Short Profit=> ' + det.shortProfit + '\n'
}
createRunResfileADV(t)
// console.log(arrNew)
// console.log(arrNew)
}
function add(date, profit,side) {
function add(date, profit, side) {
for (let i = 0; i < arr.length; i++)
if (arr[i].date === date) {
arr[i].profit = arr[i].profit + profit
arr[i].count++
if ( side ==='LONG') {
if (side === 'LONG') {
arr[i].longCount++
arr[i].longProfit= arr[i].longProfit+profit
}
else {
arr[i].longProfit = arr[i].longProfit + profit
} else {
arr[i].shortCount++
arr[i].shortProfit= arr[i].shortProfit+profit
arr[i].shortProfit = arr[i].shortProfit + profit
}
return
}
if ( side ==='LONG')
arr.push({date: date, profit: profit,count:1,longCount:1,shortCount:0,longProfit:profit,shortProfit:0})
if (side === 'LONG')
arr.push({
date: date,
profit: profit,
count: 1,
longCount: 1,
shortCount: 0,
longProfit: profit,
shortProfit: 0
})
else
arr.push({date: date, profit: profit,count:1,longCount:1,shortCount:1,longProfit:0,shortProfit:profit})
arr.push({
date: date,
profit: profit,
count: 1,
longCount: 1,
shortCount: 1,
longProfit: 0,
shortProfit: profit
})
}
......@@ -119,7 +137,6 @@ function get(date) {
}
}
......
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