mirror of
https://github.com/discountry/ritmex-bot.git
synced 2026-09-11 17:28:08 +00:00
commit
This commit is contained in:
@@ -0,0 +1,42 @@
|
||||
'use strict';
|
||||
|
||||
const ccxt = require ('../../../ccxt');
|
||||
|
||||
(async () => {
|
||||
|
||||
const streams = {
|
||||
'binance': 'BTC/USDT',
|
||||
'okex': 'BTC/USDT'
|
||||
};
|
||||
|
||||
await Promise.all (Object.keys (streams).map (exchangeId =>
|
||||
|
||||
(async () => {
|
||||
|
||||
const exchange = new ccxt.pro[exchangeId] ({
|
||||
enableRateLimit: true,
|
||||
options: {
|
||||
tradesLimit: 100, // lower = better, 1000 by default
|
||||
},
|
||||
})
|
||||
const symbol = streams[exchangeId]
|
||||
let lastId = ''
|
||||
while (true) {
|
||||
console.log ('---')
|
||||
try {
|
||||
const trades = await exchange.watchTrades (symbol)
|
||||
for (let i = 0; i < trades.length; i++) {
|
||||
const trade = trades[i]
|
||||
if (trade['id'] > lastId) {
|
||||
console.log (exchange.iso8601 (exchange.milliseconds ()), exchange.id, trade['symbol'], trade['id'], trade['datetime'], trade['price'], trade['amount'])
|
||||
lastId = trade['id']
|
||||
}
|
||||
}
|
||||
} catch (e) {
|
||||
console.log (symbol, e)
|
||||
}
|
||||
}
|
||||
|
||||
}) ())
|
||||
)
|
||||
}) ()
|
||||
Reference in New Issue
Block a user