Commit 09eb35b8 authored by Ahmad Nemati's avatar Ahmad Nemati

git pu

parent 328ab225
......@@ -4,13 +4,13 @@ let moment = require('moment-timezone')
run()
let adder = []
let root=''
let root = ''
async function run() {
let configs = await fs.readdirSync('last1000/')
root=configs[0]
configs= await fs.readdirSync('last1000/'+root+'/')
root = configs[0]
configs = await fs.readdirSync('last1000/' + root + '/')
let arr = []
let arrSide = []
......@@ -22,7 +22,7 @@ async function run() {
for (let i = 0; i < configs.length; i++) {
let config = await fs.readFileSync('./last1000/'+root+'/' + configs[i] + '/default/compound1000.json', 'utf8')
let config = await fs.readFileSync('./last1000/' + root + '/' + configs[i] + '/default/compound1000.json', 'utf8')
config = JSON.parse(config)
......@@ -30,7 +30,7 @@ async function run() {
total.push(config[j].total)
let dateString = config[j].dateString.split('_')
let runUpString = config[j].runupString.split('_')
let platfrom=config[j].platform.split('-')[1]
let platfrom = config[j].platform.split('-')[1]
let arrDate = []
for (let z = 0; z < dateString.length - 2; z++)
......@@ -43,21 +43,20 @@ async function run() {
countOfLong++
else
countOfshort++
let arrRunup = []
let arrRunup = []
for (let z = 0; z < runUpString.length - 2; z++)
arrRunup.push(parseFloat(runUpString[z]))
// console.log(arrRunup)
arrRunup=_.orderBy(arrRunup)
// console.log(arrRunup)
arrRunup = _.orderBy(arrRunup)
add(config[j].total, arrDate, config[j].type.split('targetPercentage:false')[1])
addShortLong(config[j].total, countOfshort, countOfLong)
addPoftrade(config[j].total, config[j].pftrade)
addRunup(config[j].total, arrRunup[0],arrRunup[arrRunup.length-1])
addPlatform(config[j].total,platfrom)
addRunup(config[j].total, arrRunup[0], arrRunup[arrRunup.length - 1])
addPlatform(config[j].total, platfrom)
}
......@@ -76,7 +75,7 @@ async function run() {
for (let i = 0; i < adder.length; i++) {
for (let z = i + 1; z < adder.length; z++) {
addRunup(adder[i].total, adder[z].minRunup,adder[z].maxRunup)
addRunup(adder[i].total, adder[z].minRunup, adder[z].maxRunup)
}
}
......@@ -119,8 +118,6 @@ async function run() {
}
for (let i = 0; i < adder.length; i++) {
adder[i].dates = _.uniq(adder[i].dates)
adder[i].dates = _.orderBy(adder[i].dates)
......@@ -129,29 +126,27 @@ async function run() {
for (let i = 0; i < adder.length; i++) {
adder[i].type = _.uniq(adder[i].type)
adder[i].type = _.orderBy(adder[i].type)
adder[i].countOfType=adder[i].type.length
adder[i].AllPlatfrom=adder[i].platfrom
adder[i].AllPlatfrom=_.uniq(adder[i].AllPlatfrom)
adder[i].platfrom=adder[i].platfrom.replace('R','')
adder[i].countOfType = adder[i].type.length
adder[i].AllPlatfrom = adder[i].platfrom
adder[i].AllPlatfrom = _.uniq(adder[i].AllPlatfrom)
for (let n = 0; n < adder[i].platfrom.length; n++)
adder[i].platfrom[n] = adder[i].platfrom[n].replace('R', '')
adder[i].platfrom = _.uniq(adder[i].platfrom)
adder[i].countOfPlatform=adder[i].platfrom.length
// delete adder[i].platfrom
adder[i].countOfPlatform = adder[i].platfrom.length
// delete adder[i].platfrom
adder[i].pfTrade = _.orderBy(adder[i].pfTrade)
let temp=[]
let temp = []
temp.push(adder[i].pfTrade[0])
temp.push(adder[i].pfTrade[adder[i].pfTrade.length-1])
adder[i].pfTrade=temp
temp.push(adder[i].pfTrade[adder[i].pfTrade.length - 1])
adder[i].pfTrade = temp
// adder[i].runUp = _.orderBy(adder[i].runUp)
// adder[i].runUp = _.orderBy(adder[i].runUp)
}
for (let i = 0; i < adder.length; i++) {
let dates = adder[i].dates
let maxDiff = 0
......@@ -181,8 +176,8 @@ async function run() {
}
createPlatfileADV(JSON.stringify(adder, null, 2))
for (let i = 0; i < adder.length; i++) {
adder[i].platfrom=adder[i].platfrom.replace('R','')
delete adder[i].platfrom
adder[i].platfrom = adder[i].platfrom.replace('R', '')
delete adder[i].platfrom
}
......@@ -190,7 +185,6 @@ async function run() {
console.log(adder)
createConfileADV(JSON.stringify(adder, null, 2))
......@@ -216,7 +210,18 @@ function add(total, dates, type) {
if (found)
return
adder.push({total: total, dates: dates, countDay: dates.length, type: [type], pfTrade: [],short:0,long:0,minRunup:100,maxRunup:0,platfrom:[]})
adder.push({
total: total,
dates: dates,
countDay: dates.length,
type: [type],
pfTrade: [],
short: 0,
long: 0,
minRunup: 100,
maxRunup: 0,
platfrom: []
})
}
......@@ -225,8 +230,8 @@ function addShortLong(total, short, long) {
for (let i = 0; i < adder.length; i++)
if (adder[i].total === total) {
adder[i].short =adder[i].short+ short
adder[i].long =adder[i].long+ long
adder[i].short = adder[i].short + short
adder[i].long = adder[i].long + long
}
}
......@@ -248,15 +253,15 @@ function addPlatform(total, platform) {
}
}
function addRunup(total, minRunup,maxRunup) {
function addRunup(total, minRunup, maxRunup) {
for (let i = 0; i < adder.length; i++)
if (adder[i].total === total) {
if (adder[i].minRunup > minRunup)
adder[i].minRunup=minRunup
adder[i].minRunup = minRunup
if ( maxRunup>adder[i].maxRunup)
adder[i].maxRunup=maxRunup
if (maxRunup > adder[i].maxRunup)
adder[i].maxRunup = maxRunup
}
......
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