Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
F
forex
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
forex
Commits
a59e3c7d
Commit
a59e3c7d
authored
Nov 30, 2021
by
Ahmad Nemati
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
init
parent
d395f94c
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
38 additions
and
41 deletions
+38
-41
ai.js
ai.js
+38
-41
No files found.
ai.js
View file @
a59e3c7d
...
...
@@ -3,7 +3,7 @@ let moment = require('moment-timezone')
let
plus
=
'
plus
'
let
zarib
=
'
zarib
'
let
base
=
'
base
'
let
base
=
'
base
'
function
run
(
data
,
config
)
{
...
...
@@ -19,21 +19,21 @@ function run(data, config) {
let
reserv
=
0
let
profit
=
0
let
lastCom
=
0
let
lastMoney
=
0
let
lastMoney
=
0
for
(
let
i
=
0
;
i
<
data
.
length
;
i
++
)
{
if
(
step
===
0
)
money
=
config
.
base
else
{
if
(
config
.
type
===
zarib
)
money
=
lastMoney
*
config
.
param
money
=
lastMoney
*
config
.
param
if
(
config
.
type
===
base
)
money
=
config
.
base
*
config
.
param
*
step
else
if
(
config
.
type
===
plus
)
money
=
config
.
base
*
(
step
+
1
)
money
=
config
.
base
*
(
step
+
1
)
}
let
d
=
inlineCheck
(
money
,
commision
,
data
[
i
],
profit
,
lastCom
,
config
.
target
)
let
d
=
inlineCheck
(
money
,
commision
,
data
[
i
],
profit
,
lastCom
,
config
.
target
)
if
(
Math
.
abs
(
d
.
reserve
)
>
Math
.
abs
(
maxReserve
))
...
...
@@ -54,24 +54,22 @@ function run(data, config) {
reserv
=
0
profit
=
0
lastCom
=
0
lastMoney
=
0
lastMoney
=
0
total
++
}
else
{
step
++
profit
=
profit
+
d
.
profit
lastMoney
=
d
.
lastMoney
lastMoney
=
d
.
lastMoney
lastCom
=
lastCom
+
d
.
com
}
}
let
dur
=
getMinDiff
(
data
[
0
].
openDate
,
data
[
data
.
length
-
1
].
closeDate
)
let
totalFinal
=
total
*
config
.
target
let
newT
=
totalFinal
/
dur
let
totalFinal
=
total
*
config
.
target
let
newT
=
totalFinal
/
dur
let
percentage
=
maxReserve
+
totalFinal
percentage
=
maxAllocatedMoney
/
percentage
let
minus
=
0
...
...
@@ -80,7 +78,7 @@ function run(data, config) {
percentage
=
null
}
let
profitPerMonth
=
(
newT
*
30
*
100
)
/
maxAllocatedMoney
let
profitPerMonth
=
(
newT
*
30
*
100
)
/
maxAllocatedMoney
// let percentage2 = maxReserve + newT
...
...
@@ -91,39 +89,38 @@ function run(data, config) {
// percentage2 = null
// }
let
perp
=
(
config
.
target
*
100
)
/
Math
.
abs
(
maxAllocatedMoney
)
perp
=
perp
/
100
let
sum
=
Math
.
abs
(
maxAllocatedMoney
)
for
(
let
i
=
0
;
i
<
total
;
i
++
)
sum
=
sum
+
(
sum
*
perp
)
let
newCompund
=
sum
/
dur
let
perp
=
(
config
.
target
*
100
)
/
Math
.
abs
(
maxAllocatedMoney
)
perp
=
perp
/
100
let
sum
=
Math
.
abs
(
maxAllocatedMoney
)
for
(
let
i
=
0
;
i
<
total
;
i
++
)
sum
=
sum
+
(
sum
*
perp
)
let
newCompund
=
sum
/
dur
let
compoundPerMonth
=
(
newCompund
*
30
*
100
)
/
Math
.
abs
(
maxAllocatedMoney
)
let
compoundPerMonth
=
(
newCompund
*
30
*
100
)
/
Math
.
abs
(
maxAllocatedMoney
)
let
opt
=
{
platform
:
data
[
0
].
signal
,
type
:
config
.
type
+
'
param:
'
+
config
.
param
+
'
base:
'
+
config
.
base
+
'
target:
'
+
config
.
target
,
type
:
config
.
type
+
'
param:
'
+
config
.
param
+
'
base:
'
+
config
.
base
+
'
target:
'
+
config
.
target
,
total
:
total
,
avgLevel
:
maxLevel
/
total
,
maxLevel
:
maxLevel
,
dur
:
dur
,
totalFinal
:
totalFinal
,
totalCompound
:
sum
,
profitPerMonth
:
Math
.
abs
(
profitPerMonth
),
compoundPerMonth
:
compoundPerMonth
,
dur
:
dur
,
totalFinal
:
totalFinal
,
totalCompound
:
sum
,
profitPerMonth
:
Math
.
abs
(
profitPerMonth
),
compoundPerMonth
:
compoundPerMonth
,
maxAllocatedMoney
:
maxAllocatedMoney
,
avgAllocatedMoney
:
maxAllocatedMoney
/
total
,
drawDown
:
Math
.
abs
(((
maxReserve
*
100
)
/
maxAllocatedMoney
)),
maxReseve
:
maxReserve
,
avgReserve
:
maxReserve
/
total
,
percentage
:
percentage
,
avgProfitPerDay
:
newT
,
allocatedReserve
:
(
maxAllocatedMoney
)
/
Math
.
abs
(
maxReserve
),
avgProfitPerDay
:
newT
,
allocatedReserve
:
(
maxAllocatedMoney
)
/
Math
.
abs
(
maxReserve
),
minus
:
minus
,
}
...
...
@@ -143,7 +140,7 @@ function percentage2(base, per) {
}
function
inlineCheck
(
money
,
com
,
data
,
profit
,
lastCom
,
tar
)
{
function
inlineCheck
(
money
,
com
,
data
,
profit
,
lastCom
,
tar
)
{
// console.log(profit)
com
=
com
*
money
...
...
@@ -163,7 +160,7 @@ function inlineCheck(money, com, data, profit, lastCom,tar) {
if
(
percentage
(
money
,
data
.
runUp
)
>
target
)
return
{
done
:
true
,
reserve
:
diff
}
else
return
{
done
:
false
,
reserve
:
diff
,
profit
:
profitMoney
,
com
:
com
,
lastMoney
:
money
}
return
{
done
:
false
,
reserve
:
diff
,
profit
:
profitMoney
,
com
:
com
,
lastMoney
:
money
}
}
...
...
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