Commit 6fac318f authored by Ahmad Nemati's avatar Ahmad Nemati

git pull

parent cf2893fe
let pair = 'BTCUSDT' let pair = 'ETHUSDT'
let timeframe = '5m' let timeframe = '5m'
const Downloader = require("nodejs-file-downloader"); const Downloader = require("nodejs-file-downloader");
const extract = require('extract-zip') const extract = require('extract-zip')
......
...@@ -10,8 +10,8 @@ init() ...@@ -10,8 +10,8 @@ init()
async function init() { async function init() {
res = await fs.readFileSync('run.csv', 'utf8'); // res = await fs.readFileSync('run.csv', 'utf8');
res = res.split('\n') // res = res.split('\n')
let arr = [] let arr = []
// console.log(found('ETH', 'Lp2')) // console.log(found('ETH', 'Lp2'))
......
test()
function test()
{
let s=(factoril(5000))/(factoril(50)*factoril(50))
console.log(s)
}
//console.log(factoril(4))
function factoril(num)
{
let sum=1
for (let i=1;i<=num;i++)
sum=sum*i
return sum
}
\ No newline at end of file
...@@ -213,7 +213,23 @@ async function run() { ...@@ -213,7 +213,23 @@ async function run() {
for (let i = 0; i < dates.length; i++) for (let i = 0; i < dates.length; i++)
sumAll = sumAll + dates[i].count sumAll = sumAll + dates[i].count
console.log(dates) console.log(arrDate)
// let ss=0
// for (let i=0;i<dates.length;i++)
// ss=ss+dates[i].profit
// console.log(ss/dates.length)
let yy = ['2017', '2018', '2019', '2020', '2021', '2022']
for (let i = 0; i < yy.length; i++) {
let ss = 0
let summ = 0
for (let j = 0; j < dates.length; j++)
if (dates[j].date.includes(yy[i])) {
ss++
summ = summ + dates[j].profit
}
console.log(yy[i], ss, summ / ss)
}
// let tempL=0 // let tempL=0
// let tempS=0 // let tempS=0
// for (let i=0;i<arr.length;i++) // for (let i=0;i<arr.length;i++)
...@@ -222,7 +238,8 @@ async function run() { ...@@ -222,7 +238,8 @@ async function run() {
// tempS=tempS+arr[i].shortProfit // tempS=tempS+arr[i].shortProfit
// } // }
// console.log(tempL,tempS) // console.log(tempL,tempS)
if (arrDate[0].sum === 0)
return
console.log('Balance ->', balance - lastBalance) console.log('Balance ->', balance - lastBalance)
let worth = (balance - lastBalance) / (arrDate[0].sum) let worth = (balance - lastBalance) / (arrDate[0].sum)
console.log('Worth ->', worth) console.log('Worth ->', worth)
...@@ -292,6 +309,7 @@ async function resetProfit(data) { ...@@ -292,6 +309,7 @@ async function resetProfit(data) {
function add(date, profit, side) { function add(date, profit, side) {
profit = parseFloat(parseFloat(profit).toFixed(2))
for (let i = 0; i < arr.length; i++) for (let i = 0; i < arr.length; i++)
if (arr[i].date === date) { if (arr[i].date === date) {
arr[i].profit = arr[i].profit + profit arr[i].profit = arr[i].profit + profit
...@@ -334,7 +352,7 @@ function addDate(data) { ...@@ -334,7 +352,7 @@ function addDate(data) {
for (let i = 0; i < dates.length; i++) for (let i = 0; i < dates.length; i++)
if (data.date.includes(dates[i].date)) { if (data.date.includes(dates[i].date)) {
dates[i].profit = dates[i].profit + data.profit dates[i].profit = dates[i].profit + data.profit
dates[i].profit = parseFloat(parseFloat(dates[i].profit).toFixed(2))
dates[i].count = dates[i].count + data.count dates[i].count = dates[i].count + data.count
dates[i].longCount = dates[i].longCount + data.longCount dates[i].longCount = dates[i].longCount + data.longCount
dates[i].longProfit = dates[i].longProfit + data.longProfit dates[i].longProfit = dates[i].longProfit + data.longProfit
......
...@@ -8,7 +8,7 @@ let arr = [] ...@@ -8,7 +8,7 @@ let arr = []
let lastBalance = 5000 let lastBalance = 5000
let size = 50 let size = 50
let balance = lastBalance let balance = lastBalance
let files=['newCom1.json', let files = ['newCom1.json',
'newCom2.json', 'newCom2.json',
'newCom3.json'] 'newCom3.json']
init() init()
...@@ -17,7 +17,6 @@ let base = 1 ...@@ -17,7 +17,6 @@ let base = 1
let coms let coms
//profitLossString //profitLossString
//drawDownString //drawDownString
...@@ -56,7 +55,7 @@ async function lastCheck(param1, param2, param3, arr5) { ...@@ -56,7 +55,7 @@ async function lastCheck(param1, param2, param3, arr5) {
base = parseFloat(bad.bad) base = parseFloat(bad.bad)
if (param3 < base) { if (param3 > base) {
let z = {maxReserve: param1, profit: param2, bad: param3} let z = {maxReserve: param1, profit: param2, bad: param3}
await createfileADV(JSON.stringify(z)) await createfileADV(JSON.stringify(z))
await createfileTorob(param3.toString(), JSON.stringify(arr5, null, 2)) await createfileTorob(param3.toString(), JSON.stringify(arr5, null, 2))
...@@ -71,7 +70,7 @@ function resetDates() { ...@@ -71,7 +70,7 @@ function resetDates() {
for (let i = 0; i < year.length; i++) { for (let i = 0; i < year.length; i++) {
for (let j = 0; j < month.length; j++) { for (let j = 0; j < month.length; j++) {
let t = year[i] + '-' + month[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')) 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}) dates.push({date: t, profit: 0, count: 0, longCount: 0, shortCount: 0, longProfit: 0, shortProfit: 0})
} }
} }
...@@ -121,28 +120,28 @@ async function run() { ...@@ -121,28 +120,28 @@ async function run() {
} }
arrNew = _.orderBy(arrNew, ['sum']) arrNew = _.orderBy(arrNew, ['sum'])
for (let i=0;i<arr.length;i++) for (let i = 0; i < arr.length; i++)
addDate(arr[i]) addDate(arr[i])
let arrDate=[] let arrDate = []
for (let i = 0; i < dates.length; i++) { for (let i = 0; i < dates.length; i++) {
let sums = 0 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) sums = sums + parseFloat(dates[j].profit)
if (arrDate.length ===0) if (arrDate.length === 0)
arrDate.push({sum: sums, index: i,startDate:dates[i+1].date,date:dates[j].date}) arrDate.push({sum: sums, index: i, startDate: dates[i + 1].date, date: dates[j].date})
else if (arrDate[arrDate.length-1].sum > sums) else if (arrDate[arrDate.length - 1].sum > sums)
arrDate.push({sum: sums, index: i,startDate:dates[i+1].date,date:dates[j].date}) arrDate.push({sum: sums, index: i, startDate: dates[i + 1].date, date: dates[j].date})
} }
} }
arrDate = _.orderBy(arrDate, ['sum']) arrDate = _.orderBy(arrDate, ['sum'])
balance=lastBalance balance = lastBalance
for (let i = 0; i < dates.length; i++) { for (let i = 0; i < dates.length; i++) {
balance = balance + dates[i].profit balance = balance + dates[i].profit
dates[i].balance = balance dates[i].balance = balance
...@@ -151,8 +150,11 @@ async function run() { ...@@ -151,8 +150,11 @@ async function run() {
// console.log('Balance ->',balance) // console.log('Balance ->',balance)
// console.log('Worth ->',arrNew[0]) // console.log('Worth ->',arrNew[0])
if (arrDate[0].sum === 0)
return run()
let worth = (balance - lastBalance) / (arrDate[0].sum) let worth = (balance - lastBalance) / (arrDate[0].sum)
if (worth < base) {
if (worth > 0 && worth > base) {
base = worth base = worth
console.log(arrDate[0].sum, balance - lastBalance, worth) console.log(arrDate[0].sum, balance - lastBalance, worth)
let arr5 = [] let arr5 = []
...@@ -215,13 +217,13 @@ function addDate(data) { ...@@ -215,13 +217,13 @@ function addDate(data) {
for (let i = 0; i < dates.length; i++) for (let i = 0; i < dates.length; i++)
if (data.date.includes(dates[i].date)) { if (data.date.includes(dates[i].date)) {
dates[i].profit = dates[i].profit + data.profit dates[i].profit = dates[i].profit + data.profit
dates[i].profit = parseFloat(parseFloat(dates[i].profit).toFixed(2))
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].shortCount = dates[i].shortCount + data.shortCount
dates[i].longCount=dates[i].longCount+data.longCount dates[i].shortProfit = dates[i].shortProfit + data.shortProfit
dates[i].longProfit= dates[i].longProfit+data.longProfit
dates[i].shortCount=dates[i].shortCount+data.shortCount
dates[i].shortProfit= dates[i].shortProfit+data.shortProfit
return return
...@@ -232,6 +234,7 @@ function addDate(data) { ...@@ -232,6 +234,7 @@ function addDate(data) {
function add(date, profit, side) { function add(date, profit, side) {
profit = parseFloat(parseFloat(profit).toFixed(2))
for (let i = 0; i < arr.length; i++) for (let i = 0; i < arr.length; i++)
if (arr[i].date === date) { if (arr[i].date === date) {
arr[i].profit = arr[i].profit + profit arr[i].profit = arr[i].profit + profit
......
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