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
8587bc21
Commit
8587bc21
authored
Jun 19, 2022
by
Ahmad Nemati
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
git pull
parent
3b03a34c
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
151 additions
and
85 deletions
+151
-85
bad.txt
bad.txt
+1
-1
test_json.js
test_json.js
+2
-2
tor.js
tor.js
+7
-6
torobche.js
torobche.js
+141
-76
No files found.
bad.txt
View file @
8587bc21
{"bad":2}
\ No newline at end of file
{"maxReserve":-12.310000000000004,"profit":2404.2,"bad":-195.30463038180332}
\ No newline at end of file
test_json.js
View file @
8587bc21
...
...
@@ -71,9 +71,9 @@ let fs = require('fs')
// let arr=[]
// arr.push(t)
// arr.push(t)
// console.log(JSON.stringify(arr
))
console
.
log
(
JSON
.
stringify
({
bad
:
1
}
))
test
()
//
test()
async
function
test
()
{
let
las
=
await
fs
.
readFileSync
(
'
t.json
'
,
'
utf8
'
);
...
...
tor.js
View file @
8587bc21
...
...
@@ -65,7 +65,7 @@ async function lastCheck(param1,param2,param3,arr5) {
if
(
param3
<
base
)
{
let
z
=
{
maxReserve
:
param1
,
profit
:
param2
,
bad
:
param3
}
await
createfileADV
(
JSON
.
stringify
(
z
))
//
await createfileADV(JSON.stringify(z))
await
createfileTorob
(
param3
.
toString
(),
JSON
.
stringify
(
arr5
,
null
,
2
))
}
...
...
@@ -89,9 +89,9 @@ async function run()
balance
=
lastBalance
arr
=
[]
for
(
let
i
=
0
;
i
<
size
;
i
++
)
{
let
closeDate
=
com
[
i
].
c
.
split
(
'
_
'
)
let
profits
=
com
[
i
].
p
.
split
(
'
_
'
)
let
side
=
com
[
i
].
s
.
split
(
'
_
'
)
let
closeDate
=
com
[
i
].
c
loseDate
.
split
(
'
_
'
)
let
profits
=
com
[
i
].
p
rofitLossString
.
split
(
'
_
'
)
let
side
=
com
[
i
].
s
ideString
.
split
(
'
_
'
)
for
(
let
j
=
0
;
j
<
closeDate
.
length
-
1
;
j
++
)
add
(
closeDate
[
j
],
parseFloat
(
profits
[
j
])
-
0.1
,
side
[
j
])
...
...
@@ -130,6 +130,7 @@ async function run()
// dates=_.orderBy(dates,['profit'])
let
arrDate
=
[]
// console.log(dates)
for
(
let
i
=
0
;
i
<
dates
.
length
;
i
++
)
{
let
sums
=
0
for
(
let
j
=
i
+
1
;
j
<
dates
.
length
;
j
++
)
{
...
...
@@ -176,7 +177,7 @@ async function run()
balance
=
balance
+
arr2
[
i
].
profit
arr2
[
i
].
balance
=
balance
}
createfileADV
(
JSON
.
stringify
(
arr2
,
null
,
2
))
//
createfileADV(JSON.stringify(arr2, null, 2))
let
index
=
arrNew
[
0
].
index
arrNew
=
[]
...
...
@@ -205,7 +206,7 @@ function add(date, profit,side) {
arr
[
i
].
profit
=
arr
[
i
].
profit
+
profit
arr
[
i
].
count
++
if
(
side
===
'
L
'
)
{
if
(
side
===
'
L
ONG
'
)
{
arr
[
i
].
longCount
++
arr
[
i
].
longProfit
=
arr
[
i
].
longProfit
+
profit
}
...
...
torobche.js
View file @
8587bc21
...
...
@@ -5,128 +5,160 @@ const uuid = require('uniqid')
let
pair
=
'
BNB
'
let
res
let
arr
=
[]
let
lastBalance
=
5000
let
size
=
50
let
balance
=
lastBalance
let
lastBalance
=
5000
let
size
=
50
let
balance
=
lastBalance
init
()
let
base
=
1
let
base
=
1
let
com
//profitLossString
//drawDownString
let
year
=
[
'
2017
'
,
'
2018
'
,
'
2019
'
,
'
2020
'
,
'
2021
'
,
'
2022
'
]
let
month
=
[
'
01
'
,
'
02
'
,
'
03
'
,
'
04
'
,
'
05
'
,
'
06
'
,
'
07
'
,
'
08
'
,
'
09
'
,
'
10
'
,
'
11
'
,
'
12
'
]
let
dates
=
[]
async
function
init
()
{
try
{
await
fs
.
mkdirSync
(
'
torob
'
)
}
catch
(
e
)
{
}
catch
(
e
)
{
}
com
=
await
fs
.
readFileSync
(
'
t.json
'
,
'
utf8
'
);
let
bad
=
await
fs
.
readFileSync
(
'
bad.txt
'
,
'
utf8
'
);
bad
=
JSON
.
parse
(
bad
)
com
=
await
fs
.
readFileSync
(
'
t.json
'
,
'
utf8
'
);
let
bad
=
await
fs
.
readFileSync
(
'
bad.txt
'
,
'
utf8
'
);
bad
=
JSON
.
parse
(
bad
)
base
=
parseFloat
(
bad
.
bad
)
console
.
log
(
bad
)
base
=
parseFloat
(
bad
.
bad
)
//
console.log(bad)
com
=
JSON
.
parse
(
com
)
run
()
run
()
}
async
function
lastCheck
(
param1
,
param2
,
param3
,
arr5
)
{
let
bad
=
await
fs
.
readFileSync
(
'
bad.txt
'
,
'
utf8
'
);
bad
=
JSON
.
parse
(
bad
)
base
=
parseFloat
(
bad
.
bad
)
async
function
lastCheck
(
param1
,
param2
,
param3
,
arr5
)
{
let
bad
=
await
fs
.
readFileSync
(
'
bad.txt
'
,
'
utf8
'
);
bad
=
JSON
.
parse
(
bad
)
base
=
parseFloat
(
bad
.
bad
)
if
(
param3
<
base
)
{
let
z
=
{
maxReserve
:
param1
,
profit
:
param2
,
bad
:
param3
}
if
(
param3
<
base
)
{
let
z
=
{
maxReserve
:
param1
,
profit
:
param2
,
bad
:
param3
}
await
createfileADV
(
JSON
.
stringify
(
z
))
await
createfileTorob
(
param3
.
toString
(),
JSON
.
stringify
(
arr5
,
null
,
2
))
await
createfileTorob
(
param3
.
toString
(),
JSON
.
stringify
(
arr5
,
null
,
2
))
}
}
function
resetDates
()
{
dates
=
[]
for
(
let
i
=
0
;
i
<
year
.
length
;
i
++
)
{
for
(
let
j
=
0
;
j
<
month
.
length
;
j
++
)
{
let
t
=
year
[
i
]
+
'
-
'
+
month
[
j
]
if
(
!
(
t
===
'
2017-01
'
||
t
===
'
2017-02
'
||
t
===
'
2017-03
'
||
t
===
'
2017-04
'
||
t
===
'
2017-05
'
||
t
===
'
2017-06
'
||
t
===
'
2017-07
'
||
t
===
'
2022-05
'
||
t
===
'
2022-06
'
||
t
===
'
2022-07
'
||
t
===
'
2022-08
'
||
t
===
'
2022-09
'
||
t
===
'
2022-10
'
||
t
===
'
2022-11
'
||
t
===
'
2022-12
'
))
dates
.
push
({
date
:
t
,
profit
:
0
,
count
:
0
,
longCount
:
0
,
shortCount
:
0
,
longProfit
:
0
,
shortProfit
:
0
})
}
}
}
async
function
sleep
(
millis
)
{
return
new
Promise
(
resolve
=>
setTimeout
(
resolve
,
millis
));
}
async
function
run
()
{
com
=
_
.
shuffle
(
com
)
balance
=
lastBalance
arr
=
[]
async
function
run
()
{
com
=
_
.
shuffle
(
com
)
balance
=
lastBalance
arr
=
[]
resetDates
()
for
(
let
i
=
0
;
i
<
size
;
i
++
)
{
let
closeDate
=
com
[
i
].
c
.
split
(
'
_
'
)
let
profits
=
com
[
i
].
p
.
split
(
'
_
'
)
let
side
=
com
[
i
].
s
.
split
(
'
_
'
)
let
closeDate
=
com
[
i
].
c
loseDate
.
split
(
'
_
'
)
let
profits
=
com
[
i
].
p
rofitLossString
.
split
(
'
_
'
)
let
side
=
com
[
i
].
s
ideString
.
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
[
i
+
1
].
date
,
date
:
arr
[
j
].
date
})
else
if
(
arrNew
[
arrNew
.
length
-
1
].
sum
>
sums
)
arrNew
.
push
({
sum
:
sums
,
index
:
i
,
startDate
:
arr
[
i
+
1
].
date
,
date
:
arr
[
j
].
date
})
if
(
arrNew
.
length
===
0
)
arrNew
.
push
({
sum
:
sums
,
index
:
i
,
startDate
:
arr
[
i
+
1
].
date
,
date
:
arr
[
j
].
date
})
else
if
(
arrNew
[
arrNew
.
length
-
1
].
sum
>
sums
)
arrNew
.
push
({
sum
:
sums
,
index
:
i
,
startDate
:
arr
[
i
+
1
].
date
,
date
:
arr
[
j
].
date
})
}
}
arrNew
=
_
.
orderBy
(
arrNew
,
[
'
sum
'
])
for
(
let
i
=
0
;
i
<
arr
.
length
;
i
++
)
addDate
(
arr
[
i
])
let
arrDate
=
[]
for
(
let
i
=
0
;
i
<
dates
.
length
;
i
++
)
{
let
sums
=
0
for
(
let
j
=
i
+
1
;
j
<
dates
.
length
;
j
++
)
{
sums
=
sums
+
parseFloat
(
dates
[
j
].
profit
)
if
(
arrDate
.
length
===
0
)
arrDate
.
push
({
sum
:
sums
,
index
:
i
,
startDate
:
dates
[
i
+
1
].
date
,
date
:
dates
[
j
].
date
})
else
if
(
arrDate
[
arrDate
.
length
-
1
].
sum
>
sums
)
arrDate
.
push
({
sum
:
sums
,
index
:
i
,
startDate
:
dates
[
i
+
1
].
date
,
date
:
dates
[
j
].
date
})
}
}
arrDate
=
_
.
orderBy
(
arrDate
,
[
'
sum
'
])
balance
=
lastBalance
for
(
let
i
=
0
;
i
<
dates
.
length
;
i
++
)
{
balance
=
balance
+
dates
[
i
].
profit
dates
[
i
].
balance
=
balance
}
// console.log(arr)
// console.log('Balance ->',balance)
// console.log('Worth ->',arrNew[0])
// console.log('Balance ->',balance)
// console.log('Worth ->',arrNew[0])
let
worth
=
(
balance
-
lastBalance
)
/
(
arrNew
[
0
].
sum
)
if
(
worth
<
base
)
{
base
=
worth
console
.
log
(
arrNew
[
0
].
sum
,
balance
-
lastBalance
,
worth
)
let
arr5
=
[]
for
(
let
f
=
0
;
f
<
size
;
f
++
)
{
arr5
.
push
(
com
[
f
])
let
worth
=
(
balance
-
lastBalance
)
/
(
arrDate
[
0
].
sum
)
if
(
worth
<
base
)
{
base
=
worth
console
.
log
(
arrDate
[
0
].
sum
,
balance
-
lastBalance
,
worth
)
let
arr5
=
[]
for
(
let
f
=
0
;
f
<
size
;
f
++
)
{
arr5
.
push
(
com
[
f
])
}
// let z={maxReserve:arrNew[0].sum,balance:balance,bad:base}
//
// await createfileADV(JSON.stringify(z))
await
lastCheck
(
arrDate
[
0
].
sum
,
balance
-
lastBalance
,
base
,
arr5
)
}
// let z={maxReserve:arrNew[0].sum,balance:balance,bad:base}
//
// await createfileADV(JSON.stringify(z))
await
lastCheck
(
arrNew
[
0
].
sum
,
balance
-
lastBalance
,
base
,
arr5
)
}
// let start=false
// let arr2=[]
// for (let i=0;i<arr.length;i++)
...
...
@@ -173,28 +205,62 @@ if (worth < base) {
return
run
()
}
function
addDate
(
data
)
{
for
(
let
i
=
0
;
i
<
dates
.
length
;
i
++
)
if
(
data
.
date
.
includes
(
dates
[
i
].
date
))
{
dates
[
i
].
profit
=
dates
[
i
].
profit
+
data
.
profit
function
add
(
date
,
profit
,
side
)
{
dates
[
i
].
count
=
dates
[
i
].
count
+
data
.
count
dates
[
i
].
longCount
=
dates
[
i
].
longCount
+
data
.
longCount
dates
[
i
].
longProfit
=
dates
[
i
].
longProfit
+
data
.
longProfit
dates
[
i
].
shortCount
=
dates
[
i
].
shortCount
+
data
.
shortCount
dates
[
i
].
shortProfit
=
dates
[
i
].
shortProfit
+
data
.
shortProfit
return
}
}
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
===
'
L
'
)
{
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
})
}
...
...
@@ -205,7 +271,6 @@ function get(date) {
}
}
function
createfileADV
(
data
)
{
...
...
@@ -218,10 +283,10 @@ function createfileADV(data) {
});
}
function
createfileTorob
(
name
,
data
)
{
function
createfileTorob
(
name
,
data
)
{
// console.log(data)
return
new
Promise
(
function
(
resolve
,
reject
)
{
fs
.
writeFile
(
'
torob/
'
+
name
+
'
.json
'
,
data
,
'
utf8
'
,
function
(
err
)
{
fs
.
writeFile
(
'
torob/
'
+
name
+
'
.json
'
,
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