Commit 5fe8d1fe authored by Ahmad Nemati's avatar Ahmad Nemati

git pull

parent 26d2e525
......@@ -42,7 +42,7 @@ async function init() {
//
}
console.log(JSON.stringify(files))
// console.log(JSON.stringify(files))
}
......
let fs = require('fs')
var cors = require('cors')
const _=require('lodash')
const _ = require('lodash')
let express = require('express');
let moment = require('moment-timezone')
let app = express();
let files=[]
var bodyParser = require('body-parser')
......@@ -13,7 +13,7 @@ let server = require('http').createServer(app);
let port = 80;
init()
app.use(cors())
app.use(bodyParser.text());
......@@ -24,6 +24,9 @@ server.listen(port, () => {
})
app.post('/signal', (req, res) => {
res.send('Done')
......@@ -35,6 +38,13 @@ app.post('/signal', (req, res) => {
})
async function init()
{
files = await fs.readdirSync('E:\\YashilFinal')
}
async function analyse(body) {
let t = body.split(',')
let obj = {}
......@@ -60,11 +70,10 @@ async function analyse(body) {
let final = '0,00:00,'
if (obj.side === 'Long') {
final = final + 'Buy'
obj.side='Buy'
}
else {
obj.side = 'Buy'
} else {
final = final + 'Sell'
obj.side='Sell'
obj.side = 'Sell'
}
final = final + ','
......@@ -74,6 +83,7 @@ async function analyse(body) {
// console.log('try Check ',obj.side,file[file.length - 1])
// if (file.length > 2 && !file[file.length - 1].includes(obj.side))
appendCsv(final, indicator)
appendCsvtoMain(final,indicator)
}
function appendCsv(data, name) {
......@@ -83,6 +93,29 @@ function appendCsv(data, name) {
});
}
async function appendCsvtoMain(data, config) {
config = config.replace('Kelt', 'btc4').replace('SOTT', 'btc3').replace('Pmax', 'btc2').replace('PPST', 'btc1').replace('.csv', '')
for (let i = 0; i < files.length; i++) {
if (files[i].startsWith(config + '_')) {
appendtoFile(files[i],data)
}
}
}
function appendtoFile(name,data)
{
fs.appendFile('E:\\YashilFinal\\'+name, data + '\n', function (err) {
if (err) throw err;
});
}
app.get('/', (req, res) => {
res.send('Done')
......
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