Commit 8028eb6f authored by Ahmad Nemati's avatar Ahmad Nemati

init

parent 751ef51d
......@@ -176,6 +176,8 @@ function run(data, config, risk, pfTrade, riskFreeLevel, detail, loss, durs, max
if (endDays > maxDays)
maxDays = endDays
listDays.push(endDays)
realProfit = realProfit + d.realProfit
targets.push(d.realProfit)
......@@ -563,6 +565,14 @@ function getNewMinDiff(s, c) {
}
function getTargetPrice(side,money,targetMoney,basePrice) {
let diffMoney = calPer(money, targetMoney)
if (side ==='LONG')
return percentageAdv(basePrice, diffMoney)
else
return percentageAdv(basePrice, (-1 * diffMoney))
}
module.exports =
{
......
......@@ -5,6 +5,7 @@ let directory
let configFileName
let csvFile
let checks = []
let candles
let drawDown = [30, 40, 50]
//const perf = require('execution-time')();
run()
......@@ -16,6 +17,23 @@ async function run() {
checks = args[2]
await makeStatus(directory, '1')
// perf.start()
candles = await fs.readFileSync('./csv/coin.csv', 'utf8')
// let end=candles.split('\n')
candles=candles.match(/.+/g)
let arr5=[]
for (let i=1;i<candles.length;i++)
{
let t=candles[i].split(',')
arr5.push({t:parseFloat(t[0]),o:parseFloat(t[1]),h:parseFloat(t[2]),l:parseFloat(t[3]),c:parseFloat(t[4])})
}
//candles=candles.replace('time,open,high,low,close','')
// candles=candles=candles.split('\n')
// await sleep(2000)
// console.log(arr5)
// await sleep(500)
// console.log(candles.length)
// console.log(candles.length)
let configs = await fs.readFileSync('./configs/' + configFileName, 'utf8')
checks = await fs.readFileSync('./detail.json', 'utf8')
configs = JSON.parse(configs)
......@@ -356,5 +374,9 @@ function makeStatus(directory, status) {
});
}
async function sleep(millis) {
return new Promise(resolve => setTimeout(resolve, millis));
}
let fs = require('fs')
let candles
reaD()
async function reaD() {
candles = await fs.readFileSync('./csv/coin.csv', 'utf8')
// let end=candles.split('\n')
candles = candles.match(/.+/g)
let arr = []
for (let i = 1; i < candles.length; i++) {
let t = candles[i].split(',')
arr.push({
t: parseFloat(t[0]),
o: parseFloat(t[1]),
h: parseFloat(t[2]),
l: parseFloat(t[3]),
c: parseFloat(t[4])
})
}
candles = arr
grabData(1547635200,1547636700)
//
}
function grabData(start, end) {
let arr = []
let indexStart = false
for (let i = 0; i < candles.length; i++) {
if (indexStart && candles[i].t <= end)
arr.push(candles[i])
else if (candles[i].t === start) {
indexStart = true
arr.push(candles[i])
}
}
console.log(arr)
}
\ 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