Created
July 12, 2018 21:37
-
-
Save snowkidind/a42fb2c473bf9459e39eb704bedb52e2 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
ticker:function(pair, cb){ | |
const time = new Date().getTime(); | |
if (time - lastTickerTime > 2000 ) { | |
// console.log("Get Ticker" + pair); | |
if (logAllApiCalls){ | |
console.log(apiCallsCount + " ticker.binance.prices: " + pair + " - " + Date.now()); | |
apiCallsCount += 1; | |
} | |
binance.prices(pair, (error, ticker) => { | |
if (error) { | |
console.log(pair); | |
console.log(chalk.red("binance.ticker error: " + error.body)); | |
cb(false); | |
} | |
else { | |
lastTickerTime = new Date().getTime(); | |
lastTicker = ticker[pair]; | |
cb(ticker[pair]); | |
} | |
}); | |
} | |
else { | |
// console.log("Using cached ticker"); | |
cb(lastTicker); | |
} | |
}, |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment