Commit cf2893fe authored by Ahmad Nemati's avatar Ahmad Nemati

git pull

parent 07aa862f
const fs = require('fs')
let moment = require('moment-timezone')
let _ = require('lodash')
const uuid=require('uniqid')
let pairs=''
let res
init()
async function init() {
res = await fs.readFileSync('run.csv', 'utf8');
res = res.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()
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 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=_.uniqBy(com, 'lp');
let newCom=[]
for (let i=0;i<com.length;i++)
{
newCom.push(com[i])
}
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');
//
// let header='RowNum,PPST1_stMnBarAge,PPST1_PvtPtPeriod,PPST1_AtrFactor,PPST1_AtrPeriod,szOmIdName\n'
// for (let i=0;i<arr.length;i++)
// {
// let qty=(i+5)*0.001
// let inline=(i+1)+','+arr[i].timeframe+','+arr[i].pvt+','+arr[i].factor+','+arr[i].period+','+arr[i].uniq+'_'+qty
// header=header+inline
// if (i !== arr.length-1)
// 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++)
if (isUpper(t[j]))
f=f+t[j]
return f
}
function createRunResfileADV(data) {
// console.log(data)
return new Promise(function (resolve, reject) {
fs.writeFile(pairs+'_TOP.csv', data, 'utf8', function (err) {
if (err) reject(err);
else resolve(data);
});
});
}
function createComResfileADV(data) {
// console.log(data)
return new Promise(function (resolve, reject) {
fs.writeFile(pairs+'newCom.json', data, 'utf8', function (err) {
if (err) reject(err);
else resolve(data);
});
});
}
function found(pair, lp) {
for (let i = 0; i < res.length; i++) {
if (!res[i].includes(lp + '_'))
continue
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}
}
}
let _ = require('lodash')
let fs = require('fs')
//
// let t='Num.,OpClOrds,MaxTotOpOrdNo,MaxEffOpLot,prfpDmddp,MddInPc,PrfInPc,PrfVal,InvprfpDmddp,InvMddInPc,InvPrfInPc,InvPrfVal,AnyDirPrf,PPST1_stMnBarAge,PPST1_PvtPtPeriod,PPST1_AtrFactor,PPST1_AtrPeriod,PPST2_stMnBarAge,PPST2_PvtPtPeriod,PPST2_AtrFactor,PPST2_AtrPeriod,nEntSignalCodeNum,3crm_nStopLoss_AtrPeriod,3crm_dStopLoss_AtrRiskAdjustmentCoef,3crm_nStopLoss_SwingLookbackBarNo,3crm_bUseTrailingStopLoss,3crm_enumTrailSlRef,3crm_dTrailSlAtrMultiplier,3crm_bUseTpPr,3crm_dTpSlRewardToRiskRatio,3crm_dRrToStartTrailSl,m_nToUseSym0MinSpreadPip,nInitTpPip_Sym1_Tgt1,nInitSlPip_Sym1_Tgt1,stMnRefHopAge,nAllTmMktTrEntNum,nAftLkbkTmMktTrEntNum,dToClAllSsAndRestartImd_ReqEqIncPc,SimCp1_dToClAllSsAndRestartImd_ReqEqIncPc,nByReqEgIncPcClAllSsNum,PrfPips_BestTpSl,Tp_BestTpSl,Sl_BestTpSl,InvPrfPips_BestTpSl,Tp_InvBestTpSl,Sl_InvBestTpSl, dTkSimStEquityUsd,bUpDirEntEnabled,bDnDirEntEnabled,dFixedOrdLot,dRiskPercentForLot,nMaxAnyDirOrdNo,nMaxOneDirOrdNo,nTkSimOrdExecHaltAgeMsecNo,bUseOrdExecHaltAgeForOrdClosing,bInverseEntSig,bClOppDirOrds,TotOpClLot,TotOpB_ClLot,TotOpS_ClLot,ProcTickNo,RealSsNo,PrfRealSsNo,LssRealSsNo,PotSsCnt,OpB_ClNo,OpS_ClNo,hOrds,MaxOpBuyyLots,MaxOpBuyyLots_Fr,MaxOpBuyyLots_To,MaxOpSellLots,MaxOpSellLots_Fr,MaxOpSellLots_To,MaxTotAccsEq,MaxTotAccsEq_MinusStEq,MaxTotAccsEq_Fr,MaxTotAccsEq_To,MinTotAccsEq,MinTotAccsEq_MinusStEq,MinTotAccsEq_Fr,MinTotAccsEq_To,MaxTotOpOrdNo_Fr,MaxTotOpOrdNo_To,MaxEffOpLot_Fr,MaxEffOpLot_To,MddInVal,StEq,Mdd_EqUto,Mdd_EqUto_mSt,Mdd_EqDto,Mdd_EqDto_mSt,MddTm_Fr,MddTm_To,InvMddInVal,StEq,InvMdd_EqUto,InvMdd_EqUto_mSt,InvMdd_EqDto,InvMdd_EqDto_mSt,InvMddTm_Fr,InvMddTm_To,dtTrLookBackStTime_Str,dtTrStTime_Str,dtTrEnTime_Str,SimRgAgeStr,SufxStr'
//
// t=t.split(',')
// for (let i=0;i<t.length;i++)
// console.log(i,t[i])
let t='Num.,OpClOrds,MaxTotOpOrdNo,MaxEffOpLot,prfpDmddp,MddInPc,PrfInPc,PrfVal,InvprfpDmddp,InvMddInPc,InvPrfInPc,InvPrfVal,AnyDirPrf,stMnBarAge,enumSrcType,nStochPeriod,nStochSmoothingPeriod,nOttPeriod,dOttPercent,nInitTpPip_Sym1_Tgt1,nInitSlPip_Sym1_Tgt1,stMnRefHopAge,nAllTmMktTrEntNum,nAftLkbkTmMktTrEntNum,dToClAllSsAndRestartImd_ReqEqIncPc,nByReqEgIncPcClAllSsNum,PrfPips_BestTpSl,Tp_BestTpSl,Sl_BestTpSl,InvPrfPips_BestTpSl,Tp_InvBestTpSl,Sl_InvBestTpSl, dTkSimStEquityUsd,bUpDirEntEnabled,bDnDirEntEnabled,dFixedOrdLot,dRiskPercentForLot,nMaxAnyDirOrdNo,nMaxOneDirOrdNo,nTkSimOrdExecHaltAgeMsecNo,bUseOrdExecHaltAgeForOrdClosing,bInverseEntSig,bClOppDirOrds,TotOpClLot,TotOpB_ClLot,TotOpS_ClLot,ProcTickNo,RealSsNo,PrfRealSsNo,LssRealSsNo,PotSsCnt,OpB_ClNo,OpS_ClNo,hOrds,MaxOpBuyyLots,MaxOpBuyyLots_Fr,MaxOpBuyyLots_To,MaxOpSellLots,MaxOpSellLots_Fr,MaxOpSellLots_To,MaxTotAccsEq,MaxTotAccsEq_MinusStEq,MaxTotAccsEq_Fr,MaxTotAccsEq_To,MinTotAccsEq,MinTotAccsEq_MinusStEq,MinTotAccsEq_Fr,MinTotAccsEq_To,MaxTotOpOrdNo_Fr,MaxTotOpOrdNo_To,MaxEffOpLot_Fr,MaxEffOpLot_To,MddInVal,StEq,Mdd_EqUto,Mdd_EqUto_mSt,Mdd_EqDto,Mdd_EqDto_mSt,MddTm_Fr,MddTm_To,InvMddInVal,StEq,InvMdd_EqUto,InvMdd_EqUto_mSt,InvMdd_EqDto,InvMdd_EqDto_mSt,InvMddTm_Fr,InvMddTm_To,dtTrLookBackStTime_Str,dtTrStTime_Str,dtTrEnTime_Str,SimRgAgeStr,SufxStr'
t=t.split(',')
for (let i=0;i<t.length;i++)
console.log(i,t[i])
// let t='BTCLp58071RZPDD5_Sell_2022.05.25 12:20'.replace(/_/g, '').replace(/Lp/g, '').replace(/BTC/g, '').replace(/ /g, '')
//
......@@ -71,26 +70,26 @@ let fs = require('fs')
// let arr=[]
// arr.push(t)
// arr.push(t)
console.log(JSON.stringify({bad:1}))
//test()
async function test()
{
let las = await fs.readFileSync('t.json', 'utf8');
las=JSON.parse(las)
let jj='['
for (let i=0;i<las.length;i++)
{
let sidee=las[i].sideString
sidee=sidee.replace(/LONG/g, 'L').replace(/SHORT/g, 'S')
let inline='{"closeDate":"'+las[i].closeDate+'","profitLossString":"'+las[i].profitLossString+'","sideString":"'+sidee+'"}'
if (i !==(las.length-1))
inline=inline+','
jj=jj+inline
}
jj=jj+']'
console.log(JSON.parse(jj))
}
// console.log(JSON.stringify({bad:1}))
//
// //test()
// async function test()
// {
// let las = await fs.readFileSync('t.json', 'utf8');
// las=JSON.parse(las)
// let jj='['
// for (let i=0;i<las.length;i++)
// {
// let sidee=las[i].sideString
// sidee=sidee.replace(/LONG/g, 'L').replace(/SHORT/g, 'S')
// let inline='{"closeDate":"'+las[i].closeDate+'","profitLossString":"'+las[i].profitLossString+'","sideString":"'+sidee+'"}'
// if (i !==(las.length-1))
// inline=inline+','
// jj=jj+inline
// }
// jj=jj+']'
// console.log(JSON.parse(jj))
// }
//
......
let fs=require('fs')
let _=require('lodash')
let moment=require('moment-timezone')
test()
async function test()
{
}
......@@ -5,12 +5,13 @@ const uuid = require('uniqid')
let pair = 'BNB'
let res
let arr = []
let lastBalance=5000
let size=50
let balance =lastBalance
let arrRange = []
let lastBalance = 1000
let size = 50
let balance = lastBalance
init()
let base=1
let base = 1
let com
......@@ -22,8 +23,8 @@ let dates = []
for (let i = 0; i < year.length; i++) {
for (let j = 0; j < month.length; j++) {
let t = year[i] + '-' + month[j]
if (!(t === '2017-01' || t === '2017-02' || t === '2017-03' || t === '2017-04' || t === '2017-05' || t === '2017-06' || t === '2017-07' || t === '2017-08'|| t === '2022-05' ||t === '2022-06' || t === '2022-07' || t === '2022-08' || t === '2022-09' || t === '2022-10' || t === '2022-11' || t === '2022-12'))
dates.push({date: t, profit: 0,count:0,longCount:0,shortCount:0,longProfit:0,shortProfit:0})
if (!(t === '2017-01' || t === '2017-02' || t === '2017-03' || t === '2017-04' || t === '2017-05' || t === '2017-06' || t === '2017-07' || t === '2017-08' || t === '2022-05' || t === '2022-06' || t === '2022-07' || t === '2022-08' || t === '2022-09' || t === '2022-10' || t === '2022-11' || t === '2022-12'))
dates.push({date: t, profit: 0, count: 0, longCount: 0, shortCount: 0, longProfit: 0, shortProfit: 0})
}
}
......@@ -33,48 +34,96 @@ for (let i = 0; i < year.length; i++) {
async function init() {
try {
await fs.mkdirSync('torob')
}
catch (e)
{
} catch (e) {
}
com = await fs.readFileSync('tor.json', 'utf8');
let bad = await fs.readFileSync('bad.txt', 'utf8');
bad=JSON.parse(bad)
let bad = await fs.readFileSync('bad.txt', 'utf8');
bad = JSON.parse(bad)
base=parseFloat(bad.bad)
// console.log(bad)
base = parseFloat(bad.bad)
// console.log(bad)
com = JSON.parse(com)
run()
}
// let d = await fs.readFileSync('range.csv', 'utf8')
// d = d.split('\n')
// d = _.reverse(d)
// let ranges = []
// for (let i = 0; i < d.length; i++)
// if (d[i].includes('Entry')) {
// ranges.push({
// date: d[i].split(',')[3],
// side: d[i].split(',')[1].replace('Entry Short', 'S').replace('Entry Long', 'L')
// })
// }
//
//
// for (let i = 0; i < ranges.length; i++) {
// arrRange.push(ranges[i])
//
// var start = moment(ranges[i].date);
// var finish
// try {
// finish = moment(ranges[i + 1].date);
// } catch (e) {
// // console.log(e)
// break
// }
//
//
// while (start.add(1, 'days').isBefore(finish)) {
// arrRange.push({date: start.clone().format('YYYY-MM-DD'), side: ranges[i].side});
// }
//
// }
//
// for (let i = 0; i < com.length; i++) {
// let openDate = com[i].dateString.split('_')
// let side = com[i].sideString.split('_')
// let s = ''
// for (let i = 0; i < openDate.length - 1; i++) {
// let statusOfDate = getStatusOfDate(openDate[i])
// if (typeof statusOfDate ==="undefined")
// s = s + 'SHORT' + '_'
// else if (statusOfDate === 'L' && side[i] === 'LONG')
// s = s + 'LONG' + '_'
// else if (statusOfDate === 'S' && side[i] === 'SHORT')
// s = s + 'SHORT' + '_'
// else
// s = s + 'N' + '_'
// }
// com[i].sideString = s
// }
async function lastCheck(param1,param2,param3,arr5) {
// console.log(arrRange)
let bad = await fs.readFileSync('bad.txt', 'utf8');
bad=JSON.parse(bad)
run()
base=parseFloat(bad.bad)
}
if (param3<base)
{
let z={maxReserve:param1,profit:param2,bad:param3}
// await createfileADV(JSON.stringify(z))
await createfileTorob(param3.toString(),JSON.stringify(arr5, null, 2))
}
function getStatusOfDate(date) {
for (let i = 0; i < arrRange.length; i++)
if (arrRange[i].date === date)
return arrRange[i].side
}
async function lastCheck(param1, param2, param3, arr5) {
let bad = await fs.readFileSync('bad.txt', 'utf8');
bad = JSON.parse(bad)
base = parseFloat(bad.bad)
if (param3 < base) {
let z = {maxReserve: param1, profit: param2, bad: param3}
// await createfileADV(JSON.stringify(z))
await createfileTorob(param3.toString(), JSON.stringify(arr5, null, 2))
}
}
......@@ -83,98 +132,107 @@ async function sleep(millis) {
return new Promise(resolve => setTimeout(resolve, millis));
}
async function run()
{
com=_.shuffle(com)
balance=lastBalance
arr=[]
async function run() {
com = _.shuffle(com)
balance = lastBalance
arr = []
for (let i = 0; i < size; i++) {
let closeDate = com[i].closeDate.split('_')
let profits = com[i].profitLossString.split('_')
let side = com[i].sideString.split('_')
for (let j = 0; j < closeDate.length - 1; j++)
add(closeDate[j], parseFloat(profits[j])-0.1,side[j])
if (side[j] !== 'N')
add(closeDate[j], parseFloat(profits[j]) - 0.1, side[j])
}
arr=_.orderBy(arr,['date'])
arr = _.orderBy(arr, ['date'])
for (let i=0;i<arr.length;i++)
{
balance=balance+arr[i].profit
arr[i].balance=balance
// for (let i = 0; i < arrRange.length; i++)
// resetProfit(arrRange[i])
for (let i = 0; i < arr.length; i++) {
balance = balance + arr[i].profit
arr[i].balance = balance
}
let arrNew=[]
let arrNew = []
for (let i = 0; i < arr.length; i++) {
let sums = 0
for (let j = i + 1; j < arr.length ; j++) {
for (let j = i + 1; j < arr.length; j++) {
sums = sums + parseFloat(arr[j].profit)
if (arrNew.length ===0)
arrNew.push({sum: sums, index: i,startDate:arr[i+1].date,date:arr[j].date})
else if (arrNew[arrNew.length-1].sum > sums)
arrNew.push({sum: sums, index: i,startDate:arr[i+1].date,date:arr[j].date})
if (arrNew.length === 0)
arrNew.push({sum: sums, index: i, startDate: arr[i + 1].date, date: arr[j].date})
else if (arrNew[arrNew.length - 1].sum > sums)
arrNew.push({sum: sums, index: i, startDate: arr[i + 1].date, date: arr[j].date})
}
}
arrNew = _.orderBy(arrNew, ['sum'])
// console.log(arrNew[0])
// console.log(arrNew)
for (let i=0;i<arr.length;i++)
// console.log(arrNew[0])
// console.log(arrNew)
for (let i = 0; i < arr.length; i++)
addDate(arr[i])
// dates=_.orderBy(dates,['profit'])
let arrDate=[]
// console.log(dates)
// for (let i=0;i<arr.length;i++)
// console.log(arr[i].date,arr[i].profit)
// dates=_.orderBy(dates,['profit'])
let arrDate = []
// console.log(dates)
// for (let i=0;i<arr.length;i++)
// console.log(arr[i].date,arr[i].profit)
for (let i = 0; i < dates.length; i++) {
let sums = 0
for (let j = i + 1; j < dates.length ; j++) {
for (let j = i + 1; j < dates.length; j++) {
sums = sums + parseFloat(dates[j].profit)
if (arrDate.length ===0)
arrDate.push({sum: sums, index: i,startDate:dates[i+1].date,date:dates[j].date})
else if (arrDate[arrDate.length-1].sum > sums)
arrDate.push({sum: sums, index: i,startDate:dates[i+1].date,date:dates[j].date})
if (arrDate.length === 0)
arrDate.push({sum: sums, index: i, startDate: dates[i + 1].date, date: dates[j].date})
else if (arrDate[arrDate.length - 1].sum > sums)
arrDate.push({sum: sums, index: i, startDate: dates[i + 1].date, date: dates[j].date})
}
}
// balance=lastBalance
// balance=lastBalance
// for (let i = 0; i < dates.length; i++) {
// balance = balance + dates[i].profit
// dates[i].balance = balance
// }
balance=lastBalance
for (let i=0;i<dates.length;i++)
{
balance=balance+dates[i].profit
dates[i].balance=balance
balance = lastBalance
for (let i = 0; i < dates.length; i++) {
balance = balance + dates[i].profit
dates[i].balance = balance
}
arrDate = _.orderBy(arrDate, ['sum'])
console.log(arrNew)
console.log('Balance ->',balance-lastBalance)
let sumAll = 0
for (let i = 0; i < dates.length; i++)
sumAll = sumAll + dates[i].count
console.log(dates)
// let tempL=0
// let tempS=0
// for (let i=0;i<arr.length;i++)
// if (arr[i].date ==='2017-12-01' || arr[i].date ==='2017-12-02' || arr[i].date ==='2017-12-03' || arr[i].date ==='2021-10-28' || arr[i].date ==='2021-10-29' || arr[i].date ==='2021-10-30' || arr[i].date ==='2021-10-31' || arr[i].date ==='2021-11-01' || arr[i].date ==='2021-11-02' || arr[i].date ==='2021-11-03' || arr[i].date ==='2021-11-04' || arr[i].date ==='2021-11-05' || arr[i].date ==='2021-11-06' || arr[i].date ==='2021-11-07') {
// tempL = tempL + arr[i].longProfit
// tempS=tempS+arr[i].shortProfit
// }
// console.log(tempL,tempS)
console.log('Balance ->', balance - lastBalance)
let worth = (balance - lastBalance) / (arrDate[0].sum)
console.log('Worth ->',worth)
console.log('Worth ->', worth)
let start=false
let arr2=[]
for (let i=0;i<arr.length;i++)
{
if (arr[i].date ===arrNew[0].startDate)
{
start=true
let start = false
let arr2 = []
for (let i = 0; i < arr.length; i++) {
if (arr[i].date === arrNew[0].startDate) {
start = true
arr2.push(arr[i])
}
// else if (arr[i].date === arrNew[0].date )
......@@ -186,56 +244,89 @@ async function run()
arr2.push(arr[i])
}
balance=lastBalance
for (let i=0;i<arr2.length;i++)
{
balance=balance+arr2[i].profit
arr2[i].balance=balance
balance = lastBalance
for (let i = 0; i < arr2.length; i++) {
balance = balance + arr2[i].profit
arr2[i].balance = balance
}
//createfileADV(JSON.stringify(arr2, null, 2))
// createfileADVDate(JSON.stringify(arr, null, 2))
let index=arrNew[0].index
arrNew=[]
for (let i = index; i < index+1; i++) {
let index = arrNew[0].index
arrNew = []
for (let i = index; i < index + 1; i++) {
let sums = 0
for (let j = i + 1; j < arr.length ; j++) {
for (let j = i + 1; j < arr.length; j++) {
sums = sums + parseFloat(arr[j].profit)
// if (arrNew.length ===0)
// arrNew.push({sum: sums, index: i,date:arr[j].date})
// else if (arrNew[arrNew.length-1].sum > sums)
arrNew.push({sum: sums, index: i,date:arr[j].date})
arrNew.push({sum: sums, index: i, date: arr[j].date})
}
}
// return run()
// return run()
}
async function resetProfit(data) {
for (let i = 0; i < arr.length; i++) {
if (arr[i].date === data.date) {
if (data.side === 'L') {
arr[i].profit = arr[i].profit - arr[i].shortProfit
arr[i].count = arr[i].count - arr[i].shortCount
arr[i].shortCount = 0
arr[i].shortProfit = 0
} else {
arr[i].profit = arr[i].profit - arr[i].longProfit
arr[i].count = arr[i].count - arr[i].longCount
arr[i].longCount = 0
arr[i].longProfit = 0
}
}
}
}
function add(date, profit,side) {
function add(date, profit, side) {
for (let i = 0; i < arr.length; i++)
if (arr[i].date === date) {
arr[i].profit = arr[i].profit + profit
arr[i].count++
if ( side ==='LONG') {
if (side === 'LONG') {
arr[i].longCount++
arr[i].longProfit= arr[i].longProfit+profit
}
else {
arr[i].longProfit = arr[i].longProfit + profit
} else {
arr[i].shortCount++
arr[i].shortProfit= arr[i].shortProfit+profit
arr[i].shortProfit = arr[i].shortProfit + profit
}
return
}
if ( side ==='LONG')
arr.push({date: date, profit: profit,count:1,longCount:1,shortCount:0,longProfit:profit,shortProfit:0})
if (side === 'LONG')
arr.push({
date: date,
profit: profit,
count: 1,
longCount: 1,
shortCount: 0,
longProfit: profit,
shortProfit: 0
})
else
arr.push({date: date, profit: profit,count:1,longCount:1,shortCount:1,longProfit:0,shortProfit:profit})
arr.push({
date: date,
profit: profit,
count: 1,
longCount: 1,
shortCount: 1,
longProfit: 0,
shortProfit: profit
})
}
......@@ -244,12 +335,12 @@ function addDate(data) {
if (data.date.includes(dates[i].date)) {
dates[i].profit = dates[i].profit + data.profit
dates[i].count=dates[i].count+data.count
dates[i].longCount=dates[i].longCount+data.longCount
dates[i].longProfit= dates[i].longProfit+data.longProfit
dates[i].count = dates[i].count + data.count
dates[i].longCount = dates[i].longCount + data.longCount
dates[i].longProfit = dates[i].longProfit + data.longProfit
dates[i].shortCount=dates[i].shortCount+data.shortCount
dates[i].shortProfit= dates[i].shortProfit+data.shortProfit
dates[i].shortCount = dates[i].shortCount + data.shortCount
dates[i].shortProfit = dates[i].shortProfit + data.shortProfit
return
......@@ -265,7 +356,6 @@ function get(date) {
}
}
function createfileADV(data) {
......@@ -278,10 +368,20 @@ function createfileADV(data) {
});
}
function createfileTorob(name,data) {
function createfileADVDate(data) {
// console.log(data)
return new Promise(function (resolve, reject) {
fs.writeFile('date.txt', data, 'utf8', function (err) {
if (err) reject(err);
else resolve(data);
});
});
}
function createfileTorob(name, data) {
// console.log(data)
return new Promise(function (resolve, reject) {
fs.writeFile('torob/'+name+'.json', data, 'utf8', function (err) {
fs.writeFile('torob/' + name + '.json', data, 'utf8', function (err) {
if (err) reject(err);
else resolve(data);
});
......
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