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
ec35fdd4
Commit
ec35fdd4
authored
Mar 24, 2022
by
Ahmad Nemati
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
init
parent
61b777e3
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
21 additions
and
9 deletions
+21
-9
ai.js
ai.js
+9
-2
csv.js
csv.js
+4
-4
generate.js
generate.js
+1
-1
run.js
run.js
+1
-1
test_cal.js
test_cal.js
+6
-1
No files found.
ai.js
View file @
ec35fdd4
...
@@ -11,7 +11,7 @@ let candles = []
...
@@ -11,7 +11,7 @@ let candles = []
let
timeFrame
=
0
let
timeFrame
=
0
function
run
(
data
,
config
,
risk
,
pfTrade
,
riskFreeLevel
,
detail
,
loss
,
durs
,
maxTradeDays
,
targetPercentage
,
candlesData
,
fft
,
fftPercent
,
fftRunup
,
fftPercentRunup
)
{
function
run
(
data
,
config
,
risk
,
pfTrade
,
riskFreeLevel
,
detail
,
loss
,
durs
,
maxTradeDays
,
targetPercentage
,
candlesData
,
fft
,
fftPercent
,
fftRunup
,
fftPercentRunup
,
fftDiffDrawDownProfit
)
{
let
type
=
config
.
type
+
'
param:
'
+
config
.
param
+
'
base:
'
+
config
.
base
+
'
target:
'
+
config
.
target
+
'
targetPercentage:
'
+
targetPercentage
.
enable
+
'
fft:
'
+
fft
+
'
fftPercent:
'
+
fftPercent
let
type
=
config
.
type
+
'
param:
'
+
config
.
param
+
'
base:
'
+
config
.
base
+
'
target:
'
+
config
.
target
+
'
targetPercentage:
'
+
targetPercentage
.
enable
+
'
fft:
'
+
fft
+
'
fftPercent:
'
+
fftPercent
let
saveData
=
[]
let
saveData
=
[]
candles
=
candlesData
candles
=
candlesData
...
@@ -58,6 +58,8 @@ function run(data, config, risk, pfTrade, riskFreeLevel, detail, loss, durs, max
...
@@ -58,6 +58,8 @@ function run(data, config, risk, pfTrade, riskFreeLevel, detail, loss, durs, max
let
countDropRunup
=
0
let
countDropRunup
=
0
let
allLossProfitRunup
=
0
let
allLossProfitRunup
=
0
let
diffDrawdownProfitAll
=
0
let
dur
let
dur
try
{
try
{
dur
=
getNewMinDiff
(
data
[
0
].
openDate
,
data
[
data
.
length
-
1
].
closeDate
)
dur
=
getNewMinDiff
(
data
[
0
].
openDate
,
data
[
data
.
length
-
1
].
closeDate
)
...
@@ -85,10 +87,12 @@ function run(data, config, risk, pfTrade, riskFreeLevel, detail, loss, durs, max
...
@@ -85,10 +87,12 @@ function run(data, config, risk, pfTrade, riskFreeLevel, detail, loss, durs, max
if
(
data
[
i
].
profit
<
0
)
{
if
(
data
[
i
].
profit
<
0
)
{
allLossProfit
=
allLossProfit
+
data
[
i
].
profit
allLossProfit
=
allLossProfit
+
data
[
i
].
profit
diffDrawdownProfitAll
=
diffDrawdownProfitAll
+
(
data
[
i
].
drawDown
-
data
[
i
].
profit
)
countDrop
++
countDrop
++
}
}
else
{
else
{
allLossProfit
=
0
allLossProfit
=
0
diffDrawdownProfitAll
=
0
countDrop
=
0
countDrop
=
0
}
}
if
(
data
[
i
].
runUp
<
config
.
target
)
{
if
(
data
[
i
].
runUp
<
config
.
target
)
{
...
@@ -110,7 +114,10 @@ function run(data, config, risk, pfTrade, riskFreeLevel, detail, loss, durs, max
...
@@ -110,7 +114,10 @@ function run(data, config, risk, pfTrade, riskFreeLevel, detail, loss, durs, max
// if (allLossProfit> fftPercent)
// if (allLossProfit> fftPercent)
// continue
// continue
if
(
countDropRunup
<
fftRunup
)
// if (countDropRunup < fftRunup)
// continue
if
(
diffDrawdownProfitAll
>
fftDiffDrawDownProfit
)
continue
continue
...
...
csv.js
View file @
ec35fdd4
...
@@ -6,7 +6,7 @@ let moment = require('moment-timezone')
...
@@ -6,7 +6,7 @@ let moment = require('moment-timezone')
let
ai
=
require
(
'
./ai
'
)
let
ai
=
require
(
'
./ai
'
)
async
function
parse
(
directory
,
name
,
configs
,
risk
,
pfTrade
,
side
,
riskFreeLevel
,
detail
,
onlyShortLong
,
loss
,
dur
,
maxTradeDays
,
targetPercentage
,
candles
,
fft
,
fftPercent
,
fftRunup
,
fftPercentRunup
)
{
async
function
parse
(
directory
,
name
,
configs
,
risk
,
pfTrade
,
side
,
riskFreeLevel
,
detail
,
onlyShortLong
,
loss
,
dur
,
maxTradeDays
,
targetPercentage
,
candles
,
fft
,
fftPercent
,
fftRunup
,
fftPercentRunup
,
fftDiffDrawDownProfit
)
{
return
new
Promise
(
function
(
resolve
,
reject
)
{
return
new
Promise
(
function
(
resolve
,
reject
)
{
let
arr
=
[]
let
arr
=
[]
...
@@ -15,12 +15,12 @@ async function parse(directory, name, configs, risk, pfTrade, side, riskFreeLeve
...
@@ -15,12 +15,12 @@ async function parse(directory, name, configs, risk, pfTrade, side, riskFreeLeve
.
pipe
(
csv
.
parse
({
headers
:
true
}))
.
pipe
(
csv
.
parse
({
headers
:
true
}))
.
on
(
'
error
'
,
error
=>
reject
(
error
))
.
on
(
'
error
'
,
error
=>
reject
(
error
))
.
on
(
'
data
'
,
row
=>
arr
.
push
(
row
))
.
on
(
'
data
'
,
row
=>
arr
.
push
(
row
))
.
on
(
'
end
'
,
rowCount
=>
resolve
(
initData
(
arr
,
configs
,
name
,
risk
,
pfTrade
,
side
,
riskFreeLevel
,
detail
,
onlyShortLong
,
loss
,
dur
,
maxTradeDays
,
targetPercentage
,
candles
,
fft
,
fftPercent
,
fftRunup
,
fftPercentRunup
)));
.
on
(
'
end
'
,
rowCount
=>
resolve
(
initData
(
arr
,
configs
,
name
,
risk
,
pfTrade
,
side
,
riskFreeLevel
,
detail
,
onlyShortLong
,
loss
,
dur
,
maxTradeDays
,
targetPercentage
,
candles
,
fft
,
fftPercent
,
fftRunup
,
fftPercentRunup
,
fftDiffDrawDownProfit
)));
});
});
}
}
function
initData
(
data
,
config
,
name
,
risk
,
pfTrade
,
side
,
riskFreeLevel
,
detail
,
onlyShortLong
,
loss
,
dur
,
maxTradeDays
,
targetPercentage
,
candles
,
fft
,
fftPercent
,
fftRunup
,
fftPercentRunup
)
{
function
initData
(
data
,
config
,
name
,
risk
,
pfTrade
,
side
,
riskFreeLevel
,
detail
,
onlyShortLong
,
loss
,
dur
,
maxTradeDays
,
targetPercentage
,
candles
,
fft
,
fftPercent
,
fftRunup
,
fftPercentRunup
,
fftDiffDrawDownProfit
)
{
data
=
JSON
.
stringify
(
data
)
data
=
JSON
.
stringify
(
data
)
...
@@ -140,7 +140,7 @@ function initData(data, config, name, risk, pfTrade, side, riskFreeLevel,detail,
...
@@ -140,7 +140,7 @@ function initData(data, config, name, risk, pfTrade, side, riskFreeLevel,detail,
let
cz
=
[]
let
cz
=
[]
for
(
let
i
=
0
;
i
<
config
.
length
;
i
++
)
{
for
(
let
i
=
0
;
i
<
config
.
length
;
i
++
)
{
let
d
=
ai
.
run
(
arr
,
config
[
i
],
risk
,
pfTrade
,
riskFreeLevel
,
detail
,
loss
,
dur
,
maxTradeDays
,
targetPercentage
,
candles
,
fft
,
fftPercent
,
fftRunup
,
fftPercentRunup
)
let
d
=
ai
.
run
(
arr
,
config
[
i
],
risk
,
pfTrade
,
riskFreeLevel
,
detail
,
loss
,
dur
,
maxTradeDays
,
targetPercentage
,
candles
,
fft
,
fftPercent
,
fftRunup
,
fftPercentRunup
,
fftDiffDrawDownProfit
)
if
(
d
!==
null
)
if
(
d
!==
null
)
cz
.
push
(
d
)
cz
.
push
(
d
)
}
}
...
...
generate.js
View file @
ec35fdd4
...
@@ -20,7 +20,7 @@ run()
...
@@ -20,7 +20,7 @@ run()
async
function
run
()
async
function
run
()
{
{
let
obj
=
{
sort
:
'
profitPerMonthDrawDown
'
,
alocatedReserve
:
3
,
alocatedReserveCompound
:
3
,
risk
:
0
,
start
:
10000
,
pfTrade
:
2
,
side
:
'
both
'
,
riskFreeLevel
:
100
,
onlyShortLong
:
false
,
loss
:
0
,
level
:
200
,
dur
:
1500
,
maxTradeDays
:
40
,
targetPercentage
:{
enable
:
true
},
fft
:
1
,
fftPercent
:
-
2
,
fftRunup
:
2
,
fftPercentRunup
:
2
}
let
obj
=
{
sort
:
'
profitPerMonthDrawDown
'
,
alocatedReserve
:
3
,
alocatedReserveCompound
:
3
,
risk
:
0
,
start
:
10000
,
pfTrade
:
2
,
side
:
'
both
'
,
riskFreeLevel
:
100
,
onlyShortLong
:
false
,
loss
:
0
,
level
:
200
,
dur
:
1500
,
maxTradeDays
:
40
,
targetPercentage
:{
enable
:
true
},
fft
:
1
,
fftPercent
:
-
2
,
fftRunup
:
2
,
fftPercentRunup
:
2
,
fftDiffDrawDownProfit
:
-
0.5
}
let
detail
=
[
'
configs2.json-211021092159_O1_BNC_BTCUSD_Lp1_Y211020a - Copy_Mn.csv&zarib param:1.1 base:200 target:1
'
]
let
detail
=
[
'
configs2.json-211021092159_O1_BNC_BTCUSD_Lp1_Y211020a - Copy_Mn.csv&zarib param:1.1 base:200 target:1
'
]
obj
.
detail
=
detail
obj
.
detail
=
detail
let
all
=
[]
let
all
=
[]
...
...
run.js
View file @
ec35fdd4
...
@@ -44,7 +44,7 @@ async function run() {
...
@@ -44,7 +44,7 @@ async function run() {
for
(
let
i
=
0
;
i
<
files
.
length
;
i
++
)
for
(
let
i
=
0
;
i
<
files
.
length
;
i
++
)
if
(
files
[
i
].
includes
(
'
.csv
'
))
{
if
(
files
[
i
].
includes
(
'
.csv
'
))
{
csvFile
=
files
[
i
]
csvFile
=
files
[
i
]
arr
.
push
(
csv
.
parse
(
directory
,
files
[
i
],
configs
.
data
,
configs
.
risk
,
configs
.
pfTrade
,
configs
.
side
,
configs
.
riskFreeLevel
,
JSON
.
parse
(
checks
),
configs
.
onlyShortLong
,
configs
.
loss
,
configs
.
dur
,
configs
.
maxTradeDays
,
configs
.
targetPercentage
,
arr5
,
configs
.
fft
,
configs
.
fftPercent
,
configs
.
fftRunup
,
configs
.
fftPercentRunup
))
arr
.
push
(
csv
.
parse
(
directory
,
files
[
i
],
configs
.
data
,
configs
.
risk
,
configs
.
pfTrade
,
configs
.
side
,
configs
.
riskFreeLevel
,
JSON
.
parse
(
checks
),
configs
.
onlyShortLong
,
configs
.
loss
,
configs
.
dur
,
configs
.
maxTradeDays
,
configs
.
targetPercentage
,
arr5
,
configs
.
fft
,
configs
.
fftPercent
,
configs
.
fftRunup
,
configs
.
fftPercentRunup
,
configs
.
fftDiffDrawDownProfit
))
}
}
arr
=
await
Promise
.
all
(
arr
)
arr
=
await
Promise
.
all
(
arr
)
...
...
test_cal.js
View file @
ec35fdd4
console
.
log
(
typeof
Math
.
abs
(
-
10.2
))
\ No newline at end of file
console
.
log
(
-
1.5
,
-
1
)
function
calPer
(
entry
,
last
)
{
return
((
last
-
entry
)
/
entry
)
*
100
}
\ 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