Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
A
ai
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
ai
Commits
3cb22307
Commit
3cb22307
authored
Jul 21, 2022
by
Ahmad Nemati
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
git pull
parent
e137ad6e
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
93 additions
and
4 deletions
+93
-4
router.js
router.js
+48
-0
temp.csv
temp.csv
+1
-0
test_json2.js
test_json2.js
+43
-3
test_moment.js
test_moment.js
+1
-1
No files found.
router.js
View file @
3cb22307
var
cors
=
require
(
'
cors
'
)
let
express
=
require
(
'
express
'
);
let
moment
=
require
(
'
moment-timezone
'
)
let
app
=
express
();
...
...
@@ -29,9 +30,52 @@ app.post('/signal', (req, res) => {
res
.
send
(
'
Done
'
)
console
.
log
(
req
.
body
)
analyse
(
req
.
body
)
})
function
analyse
(
body
)
{
let
t
=
body
.
split
(
'
,
'
)
let
obj
=
{}
obj
.
symbol
=
t
[
0
]
obj
.
entry
=
parseFloat
(
t
[
1
])
obj
.
exit
=
parseFloat
(
t
[
2
])
obj
.
side
=
t
[
3
]
obj
.
timeframe
=
t
[
4
]
obj
.
runUp
=
parseFloat
(
t
[
5
])
obj
.
drawDown
=
parseFloat
(
t
[
6
])
obj
.
profit
=
getPercent
(
obj
.
entry
,
obj
.
exit
)
obj
.
runUp
=
getPercent
(
obj
.
entry
,(
obj
.
runUp
+
obj
.
entry
))
obj
.
drawDown
=
getPercent
(
obj
.
entry
,(
obj
.
drawDown
+
obj
.
entry
))
obj
.
closeTime
=
moment
().
utc
().
format
(
'
YYYY.MM.DD HH:mm
'
)
+
'
:00.000
'
let
indicator
=
''
for
(
let
i
=
7
;
i
<
t
.
length
;
i
++
)
{
indicator
=
indicator
+
t
[
i
]
if
(
i
!==
t
.
length
-
1
)
indicator
=
indicator
+
'
_
'
}
//Ticket,Open_Time,Type,Symbol,Open_Price,Close_Price,Close_Time,dPrfPipWrtOpPrPc,dAgeHiPrfInPrPc_RunUpPc,dAgeLoPrfInPrPc_DrawDownPc
let
final
=
'
0,00:00,
'
if
(
obj
.
side
===
'
Long
'
)
final
=
final
+
'
Buy
'
else
final
=
final
+
'
Sell
'
final
=
final
+
'
,
'
final
=
final
+
obj
.
entry
+
'
,
'
+
obj
.
exit
+
'
,
'
+
obj
.
closeTime
+
'
,
'
+
obj
.
profit
+
'
,
'
+
obj
.
runUp
+
'
,
'
+
obj
.
drawDown
appendCsv
(
final
)
}
function
appendCsv
(
data
)
{
fs
.
appendFile
(
'
temp.csv
'
,
log
+
'
\n
'
,
function
(
err
)
{
if
(
err
)
throw
err
;
});
}
app
.
get
(
'
/
'
,
(
req
,
res
)
=>
{
res
.
send
(
'
Done
'
)
...
...
@@ -41,6 +85,10 @@ app.get('/', (req, res) => {
})
function
getPercent
(
basePrice
,
value
)
{
return
((
value
-
basePrice
)
/
basePrice
)
*
100
}
...
...
temp.csv
0 → 100644
View file @
3cb22307
Ticket,Open_Time,Type,Symbol,Open_Price,Close_Price,Close_Time,dPrfPipWrtOpPrPc,dAgeHiPrfInPrPc_RunUpPc,dAgeLoPrfInPrPc_DrawDownPc
\ No newline at end of file
test_json2.js
View file @
3cb22307
let
t
=
'
last.json-220519074704_o1_bnc_btcusdt_lp4690_3btc7425192022.csv
'
let
s
=
t
.
split
(
'
_
'
)
console
.
log
(
parseInt
(
s
[
s
.
length
-
1
]))
\ No newline at end of file
let
moment
=
require
(
'
moment-timezone
'
)
let
t
=
'
BTCUSDTPERP,22529.7,22519.4,Long,5S,19,-10.4,PPST,1,1,1
'
t
=
t
.
split
(
'
,
'
)
let
obj
=
{}
obj
.
symbol
=
t
[
0
]
obj
.
entry
=
parseFloat
(
t
[
1
])
obj
.
exit
=
parseFloat
(
t
[
2
])
obj
.
side
=
t
[
3
]
obj
.
timeframe
=
t
[
4
]
obj
.
runUp
=
parseFloat
(
t
[
5
])
obj
.
drawDown
=
parseFloat
(
t
[
6
])
obj
.
profit
=
getPercent
(
obj
.
entry
,
obj
.
exit
)
obj
.
runUp
=
getPercent
(
obj
.
entry
,(
obj
.
runUp
+
obj
.
entry
))
obj
.
drawDown
=
getPercent
(
obj
.
entry
,(
obj
.
drawDown
+
obj
.
entry
))
obj
.
closeTime
=
moment
().
utc
().
format
(
'
YYYY.MM.DD HH:mm
'
)
+
'
:00.000
'
let
indicator
=
''
for
(
let
i
=
7
;
i
<
t
.
length
;
i
++
)
{
indicator
=
indicator
+
t
[
i
]
if
(
i
!==
t
.
length
-
1
)
indicator
=
indicator
+
'
_
'
}
//Ticket,Open_Time,Type,Symbol,Open_Price,Close_Price,Close_Time,dPrfPipWrtOpPrPc,dAgeHiPrfInPrPc_RunUpPc,dAgeLoPrfInPrPc_DrawDownPc
let
final
=
'
0,00:00,
'
if
(
obj
.
side
===
'
Long
'
)
final
=
final
+
'
Buy
'
else
final
=
final
+
'
Sell
'
final
=
final
+
'
,
'
final
=
final
+
obj
.
entry
+
'
,
'
+
obj
.
exit
+
'
,
'
+
obj
.
closeTime
+
'
,
'
+
obj
.
profit
+
'
,
'
+
obj
.
runUp
+
'
,
'
+
obj
.
drawDown
console
.
log
(
final
)
//console.log(obj)
function
getPercent
(
basePrice
,
value
)
{
return
((
value
-
basePrice
)
/
basePrice
)
*
100
}
\ No newline at end of file
test_moment.js
View file @
3cb22307
...
...
@@ -5,7 +5,7 @@ let moment=require('moment-timezone')
test
()
async
function
test
()
{
console
.
log
(
moment
.
utc
().
format
())
}
...
...
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