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
09eb35b8
Commit
09eb35b8
authored
Apr 16, 2022
by
Ahmad Nemati
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
git pu
parent
328ab225
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
43 additions
and
38 deletions
+43
-38
uniq2.js
uniq2.js
+43
-38
No files found.
uniq2.js
View file @
09eb35b8
...
...
@@ -4,13 +4,13 @@ let moment = require('moment-timezone')
run
()
let
adder
=
[]
let
root
=
''
let
root
=
''
async
function
run
()
{
let
configs
=
await
fs
.
readdirSync
(
'
last1000/
'
)
root
=
configs
[
0
]
configs
=
await
fs
.
readdirSync
(
'
last1000/
'
+
root
+
'
/
'
)
root
=
configs
[
0
]
configs
=
await
fs
.
readdirSync
(
'
last1000/
'
+
root
+
'
/
'
)
let
arr
=
[]
let
arrSide
=
[]
...
...
@@ -22,7 +22,7 @@ async function run() {
for
(
let
i
=
0
;
i
<
configs
.
length
;
i
++
)
{
let
config
=
await
fs
.
readFileSync
(
'
./last1000/
'
+
root
+
'
/
'
+
configs
[
i
]
+
'
/default/compound1000.json
'
,
'
utf8
'
)
let
config
=
await
fs
.
readFileSync
(
'
./last1000/
'
+
root
+
'
/
'
+
configs
[
i
]
+
'
/default/compound1000.json
'
,
'
utf8
'
)
config
=
JSON
.
parse
(
config
)
...
...
@@ -30,7 +30,7 @@ async function run() {
total
.
push
(
config
[
j
].
total
)
let
dateString
=
config
[
j
].
dateString
.
split
(
'
_
'
)
let
runUpString
=
config
[
j
].
runupString
.
split
(
'
_
'
)
let
platfrom
=
config
[
j
].
platform
.
split
(
'
-
'
)[
1
]
let
platfrom
=
config
[
j
].
platform
.
split
(
'
-
'
)[
1
]
let
arrDate
=
[]
for
(
let
z
=
0
;
z
<
dateString
.
length
-
2
;
z
++
)
...
...
@@ -43,21 +43,20 @@ async function run() {
countOfLong
++
else
countOfshort
++
let
arrRunup
=
[]
let
arrRunup
=
[]
for
(
let
z
=
0
;
z
<
runUpString
.
length
-
2
;
z
++
)
arrRunup
.
push
(
parseFloat
(
runUpString
[
z
]))
// console.log(arrRunup)
arrRunup
=
_
.
orderBy
(
arrRunup
)
// console.log(arrRunup)
arrRunup
=
_
.
orderBy
(
arrRunup
)
add
(
config
[
j
].
total
,
arrDate
,
config
[
j
].
type
.
split
(
'
targetPercentage:false
'
)[
1
])
addShortLong
(
config
[
j
].
total
,
countOfshort
,
countOfLong
)
addPoftrade
(
config
[
j
].
total
,
config
[
j
].
pftrade
)
addRunup
(
config
[
j
].
total
,
arrRunup
[
0
],
arrRunup
[
arrRunup
.
length
-
1
])
addPlatform
(
config
[
j
].
total
,
platfrom
)
addRunup
(
config
[
j
].
total
,
arrRunup
[
0
],
arrRunup
[
arrRunup
.
length
-
1
])
addPlatform
(
config
[
j
].
total
,
platfrom
)
}
...
...
@@ -76,7 +75,7 @@ async function run() {
for
(
let
i
=
0
;
i
<
adder
.
length
;
i
++
)
{
for
(
let
z
=
i
+
1
;
z
<
adder
.
length
;
z
++
)
{
addRunup
(
adder
[
i
].
total
,
adder
[
z
].
minRunup
,
adder
[
z
].
maxRunup
)
addRunup
(
adder
[
i
].
total
,
adder
[
z
].
minRunup
,
adder
[
z
].
maxRunup
)
}
}
...
...
@@ -119,8 +118,6 @@ async function run() {
}
for
(
let
i
=
0
;
i
<
adder
.
length
;
i
++
)
{
adder
[
i
].
dates
=
_
.
uniq
(
adder
[
i
].
dates
)
adder
[
i
].
dates
=
_
.
orderBy
(
adder
[
i
].
dates
)
...
...
@@ -129,29 +126,27 @@ async function run() {
for
(
let
i
=
0
;
i
<
adder
.
length
;
i
++
)
{
adder
[
i
].
type
=
_
.
uniq
(
adder
[
i
].
type
)
adder
[
i
].
type
=
_
.
orderBy
(
adder
[
i
].
type
)
adder
[
i
].
countOfType
=
adder
[
i
].
type
.
length
adder
[
i
].
AllPlatfrom
=
adder
[
i
].
platfrom
adder
[
i
].
AllPlatfrom
=
_
.
uniq
(
adder
[
i
].
AllPlatfrom
)
adder
[
i
].
platfrom
=
adder
[
i
].
platfrom
.
replace
(
'
R
'
,
''
)
adder
[
i
].
countOfType
=
adder
[
i
].
type
.
length
adder
[
i
].
AllPlatfrom
=
adder
[
i
].
platfrom
adder
[
i
].
AllPlatfrom
=
_
.
uniq
(
adder
[
i
].
AllPlatfrom
)
for
(
let
n
=
0
;
n
<
adder
[
i
].
platfrom
.
length
;
n
++
)
adder
[
i
].
platfrom
[
n
]
=
adder
[
i
].
platfrom
[
n
].
replace
(
'
R
'
,
''
)
adder
[
i
].
platfrom
=
_
.
uniq
(
adder
[
i
].
platfrom
)
adder
[
i
].
countOfPlatform
=
adder
[
i
].
platfrom
.
length
// delete adder[i].platfrom
adder
[
i
].
countOfPlatform
=
adder
[
i
].
platfrom
.
length
// delete adder[i].platfrom
adder
[
i
].
pfTrade
=
_
.
orderBy
(
adder
[
i
].
pfTrade
)
let
temp
=
[]
let
temp
=
[]
temp
.
push
(
adder
[
i
].
pfTrade
[
0
])
temp
.
push
(
adder
[
i
].
pfTrade
[
adder
[
i
].
pfTrade
.
length
-
1
])
adder
[
i
].
pfTrade
=
temp
temp
.
push
(
adder
[
i
].
pfTrade
[
adder
[
i
].
pfTrade
.
length
-
1
])
adder
[
i
].
pfTrade
=
temp
// adder[i].runUp = _.orderBy(adder[i].runUp)
// adder[i].runUp = _.orderBy(adder[i].runUp)
}
for
(
let
i
=
0
;
i
<
adder
.
length
;
i
++
)
{
let
dates
=
adder
[
i
].
dates
let
maxDiff
=
0
...
...
@@ -181,8 +176,8 @@ async function run() {
}
createPlatfileADV
(
JSON
.
stringify
(
adder
,
null
,
2
))
for
(
let
i
=
0
;
i
<
adder
.
length
;
i
++
)
{
adder
[
i
].
platfrom
=
adder
[
i
].
platfrom
.
replace
(
'
R
'
,
''
)
delete
adder
[
i
].
platfrom
adder
[
i
].
platfrom
=
adder
[
i
].
platfrom
.
replace
(
'
R
'
,
''
)
delete
adder
[
i
].
platfrom
}
...
...
@@ -190,7 +185,6 @@ async function run() {
console
.
log
(
adder
)
createConfileADV
(
JSON
.
stringify
(
adder
,
null
,
2
))
...
...
@@ -216,7 +210,18 @@ function add(total, dates, type) {
if
(
found
)
return
adder
.
push
({
total
:
total
,
dates
:
dates
,
countDay
:
dates
.
length
,
type
:
[
type
],
pfTrade
:
[],
short
:
0
,
long
:
0
,
minRunup
:
100
,
maxRunup
:
0
,
platfrom
:[]})
adder
.
push
({
total
:
total
,
dates
:
dates
,
countDay
:
dates
.
length
,
type
:
[
type
],
pfTrade
:
[],
short
:
0
,
long
:
0
,
minRunup
:
100
,
maxRunup
:
0
,
platfrom
:
[]
})
}
...
...
@@ -225,8 +230,8 @@ function addShortLong(total, short, long) {
for
(
let
i
=
0
;
i
<
adder
.
length
;
i
++
)
if
(
adder
[
i
].
total
===
total
)
{
adder
[
i
].
short
=
adder
[
i
].
short
+
short
adder
[
i
].
long
=
adder
[
i
].
long
+
long
adder
[
i
].
short
=
adder
[
i
].
short
+
short
adder
[
i
].
long
=
adder
[
i
].
long
+
long
}
}
...
...
@@ -248,15 +253,15 @@ function addPlatform(total, platform) {
}
}
function
addRunup
(
total
,
minRunup
,
maxRunup
)
{
function
addRunup
(
total
,
minRunup
,
maxRunup
)
{
for
(
let
i
=
0
;
i
<
adder
.
length
;
i
++
)
if
(
adder
[
i
].
total
===
total
)
{
if
(
adder
[
i
].
minRunup
>
minRunup
)
adder
[
i
].
minRunup
=
minRunup
adder
[
i
].
minRunup
=
minRunup
if
(
maxRunup
>
adder
[
i
].
maxRunup
)
adder
[
i
].
maxRunup
=
maxRunup
if
(
maxRunup
>
adder
[
i
].
maxRunup
)
adder
[
i
].
maxRunup
=
maxRunup
}
...
...
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