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')
...
@@ -3,7 +3,7 @@ let moment = require('moment-timezone')
let
plus
=
'
plus
'
let
plus
=
'
plus
'
let
zarib
=
'
zarib
'
let
zarib
=
'
zarib
'
let
base
=
'
base
'
let
base
=
'
base
'
function
run
(
data
,
config
)
{
function
run
(
data
,
config
)
{
...
@@ -19,21 +19,21 @@ function run(data, config) {
...
@@ -19,21 +19,21 @@ function run(data, config) {
let
reserv
=
0
let
reserv
=
0
let
profit
=
0
let
profit
=
0
let
lastCom
=
0
let
lastCom
=
0
let
lastMoney
=
0
let
lastMoney
=
0
for
(
let
i
=
0
;
i
<
data
.
length
;
i
++
)
{
for
(
let
i
=
0
;
i
<
data
.
length
;
i
++
)
{
if
(
step
===
0
)
if
(
step
===
0
)
money
=
config
.
base
money
=
config
.
base
else
{
else
{
if
(
config
.
type
===
zarib
)
if
(
config
.
type
===
zarib
)
money
=
lastMoney
*
config
.
param
money
=
lastMoney
*
config
.
param
if
(
config
.
type
===
base
)
if
(
config
.
type
===
base
)
money
=
config
.
base
*
config
.
param
*
step
money
=
config
.
base
*
config
.
param
*
step
else
if
(
config
.
type
===
plus
)
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
))
if
(
Math
.
abs
(
d
.
reserve
)
>
Math
.
abs
(
maxReserve
))
...
@@ -54,24 +54,22 @@ function run(data, config) {
...
@@ -54,24 +54,22 @@ function run(data, config) {
reserv
=
0
reserv
=
0
profit
=
0
profit
=
0
lastCom
=
0
lastCom
=
0
lastMoney
=
0
lastMoney
=
0
total
++
total
++
}
else
{
}
else
{
step
++
step
++
profit
=
profit
+
d
.
profit
profit
=
profit
+
d
.
profit
lastMoney
=
d
.
lastMoney
lastMoney
=
d
.
lastMoney
lastCom
=
lastCom
+
d
.
com
lastCom
=
lastCom
+
d
.
com
}
}
}
}
let
dur
=
getMinDiff
(
data
[
0
].
openDate
,
data
[
data
.
length
-
1
].
closeDate
)
let
dur
=
getMinDiff
(
data
[
0
].
openDate
,
data
[
data
.
length
-
1
].
closeDate
)
let
totalFinal
=
total
*
config
.
target
let
totalFinal
=
total
*
config
.
target
let
newT
=
totalFinal
/
dur
let
newT
=
totalFinal
/
dur
let
percentage
=
maxReserve
+
totalFinal
let
percentage
=
maxReserve
+
totalFinal
percentage
=
maxAllocatedMoney
/
percentage
percentage
=
maxAllocatedMoney
/
percentage
let
minus
=
0
let
minus
=
0
...
@@ -80,7 +78,7 @@ function run(data, config) {
...
@@ -80,7 +78,7 @@ function run(data, config) {
percentage
=
null
percentage
=
null
}
}
let
profitPerMonth
=
(
newT
*
30
*
100
)
/
maxAllocatedMoney
let
profitPerMonth
=
(
newT
*
30
*
100
)
/
maxAllocatedMoney
// let percentage2 = maxReserve + newT
// let percentage2 = maxReserve + newT
...
@@ -91,39 +89,38 @@ function run(data, config) {
...
@@ -91,39 +89,38 @@ function run(data, config) {
// percentage2 = null
// percentage2 = null
// }
// }
let
perp
=
(
config
.
target
*
100
)
/
Math
.
abs
(
maxAllocatedMoney
)
let
perp
=
(
config
.
target
*
100
)
/
Math
.
abs
(
maxAllocatedMoney
)
perp
=
perp
/
100
perp
=
perp
/
100
let
sum
=
Math
.
abs
(
maxAllocatedMoney
)
let
sum
=
Math
.
abs
(
maxAllocatedMoney
)
for
(
let
i
=
0
;
i
<
total
;
i
++
)
for
(
let
i
=
0
;
i
<
total
;
i
++
)
sum
=
sum
+
(
sum
*
perp
)
sum
=
sum
+
(
sum
*
perp
)
let
newCompund
=
sum
/
dur
let
newCompund
=
sum
/
dur
let
compoundPerMonth
=
(
newCompund
*
30
*
100
)
/
Math
.
abs
(
maxAllocatedMoney
)
let
compoundPerMonth
=
(
newCompund
*
30
*
100
)
/
Math
.
abs
(
maxAllocatedMoney
)
let
opt
=
{
let
opt
=
{
platform
:
data
[
0
].
signal
,
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
,
total
:
total
,
avgLevel
:
maxLevel
/
total
,
avgLevel
:
maxLevel
/
total
,
maxLevel
:
maxLevel
,
maxLevel
:
maxLevel
,
dur
:
dur
,
dur
:
dur
,
totalFinal
:
totalFinal
,
totalFinal
:
totalFinal
,
totalCompound
:
sum
,
totalCompound
:
sum
,
profitPerMonth
:
Math
.
abs
(
profitPerMonth
),
profitPerMonth
:
Math
.
abs
(
profitPerMonth
),
compoundPerMonth
:
compoundPerMonth
,
compoundPerMonth
:
compoundPerMonth
,
maxAllocatedMoney
:
maxAllocatedMoney
,
maxAllocatedMoney
:
maxAllocatedMoney
,
avgAllocatedMoney
:
maxAllocatedMoney
/
total
,
avgAllocatedMoney
:
maxAllocatedMoney
/
total
,
drawDown
:
Math
.
abs
(((
maxReserve
*
100
)
/
maxAllocatedMoney
)),
maxReseve
:
maxReserve
,
maxReseve
:
maxReserve
,
avgReserve
:
maxReserve
/
total
,
avgReserve
:
maxReserve
/
total
,
percentage
:
percentage
,
percentage
:
percentage
,
avgProfitPerDay
:
newT
,
avgProfitPerDay
:
newT
,
allocatedReserve
:
(
maxAllocatedMoney
)
/
Math
.
abs
(
maxReserve
),
allocatedReserve
:
(
maxAllocatedMoney
)
/
Math
.
abs
(
maxReserve
),
minus
:
minus
,
minus
:
minus
,
}
}
...
@@ -143,7 +140,7 @@ function percentage2(base, per) {
...
@@ -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)
// console.log(profit)
com
=
com
*
money
com
=
com
*
money
...
@@ -163,7 +160,7 @@ function inlineCheck(money, com, data, profit, lastCom,tar) {
...
@@ -163,7 +160,7 @@ function inlineCheck(money, com, data, profit, lastCom,tar) {
if
(
percentage
(
money
,
data
.
runUp
)
>
target
)
if
(
percentage
(
money
,
data
.
runUp
)
>
target
)
return
{
done
:
true
,
reserve
:
diff
}
return
{
done
:
true
,
reserve
:
diff
}
else
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