@quotemedia.com/streamer 2.60.0 → 2.62.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.
@@ -1,7 +1,7 @@
1
1
  <html>
2
2
 
3
3
  <head>
4
- <script src="qmci-streamer-2.60.0.min.js"></script>
4
+ <script src="qmci-streamer-2.62.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.60.0.min.js"></script>
4
+ <script src="qmci-streamer-2.62.0.min.js"></script>
5
5
  </head>
6
6
 
7
7
  <body>
@@ -0,0 +1,231 @@
1
+ <html>
2
+
3
+ <head>
4
+ <script src="qmci-streamer-2.62.0.min.js"></script>
5
+ </head>
6
+
7
+ <body>
8
+ <script type="text/javascript">
9
+ /**
10
+ * Demonstrates how to:
11
+ * - Configure and creating stream
12
+ * - Configure and opening connection
13
+ * - Set up callback to handle messages
14
+ * - Subscribe for symbols with different type of messages
15
+ * - Unsubscribe for the symbols and the messages type
16
+ * - Close the connection and stream
17
+ */
18
+ window.onload = function() {
19
+ var Streamer = qmci.Streamer;
20
+ /**
21
+ * Step 1: Configure your login credentials inside the login method to get an SID
22
+ * Step 2: Open the streaming connection
23
+ * Step 3: Add the event listeners and the handlers for the messages
24
+ * Step 4: Make a subscription
25
+ * Step 5: Make unsubscribe
26
+ * Step 6: Close stream
27
+ */
28
+
29
+ Streamer.open({
30
+ host: 'https://app.quotemedia.com/cache',
31
+ cors: true,
32
+ rejectExcessiveConnection: false,
33
+ conflation: null,
34
+ format: 'application/json',
35
+ credentials: {
36
+ oauth_token: "YourOAuthToken"
37
+ }
38
+ }, then(function(stream) {
39
+ // After successfully opening the stream,
40
+ // listen for its events.
41
+ stream
42
+ // The stream will asynchronously callback with
43
+ // incoming market data messages.
44
+ .on("message", function(message) {
45
+ switch (Streamer.marketDataTypes.get(message)) {
46
+ case Streamer.marketDataTypes.PRICEDATA:
47
+ print("Price data: " + message.symbol, "blue");
48
+ break;
49
+ // For checking all the available marketDataTypes, go to the README.md file or check Object.keys(Streamer.marketDataTypes)
50
+ case Streamer.marketDataTypes.QUOTE:
51
+ print("Quote :" + message.symbol, "blue");
52
+ break;
53
+ case Streamer.marketDataTypes.MMQUOTE:
54
+ print("MMQuote :" + message.symbol, "blue");
55
+ break;
56
+ case Streamer.marketDataTypes.ORDERBOOK:
57
+ print("Orderbook :" + message.symbol, "blue");
58
+ break;
59
+ case Streamer.marketDataTypes.INTERVAL:
60
+ print("Interval :" + message.symbol, "blue");
61
+ break;
62
+ case Streamer.marketDataTypes.NETHOUSEPOSITION:
63
+ print("Nethouse Position :" + message.symbol, "blue");
64
+ break;
65
+ case Streamer.marketDataTypes.LASTSALE:
66
+ print("Last Sale :" + message.symbol, "blue");
67
+ break;
68
+ case Streamer.marketDataTypes.LIMITUPLIMITDOWN:
69
+ print("LULD :" + message.symbol, "blue");
70
+ break;
71
+ case Streamer.marketDataTypes.IVGREEKS:
72
+ print("IVGreeks :" + message.symbol, "blue");
73
+ break;
74
+ case Streamer.marketDataTypes.IMBALANCESTATUS:
75
+ print("Imbalance status :" + message.symbol, "blue");
76
+ break;
77
+ case Streamer.marketDataTypes.TRADE:
78
+ print("Trade :" + message.symbol + " " + message.price, "blue");
79
+ break;
80
+ }
81
+ })
82
+
83
+ // It's recommended to attach an error handler
84
+ // to help diagnose unexpected errors.
85
+ .on("error", function(err) {
86
+ print(err, "red");
87
+ })
88
+ .on("stats", function(msg) {
89
+ print("STATS. Number of l1 symbols available: " + msg.numberOfAvailableSymbolsL1 +
90
+ ", number of l2 symbols available " + msg.numberOfAvailableSymbolsL2 +
91
+ ", number of subscribed exchanges: " + msg.numberOfSubscribedExchanges +
92
+ ", number of available connections: " + msg.numberOfAvailableConnections, "green");
93
+ })
94
+ .on("slow", function(msg) {
95
+ print("Slow -> TimesExceeded: " + msg.timesExceeded + " MaxExceed: " + msg.maxExceed);
96
+ })
97
+ .on("initialDataSent", function(msg) {
98
+ print("Initial data sent. Timestamp: " + msg.timestamp);
99
+ })
100
+ .on("resubscribeMessage", function(msg) {
101
+ print("Resubscription has been triggered. Timestamp: " + msg.timestamp);
102
+ })
103
+ // Due to network hiccups or other unexepected errors,
104
+ // the stream may be unexpectedly closed.
105
+ // For robustness, it's recommended to add reconnection logic.
106
+ .on("close", function(msg) {
107
+ print("Closed: " + msg);
108
+ });
109
+
110
+ // Subscribe for symbols and subscription types.
111
+ // These can be either single strings or arrays of strings.
112
+ // See Object.keys(Streamer.subscriptionTypes) for available types.
113
+ // An optional options object can also be passed in. Current available options include:
114
+ // - skipHeavyInitialLoad: whether to skip initial heavy loads (e.g., previous trades and intervals), defaults to false.
115
+ // - conflation: Override default connection conflation, default to null. A matching conflation must be supplied when unsubscribing.
116
+ stream.subscribe(["GOOG"], [Streamer.subscriptionTypes.PRICEDATA], { skipHeavyInitialLoad: false }, then(function(result) {
117
+ // The subscription result will include the successful subscriptions
118
+ // as well as the unentitled and rejected subscriptions and invalid symbols.
119
+ var subscribed = result.subscribed;
120
+ for (var i = 0; i < subscribed.length; ++i) {
121
+ print("Subscribed: " + subscribed[i].symbol + " - " + subscribed[i].type + " (" + subscribed[i].entitlement + ")");
122
+ }
123
+
124
+ // Retrieve available number of symbols and connections, number of currently open connections and subscribed symbols.
125
+ stream.getSessionStats();
126
+
127
+ setTimeout(function() {
128
+ // Unsubscribe for symbols and data types.
129
+ // These can be either single strings or arrays of strings.
130
+ // An optional options object can also be passed in. Current available options include:
131
+ // - conflation: Override default connection conflation, default to null. Should match a subscribe conflation.
132
+ stream.unsubscribe(["GOOG"], [Streamer.subscriptionTypes.PRICEDATA], {}, then(function(result) {
133
+ // The unsubscription result will include the unsubscriptions.
134
+ var unsubscribed = result.unsubscribed;
135
+ for (var i = 0; i < unsubscribed.length; ++i) {
136
+ print("Unsubscribed: " + unsubscribed[i].symbol + " - " + unsubscribed[i].type);
137
+ }
138
+
139
+ // Finally, close the stream.
140
+ //stream.close(then(function(){
141
+ //
142
+ //}));
143
+ }));
144
+ }, 5000);
145
+ }));
146
+
147
+ //Another example for a subscription for the Trade datatype
148
+ stream.subscribe(["MSFT", "AAPL"], [Streamer.subscriptionTypes.QUOTE, Streamer.subscriptionTypes.TRADE], { skipHeavyInitialLoad: false }, then(function(result) {
149
+ var subscribed = result.subscribed;
150
+ for (var i = 0; i < subscribed.length; ++i) {
151
+ print("Subscribed: " + subscribed[i].symbol + " - " + subscribed[i].type + " (" + subscribed[i].entitlement + ")");
152
+ }
153
+ stream.getSessionStats();
154
+
155
+ setTimeout(function() {
156
+
157
+ stream.unsubscribe(["MSFT", "AAPL"], [Streamer.subscriptionTypes.QUOTE, Streamer.subscriptionTypes.TRADE], {}, then(function(result) {
158
+
159
+ var unsubscribed = result.unsubscribed;
160
+ for (var i = 0; i < unsubscribed.length; ++i) {
161
+ print("Unsubscribed: " + unsubscribed[i].symbol + " - " + unsubscribed[i].type);
162
+ }
163
+ // Finally, close the stream.
164
+ stream.close(then(function() {
165
+ print("Streamer connection closed", "red");
166
+ }));
167
+ }));
168
+ }, 5000);
169
+ }));
170
+
171
+
172
+ /**
173
+ * Subscription to an exchange to receive stock status messages containing data such as halt,
174
+ * resume, regSHO.
175
+ * ************** NOTE: **************
176
+ * The stock status by exchange feature in the streaming datafeed api is considered a premium service
177
+ * that requires additional entitlements for clients to have access to the service and helps active traders
178
+ * to monitor the market. If you are entitled to this premium service and you want exchange data,
179
+ * you can uncomment the code below.
180
+ *
181
+ * Please inquire about your account if you need further information in this regard.
182
+ * @see https://quotemediasupport.freshdesk.com/support/solutions/articles/13000088921-exchange-level-subscriptions-only-stock-status-halt-regsho-is-supported
183
+ * ***********************************
184
+ *
185
+ * An optional options object can also be passed in. Current available options include:
186
+ * - conflation: Override default connection conflation, default to null.
187
+ */
188
+
189
+ // stream.subscribeExchange("NYE", then(function(result) {
190
+ // print("Subscribed Exchange: " + result.exchange);
191
+
192
+ // setTimeout(function() {
193
+ // // Unsubscribe from the exchange.
194
+ // // An optional options object can also be passed in. Current available options include:
195
+ // // - conflation: Override default connection conflation, default to null. Should match a subscribe conflation.
196
+ // stream.unsubscribeExchange("NYE", then(function(result) {
197
+ // print("Unsubscribed Exchange: " + result.exchange);
198
+
199
+ // // Finally, close the stream.
200
+ // stream.close(then(function() {
201
+
202
+ // }));
203
+ // }));
204
+ // }, 5000);
205
+ // }));
206
+ }));
207
+
208
+
209
+ function print(msg, color) {
210
+ var el = document.createElement("div");
211
+ el.innerText = msg;
212
+ if (color) {
213
+ el.style.color = color;
214
+ }
215
+ document.body.appendChild(el);
216
+ }
217
+
218
+ function then(onSuccess) {
219
+ return function(err, result) {
220
+ if (err) {
221
+ print(err, "red");
222
+ } else {
223
+ onSuccess(result);
224
+ }
225
+ }
226
+ }
227
+ };
228
+ </script>
229
+ </body>
230
+
231
+ </html>
@@ -1,7 +1,7 @@
1
1
  <html>
2
2
 
3
3
  <head>
4
- <script src="qmci-streamer-2.60.0.min.js"></script>
4
+ <script src="qmci-streamer-2.62.0.min.js"></script>
5
5
  </head>
6
6
 
7
7
  <body>
@@ -179,7 +179,7 @@
179
179
  }));
180
180
 
181
181
  //Another example for a subscription for the Trade datatype
182
- stream.subscribe(["MSFT"], [Streamer.subscriptionTypes.TRADE], { skipHeavyInitialLoad: false }, then(function(result) {
182
+ stream.subscribe(["MSFT", "AAPL"], [Streamer.subscriptionTypes.QUOTE, Streamer.subscriptionTypes.TRADE], { skipHeavyInitialLoad: false }, then(function(result) {
183
183
  var subscribed = result.subscribed;
184
184
  for (var i = 0; i < subscribed.length; ++i) {
185
185
  print("Subscribed: " + subscribed[i].symbol + " - " + subscribed[i].type + " (" + subscribed[i].entitlement + ")");
@@ -188,7 +188,7 @@
188
188
 
189
189
  setTimeout(function() {
190
190
 
191
- stream.unsubscribe(["MSFT"], [Streamer.subscriptionTypes.TRADE], {}, then(function(result) {
191
+ stream.unsubscribe(["MSFT", "AAPL"], [Streamer.subscriptionTypes.QUOTE, Streamer.subscriptionTypes.TRADE], {}, then(function(result) {
192
192
 
193
193
  var unsubscribed = result.unsubscribed;
194
194
  for (var i = 0; i < unsubscribed.length; ++i) {
@@ -2,7 +2,7 @@
2
2
  <html lang="en">
3
3
 
4
4
  <head>
5
- <script src="qmci-streamer-2.60.0.min.js"></script>
5
+ <script src="qmci-streamer-2.62.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.60.0.min.js"></script>
4
+ <script src="qmci-streamer-2.62.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.60.0.min.js"></script>
4
+ <script src="qmci-streamer-2.62.0.min.js"></script>
5
5
  </head>
6
6
 
7
7
  <body>
@@ -166,7 +166,7 @@
166
166
  }));
167
167
 
168
168
  //Another example for a subscription for the Trade datatype
169
- stream.subscribe(["MSFT"], [Streamer.subscriptionTypes.TRADE], { skipHeavyInitialLoad: false }, then(function(result) {
169
+ stream.subscribe(["MSFT", "AAPL"], [Streamer.subscriptionTypes.QUOTE, Streamer.subscriptionTypes.TRADE], { skipHeavyInitialLoad: false }, then(function(result) {
170
170
  var subscribed = result.subscribed;
171
171
  for (var i = 0; i < subscribed.length; ++i) {
172
172
  print("Subscribed: " + subscribed[i].symbol + " - " + subscribed[i].type + " (" + subscribed[i].entitlement + ")");
@@ -175,7 +175,7 @@
175
175
 
176
176
  setTimeout(function() {
177
177
 
178
- stream.unsubscribe(["MSFT"], [Streamer.subscriptionTypes.TRADE], {}, then(function(result) {
178
+ stream.unsubscribe(["MSFT", "AAPL"], [Streamer.subscriptionTypes.QUOTE, Streamer.subscriptionTypes.TRADE], {}, then(function(result) {
179
179
 
180
180
  var unsubscribed = result.unsubscribed;
181
181
  for (var i = 0; i < unsubscribed.length; ++i) {
@@ -1,7 +1,7 @@
1
1
  <html>
2
2
 
3
3
  <head>
4
- <script src="qmci-streamer-2.60.0.min.js"></script>
4
+ <script src="qmci-streamer-2.62.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.60.0",
3
+ "version": "2.62.0",
4
4
  "description": "A JavaScript client for QuoteMedia's streaming data service.",
5
5
  "main": "lib/index.js",
6
6
  "author": "QuoteMedia",
@@ -1493,7 +1493,10 @@ var Stream = function () {
1493
1493
  }
1494
1494
  };
1495
1495
 
1496
- Stream.prototype.onHeartbeat = function onHeartbeat(msg) {};
1496
+ Stream.prototype.onHeartbeat = function onHeartbeat(msg) {
1497
+ this.log.debug(_formatting.msgfmt.fmt(msg));
1498
+ this.events.fire("heartbeat", msg);
1499
+ };
1497
1500
 
1498
1501
  Stream.prototype.onSubscribeResponse = function onSubscribeResponse(msg) {
1499
1502
  var subscription = this.pendingsubscriptions[msg.__id];
@@ -6717,6 +6720,8 @@ fmt.Formatter.prototype._fmttrade = function (val) {
6717
6720
  s.append(val.accumulatedVolume);
6718
6721
  s.sep();
6719
6722
  s.append(val.vwap);
6723
+ s.sep();
6724
+ s.append(val.orderExecutions);
6720
6725
  // TODO flags
6721
6726
  return s.toString();
6722
6727
  };
@@ -7212,6 +7217,8 @@ fmt.Formatter.prototype._fmtorderexecuted = function (val) {
7212
7217
  s.append(val.marketMakerID);
7213
7218
  s.sep();
7214
7219
  s.append(val.orderID);
7220
+ s.sep();
7221
+ s.append(val.aggressorSide);
7215
7222
 
7216
7223
  return s.toString();
7217
7224
  };
@@ -7267,7 +7274,7 @@ fmt.Formatter.prototype._fmtauthtokenresponse = function (val) {
7267
7274
 
7268
7275
  fmt.Formatter.prototype._fmtheartbeat = function (val) {
7269
7276
  var s = new fmt.StringBuilder();
7270
- s.append("HEARBEAT");
7277
+ s.append("HEARTBEAT");
7271
7278
  s.sep();
7272
7279
  s.datetime(val.timestamp);
7273
7280
  return s.toString();
@@ -8501,7 +8508,7 @@ var EnumValueTranslator = function () {
8501
8508
  case 8:
8502
8509
  return "DLN";
8503
8510
  case 9:
8504
- return "LCQ";
8511
+ return "RTQ";
8505
8512
  default:
8506
8513
  return "NA";
8507
8514
  }
@@ -14384,6 +14391,30 @@ var StompStream = function () {
14384
14391
  this.send(msg);
14385
14392
  };
14386
14393
 
14394
+ StompStream.prototype.updateOAuthToken = function updateOAuthToken(token, previousToken, callbackOrNothing) {
14395
+ var callback = callbackOrNothing ? callbackOrNothing : optsOrCallback && typeof optsOrCallback === "function" ? optsOrCallback : null;
14396
+
14397
+ if (this.isClosed()) {
14398
+ var event = events.error("Stream is disconnected", {
14399
+ code: -1,
14400
+ reason: "Already disconnected"
14401
+ });
14402
+ this.events.fire("error", event);
14403
+ return;
14404
+ }
14405
+
14406
+ var updateToken = {
14407
+ mimetype: this.format,
14408
+ callback: callback
14409
+ };
14410
+
14411
+ var request = this.buildUpdateAuthTokenRequest("oauth", token, previousToken, updateToken);
14412
+ var id = this.requestid.next();
14413
+ request.id = id;
14414
+
14415
+ this.send(request);
14416
+ };
14417
+
14387
14418
  StompStream.prototype.cmdFilterNews = function cmdFilterNews(callbackOrNothing) {
14388
14419
  var callback = callbackOrNothing ? callbackOrNothing : optsOrCallback && typeof optsOrCallback === "function" ? optsOrCallback : null;
14389
14420
 
@@ -14733,6 +14764,17 @@ var StompStream = function () {
14733
14764
  return msg;
14734
14765
  };
14735
14766
 
14767
+ StompStream.prototype.buildUpdateAuthTokenRequest = function buildUpdateAuthTokenRequest(authMethod, token, previousToken, updateToken) {
14768
+ var msg = new _streamerApi.messages.control.AuthTokenMessage();
14769
+ msg.authMethod = authMethod;
14770
+ msg.authParams = {
14771
+ "oauthToken": token,
14772
+ "previousToken": previousToken
14773
+ };
14774
+ msg.mimetype = updateToken.mimetype;
14775
+ return msg;
14776
+ };
14777
+
14736
14778
  StompStream.prototype.buildNewsCommandRequest = function buildNewsCommandRequest(sub, newsAction) {
14737
14779
  var msg = new _streamerApi.messages.control.NewsCommandMessage();
14738
14780
  msg.newsAction = newsAction;
@@ -14817,6 +14859,9 @@ var StompStream = function () {
14817
14859
  case _streamerApi.messages.MessageTypeNames.ctrl.MISSED_DATA_SENT:
14818
14860
  this.onMissedDataSent(msg);
14819
14861
  break;
14862
+ case _streamerApi.messages.MessageTypeNames.ctrl.AUTH_TOKEN_RESPONSE:
14863
+ this.onAuthTokenResponse(msg);
14864
+ break;
14820
14865
  }
14821
14866
  };
14822
14867
 
@@ -14846,7 +14891,10 @@ var StompStream = function () {
14846
14891
  }
14847
14892
  };
14848
14893
 
14849
- StompStream.prototype.onHeartbeat = function onHeartbeat(msg) {};
14894
+ StompStream.prototype.onHeartbeat = function onHeartbeat(msg) {
14895
+ this.log.debug(_formatting.msgfmt.fmt(msg));
14896
+ this.events.fire("heartbeat", msg);
14897
+ };
14850
14898
 
14851
14899
  StompStream.prototype.onSubscribeResponse = function onSubscribeResponse(msg) {
14852
14900
  var subscription = this.pendingsubscriptions[msg.__id];
@@ -15435,6 +15483,11 @@ var StompStream = function () {
15435
15483
  this.conn.send(msg);
15436
15484
  };
15437
15485
 
15486
+ StompStream.prototype.onAuthTokenResponse = function onAuthTokenResponse(msg) {
15487
+ this.log.debug(_formatting.msgfmt.fmt(msg));
15488
+ this.events.fire("authTokenResponse", msg);
15489
+ };
15490
+
15438
15491
  StompStream.prototype._handledatamsg = function _handledatamsg(msg) {
15439
15492
  this.events.fire("message", msg);
15440
15493
  };
@@ -15651,6 +15704,9 @@ var StompStreamingService = function () {
15651
15704
  } else if (this.config.credentials.data_token !== undefined) {
15652
15705
  authMessage.authenticationMethod = "datatool";
15653
15706
  authMessage.authorization = this.config.credentials.data_token;
15707
+ } else if (this.config.credentials.oauth_token !== undefined) {
15708
+ authMessage.authenticationMethod = "oauth";
15709
+ authMessage.authorization = this.config.credentials.oauth_token;
15654
15710
  }
15655
15711
 
15656
15712
  if (this.config.conflation != null && this.config.conflation !== "") {
@@ -15754,7 +15810,7 @@ exports.__esModule = true;
15754
15810
  */
15755
15811
 
15756
15812
  var LIBRARY_NAME = exports.LIBRARY_NAME = "JavaScript";
15757
- var VERSION = exports.VERSION = "2.60.0";
15813
+ var VERSION = exports.VERSION = "2.62.0";
15758
15814
 
15759
15815
  /**
15760
15816
  * Streamer API namespace.
@@ -16663,7 +16719,7 @@ messages.control.StreamEntitlementType = {
16663
16719
  DL: "Delayed",
16664
16720
  DLO: "Delayed CBOE One",
16665
16721
  DLN: "Delayed NASDAQ",
16666
- LCQ: "Low Cost QM",
16722
+ RTQ: "QM Zero",
16667
16723
  NA: "Not Entitled"
16668
16724
  };
16669
16725