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
8bc75bc0
Commit
8bc75bc0
authored
Aug 31, 2021
by
Ahmad Nemati
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
init
parent
7a99f950
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
68 additions
and
47 deletions
+68
-47
ai.js
ai.js
+66
-45
configTemp.json
configTemp.json
+0
-0
test.js
test.js
+2
-2
No files found.
ai.js
View file @
8bc75bc0
let
moment
=
require
(
'
moment-timezone
'
)
let
plus
=
'
plus
'
let
zarib
=
'
zarib
'
let
plus
=
'
plus
'
function
run
(
data
,
config
)
{
let
zarib
=
'
zarib
'
function
run
(
data
,
config
)
{
let
commision
=
config
.
commision
let
commision
=
config
.
commision
let
money
=
config
.
base
let
money
=
config
.
base
let
total
=
0
let
total
=
0
...
@@ -18,22 +15,21 @@ let zarib='zarib'
...
@@ -18,22 +15,21 @@ let zarib='zarib'
// console.log(data)
// console.log(data)
let
step
=
0
let
step
=
0
let
reserv
=
0
let
reserv
=
0
let
profit
=
0
let
profit
=
0
let
lastCom
=
0
let
lastCom
=
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
=
config
.
base
*
config
.
param
*
step
money
=
config
.
base
*
config
.
param
*
step
else
if
(
config
.
type
===
plus
)
else
if
(
config
.
type
===
plus
)
money
=
config
.
base
+
(
config
.
param
*
step
)
money
=
config
.
base
+
(
config
.
param
*
step
)
}
}
let
d
=
inlineCheck
(
money
,
commision
,
data
[
i
],
profit
,
lastCom
)
let
d
=
inlineCheck
(
money
,
commision
,
data
[
i
],
profit
,
lastCom
)
if
(
Math
.
abs
(
d
.
reserve
)
>
Math
.
abs
(
maxReserve
))
if
(
Math
.
abs
(
d
.
reserve
)
>
Math
.
abs
(
maxReserve
))
...
@@ -45,50 +41,66 @@ let zarib='zarib'
...
@@ -45,50 +41,66 @@ let zarib='zarib'
// console.log( 'step->'+step)
// console.log( 'step->'+step)
// console.log(d)
// console.log(d)
if
(
step
>
maxLevel
)
if
(
step
>
maxLevel
)
maxLevel
=
step
maxLevel
=
step
if
(
d
.
done
===
true
)
{
if
(
d
.
done
===
true
)
{
step
=
0
step
=
0
reserv
=
0
reserv
=
0
profit
=
0
profit
=
0
lastCom
=
0
lastCom
=
0
total
++
total
++
}
else
{
}
else
{
step
++
step
++
profit
=
profit
+
d
.
profit
profit
=
profit
+
d
.
profit
lastCom
=
lastCom
+
d
.
com
lastCom
=
lastCom
+
d
.
com
}
}
}
}
let
percentage
=
maxReserve
+
total
percentage
=
maxAllocatedMoney
/
percentage
let
minus
=
0
if
(
percentage
<
0
)
{
let
dur
=
getMinDiff
(
data
[
0
].
openDate
,
data
[
data
.
length
-
1
].
closeDate
)
minus
=
percentage
let
newT
=
total
/
dur
let
percentage
=
maxReserve
+
total
percentage
=
maxAllocatedMoney
/
percentage
let
minus
=
0
if
(
percentage
<
0
)
{
minus
=
percentage
percentage
=
null
percentage
=
null
}
}
// let percentage2 = maxReserve + newT
// percentage2 = maxAllocatedMoney / percentage2
// let minus2 = 0
// if (percentage2 < 0) {
// minus2 = percentage2
// percentage2 = null
// }
let
opt
=
{
let
opt
=
{
platform
:
data
[
0
].
signal
,
platform
:
data
[
0
].
signal
,
type
:
config
.
type
+
'
param:
'
+
config
.
param
+
'
base:
'
+
config
.
base
,
type
:
config
.
type
+
'
param:
'
+
config
.
param
+
'
base:
'
+
config
.
base
,
total
:
total
,
total
:
total
,
avgLevel
:
maxLevel
/
total
,
avgLevel
:
maxLevel
/
total
,
maxLevel
:
maxLevel
,
maxLevel
:
maxLevel
,
dur
:
dur
,
maxAllocatedMoney
:
maxAllocatedMoney
,
maxAllocatedMoney
:
maxAllocatedMoney
,
avgAllocatedMoney
:
maxAllocatedMoney
/
total
,
avgAllocatedMoney
:
maxAllocatedMoney
/
total
,
maxReseve
:
maxReserve
,
maxReseve
:
maxReserve
,
avgReserve
:
maxReserve
/
total
,
avgReserve
:
maxReserve
/
total
,
percentage
:
percentage
,
percentage
:
percentage
,
minus
:
minus
avgProfitPerDay
:
newT
,
minus
:
minus
,
}
}
return
opt
return
opt
...
@@ -98,27 +110,27 @@ let zarib='zarib'
...
@@ -98,27 +110,27 @@ let zarib='zarib'
}
}
function
inlineCheck
(
money
,
com
,
data
,
profit
,
lastCom
)
{
function
inlineCheck
(
money
,
com
,
data
,
profit
,
lastCom
)
{
// console.log(profit)
// console.log(profit)
com
=
com
*
money
com
=
com
*
money
let
target
=
money
+
Math
.
abs
(
profit
)
+
com
+
lastCom
+
1
let
target
=
money
+
Math
.
abs
(
profit
)
+
com
+
lastCom
+
1
let
reserve
=
percentage
(
money
,
data
.
drawDown
)
let
reserve
=
percentage
(
money
,
data
.
drawDown
)
let
profitMoney
=
percentageMinus
(
money
,
data
.
profit
)
let
profitMoney
=
percentageMinus
(
money
,
data
.
profit
)
let
diff
=
reserve
-
money
let
diff
=
reserve
-
money
diff
=
diff
-
com
-
lastCom
+
profit
diff
=
diff
-
com
-
lastCom
+
profit
// console.log('reserve->'+reserve + ' money->'+money +' com->'+com +' lastCom->'+lastCom + 'profit->'+profit +' diff->'+diff)
// console.log('reserve->'+reserve + ' money->'+money +' com->'+com +' lastCom->'+lastCom + 'profit->'+profit +' diff->'+diff)
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
}
return
{
done
:
false
,
reserve
:
diff
,
profit
:
profitMoney
,
com
:
com
}
}
}
...
@@ -146,12 +158,21 @@ function percentageMinus(base, per) {
...
@@ -146,12 +158,21 @@ function percentageMinus(base, per) {
return
temp
return
temp
}
}
function
getMinDiff
(
start
,
closed
)
{
//2019-05-25T05:34:27+04:30
var
now
=
moment
(
moment
(
closed
).
tz
(
'
Asia/Tehran
'
).
format
());
var
end
=
moment
.
duration
(
now
.
diff
(
moment
(
start
).
tz
(
'
Asia/Tehran
'
)));
// console.log(parseInt(end.asDays()))
return
parseInt
(
end
.
asDays
())
}
module
.
exports
=
module
.
exports
=
{
{
run
:
run
,
run
:
run
,
}
}
\ No newline at end of file
config.json
→
config
Temp
.json
View file @
8bc75bc0
File moved
test.js
View file @
8bc75bc0
...
@@ -5,7 +5,7 @@ let _ = require('lodash')
...
@@ -5,7 +5,7 @@ let _ = require('lodash')
test
()
test
()
async
function
test
()
{
async
function
test
()
{
let
configs
=
await
fs
.
readFileSync
(
'
./config.json
'
,
'
utf8
'
)
let
configs
=
await
fs
.
readFileSync
(
'
./config
s
.json
'
,
'
utf8
'
)
configs
=
JSON
.
parse
(
configs
)
configs
=
JSON
.
parse
(
configs
)
let
arr
=
[]
let
arr
=
[]
let
files
=
await
fs
.
readdirSync
(
'
./work
'
)
let
files
=
await
fs
.
readdirSync
(
'
./work
'
)
...
@@ -44,7 +44,7 @@ function createfile(data) {
...
@@ -44,7 +44,7 @@ function createfile(data) {
async
function
test2
()
{
async
function
test2
()
{
let
configs
=
await
fs
.
readFileSync
(
'
./config.json
'
,
'
utf8
'
)
let
configs
=
await
fs
.
readFileSync
(
'
./config
Temp
.json
'
,
'
utf8
'
)
configs
=
JSON
.
parse
(
configs
)
configs
=
JSON
.
parse
(
configs
)
console
.
log
(
configs
)
console
.
log
(
configs
)
}
}
...
...
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