@quotemedia.com/streamer 2.50.0 → 2.52.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,3 +1,49 @@
1
+ # Overview
1
2
  JavaScript streaming client that provides easy-to-use client APIs to connect and subscribe to QuoteMedia's market data streaming services.
2
3
 
3
- https://quotemedia.com/
4
+ https://quotemedia.com/
5
+ ## Getting Started
6
+ The Javascript streaming client is a library that contains all the necessary dependencies to run not only in the `browser`, but also in `Node.js` environments.
7
+
8
+ ### Browser Usage
9
+ To use the library in your browser project simply include the library file in your HTML page as a script.
10
+
11
+ ### Node.js Usage
12
+ Since the `window` object is not available in `Node.js`, it will need to be mocked before we import the library.
13
+ 1. Mock the window object before importing the library:
14
+ ```javascript
15
+ if (typeof global.window === 'undefined') {
16
+ var window = {
17
+ navigator: { userAgent: "atmosphere.js" },
18
+ document: {},
19
+ location: {
20
+ protocol: 'https:'},
21
+ JSON: JSON
22
+ };
23
+
24
+ window.WebSocket = require("ws");
25
+ window.EventSource = require("eventsource");
26
+ window.XMLHttpRequest = require("xmlhttprequest").XMLHttpRequest;
27
+
28
+ global.window = window;
29
+ global.location = window.location;
30
+ global.WebSocket = window.WebSocket;
31
+ global.EventSource = window.EventSource;
32
+ global.navigator = window.navigator;
33
+ global.document = window.document;
34
+ }
35
+
36
+ 2. Then import the library with require syntax:
37
+ ```javascript
38
+ var Streamer = require("<path to the library>");
39
+ ```
40
+ 3. The library is ready for use in your `Node.js` project.
41
+
42
+ ## Examples
43
+
44
+ - [Enterprise Example](./enterprise-example.html) <br> An example showing how to configure, create a stream, and subscribe to market data with tokens. <br>
45
+ - [Enduser Example](./enduser-example.html): <br> An example showing how to configure, create a stream, and subscribe to market data with enduser credentials.
46
+ - [WMID Example](./wmid-example.html): <br> An example showing how to configure, create a stream, and subscribe to market data with a webmaster ID. <br>
47
+ - [Stomp Example](./stomp-example.html): <br> An example showing how to subscribe and unsubscribe to market data using the Stomp protocol. <br>
48
+ - [Reconnect Example](./reconnect-example.html): <br> An example showing how configure and setup automatic reconnection.
49
+ - [Subscription Example](./subscription-example.html): <br> An example showing how to subscribe to the trade data market type.
@@ -1,7 +1,7 @@
1
1
  <html>
2
2
 
3
3
  <head>
4
- <script src="qmci-streamer-2.50.0.min.js"></script>
4
+ <script src="qmci-streamer-2.52.0.min.js"></script>
5
5
  </head>
6
6
 
7
7
  <body>
@@ -1,7 +1,7 @@
1
1
  <html>
2
2
 
3
3
  <head>
4
- <script src="qmci-streamer-2.50.0.min.js"></script>
4
+ <script src="qmci-streamer-2.52.0.min.js"></script>
5
5
  </head>
6
6
 
7
7
  <body>
@@ -1,7 +1,7 @@
1
1
  <html>
2
2
 
3
3
  <head>
4
- <script src="qmci-streamer-2.50.0.min.js"></script>
4
+ <script src="qmci-streamer-2.52.0.min.js"></script>
5
5
  </head>
6
6
 
7
7
  <body>
@@ -2,7 +2,7 @@
2
2
  <html lang="en">
3
3
 
4
4
  <head>
5
- <script src="qmci-streamer-2.50.0.min.js"></script>
5
+ <script src="qmci-streamer-2.52.0.min.js"></script>
6
6
  <script src="https://cdnjs.cloudflare.com/ajax/libs/stomp.js/2.3.3/stomp.min.js"></script>
7
7
  </head>
8
8
 
@@ -1,7 +1,7 @@
1
1
  <html>
2
2
 
3
3
  <head>
4
- <script src="qmci-streamer-2.50.0.min.js"></script>
4
+ <script src="qmci-streamer-2.52.0.min.js"></script>
5
5
  </head>
6
6
 
7
7
  <body>
@@ -1,7 +1,7 @@
1
1
  <html>
2
2
 
3
3
  <head>
4
- <script src="qmci-streamer-2.50.0.min.js"></script>
4
+ <script src="qmci-streamer-2.52.0.min.js"></script>
5
5
  </head>
6
6
 
7
7
  <body>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@quotemedia.com/streamer",
3
- "version": "2.50.0",
3
+ "version": "2.52.0",
4
4
  "description": "A JavaScript client for QuoteMedia's streaming data service.",
5
5
  "main": "lib/index.js",
6
6
  "author": "QuoteMedia",
@@ -1451,7 +1451,6 @@ var Stream = function () {
1451
1451
  (0, _utils.removeFromArray)(exchangeSub.id, msg.__id);
1452
1452
  delete this.pendingExchangeSubscriptions[msg.__id];
1453
1453
 
1454
- console.log(msg);
1455
1454
  if (msg.code != 200) {
1456
1455
  var event = events.error("Error subscribing", {
1457
1456
  code: msg.code,
@@ -1479,7 +1478,6 @@ var Stream = function () {
1479
1478
 
1480
1479
  var result = newsSub.result;
1481
1480
 
1482
- console.log(msg);
1483
1481
  if (msg.code != 200) {
1484
1482
  var event = events.error("Error subscribing to news", {
1485
1483
  code: msg.code,
@@ -1562,7 +1560,6 @@ var Stream = function () {
1562
1560
 
1563
1561
  var result = corpEventSub.result;
1564
1562
 
1565
- console.log(msg);
1566
1563
  if (msg.code != 200) {
1567
1564
  var event = events.error("Error subscribing to Corporate Events", {
1568
1565
  code: msg.code,
@@ -1643,7 +1640,6 @@ var Stream = function () {
1643
1640
  (0, _utils.removeFromArray)(alertsSub.id, msg.__id);
1644
1641
  delete this.pendingAlertSubscription[msg.__id];
1645
1642
 
1646
- console.log(msg);
1647
1643
  if (msg.code != 200 && !alertsSub.failed) {
1648
1644
  alertsSub.failed = true;
1649
1645
  var event = events.error("Error subscribing", {
@@ -1678,7 +1674,6 @@ var Stream = function () {
1678
1674
  (0, _utils.removeFromArray)(tradeSub.id, msg.__id);
1679
1675
  delete this.pendingTradeSubscription[msg.__id];
1680
1676
 
1681
- console.log(msg);
1682
1677
  if (msg.code != 200 && !tradeSub.failed) {
1683
1678
  tradeSub.failed = true;
1684
1679
  var event = events.error("Error subscribing", {
@@ -1713,7 +1708,6 @@ var Stream = function () {
1713
1708
  (0, _utils.removeFromArray)(newsUnsub.id, msg.__id);
1714
1709
  delete this.pendingNewsUnsubscriptions[msg.__id];
1715
1710
 
1716
- console.log("msg", msg);
1717
1711
  var result = newsUnsub.result;
1718
1712
 
1719
1713
  if (msg.code != 200 && !newsUnsub.failed) {
@@ -1762,7 +1756,6 @@ var Stream = function () {
1762
1756
  (0, _utils.removeFromArray)(tradeSub.id, msg.__id);
1763
1757
  delete this.pendingTradeUnsubscription[msg.__id];
1764
1758
 
1765
- console.log(msg);
1766
1759
  if (msg.code != 200 && !tradeSub.failed) {
1767
1760
  tradeSub.failed = true;
1768
1761
  var event = events.error("Error unsubscribing", {
@@ -1791,7 +1784,6 @@ var Stream = function () {
1791
1784
  };
1792
1785
 
1793
1786
  Stream.prototype.onNewsCmdFilterRefreshResponse = function onNewsCmdFilterRefreshResponse(msg) {
1794
- console.log("msg", msg);
1795
1787
  if (msg.code != 200) {
1796
1788
  var event = events.error("Error Refreshing News Filters", {
1797
1789
  code: msg.code,
@@ -1805,7 +1797,6 @@ var Stream = function () {
1805
1797
  };
1806
1798
 
1807
1799
  Stream.prototype.onNewsCmdFilterResponse = function onNewsCmdFilterResponse(msg) {
1808
- console.log("msg", msg);
1809
1800
  if (msg.code != 200) {
1810
1801
  var event = events.error("Error Getting News Filters Status", {
1811
1802
  code: msg.code,
@@ -1862,7 +1853,6 @@ var Stream = function () {
1862
1853
  (0, _utils.removeFromArray)(exchangeSub.id, msg.__id);
1863
1854
  delete this.pendingExchangeUnsubscriptions[msg.__id];
1864
1855
 
1865
- console.log(msg);
1866
1856
  if (msg.code != 200) {
1867
1857
  var event = events.error("Error unsubscribing", {
1868
1858
  code: msg.code,
@@ -1888,7 +1878,6 @@ var Stream = function () {
1888
1878
  this.conn.setReconnect = false;
1889
1879
  }
1890
1880
  this.events.fire("reconnectMessage", msg);
1891
- console.log(msg);
1892
1881
  };
1893
1882
 
1894
1883
  Stream.prototype.onConnectResponse = function onConnectResponse(msg) {
@@ -2284,6 +2273,11 @@ var StreamingService = function () {
2284
2273
  headers['X-Stream-connectionFrom'] = _connectionFrom;
2285
2274
  }
2286
2275
 
2276
+ var _userSymbology = this.config.userSymbology;
2277
+ if (_userSymbology != null && _userSymbology !== '') {
2278
+ headers['X-Stream-User-Symbology'] = _userSymbology;
2279
+ }
2280
+
2287
2281
  Object.assign(headers, this.config.credentials.getHeaders());
2288
2282
 
2289
2283
  var request = {
@@ -6154,6 +6148,7 @@ fmt.Formatter = function () {
6154
6148
  this.formatters[_streamerApi.messages.MessageTypeNames.data.MMQUOTE] = this._fmtmmquote;
6155
6149
  this.formatters[_streamerApi.messages.MessageTypeNames.data.BOOKORDER] = this._fmtbookorder;
6156
6150
  this.formatters[_streamerApi.messages.MessageTypeNames.data.PRICELEVEL] = this._fmtpricelevel;
6151
+ this.formatters[_streamerApi.messages.MessageTypeNames.data.MMPRICELEVEL] = this._fmtmmpricelevel;
6157
6152
  this.formatters[_streamerApi.messages.MessageTypeNames.data.PURGEBOOK] = this._fmtpurgebook;
6158
6153
  this.formatters[_streamerApi.messages.MessageTypeNames.data.BOOKDELETE] = this._fmtbookdelete;
6159
6154
  this.formatters[_streamerApi.messages.MessageTypeNames.data.SYMBOLINFO] = this._fmtsymbolinfo;
@@ -6580,6 +6575,34 @@ fmt.Formatter.prototype._fmtpricelevel = function (val) {
6580
6575
  return s.toString();
6581
6576
  };
6582
6577
 
6578
+ fmt.Formatter.prototype._fmtmmpricelevel = function (val) {
6579
+ var s = new fmt.StringBuilder();
6580
+ s.append('MMPL');
6581
+ s.sep();
6582
+ s.datetime(val.timestamp);
6583
+ s.sep();
6584
+ s.append(val.symbol);
6585
+ s.sep();
6586
+ s.append(val.locateCode);
6587
+ s.sep();
6588
+ s.append(val.marketMakerID);
6589
+ s.sep();
6590
+ s.append(val.excode);
6591
+ s.sep();
6592
+ s.append(val.orderSide);
6593
+ s.sep();
6594
+ s.append(val.price);
6595
+ s.sep();
6596
+ s.append(val.size);
6597
+ s.sep();
6598
+ s.append(val.count);
6599
+ s.sep();
6600
+ s.append(val.bookType);
6601
+ s.sep();
6602
+ s.append(val.changeType);
6603
+ return s.toString();
6604
+ };
6605
+
6583
6606
  fmt.Formatter.prototype._fmtbookorder = function (val) {
6584
6607
  var s = new fmt.StringBuilder();
6585
6608
  s.append('BO');
@@ -13730,8 +13753,6 @@ var StompStream = function () {
13730
13753
  };
13731
13754
 
13732
13755
  StompStream.prototype.SCFSendMessage = function SCFSendMessage(destination, frame, headers, message, callbackOrNothing) {
13733
- var jsonMessage = JSON.parse(message);
13734
-
13735
13756
  var callback = callbackOrNothing ? callbackOrNothing : optsOrCallback && typeof optsOrCallback === "function" ? optsOrCallback : null;
13736
13757
 
13737
13758
  if (this.isClosed()) {
@@ -13748,21 +13769,27 @@ var StompStream = function () {
13748
13769
 
13749
13770
  var subscription = {
13750
13771
  ids: [],
13751
- dataTypes: jsonMessage["@T"],
13752
- action: jsonMessage["action"],
13753
13772
  callback: callback
13754
13773
  };
13755
13774
 
13756
- if (jsonMessage === undefined || jsonMessage === null) {
13757
- callback(null, null);
13758
- return;
13775
+ var id = this.requestid.next();
13776
+
13777
+ var jsonMessage = void 0;
13778
+ if (message && message !== "") {
13779
+ try {
13780
+ jsonMessage = JSON.parse(message);
13781
+ } catch (err) {
13782
+ this.log.info("Error parsing message content: " + err.message);
13783
+ callback(null, null);
13784
+ return;
13785
+ }
13786
+ subscription.dataTypes = jsonMessage["@T"];
13787
+ subscription.action = jsonMessage["action"];
13788
+ jsonMessage.id = id;
13759
13789
  }
13760
13790
 
13761
- var id = this.requestid.next();
13762
13791
  subscription.ids.push(id);
13763
13792
  this.pendingSCFMessages[id] = subscription;
13764
- jsonMessage.id = id;
13765
-
13766
13793
  this.sendCustomFrame(destination, frame, headers, jsonMessage);
13767
13794
  };
13768
13795
 
@@ -14501,7 +14528,6 @@ var StompStream = function () {
14501
14528
 
14502
14529
  StompStream.prototype.SCFHandlectrlmsg = function SCFHandlectrlmsg(msg) {
14503
14530
  this.log.debug(_formatting.msgfmt.fmt(msg));
14504
- console.log(this.pendingSCFMessages);
14505
14531
  var request = this.pendingSCFMessages[msg.__id];
14506
14532
  var callback = request.callback;
14507
14533
 
@@ -14635,7 +14661,6 @@ var StompStream = function () {
14635
14661
  (0, _utils.removeFromArray)(exchangeSub.id, msg.__id);
14636
14662
  delete this.pendingExchangeSubscriptions[msg.__id];
14637
14663
 
14638
- console.log(msg);
14639
14664
  if (msg.code != 200) {
14640
14665
  var event = events.error("Error subscribing", {
14641
14666
  code: msg.code,
@@ -14663,7 +14688,6 @@ var StompStream = function () {
14663
14688
 
14664
14689
  var result = newsSub.result;
14665
14690
 
14666
- console.log(msg);
14667
14691
  if (msg.code != 200) {
14668
14692
  var event = events.error("Error subscribing to news", {
14669
14693
  code: msg.code,
@@ -14746,7 +14770,6 @@ var StompStream = function () {
14746
14770
 
14747
14771
  var result = corpEventSub.result;
14748
14772
 
14749
- console.log(msg);
14750
14773
  if (msg.code != 200) {
14751
14774
  var event = events.error("Error subscribing to Corporate Events", {
14752
14775
  code: msg.code,
@@ -14827,7 +14850,6 @@ var StompStream = function () {
14827
14850
  (0, _utils.removeFromArray)(alertsSub.id, msg.__id);
14828
14851
  delete this.pendingAlertSubscription[msg.__id];
14829
14852
 
14830
- console.log(msg);
14831
14853
  if (msg.code != 200 && !alertsSub.failed) {
14832
14854
  alertsSub.failed = true;
14833
14855
  var event = events.error("Error subscribing", {
@@ -14862,7 +14884,6 @@ var StompStream = function () {
14862
14884
  (0, _utils.removeFromArray)(tradeSub.id, msg.__id);
14863
14885
  delete this.pendingTradeSubscription[msg.__id];
14864
14886
 
14865
- console.log(msg);
14866
14887
  if (msg.code != 200 && !tradeSub.failed) {
14867
14888
  tradeSub.failed = true;
14868
14889
  var event = events.error("Error subscribing", {
@@ -14897,7 +14918,6 @@ var StompStream = function () {
14897
14918
  (0, _utils.removeFromArray)(newsUnsub.id, msg.__id);
14898
14919
  delete this.pendingNewsUnsubscriptions[msg.__id];
14899
14920
 
14900
- console.log("msg", msg);
14901
14921
  var result = newsUnsub.result;
14902
14922
 
14903
14923
  if (msg.code != 200 && !newsUnsub.failed) {
@@ -14946,7 +14966,6 @@ var StompStream = function () {
14946
14966
  (0, _utils.removeFromArray)(tradeSub.id, msg.__id);
14947
14967
  delete this.pendingTradeUnsubscription[msg.__id];
14948
14968
 
14949
- console.log(msg);
14950
14969
  if (msg.code != 200 && !tradeSub.failed) {
14951
14970
  tradeSub.failed = true;
14952
14971
  var event = events.error("Error unsubscribing", {
@@ -14975,7 +14994,6 @@ var StompStream = function () {
14975
14994
  };
14976
14995
 
14977
14996
  StompStream.prototype.onNewsCmdFilterRefreshResponse = function onNewsCmdFilterRefreshResponse(msg) {
14978
- console.log("msg", msg);
14979
14997
  if (msg.code != 200) {
14980
14998
  var event = events.error("Error Refreshing News Filters", {
14981
14999
  code: msg.code,
@@ -14989,7 +15007,6 @@ var StompStream = function () {
14989
15007
  };
14990
15008
 
14991
15009
  StompStream.prototype.onNewsCmdFilterResponse = function onNewsCmdFilterResponse(msg) {
14992
- console.log("msg", msg);
14993
15010
  if (msg.code != 200) {
14994
15011
  var event = events.error("Error Getting News Filters Status", {
14995
15012
  code: msg.code,
@@ -15046,7 +15063,6 @@ var StompStream = function () {
15046
15063
  (0, _utils.removeFromArray)(exchangeSub.id, msg.__id);
15047
15064
  delete this.pendingExchangeUnsubscriptions[msg.__id];
15048
15065
 
15049
- console.log(msg);
15050
15066
  if (msg.code != 200) {
15051
15067
  var event = events.error("Error unsubscribing", {
15052
15068
  code: msg.code,
@@ -15072,7 +15088,6 @@ var StompStream = function () {
15072
15088
  this.conn.setReconnect = false;
15073
15089
  }
15074
15090
  this.events.fire("reconnectMessage", msg);
15075
- console.log(msg);
15076
15091
  };
15077
15092
 
15078
15093
  StompStream.prototype.onConnectResponse = function onConnectResponse(msg) {
@@ -15343,6 +15358,12 @@ var StompStreamingService = function () {
15343
15358
  this.addToHeaderParams('wmid', _stompWmid);
15344
15359
  }
15345
15360
 
15361
+ var _userSymbology = this.config.userSymbology;
15362
+ if (_userSymbology != null && _userSymbology !== '') {
15363
+ headers['X-Stream-User-Symbology'] = _userSymbology;
15364
+ this.addToHeaderParams('X-Stream-User-Symbology', _userSymbology);
15365
+ }
15366
+
15346
15367
  Object.assign(headers, this.config.credentials.getHeaders());
15347
15368
 
15348
15369
  var url = this.config.url + STREAMURLS.streamStomp + HEADERPARAMS;
@@ -15461,7 +15482,7 @@ exports.__esModule = true;
15461
15482
  */
15462
15483
 
15463
15484
  var LIBRARY_NAME = exports.LIBRARY_NAME = "JavaScript";
15464
- var VERSION = exports.VERSION = "2.50.0";
15485
+ var VERSION = exports.VERSION = "2.52.0";
15465
15486
 
15466
15487
  /**
15467
15488
  * Streamer message api namespace.
@@ -15564,7 +15585,8 @@ messages.MessageTypeNames = {
15564
15585
  EARNINGS: 'D23',
15565
15586
  SPLIT: 'D24',
15566
15587
  SYMBOLCHANGED: 'D25',
15567
- PRICELEVEL: 'D26'
15588
+ PRICELEVEL: 'D26',
15589
+ MMPRICELEVEL: 'D27'
15568
15590
  }
15569
15591
  };
15570
15592
 
@@ -16343,6 +16365,7 @@ messages.control.MarketdataType = {
16343
16365
  BOOKORDER: "BOOKORDER",
16344
16366
  BOOKDELETE: "BOOKDELETE",
16345
16367
  PRICELEVEL: "PRICELEVEL",
16368
+ MMPRICELEVEL: "MMPRICELEVEL",
16346
16369
  PURGEBOOK: "PURGEBOOK",
16347
16370
  LIMITUPLIMITDOWN: "LIMITUPLIMITDOWN",
16348
16371
  IVGREEKS: "IVGREEKS",
@@ -16391,6 +16414,7 @@ messages.market.SubscriptionTypes = {
16391
16414
  NETHOUSEPOSITION: "NETHOUSEPOSITION",
16392
16415
  MMQUOTE: "MMQUOTE",
16393
16416
  PRICELEVEL: "PRICELEVEL",
16417
+ MMPRICELEVEL: "MMPRICELEVEL",
16394
16418
  BOOKORDER: "BOOKORDER",
16395
16419
  PURGEBOOK: "PURGEBOOK",
16396
16420
  BOOKDELETE: "BOOKDELETE",
@@ -16541,6 +16565,17 @@ messages.market.PriceLevel = function () {
16541
16565
  };
16542
16566
  messages.market.PriceLevel.prototype = new messages.market.DataMessage();
16543
16567
 
16568
+ /**
16569
+ *
16570
+ * @constructor
16571
+ */
16572
+ messages.market.MMPriceLevel = function () {
16573
+ this.init(messages.MessageTypeNames.data.MMPRICELEVEL);
16574
+
16575
+ // TODO properties
16576
+ };
16577
+ messages.market.MMPriceLevel.prototype = new messages.market.DataMessage();
16578
+
16544
16579
  /**
16545
16580
  *
16546
16581
  * @constructor