Commit da853f7d authored by Ahmad Nemati's avatar Ahmad Nemati

git pull

parent a6abdb39
let moment = require('moment-timezone')
console.log('BTCUSDTPERP,21626.9,20927.8,Short,10,937.3,-122.5,SOTT,100,100,0.1,12')
console.log(analyse('BTCUSDTPERP,21626.9,20927.8,Short,10,937.3,-122.5,SOTT,100,100,0.1,12'))
async 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)
if (obj.side ==='Short' )
obj.profit=obj.profit*-1
// console.log(obj.entry,obj.exit)
// console.log(obj.profit)
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'
obj.side = 'Buy'
} else {
final = final + 'Sell'
obj.side = 'Sell'
}
final = final + ',BTCUSDT,'
final = final + obj.entry + ',' + obj.exit + ',' + obj.closeTime + ',' + obj.profit + ',' + obj.runUp + ',' + obj.drawDown
indicator = indicator.replace('Kelt', 'btc4').replace('SOTT', 'btc3').replace('Pmax', 'btc2').replace('PPST', 'btc1').replace('.csv', '')
// appendCsv(final, indicator)
// appendCsvtoMain(final,indicator)
// updateVars(indicator,final)
console.log(final)
}
function getPercent(basePrice, value) {
return ((value - basePrice) / basePrice) * 100
}
\ No newline at end of file
......@@ -65,6 +65,8 @@ async function analyse(body) {
obj.runUp = parseFloat(t[5])
obj.drawDown = parseFloat(t[6])
obj.profit = getPercent(obj.entry, obj.exit)
if (obj.side ==='Short' )
obj.profit=obj.profit*-1
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'
......@@ -87,11 +89,19 @@ async function analyse(body) {
final = final + ',BTCUSDT,'
final = final + obj.entry + ',' + obj.exit + ',' + obj.closeTime + ',' + obj.profit + ',' + obj.runUp + ',' + obj.drawDown
appendCsv(final, indicator)
indicator = indicator.replace('Kelt', 'btc4').replace('SOTT', 'btc3').replace('Pmax', 'btc2').replace('PPST', 'btc1').replace('.csv', '')
// appendCsv(final, indicator)
appendCsvtoMain(final,indicator)
updateVars(indicator,final)
// appendCsvtoMain(final,indicator)
// updateVars(indicator,final)
}
function appendCsv(data, name) {
fs.appendFile('temp/' + name + '.csv', data + '\n', function (err) {
if (err) throw err;
});
}
async function appendCsvtoMain(data, config) {
......
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