Commit 3cb22307 authored by Ahmad Nemati's avatar Ahmad Nemati

git pull

parent e137ad6e
var cors = require('cors') var cors = require('cors')
let express = require('express'); let express = require('express');
let moment = require('moment-timezone')
let app = express(); let app = express();
...@@ -29,9 +30,52 @@ app.post('/signal', (req, res) => { ...@@ -29,9 +30,52 @@ app.post('/signal', (req, res) => {
res.send('Done') res.send('Done')
console.log(req.body) 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) => { app.get('/', (req, res) => {
res.send('Done') res.send('Done')
...@@ -41,6 +85,10 @@ app.get('/', (req, res) => { ...@@ -41,6 +85,10 @@ app.get('/', (req, res) => {
}) })
function getPercent(basePrice, value) {
return ((value - basePrice) / basePrice) * 100
}
......
Ticket,Open_Time,Type,Symbol,Open_Price,Close_Price,Close_Time,dPrfPipWrtOpPrPc,dAgeHiPrfInPrPc_RunUpPc,dAgeLoPrfInPrPc_DrawDownPc
\ No newline at end of file
let t='last.json-220519074704_o1_bnc_btcusdt_lp4690_3btc7425192022.csv' let moment = require('moment-timezone')
let s=t.split('_') let t='BTCUSDTPERP,22529.7,22519.4,Long,5S,19,-10.4,PPST,1,1,1'
console.log(parseInt(s[s.length-1])) t=t.split(',')
\ No newline at end of file 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
...@@ -5,7 +5,7 @@ let moment=require('moment-timezone') ...@@ -5,7 +5,7 @@ let moment=require('moment-timezone')
test() test()
async function test() async function test()
{ {
console.log(moment.utc().format())
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment