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
Hide 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
'
let
zarib
=
'
zarib
'
function
run
(
data
,
config
)
{
function
run
(
data
,
config
)
{
let
commision
=
config
.
commision
let
money
=
config
.
base
let
total
=
0
...
...
@@ -18,22 +15,21 @@ let zarib='zarib'
// console.log(data)
let
step
=
0
let
reserv
=
0
let
profit
=
0
let
lastCom
=
0
let
reserv
=
0
let
profit
=
0
let
lastCom
=
0
for
(
let
i
=
0
;
i
<
data
.
length
;
i
++
)
{
if
(
step
===
0
)
money
=
config
.
base
else
{
if
(
config
.
type
===
zarib
)
else
{
if
(
config
.
type
===
zarib
)
money
=
config
.
base
*
config
.
param
*
step
else
if
(
config
.
type
===
plus
)
money
=
config
.
base
+
(
config
.
param
*
step
)
else
if
(
config
.
type
===
plus
)
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
))
...
...
@@ -41,54 +37,70 @@ let zarib='zarib'
if
(
money
>
maxAllocatedMoney
)
maxAllocatedMoney
=
money
// console.log(data[i])
// console.log( 'step->'+step)
// console.log(d)
// console.log(data[i])
// console.log( 'step->'+step)
// console.log(d)
if
(
step
>
maxLevel
)
maxLevel
=
step
if
(
step
>
maxLevel
)
maxLevel
=
step
if
(
d
.
done
===
true
)
{
step
=
0
reserv
=
0
profit
=
0
lastCom
=
0
reserv
=
0
profit
=
0
lastCom
=
0
total
++
}
else
{
step
++
profit
=
profit
+
d
.
profit
lastCom
=
lastCom
+
d
.
com
profit
=
profit
+
d
.
profit
lastCom
=
lastCom
+
d
.
com
}
}
let
percentage
=
maxReserve
+
total
percentage
=
maxAllocatedMoney
/
percentage
let
minus
=
0
if
(
percentage
<
0
)
{
minus
=
percentage
let
dur
=
getMinDiff
(
data
[
0
].
openDate
,
data
[
data
.
length
-
1
].
closeDate
)
let
newT
=
total
/
dur
let
percentage
=
maxReserve
+
total
percentage
=
maxAllocatedMoney
/
percentage
let
minus
=
0
if
(
percentage
<
0
)
{
minus
=
percentage
percentage
=
null
}
// let percentage2 = maxReserve + newT
// percentage2 = maxAllocatedMoney / percentage2
// let minus2 = 0
// if (percentage2 < 0) {
// minus2 = percentage2
// percentage2 = null
// }
let
opt
=
{
platform
:
data
[
0
].
signal
,
type
:
config
.
type
+
'
param:
'
+
config
.
param
+
'
base:
'
+
config
.
base
,
type
:
config
.
type
+
'
param:
'
+
config
.
param
+
'
base:
'
+
config
.
base
,
total
:
total
,
avgLevel
:
maxLevel
/
total
,
avgLevel
:
maxLevel
/
total
,
maxLevel
:
maxLevel
,
dur
:
dur
,
maxAllocatedMoney
:
maxAllocatedMoney
,
avgAllocatedMoney
:
maxAllocatedMoney
/
total
,
avgAllocatedMoney
:
maxAllocatedMoney
/
total
,
maxReseve
:
maxReserve
,
avgReserve
:
maxReserve
/
total
,
percentage
:
percentage
,
minus
:
minus
avgReserve
:
maxReserve
/
total
,
percentage
:
percentage
,
avgProfitPerDay
:
newT
,
minus
:
minus
,
}
}
return
opt
...
...
@@ -98,27 +110,27 @@ let zarib='zarib'
}
function
inlineCheck
(
money
,
com
,
data
,
profit
,
lastCom
)
{
function
inlineCheck
(
money
,
com
,
data
,
profit
,
lastCom
)
{
// console.log(profit)
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
profitMoney
=
percentageMinus
(
money
,
data
.
profit
)
let
diff
=
reserve
-
money
diff
=
diff
-
com
-
lastCom
+
profit
let
diff
=
reserve
-
money
diff
=
diff
-
com
-
lastCom
+
profit
// 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
}
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) {
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
=
{
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')
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
)
let
arr
=
[]
let
files
=
await
fs
.
readdirSync
(
'
./work
'
)
...
...
@@ -44,7 +44,7 @@ function createfile(data) {
async
function
test2
()
{
let
configs
=
await
fs
.
readFileSync
(
'
./config.json
'
,
'
utf8
'
)
let
configs
=
await
fs
.
readFileSync
(
'
./config
Temp
.json
'
,
'
utf8
'
)
configs
=
JSON
.
parse
(
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