alpacahq / alpaca-ts

A TypeScript Node.js library for the https://alpaca.markets REST API and WebSocket streams.
ISC License
156 stars 42 forks source link

fix error message type for WebSocket events #118

Open bennycode opened 9 months ago

bennycode commented 9 months ago

I noticed that the error object looks as follows:

{
  "code": 406,
  "msg": "connection limit exceeded",
  "T": "error"
}

My test code:

import {AlpacaStream, Message} from '@master-chief/alpaca';

const connection = new AlpacaStream({
  credentials: {
    key: options.apiKey,
    paper: options.usePaperTrading,
    secret: options.apiSecret,
  },
  source: 'iex',
  type: "market_data",
});

connection.once("error", (error: Message) => {
  console.log(error);
});