Created
April 25, 2018 15:43
-
-
Save bumi/e9e79d62b52ea424065b9fa6741fe959 to your computer and use it in GitHub Desktop.
streams all bitstamp buy/sell order updates and trades
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 { LiveOrderStream, TickerStream, CURRENCY } = require("node-bitstamp"); | |
const liveOrderStream = new LiveOrderStream(); | |
const liveOrderTopic = liveOrderStream.subscribe(CURRENCY.BTC_EUR); | |
liveOrderStream.on("connected", () => { console.log('connected to live orders'); }); | |
liveOrderStream.on("disconnected", () => { console.log('disconnected'); }); | |
liveOrderStream.on(liveOrderTopic, data => { | |
console.log(`${data.id}: ${data.order_type === 1 ? 'SELL' : 'BUY'} ${data.amount}@${data.price}`); | |
}); | |
const tickerStream = new TickerStream(); | |
const tickerStreamTopic = tickerStream.subscribe(CURRENCY.BTC_EUR); | |
tickerStream.on("connected", () => { console.log('connected to trades'); }); | |
tickerStream.on("disconnected", () => { console.log('disconnected'); }); | |
tickerStream.on(tickerStreamTopic, data => { | |
console.log(`--- TRADE: buy ID: ${data.buy_order_id} sell ID: ${data.sell_order_id} amount: ${data.amount}@${data.price_str}`); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment