Last active
November 10, 2018 15:03
-
-
Save trestrantham/f71a575edf38fe11360f85007b37a419 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 https = require("https"); | |
const KEY = "your-api-key"; | |
const CURRENCY = "BTC"; | |
const INTERVAL = "1h"; | |
const PRICE = 6500; | |
let body = ""; | |
let candles; | |
https.get(`https://api.nomics.com/v1/candles?key=${KEY}&interval=${INTERVAL}¤cy=${CURRENCY}`, res => { | |
res.on("data", chunk => (body += chunk)); | |
res.on("end", () => { | |
console.log( | |
JSON.parse(body).filter(candle => { | |
return ( | |
(parseFloat(candle.open) <= PRICE && parseFloat(candle.close) >= PRICE) || | |
(parseFloat(candle.close) <= PRICE && parseFloat(candle.open) >= PRICE) | |
); | |
}) | |
); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.