Commit 1c293c51 authored by Ahmad Nemati's avatar Ahmad Nemati

git pu

parent c9151111
......@@ -2,7 +2,6 @@ const fs = require('fs')
let moment = require('moment-timezone')
async function init() {
try {
await fs.mkdirSync('files')
......@@ -11,30 +10,33 @@ async function init() {
}
let files = await fs.readdirSync('files')
let arr=[]
let arr = []
for (let i = 0; i < files.length; i++) {
if (files[i].includes('R'))
continue
let isFound = haveReverse(files[i], files)
if (!isFound)
arr.push(files[i])
}
files=arr
files = arr
let prom = []
let num=50
let num = 50
for (let i = 0; i < files.length; i=i+10) {
for (let i = 0; i < files.length; i = i + 10) {
if (files[i].includes('.csv')) {
try {
format(files[i])
format(files[i+1])
format(files[i+2])
format(files[i+3])
format(files[i+4])
format(files[i+5])
format(files[i+6])
format(files[i+7])
format(files[i+8])
await format(files[i+9])
format(files[i + 1])
format(files[i + 2])
format(files[i + 3])
format(files[i + 4])
format(files[i + 5])
format(files[i + 6])
format(files[i + 7])
format(files[i + 8])
await format(files[i + 9])
} catch (e) {
......@@ -49,6 +51,15 @@ let arr=[]
}
function haveReverse(name, arr) {
for (let i = 0; i < arr.length; i++)
if ('R' + name === arr[i])
return true
return false
}
async function format(name) {
let res = await fs.readFileSync('./files/' + name, 'utf8');
......@@ -58,7 +69,7 @@ async function format(name) {
// }
let header = 'Ticket,Open_Time,Type,Symbol,Open_Price,Close_Price,Close_Time,dPrfPipWrtOpPrPc,dAgeHiPrfInPrPc_RunUpPc,dAgeLoPrfInPrPc_DrawDownPc\n'
// res[0] = header
let t=''
let t = ''
for (let i = 1; i < res.length; i++) {
res[i] = res[i].replace('\r', '')
......@@ -68,38 +79,35 @@ async function format(name) {
if (typeof side === "undefined")
continue
if (side ==='Buy')
temp[2]='Sell'
if (side === 'Buy')
temp[2] = 'Sell'
else
temp[2]='Buy'
let profit=parseFloat(temp[7])
let runUp=parseFloat(temp[8])
let drawDown=parseFloat(temp[9])
temp[2] = 'Buy'
let profit = parseFloat(temp[7])
let runUp = parseFloat(temp[8])
let drawDown = parseFloat(temp[9])
temp[7]=profit*-1
temp[8]=drawDown*-1
temp[9]=runUp*-1
for (let z=0;z<temp.length;z++)
{
t=t+temp[z]
if (z !== temp.length-1)
t=t+','
temp[7] = profit * -1
temp[8] = drawDown * -1
temp[9] = runUp * -1
for (let z = 0; z < temp.length; z++) {
t = t + temp[z]
if (z !== temp.length - 1)
t = t + ','
}
t=t+'\n'
t = t + '\n'
}
let z=header
z=z+t
let z = header
z = z + t
console.log(z)
await createFile('R'+name, z)
await createFile('R' + name, z)
}
......@@ -113,9 +121,6 @@ function createFile(name, body) {
}
module.exports =
{
......
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