Created
May 16, 2019 17:34
-
-
Save brettkrueger/832bbf1aab21aa9e8ce6f37c97669509 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const getIndicators = async (req, res) => { | |
binance2 = new ccxt.binance() | |
coins = await binance2.fetchMarkets() | |
pairs = [] | |
coins.forEach(pair => { | |
pairs.push(pair.symbol.replace('/','')) | |
}) | |
console.log(pairs.slice(0, 20)) | |
timeframe = req.params.timeframe || "1D" | |
direction = req.params.direction.toUpperCase() || "BOTH" | |
var response; | |
binance.websockets.chart("BNBBTC", "1M", (symbol, interval, chart) => { | |
// call the indicator calculate stuff | |
let data = { | |
time: [], | |
open: [], | |
high: [], | |
low: [], | |
close: [], | |
volume: [] | |
}; | |
// time,item.open,item.high,item.low,item.close,item.volume | |
_.each(chart, (item) => { | |
data.time.push(item.time); | |
data.open.push(item.open); | |
data.high.push(item.high); | |
data.low.push(item.low); | |
data.close.push(item.close); | |
data.volume.push(item.volume); | |
}); | |
console.log(chart) | |
if (direction != "BOTH") { | |
if (direction === "BEARISH") { | |
var bearish = require('technicalindicators').bearish; | |
let response = bearish(data); | |
} else if (direction === "BULLISH") { | |
var bullish = require('technicalindicators').bullish; | |
let response = bullish(data); | |
} | |
res.send(response) | |
} else { | |
var bullish = require('technicalindicators').bullish; | |
var bearish = require('technicalindicators').bearish; | |
//let data = indicator(chartData); | |
let bullishResponse = bullish(data); | |
let bearishResponse = bearish(data); | |
let response = JSON.parse(JSON.stringify({ | |
"bullish": bullishResponse, | |
"bearish": bearishResponse | |
})) | |
res.send(response) | |
} | |
//res.send(response) | |
}); | |
//res.send(response) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment