Takes in messages from the gdax (coinbase-pro) web-socket and monitors for specific events.
This module is designed with the intent of doing research. You and only you are solely responsible for the actions you and the code that you write with this module make. Please be responsible.
npm i gdax-pulse
const Gdax = require('gdax');
const GdaxPulse = require('gdax-pulse');
let pulse = new GdaxPulse();
pulse.on('m1', (price, time) => {
console.log('do this every minute');
});
pulse.on('new-price', (price, time) => {
console.log('current price:', price);
});
const websocket = new Gdax.WebsocketClient('BTC-USD');
websocket.on("message", data => {
pulse.analyze(data);
});
A delay was introduced to help better manage exchange api compliance. Coinbase Pro specifically axes out at 4 calls per second. If you call get historic rates on more then 4 assets every hour then you will max out and stop receiving information.
const Gdax = require('gdax');
const GdaxPulse = require('gdax-pulse').Pulse;
let pulse = new GdaxPulse();
let delayedPulse = new GdaxPulse(10);
pulse.on('m1', (price, time) => {
console.log('now');
});
delayedPulse.on('m1', (price, time) => {
console.log('10 seconds from now');
});
const websocket = new Gdax.WebsocketClient('BTC-USD');
websocket.on("message", data => {
pulse.analyze(data);
delayedPulse.analyze(data);
});
const binance = require('node-binance-api')().options({});
const GdaxPulse = require('gdax-pulse').Pulse;
let pulse = new GdaxPulse(0, 'binance');
pulse.on('m1', (price, time) => {
console.log('now');
});
binance.websockets.trades(['BTCUSDC'], (message) => {
pulse.analyze(data);
});
const ccxws = require("ccxws");
const hitbtcExchange = new ccxws.hitbtc();
const GdaxPulse = require('../gdax-pulse').Pulse;
let pulse = new GdaxPulse(0, 'ccxws');
pulse.on('m1', (price, time) => {
console.log('now');
});
const market = {
id: "ETHBTC",
base: "ETH",
quote: "BTC",
};
hitbtcExchange.on("ticker", (tick) => {
pulse.analyze(tick);
});
hitbtcExchange.subscribeTicker(market);
This is intended to help convert UTC time to the local time of the exchange.
const {Nyc} = require('../gdax-pulse').ConvertToExchangeTimes;
let time = new Date("4/16/2021 013:30 utc");
let conversion = Nyc(time);
//{
// day: 16,
// hour: 9,
// minute: 30,
// month: 4,
// year: 2021
//};