Skip to content

Commit

Permalink
added examples/js/fetch-ticker-from-multiple-exchanges.js
Browse files Browse the repository at this point in the history
  • Loading branch information
kroitor committed Nov 13, 2017
1 parent 22f95a4 commit 8600fdf
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions examples/js/fetch-ticker-from-multiple-exchanges.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
"use strict";

const ccxt = require ('../../ccxt.js')

;(async () => {

const exchanges = [
'bittrex',
'poloniex',
]

const symbol = 'BTC/USDT'
const tickers = {}

console.log (await Promise.all (exchanges.map (exchangeId => new Promise (async (resolve, reject) => {

const exchange = new ccxt[exchangeId] ({ enableRateLimit: true })

while (true) {

const ticker = await exchange.fetchTicker (symbol)
tickers[exchangeId] = ticker;

Object.keys (tickers).map (exchangeId => {
const ticker = tickers[exchangeId]
console.log (ticker['datetime'], exchangeId, ticker['bid'], ticker['ask']);
})
}

}))))

}) ()

0 comments on commit 8600fdf

Please sign in to comment.