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
8028eb6f
Commit
8028eb6f
authored
Mar 13, 2022
by
Ahmad Nemati
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
init
parent
751ef51d
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
76 additions
and
0 deletions
+76
-0
ai.js
ai.js
+10
-0
run.js
run.js
+22
-0
test_file.js
test_file.js
+44
-0
No files found.
ai.js
View file @
8028eb6f
...
@@ -176,6 +176,8 @@ function run(data, config, risk, pfTrade, riskFreeLevel, detail, loss, durs, max
...
@@ -176,6 +176,8 @@ function run(data, config, risk, pfTrade, riskFreeLevel, detail, loss, durs, max
if
(
endDays
>
maxDays
)
if
(
endDays
>
maxDays
)
maxDays
=
endDays
maxDays
=
endDays
listDays
.
push
(
endDays
)
listDays
.
push
(
endDays
)
realProfit
=
realProfit
+
d
.
realProfit
realProfit
=
realProfit
+
d
.
realProfit
targets
.
push
(
d
.
realProfit
)
targets
.
push
(
d
.
realProfit
)
...
@@ -563,6 +565,14 @@ function getNewMinDiff(s, c) {
...
@@ -563,6 +565,14 @@ function getNewMinDiff(s, c) {
}
}
function
getTargetPrice
(
side
,
money
,
targetMoney
,
basePrice
)
{
let
diffMoney
=
calPer
(
money
,
targetMoney
)
if
(
side
===
'
LONG
'
)
return
percentageAdv
(
basePrice
,
diffMoney
)
else
return
percentageAdv
(
basePrice
,
(
-
1
*
diffMoney
))
}
module
.
exports
=
module
.
exports
=
{
{
...
...
run.js
View file @
8028eb6f
...
@@ -5,6 +5,7 @@ let directory
...
@@ -5,6 +5,7 @@ let directory
let
configFileName
let
configFileName
let
csvFile
let
csvFile
let
checks
=
[]
let
checks
=
[]
let
candles
let
drawDown
=
[
30
,
40
,
50
]
let
drawDown
=
[
30
,
40
,
50
]
//const perf = require('execution-time')();
//const perf = require('execution-time')();
run
()
run
()
...
@@ -16,6 +17,23 @@ async function run() {
...
@@ -16,6 +17,23 @@ async function run() {
checks
=
args
[
2
]
checks
=
args
[
2
]
await
makeStatus
(
directory
,
'
1
'
)
await
makeStatus
(
directory
,
'
1
'
)
// perf.start()
// perf.start()
candles
=
await
fs
.
readFileSync
(
'
./csv/coin.csv
'
,
'
utf8
'
)
// let end=candles.split('\n')
candles
=
candles
.
match
(
/.+/g
)
let
arr5
=
[]
for
(
let
i
=
1
;
i
<
candles
.
length
;
i
++
)
{
let
t
=
candles
[
i
].
split
(
'
,
'
)
arr5
.
push
({
t
:
parseFloat
(
t
[
0
]),
o
:
parseFloat
(
t
[
1
]),
h
:
parseFloat
(
t
[
2
]),
l
:
parseFloat
(
t
[
3
]),
c
:
parseFloat
(
t
[
4
])})
}
//candles=candles.replace('time,open,high,low,close','')
// candles=candles=candles.split('\n')
// await sleep(2000)
// console.log(arr5)
// await sleep(500)
// console.log(candles.length)
// console.log(candles.length)
let
configs
=
await
fs
.
readFileSync
(
'
./configs/
'
+
configFileName
,
'
utf8
'
)
let
configs
=
await
fs
.
readFileSync
(
'
./configs/
'
+
configFileName
,
'
utf8
'
)
checks
=
await
fs
.
readFileSync
(
'
./detail.json
'
,
'
utf8
'
)
checks
=
await
fs
.
readFileSync
(
'
./detail.json
'
,
'
utf8
'
)
configs
=
JSON
.
parse
(
configs
)
configs
=
JSON
.
parse
(
configs
)
...
@@ -356,5 +374,9 @@ function makeStatus(directory, status) {
...
@@ -356,5 +374,9 @@ function makeStatus(directory, status) {
});
});
}
}
async
function
sleep
(
millis
)
{
return
new
Promise
(
resolve
=>
setTimeout
(
resolve
,
millis
));
}
test_file.js
0 → 100644
View file @
8028eb6f
let
fs
=
require
(
'
fs
'
)
let
candles
reaD
()
async
function
reaD
()
{
candles
=
await
fs
.
readFileSync
(
'
./csv/coin.csv
'
,
'
utf8
'
)
// let end=candles.split('\n')
candles
=
candles
.
match
(
/.+/g
)
let
arr
=
[]
for
(
let
i
=
1
;
i
<
candles
.
length
;
i
++
)
{
let
t
=
candles
[
i
].
split
(
'
,
'
)
arr
.
push
({
t
:
parseFloat
(
t
[
0
]),
o
:
parseFloat
(
t
[
1
]),
h
:
parseFloat
(
t
[
2
]),
l
:
parseFloat
(
t
[
3
]),
c
:
parseFloat
(
t
[
4
])
})
}
candles
=
arr
grabData
(
1547635200
,
1547636700
)
//
}
function
grabData
(
start
,
end
)
{
let
arr
=
[]
let
indexStart
=
false
for
(
let
i
=
0
;
i
<
candles
.
length
;
i
++
)
{
if
(
indexStart
&&
candles
[
i
].
t
<=
end
)
arr
.
push
(
candles
[
i
])
else
if
(
candles
[
i
].
t
===
start
)
{
indexStart
=
true
arr
.
push
(
candles
[
i
])
}
}
console
.
log
(
arr
)
}
\ No newline at end of file
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