Commit 44f4eef4 authored by Ahmad Nemati's avatar Ahmad Nemati

init

parent 7973eb90
......@@ -23,7 +23,7 @@ function run(data, config,risk,pfTrade) {
let levels=[]
let dur = getMinDiff(data[0].openDate, data[data.length - 1].closeDate)
let newP=dur/data.length
console.log(newP)
// console.log(newP)
if (pfTrade>newP)
return null
for (let i = 0; i < data.length; i++) {
......
......@@ -19,7 +19,7 @@ async function run() {
for (let i = 0; i < files.length; i++)
if (files[i].includes('.csv')) {
csvFile = files[i]
arr.push(csv.parse(directory, files[i], configs.data, configs.risk,configs.pfTrade))
arr.push(csv.parse(directory, files[i], configs.data, configs.risk, configs.pfTrade))
}
arr = await Promise.all(arr)
......@@ -35,7 +35,7 @@ async function run() {
}
}
// console.log(arr2)
arr2=_.without(arr2,undefined,null);
arr2 = _.without(arr2, undefined, null);
arr2 = _.orderBy(arr2, ['profitPerMonthDrawDown'], ['desc']);
let arr20Max = []
let arr1000Compound = []
......@@ -45,30 +45,26 @@ async function run() {
let arrResrv200 = []
let arrReservCompound = []
for (let i = 0; i < 1000; i++) {
if (typeof arr2[i] !== "undefined")
arr3.push(arr2[i])
if (typeof arrResrv200[i] !== "undefined")
arrResrv200.push(arrReserv[i])
if (typeof arr1000Compound[i] !== "undefined")
arr1000Compound.push(arrCompound[i])
}
for (let i = 0; i < arr2.length; i++) {
if (arr2[i].allocatedReserve < 3)
arr20Max.push(arr2[i])
}
for (let i = 0; i < arrCompound.length; i++) {
if (arrCompound[i].allocatedReserve < 3)
arrReservCompound.push(arrCompound[i])
}
let arr20MaxNew = []
let arrReservCompoundNew = []
for (let i = 0; i < 1000; i++) {
if (typeof arr20Max[i] !== "undefined")
if (i < arr20Max.length)
arr20MaxNew.push(arr20Max[i])
if (typeof arrReservCompound[i] !== "undefined")
if (i < arrReservCompound.length)
arrReservCompoundNew.push(arrReservCompound[i])
......@@ -115,7 +111,7 @@ async function run() {
// createfileADV('allocatedReservePerMonthUnder2', JSON.stringify(arr20MaxNew, null, 2))
// createfileADV('allocatedReserveCompoundUnder2' , JSON.stringify(arrReservCompoundNew, null, 2))
startAgain(arr,configs.start)
startAgain(arr, configs.start)
console.log('Done')
await makeStatus(directory, '0')
// process.exit(0)
......@@ -123,13 +119,13 @@ startAgain(arr,configs.start)
}
async function startAgain(arr,start){
async function startAgain(arr, start) {
let count = 0
let arr2 = []
let arr3 = []
for (let i = 0; i < arr.length; i++) {
let inline = arr[i]
inline = _.without(inline, undefined, null);
for (let j = 0; j < inline.length; j++) {
if (inline[j].maxAllocatedMoney < start)
arr2.push(inline[j])
......@@ -138,7 +134,7 @@ async function startAgain(arr,start){
}
}
// console.log(arr2)
arr2=_.without(arr2,undefined,null);
arr2 = _.without(arr2, undefined, null);
arr2 = _.orderBy(arr2, ['profitPerMonthDrawDown'], ['desc']);
let arr20Max = []
let arr1000Compound = []
......@@ -148,42 +144,41 @@ async function startAgain(arr,start){
let arrResrv200 = []
let arrReservCompound = []
for (let i = 0; i < 1000; i++) {
if(typeof arr2[i] !=="undefined")
if (typeof arr2[i] !== "undefined")
arr3.push(arr2[i])
if(typeof arrReserv[i] !=="undefined")
if (typeof arrReserv[i] !== "undefined")
arrResrv200.push(arrReserv[i])
if(typeof arrCompound[i] !=="undefined")
if (typeof arrCompound[i] !== "undefined")
arr1000Compound.push(arrCompound[i])
}
for (let i = 0; i < arr2.length; i++) {
if (arr2[i].allocatedReserve < 3)
arr20Max.push(arr2[i])
}
// for (let i = 0; i < arr2.length; i++) {
//
// if (arr2[i].allocatedReserve < 3)
// arr20Max.push(arr2[i])
// }
for (let i = 0; i < arrCompound.length; i++) {
if (arrCompound[i].allocatedReserve < 3)
arrReservCompound.push(arrCompound[i])
}
// for (let i = 0; i < arrCompound.length; i++) {
//
// if (arrCompound[i].allocatedReserve < 3)
// arrReservCompound.push(arrCompound[i])
// }
let arr20MaxNew = []
let arrReservCompoundNew = []
for (let i = 0; i < 1000; i++) {
if (typeof arr20Max !== "undefined")
if (i < arr20Max.length)
arr20MaxNew.push(arr20Max[i])
if (typeof arrReservCompound !== "undefined")
if (i < arrReservCompound.length)
arrReservCompoundNew.push(arrReservCompound[i])
}
// await fs.unlinkSync(directory + '/' + csvFile)
// createfileADV('allDataSortedByProfit', JSON.stringify(arr2, null, 2))
createfileADV('profitPerMonth1000Start', JSON.stringify(arr3, null, 2))
......@@ -193,7 +188,6 @@ async function startAgain(arr,start){
// createfileADV('allocatedReserveCompoundUnder3' , JSON.stringify(arrReservCompoundNew, null, 2))
}
function createfile(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