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

git pu

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