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
0a8bca4c
Commit
0a8bca4c
authored
Dec 02, 2021
by
Ahmad Nemati
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
init
parent
0fa9862e
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
17 additions
and
7 deletions
+17
-7
ai.js
ai.js
+11
-1
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 @
0a8bca4c
...
@@ -6,7 +6,7 @@ let zarib = 'zarib'
...
@@ -6,7 +6,7 @@ let zarib = 'zarib'
let
base
=
'
base
'
let
base
=
'
base
'
function
run
(
data
,
config
)
{
function
run
(
data
,
config
,
risk
)
{
let
commision
=
config
.
commision
let
commision
=
config
.
commision
let
money
=
config
.
base
let
money
=
config
.
base
let
total
=
0
let
total
=
0
...
@@ -65,6 +65,13 @@ function run(data, config) {
...
@@ -65,6 +65,13 @@ function run(data, config) {
}
}
}
}
let
firstMaxAllocatedMoney
=
maxAllocatedMoney
if
(
config
.
param
!==
0
)
{
for
(
let
i
=
0
;
i
<
risk
;
i
++
)
maxAllocatedMoney
=
maxAllocatedMoney
*
config
.
param
}
let
dur
=
getMinDiff
(
data
[
0
].
openDate
,
data
[
data
.
length
-
1
].
closeDate
)
let
dur
=
getMinDiff
(
data
[
0
].
openDate
,
data
[
data
.
length
-
1
].
closeDate
)
...
@@ -110,7 +117,10 @@ function run(data, config) {
...
@@ -110,7 +117,10 @@ function run(data, config) {
totalCompound
:
sum
,
totalCompound
:
sum
,
profitPerMonth
:
Math
.
abs
(
profitPerMonth
),
profitPerMonth
:
Math
.
abs
(
profitPerMonth
),
compoundPerMonth
:
compoundPerMonth
,
compoundPerMonth
:
compoundPerMonth
,
risk
:
risk
,
firstMaxAllocatedMoney
:
firstMaxAllocatedMoney
,
maxAllocatedMoney
:
maxAllocatedMoney
,
maxAllocatedMoney
:
maxAllocatedMoney
,
avgAllocatedMoney
:
maxAllocatedMoney
/
total
,
avgAllocatedMoney
:
maxAllocatedMoney
/
total
,
drawDown
:
drawDown
,
drawDown
:
drawDown
,
CompoundPerMonthDrawDown
:
compoundPerMonth
/
drawDown
,
CompoundPerMonthDrawDown
:
compoundPerMonth
/
drawDown
,
...
...
csv.js
View file @
0a8bca4c
...
@@ -6,7 +6,7 @@ let moment = require('moment-timezone')
...
@@ -6,7 +6,7 @@ let moment = require('moment-timezone')
let
ai
=
require
(
'
./ai
'
)
let
ai
=
require
(
'
./ai
'
)
async
function
parse
(
directory
,
name
,
configs
)
{
async
function
parse
(
directory
,
name
,
configs
,
risk
)
{
return
new
Promise
(
function
(
resolve
,
reject
)
{
return
new
Promise
(
function
(
resolve
,
reject
)
{
let
arr
=
[]
let
arr
=
[]
// console.log(name)
// console.log(name)
...
@@ -14,12 +14,12 @@ async function parse(directory,name, configs) {
...
@@ -14,12 +14,12 @@ async function parse(directory,name, configs) {
.
pipe
(
csv
.
parse
({
headers
:
true
}))
.
pipe
(
csv
.
parse
({
headers
:
true
}))
.
on
(
'
error
'
,
error
=>
reject
(
error
))
.
on
(
'
error
'
,
error
=>
reject
(
error
))
.
on
(
'
data
'
,
row
=>
arr
.
push
(
row
))
.
on
(
'
data
'
,
row
=>
arr
.
push
(
row
))
.
on
(
'
end
'
,
rowCount
=>
resolve
(
initData
(
arr
,
configs
,
name
)));
.
on
(
'
end
'
,
rowCount
=>
resolve
(
initData
(
arr
,
configs
,
name
,
risk
)));
});
});
}
}
function
initData
(
data
,
config
,
name
)
{
function
initData
(
data
,
config
,
name
,
risk
)
{
data
=
JSON
.
stringify
(
data
)
data
=
JSON
.
stringify
(
data
)
...
@@ -106,7 +106,7 @@ function initData(data, config, name) {
...
@@ -106,7 +106,7 @@ function initData(data, config, name) {
let
cz
=
[]
let
cz
=
[]
for
(
let
i
=
0
;
i
<
config
.
length
;
i
++
)
{
for
(
let
i
=
0
;
i
<
config
.
length
;
i
++
)
{
cz
.
push
(
ai
.
run
(
arr
,
config
[
i
]))
cz
.
push
(
ai
.
run
(
arr
,
config
[
i
]
,
risk
))
}
}
return
cz
return
cz
...
...
generate.js
View file @
0a8bca4c
...
@@ -20,7 +20,7 @@ run()
...
@@ -20,7 +20,7 @@ run()
async
function
run
()
async
function
run
()
{
{
let
obj
=
{
sort
:
'
profitPerMonthDrawDown
'
,
alocatedReserve
:
3
,
alocatedReserveCompound
:
3
}
let
obj
=
{
sort
:
'
profitPerMonthDrawDown
'
,
alocatedReserve
:
3
,
alocatedReserveCompound
:
3
,
risk
:
0
}
let
all
=
[]
let
all
=
[]
for
(
let
i
=
0
;
i
<
arr
.
length
;
i
++
)
for
(
let
i
=
0
;
i
<
arr
.
length
;
i
++
)
all
.
push
(
add
(
arr
[
i
]))
all
.
push
(
add
(
arr
[
i
]))
...
...
run.js
View file @
0a8bca4c
...
@@ -19,7 +19,7 @@ async function run() {
...
@@ -19,7 +19,7 @@ async function run() {
for
(
let
i
=
0
;
i
<
files
.
length
;
i
++
)
for
(
let
i
=
0
;
i
<
files
.
length
;
i
++
)
if
(
files
[
i
].
includes
(
'
.csv
'
))
{
if
(
files
[
i
].
includes
(
'
.csv
'
))
{
csvFile
=
files
[
i
]
csvFile
=
files
[
i
]
arr
.
push
(
csv
.
parse
(
directory
,
files
[
i
],
configs
.
data
))
arr
.
push
(
csv
.
parse
(
directory
,
files
[
i
],
configs
.
data
,
configs
.
risk
))
}
}
arr
=
await
Promise
.
all
(
arr
)
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