Commit 5970e787 authored by Ahmad Nemati's avatar Ahmad Nemati

git pull

parent 4e7ee58e
const fs = require('fs')
let moment = require('moment-timezone')
let _ = require('lodash')
const uuid=require('uniqid')
let pairs=''
let res
const uuid = require('uniqid')
let pairs = ''
let res2
let res3
let res4
init()
......@@ -12,59 +15,66 @@ async function init() {
// res = await fs.readFileSync('run.csv', 'utf8');
// res = res.split('\n')
res2 = await fs.readFileSync('run2.csv', 'utf8');
res2 = res2.split('\n')
res3 = await fs.readFileSync('run3.csv', 'utf8');
res3 = res3.split('\n')
res4 = await fs.readFileSync('run4.csv', 'utf8');
res4 = res4.split('\n')
let arr = []
// console.log(found('ETH', 'Lp2'))
let com = await fs.readFileSync('com.json', 'utf8');
com = JSON.parse(com)
for (let i=0;i<com.length;i++)
{
com[i].platform=com[i].platform.toLowerCase()
for (let i = 0; i < com.length; i++) {
com[i].platform = com[i].platform.toLowerCase()
let t = com[i].platform
t = t.split('_')
let pair = t[3].replace('usdt', '').replace('usd', '')
let lp = t[4].replace('lp','Lp')
com[i].lp=lp
let p=t[t.length-1].split('.')
p=p[0].split(pair)[0]
let lp = t[4].replace('lp', 'Lp')
com[i].lp = lp
let p = t[t.length - 1].split('.')
p = p[0].split(pair)[0]
let uniq=pair+lp+p+capital(com[i].type.split(' ')[5])+parseFloat(com[i].type.split(' ')[6])*-10
let uniq = pair + lp + p + capital(com[i].type.split(' ')[5]) + parseFloat(com[i].type.split(' ')[6]) * -10
com[i].uniq=uniq+'_'+com[i].avgRunup+'_'+com[i].avgDrawdown+'_'+com[i].type.split(' ')[5]+'_'+(parseFloat(com[i].type.split(' ')[6])*-1)
com[i].uniq = uniq + '_' + com[i].avgRunup + '_' + com[i].avgDrawdown + '_' + com[i].type.split(' ')[5] + '_' + (parseFloat(com[i].type.split(' ')[6]) * -1)
}
com=_.uniqBy(com, 'lp');
let newCom=[]
for (let i=0;i<com.length;i++)
{
com = _.uniqBy(com, 'lp');
let newCom = []
for (let i = 0; i < com.length; i++) {
newCom.push(com[i])
}
com=newCom
com = newCom
createComResfileADV(JSON.stringify(com, null, 2))
// for (let i = 0; i < com.length; i++) {
// let t = com[i].platform
// t = t.split('_')
//
//
// let pair = t[3].replace('usdt', '').replace('usd', '')
// pairs=pair
// let p=t[t.length-1].split('.')
// p=p[0].split(pairs)[0]
// let lp = t[4].replace('lp','Lp')
// let f=found(pair, lp)
// f.period=p
// f.uniq=com[i].uniq
// arr.push(f)
// }
// arr=_.uniqBy(arr, 'name');
//
for (let i = 0; i < com.length; i++) {
let t = com[i].platform
t = t.split('_')
let indicator = parseInt(t[t.length - 1])
let pair = t[3].replace('usdt', '').replace('usd', '')
pairs = pair
let p = t[t.length - 1].split('.')
p = p[0].split(pairs)[0]
let lp = t[4].replace('lp', 'Lp')
let f = found(pair, lp)
f.period = p
f.uniq = com[i].uniq
console.log(com[i].platform, f.timeframe)
arr.push(f)
}
arr = _.uniqBy(arr, 'name');
// let header='RowNum,PPST1_stMnBarAge,PPST1_PvtPtPeriod,PPST1_AtrFactor,PPST1_AtrPeriod,szOmIdName\n'
// for (let i=0;i<arr.length;i++)
// {
......@@ -75,21 +85,21 @@ async function init() {
// header= header+'\n'
//
// }
//
// createRunResfileADV(header)
}
function isUpper(str) {
return !/[a-z]/.test(str) && /[A-Z]/.test(str);
}
function capital(t)
{
let f=''
for (let j=0;j<t.length;j++)
function capital(t) {
let f = ''
for (let j = 0; j < t.length; j++)
if (isUpper(t[j]))
f=f+t[j]
f = f + t[j]
return f
}
......@@ -97,7 +107,7 @@ function capital(t)
function createRunResfileADV(data) {
// console.log(data)
return new Promise(function (resolve, reject) {
fs.writeFile(pairs+'_TOP.csv', data, 'utf8', function (err) {
fs.writeFile(pairs + '_TOP.csv', data, 'utf8', function (err) {
if (err) reject(err);
else resolve(data);
});
......@@ -107,14 +117,21 @@ function createRunResfileADV(data) {
function createComResfileADV(data) {
// console.log(data)
return new Promise(function (resolve, reject) {
fs.writeFile(pairs+'newCom.json', data, 'utf8', function (err) {
fs.writeFile(pairs + 'newCom.json', data, 'utf8', function (err) {
if (err) reject(err);
else resolve(data);
});
});
}
function found(pair, lp) {
function found(indicator,pair, lp) {
let res=[]
if (indicator ===2)
res=res2
else if (indicator ===3)
res=res3
else if (indicator ===4)
res =res4
for (let i = 0; i < res.length; i++) {
if (!res[i].includes(lp + '_'))
continue
......@@ -122,22 +139,23 @@ function found(pair, lp) {
let d = res[i].split(',')
let timeframe = d[13]
timeframe=timeframe.split(' ')
let newTimeframe='0d '
for (let z=1;z<timeframe.length;z++)
{
newTimeframe=newTimeframe+timeframe[z]
if (z !== timeframe.length-1)
newTimeframe=newTimeframe+' '
}
timeframe=newTimeframe
let nStochPeriod=parseFloat(d[15])
let nStochSmoothingPeriod=parseFloat(d[16])
let dOttPercent=parseFloat(d[18])
let name = d[92]
return {name, timeframe, nStochPeriod, nStochSmoothingPeriod, dOttPercent}
// timeframe=timeframe.split(' ')
// let newTimeframe='0d '
// for (let z=1;z<timeframe.length;z++)
// {
// newTimeframe=newTimeframe+timeframe[z]
// if (z !== timeframe.length-1)
// newTimeframe=newTimeframe+' '
// }
// timeframe=newTimeframe
// let nStochPeriod=parseFloat(d[15])
// let nStochSmoothingPeriod=parseFloat(d[16])
// let dOttPercent=parseFloat(d[18])
//
// let name = d[92]
// return {name, timeframe, nStochPeriod, nStochSmoothingPeriod, dOttPercent}
return timeframe
}
}
......
let t='220601111131_O1_ETHUSDT_Lp92_ethLp45101RZDD5_6.332963350785343_-2.4975497382198952_RunupZeroDrawDown_0.5_0.096_ETH'
t=t.split('_')
let pair=t[t.length-1]
console.log(pair)
\ No newline at end of file
let t='last.json-220519074704_o1_bnc_btcusdt_lp4690_3btc7425192022.csv'
let s=t.split('_')
console.log(parseInt(s[s.length-1]))
\ No newline at end of file
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