Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
A
ai
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Administrator
ai
Commits
85c1807b
Commit
85c1807b
authored
Jun 16, 2022
by
Ahmad Nemati
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
git pull
parent
3cf8cadb
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
47 additions
and
80 deletions
+47
-80
torobche.js
torobche.js
+47
-80
No files found.
torobche.js
View file @
85c1807b
...
...
@@ -5,7 +5,7 @@ const uuid = require('uniqid')
let
pair
=
'
BNB
'
let
res
let
arr
=
[]
let
balance
=
10000
let
balance
=
10000
init
()
//profitLossString
...
...
@@ -19,27 +19,28 @@ 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
,
startDate
:
arr
[
j
].
date
,
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
})
}
...
...
@@ -47,86 +48,62 @@ async function init() {
}
arrNew
=
_
.
orderBy
(
arrNew
,
[
'
sum
'
])
// 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
=
[]
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
arrNew
=
[]
for
(
let
i
=
index
;
i
<
index
+
1
;
i
++
)
{
let
sums
=
0
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
)
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
[
i
].
date
})
}
let
t
=
''
for
(
let
i
=
0
;
i
<
arrNew
.
length
;
i
++
)
{
let
det
=
get
(
arrNew
[
i
].
date
)
arrNew
.
push
({
sum
:
sums
,
index
:
i
,
date
:
arr
[
j
].
date
})
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
'
}
}
createRunResfileADV
(
t
)
for
(
let
i
=
0
;
i
<
arrNew
.
length
;
i
++
)
{
let
det
=
get
(
arrNew
[
i
].
date
)
if
(
worth
===
arrNew
[
i
].
sum
)
console
.
log
(
'
Worth* ->
'
,
arrNew
[
i
].
date
,
'
Profits->
'
,
arrNew
[
i
].
sum
,
'
Count->
'
,
det
.
count
,
'
Longs->
'
,
det
.
longCount
,
'
Long Profit->
'
,
det
.
longProfit
,
'
Shorts->
'
,
det
.
shortCount
,
'
Short Profit=>
'
,
det
.
shortProfit
)
else
console
.
log
(
arrNew
[
i
].
date
,
'
Profits->
'
,
arrNew
[
i
].
sum
,
'
Count->
'
,
det
.
count
,
'
Longs->
'
,
det
.
longCount
,
'
Long Profit->
'
,
det
.
longProfit
,
'
Shorts->
'
,
det
.
shortCount
,
'
Short Profit=>
'
,
det
.
shortProfit
)
}
// 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
})
}
...
...
@@ -137,15 +114,5 @@ function get(date) {
}
}
function
createRunResfileADV
(
data
)
{
// console.log(data)
return
new
Promise
(
function
(
resolve
,
reject
)
{
fs
.
writeFile
(
'
worth.txt
'
,
data
,
'
utf8
'
,
function
(
err
)
{
if
(
err
)
reject
(
err
);
else
resolve
(
data
);
});
});
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment