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

git pu

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