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

git pull

parent cf2893fe
let pair = 'BTCUSDT'
let pair = 'ETHUSDT'
let timeframe = '5m'
const Downloader = require("nodejs-file-downloader");
const extract = require('extract-zip')
......
......@@ -10,8 +10,8 @@ init()
async function init() {
res = await fs.readFileSync('run.csv', 'utf8');
res = res.split('\n')
// res = await fs.readFileSync('run.csv', 'utf8');
// res = res.split('\n')
let arr = []
// 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() {
for (let i = 0; i < dates.length; i++)
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 tempS=0
// for (let i=0;i<arr.length;i++)
......@@ -222,7 +238,8 @@ async function run() {
// tempS=tempS+arr[i].shortProfit
// }
// console.log(tempL,tempS)
if (arrDate[0].sum === 0)
return
console.log('Balance ->', balance - lastBalance)
let worth = (balance - lastBalance) / (arrDate[0].sum)
console.log('Worth ->', worth)
......@@ -292,6 +309,7 @@ async function resetProfit(data) {
function add(date, profit, side) {
profit = parseFloat(parseFloat(profit).toFixed(2))
for (let i = 0; i < arr.length; i++)
if (arr[i].date === date) {
arr[i].profit = arr[i].profit + profit
......@@ -334,7 +352,7 @@ function addDate(data) {
for (let i = 0; i < dates.length; i++)
if (data.date.includes(dates[i].date)) {
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
......
......@@ -8,7 +8,7 @@ let arr = []
let lastBalance = 5000
let size = 50
let balance = lastBalance
let files=['newCom1.json',
let files = ['newCom1.json',
'newCom2.json',
'newCom3.json']
init()
......@@ -17,7 +17,6 @@ let base = 1
let coms
//profitLossString
//drawDownString
......@@ -56,7 +55,7 @@ async function lastCheck(param1, param2, param3, arr5) {
base = parseFloat(bad.bad)
if (param3 < base) {
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))
......@@ -121,28 +120,28 @@ async function run() {
}
arrNew = _.orderBy(arrNew, ['sum'])
for (let i=0;i<arr.length;i++)
for (let i = 0; i < arr.length; i++)
addDate(arr[i])
let arrDate=[]
let arrDate = []
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})
}
}
arrDate = _.orderBy(arrDate, ['sum'])
balance=lastBalance
balance = lastBalance
for (let i = 0; i < dates.length; i++) {
balance = balance + dates[i].profit
dates[i].balance = balance
......@@ -151,8 +150,11 @@ async function run() {
// console.log('Balance ->',balance)
// console.log('Worth ->',arrNew[0])
if (arrDate[0].sum === 0)
return run()
let worth = (balance - lastBalance) / (arrDate[0].sum)
if (worth < base) {
if (worth > 0 && worth > base) {
base = worth
console.log(arrDate[0].sum, balance - lastBalance, worth)
let arr5 = []
......@@ -215,13 +217,13 @@ function addDate(data) {
for (let i = 0; i < dates.length; i++)
if (data.date.includes(dates[i].date)) {
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].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
......@@ -232,6 +234,7 @@ function addDate(data) {
function add(date, profit, side) {
profit = parseFloat(parseFloat(profit).toFixed(2))
for (let i = 0; i < arr.length; i++)
if (arr[i].date === date) {
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