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
3e989826
Commit
3e989826
authored
Apr 21, 2022
by
Ahmad Nemati
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
git pu
parent
d0293aab
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
35 additions
and
35 deletions
+35
-35
ai.js
ai.js
+22
-22
combiner.js
combiner.js
+7
-7
csv.js
csv.js
+4
-4
generate.js
generate.js
+1
-1
run.js
run.js
+1
-1
No files found.
ai.js
View file @
3e989826
...
...
@@ -14,20 +14,20 @@ let avgDrawdown = 0
let
avgProfit
=
0
function
run
(
data
,
config
,
risk
,
pfTrade
,
riskFreeLevel
,
detail
,
loss
,
durs
,
maxTradeDays
,
targetPercentage
,
candlesData
,
fft
,
fftPercent
,
fftRunup
,
fftPercentRunup
,
fftDiffDrawDownProfit
,
fft
DrawDown
,
ddPlusRunCount
,
ddPlusRunPercent
,
ProfitZeroRunupProfit
,
ProfitZeroRunupDrawDown
,
usage
)
{
function
run
(
data
,
config
,
risk
,
pfTrade
,
riskFreeLevel
,
detail
,
loss
,
durs
,
maxTradeDays
,
targetPercentage
,
candlesData
,
fft
,
ProfitZeroProfit
,
fftRunup
,
ProfitZeroProfitRunup
,
ProfitZeroDrawDownProfit
,
ProfitZero
DrawDown
,
ddPlusRunCount
,
ddPlusRunPercent
,
ProfitZeroRunupProfit
,
ProfitZeroRunupDrawDown
,
usage
)
{
let
type
=
config
.
type
+
'
param:
'
+
config
.
param
+
'
base:
'
+
config
.
base
+
'
target:
'
+
config
.
target
+
'
targetPercentage:
'
+
targetPercentage
.
enable
if
(
usage
===
'
fft
'
)
{
type
=
type
+
'
'
+
usage
+
'
'
+
fft
}
else
if
(
usage
===
'
fftPercen
t
'
)
{
type
=
type
+
'
'
+
usage
+
'
'
+
fftPercen
t
}
else
if
(
usage
===
'
ProfitZeroProfi
t
'
)
{
type
=
type
+
'
'
+
usage
+
'
'
+
ProfitZeroProfi
t
}
else
if
(
usage
===
'
fftRunup
'
)
{
type
=
type
+
'
'
+
usage
+
'
'
+
fftRunup
}
else
if
(
usage
===
'
fftDiff
DrawDownProfit
'
)
{
type
=
type
+
'
'
+
usage
+
'
'
+
fftDiff
DrawDownProfit
}
else
if
(
usage
===
'
fftPercen
tRunup
'
)
{
type
=
type
+
'
'
+
usage
+
'
Count:
'
+
fftPercentRunup
.
count
+
'
Percent:
'
+
fftPercen
tRunup
.
percent
}
else
if
(
usage
===
'
fft
DrawDown
'
)
{
type
=
type
+
'
'
+
usage
+
'
'
+
fft
DrawDown
}
else
if
(
usage
===
'
ProfitZero
DrawDownProfit
'
)
{
type
=
type
+
'
'
+
usage
+
'
'
+
ProfitZero
DrawDownProfit
}
else
if
(
usage
===
'
ProfitZeroProfi
tRunup
'
)
{
type
=
type
+
'
'
+
usage
+
'
Count:
'
+
ProfitZeroProfitRunup
.
count
+
'
Percent:
'
+
ProfitZeroProfi
tRunup
.
percent
}
else
if
(
usage
===
'
ProfitZero
DrawDown
'
)
{
type
=
type
+
'
'
+
usage
+
'
'
+
ProfitZero
DrawDown
}
else
if
(
usage
===
'
ddPlusRunCount
'
)
{
type
=
type
+
'
'
+
usage
+
'
'
+
ddPlusRunCount
}
else
if
(
usage
===
'
ddPlusRunPercent
'
)
{
...
...
@@ -92,7 +92,7 @@ function run(data, config, risk, pfTrade, riskFreeLevel, detail, loss, durs, max
let
VarProfitZeroRunupDrawDown
=
0
let
countDropRunup
=
0
let
fft
DrawDownPercent
=
0
let
ProfitZero
DrawDownPercent
=
0
let
allLossProfitRunup
=
0
let
diffDrawdownProfitAll
=
0
...
...
@@ -140,8 +140,8 @@ function run(data, config, risk, pfTrade, riskFreeLevel, detail, loss, durs, max
runBefore
=
false
else
runBefore
=
true
}
else
if
(
usage
===
'
fftPercen
t
'
)
{
if
(
allLossProfit
>
fftPercen
t
)
}
else
if
(
usage
===
'
ProfitZeroProfi
t
'
)
{
if
(
allLossProfit
>
ProfitZeroProfi
t
)
runBefore
=
false
else
runBefore
=
true
...
...
@@ -150,8 +150,8 @@ function run(data, config, risk, pfTrade, riskFreeLevel, detail, loss, durs, max
runBefore
=
false
else
runBefore
=
true
}
else
if
(
usage
===
'
fft
DrawDown
'
)
{
if
(
fftDrawDownPercent
>
fft
DrawDown
)
}
else
if
(
usage
===
'
ProfitZero
DrawDown
'
)
{
if
(
ProfitZeroDrawDownPercent
>
ProfitZero
DrawDown
)
runBefore
=
false
else
runBefore
=
true
...
...
@@ -160,12 +160,12 @@ function run(data, config, risk, pfTrade, riskFreeLevel, detail, loss, durs, max
runBefore
=
false
else
runBefore
=
true
}
else
if
(
usage
===
'
fftDiff
DrawDownProfit
'
)
{
if
(
diffDrawdownProfitAll
>
fftDiff
DrawDownProfit
)
}
else
if
(
usage
===
'
ProfitZero
DrawDownProfit
'
)
{
if
(
diffDrawdownProfitAll
>
ProfitZero
DrawDownProfit
)
runBefore
=
false
else
runBefore
=
true
}
else
if
(
usage
===
'
fftPercen
tRunup
'
)
{
}
else
if
(
usage
===
'
ProfitZeroProfi
tRunup
'
)
{
if
(
canCreateRunupPercent
===
false
)
runBefore
=
false
else
...
...
@@ -233,7 +233,7 @@ function run(data, config, risk, pfTrade, riskFreeLevel, detail, loss, durs, max
if
(
data
[
i
].
profit
<
0
)
{
allLossProfit
=
allLossProfit
+
data
[
i
].
profit
diffDrawdownProfitAll
=
diffDrawdownProfitAll
+
(
data
[
i
].
drawDown
-
data
[
i
].
profit
)
fftDrawDownPercent
=
fft
DrawDownPercent
+
data
[
i
].
drawDown
ProfitZeroDrawDownPercent
=
ProfitZero
DrawDownPercent
+
data
[
i
].
drawDown
VarProfitZeroRunupProfit
=
VarProfitZeroRunupProfit
+
(
data
[
i
].
runUp
+
data
[
i
].
profit
)
VarProfitZeroRunupDrawDown
=
VarProfitZeroRunupDrawDown
+
(
data
[
i
].
runUp
+
data
[
i
].
drawDown
)
countDrop
++
...
...
@@ -243,7 +243,7 @@ function run(data, config, risk, pfTrade, riskFreeLevel, detail, loss, durs, max
VarProfitZeroRunupDrawDown
=
0
diffDrawdownProfitAll
=
0
countDrop
=
0
fft
DrawDownPercent
=
0
ProfitZero
DrawDownPercent
=
0
}
if
(
data
[
i
].
runUp
<
config
.
target
)
{
allLossProfitRunup
=
allLossProfitRunup
+
data
[
i
].
runUp
...
...
@@ -253,9 +253,9 @@ function run(data, config, risk, pfTrade, riskFreeLevel, detail, loss, durs, max
countDropRunup
=
0
}
if
(
usage
===
'
fftPercen
tRunup
'
)
{
if
(
usage
===
'
ProfitZeroProfi
tRunup
'
)
{
let
temp
=
0
for
(
let
z
=
i
+
1
;
z
<=
(
i
+
fftPercen
tRunup
.
count
);
z
++
)
{
for
(
let
z
=
i
+
1
;
z
<=
(
i
+
ProfitZeroProfi
tRunup
.
count
);
z
++
)
{
try
{
let
runup
=
data
[
z
].
runUp
...
...
@@ -265,7 +265,7 @@ function run(data, config, risk, pfTrade, riskFreeLevel, detail, loss, durs, max
}
}
if
(
temp
<=
fftPercen
tRunup
.
percent
)
{
if
(
temp
<=
ProfitZeroProfi
tRunup
.
percent
)
{
canCreateRunupPercent
=
true
}
}
...
...
combiner.js
View file @
3e989826
...
...
@@ -21,10 +21,10 @@ async function run() {
"
enable
"
:
false
},
"
fft
"
:
10
,
"
fftPercen
t
"
:
-
20
,
"
ProfitZeroProfi
t
"
:
-
20
,
"
fftRunup
"
:
4
,
"
fftPercen
tRunup
"
:
1
,
"
fftDiff
DrawDownProfit
"
:
-
5
,
"
ProfitZeroProfi
tRunup
"
:
1
,
"
ProfitZero
DrawDownProfit
"
:
-
5
,
"
usage
"
:
"
fftRunup
"
,
"
detail
"
:
[
...
...
@@ -59,11 +59,11 @@ async function run() {
i
.
targetPercentage
=
config
.
targetPercentage
i
.
fft
=
config
.
fft
i
.
fftPercent
=
config
.
fftPercen
t
i
.
ProfitZeroProfit
=
config
.
ProfitZeroProfi
t
i
.
fftRunup
=
config
.
fftRunup
i
.
fftPercentRunup
=
config
.
fftPercen
tRunup
i
.
fftDiffDrawDownProfit
=
config
.
fftDiff
DrawDownProfit
i
.
fftDrawDown
=
config
.
fft
DrawDown
i
.
ProfitZeroProfitRunup
=
config
.
ProfitZeroProfi
tRunup
i
.
ProfitZeroDrawDownProfit
=
config
.
ProfitZero
DrawDownProfit
i
.
ProfitZeroDrawDown
=
config
.
ProfitZero
DrawDown
i
.
ddPlusRunCount
=
config
.
ddPlusRunCount
i
.
ddPlusRunPercent
=
config
.
ddPlusRunPercent
...
...
csv.js
View file @
3e989826
...
...
@@ -6,7 +6,7 @@ let moment = require('moment-timezone')
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
,
fftDiff
DrawDownProfit
,
usage
)
{
async
function
parse
(
directory
,
name
,
configs
,
risk
,
pfTrade
,
side
,
riskFreeLevel
,
detail
,
onlyShortLong
,
loss
,
dur
,
maxTradeDays
,
targetPercentage
,
candles
,
fft
,
ProfitZeroProfit
,
fftRunup
,
ProfitZeroProfitRunup
,
ProfitZero
DrawDownProfit
,
usage
)
{
return
new
Promise
(
function
(
resolve
,
reject
)
{
let
arr
=
[]
...
...
@@ -15,12 +15,12 @@ async function parse(directory, name, configs, risk, pfTrade, side, riskFreeLeve
.
pipe
(
csv
.
parse
({
headers
:
true
}))
.
on
(
'
error
'
,
error
=>
reject
(
error
))
.
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
,
fftDiff
DrawDownProfit
,
usage
)));
.
on
(
'
end
'
,
rowCount
=>
resolve
(
initData
(
arr
,
configs
,
name
,
risk
,
pfTrade
,
side
,
riskFreeLevel
,
detail
,
onlyShortLong
,
loss
,
dur
,
maxTradeDays
,
targetPercentage
,
candles
,
fft
,
ProfitZeroProfit
,
fftRunup
,
ProfitZeroProfitRunup
,
ProfitZero
DrawDownProfit
,
usage
)));
});
}
function
initData
(
data
,
config
,
name
,
risk
,
pfTrade
,
side
,
riskFreeLevel
,
detail
,
onlyShortLong
,
loss
,
dur
,
maxTradeDays
,
targetPercentage
,
candles
,
fft
,
fftPercent
,
fftRunup
,
fftPercentRunup
,
fftDiff
DrawDownProfit
,
usage
)
{
function
initData
(
data
,
config
,
name
,
risk
,
pfTrade
,
side
,
riskFreeLevel
,
detail
,
onlyShortLong
,
loss
,
dur
,
maxTradeDays
,
targetPercentage
,
candles
,
fft
,
ProfitZeroProfit
,
fftRunup
,
ProfitZeroProfitRunup
,
ProfitZero
DrawDownProfit
,
usage
)
{
data
=
JSON
.
stringify
(
data
)
...
...
@@ -140,7 +140,7 @@ function initData(data, config, name, risk, pfTrade, side, riskFreeLevel,detail,
let
cz
=
[]
for
(
let
i
=
0
;
i
<
config
.
length
;
i
++
)
{
let
d
=
ai
.
run
(
arr
,
config
[
i
],
config
[
i
].
risk
,
config
[
i
].
pfTrade
,
config
[
i
].
riskFreeLevel
,
detail
,
config
[
i
].
loss
,
config
[
i
].
dur
,
config
[
i
].
maxTradeDays
,
config
[
i
].
targetPercentage
,
candles
,
config
[
i
].
fft
,
config
[
i
].
fftPercent
,
config
[
i
].
fftRunup
,
config
[
i
].
fftPercentRunup
,
config
[
i
].
fftDiffDrawDownProfit
,
config
[
i
].
fft
DrawDown
,
config
[
i
].
ddPlusRunCount
,
config
[
i
].
ddPlusRunPercent
,
config
[
i
].
ProfitZeroRunupProfit
,
config
[
i
].
ProfitZeroRunupDrawDown
,
config
[
i
].
usage
)
let
d
=
ai
.
run
(
arr
,
config
[
i
],
config
[
i
].
risk
,
config
[
i
].
pfTrade
,
config
[
i
].
riskFreeLevel
,
detail
,
config
[
i
].
loss
,
config
[
i
].
dur
,
config
[
i
].
maxTradeDays
,
config
[
i
].
targetPercentage
,
candles
,
config
[
i
].
fft
,
config
[
i
].
ProfitZeroProfit
,
config
[
i
].
fftRunup
,
config
[
i
].
ProfitZeroProfitRunup
,
config
[
i
].
ProfitZeroDrawDownProfit
,
config
[
i
].
ProfitZero
DrawDown
,
config
[
i
].
ddPlusRunCount
,
config
[
i
].
ddPlusRunPercent
,
config
[
i
].
ProfitZeroRunupProfit
,
config
[
i
].
ProfitZeroRunupDrawDown
,
config
[
i
].
usage
)
if
(
d
!==
null
)
cz
.
push
(
d
)
}
...
...
generate.js
View file @
3e989826
...
...
@@ -22,7 +22,7 @@ async function run()
{
for
(
let
n
=
1
;
n
<
40
;
n
++
)
{
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
:
false
},
fft
:
1
,
fftPercent
:
-
2
,
fftRunup
:
2
,
fftPercentRunup
:{
count
:
7
,
percent
:
15
},
fftDiffDrawDownProfit
:
-
0.5
,
fft
DrawDown
:
-
1
,
ddPlusRunCount
:
4
,
ddPlusRunPercent
:
-
2
,
ProfitZeroRunupProfit
:(
n
*-
1
),
ProfitZeroRunupDrawDown
:(
n
*-
1
),
usage
:
'
ProfitZeroRunupProfit
'
}
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
:
false
},
fft
:
1
,
ProfitZeroProfit
:
-
2
,
fftRunup
:
2
,
ProfitZeroProfitRunup
:{
count
:
7
,
percent
:
15
},
ProfitZeroDrawDownProfit
:
-
0.5
,
ProfitZero
DrawDown
:
-
1
,
ddPlusRunCount
:
4
,
ddPlusRunPercent
:
-
2
,
ProfitZeroRunupProfit
:(
n
*-
1
),
ProfitZeroRunupDrawDown
:(
n
*-
1
),
usage
:
'
ProfitZeroRunupProfit
'
}
// let detail=['configs2.json-211021092159_O1_BNC_BTCUSD_Lp1_Y211020a - Copy_Mn.csv&zarib param:1.1 base:200 target:1']
obj
.
detail
=
[]
// let all=[]
...
...
run.js
View file @
3e989826
...
...
@@ -44,7 +44,7 @@ async function run() {
for
(
let
i
=
0
;
i
<
files
.
length
;
i
++
)
if
(
files
[
i
].
includes
(
'
.csv
'
))
{
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
,
configs
.
fftDiff
DrawDownProfit
,
configs
.
usage
))
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
.
ProfitZeroProfit
,
configs
.
fftRunup
,
configs
.
ProfitZeroProfitRunup
,
configs
.
ProfitZero
DrawDownProfit
,
configs
.
usage
))
}
arr
=
await
Promise
.
all
(
arr
)
...
...
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