@quotemedia.com/streamer 2.56.0 → 2.58.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.56.0.min.js"></script>
4
+ <script src="qmci-streamer-2.58.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.56.0.min.js"></script>
4
+ <script src="qmci-streamer-2.58.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.56.0.min.js"></script>
4
+ <script src="qmci-streamer-2.58.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.56.0.min.js"></script>
5
+ <script src="qmci-streamer-2.58.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
 
@@ -0,0 +1,221 @@
1
+ <html>
2
+
3
+ <head>
4
+ <script src="qmci-streamer-2.58.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 News Filters
15
+ * - Update for News Filters
16
+ * - Unsubscribe for the News Filters
17
+ * - Close the connection and stream
18
+ */
19
+ window.onload = function() {
20
+ const Streamer = qmci.Streamer;
21
+ const msgFmt = new qmci.Streamer.formatting.Formatter();
22
+ /**
23
+ * Step 1: Configure your login credentials inside the login method to get an SID
24
+ * Step 2: Open the streaming connection
25
+ * Step 3: Add the event listeners and the handlers for the messages
26
+ * Step 4: Make News Filters subscription
27
+ * Step 4: Update News Filters subscription
28
+ * Step 5: Make News Filters unsubscribe
29
+ * Step 8: Close stream
30
+ */
31
+
32
+ // Log in to get an SID.
33
+ // This can be done by directly calling to QuoteMedia's auth service.
34
+ Streamer.login({
35
+ host: 'https://app.quotemedia.com/auth',
36
+ credentials: {
37
+ wmid: "YourWebmasterID",
38
+ username: "YourUsername",
39
+ password: "YourPassword"
40
+ }
41
+ }, handleResult(function(sid) {
42
+ Streamer.open({
43
+ host: 'https://app.quotemedia.com/cache',
44
+ cors: true,
45
+ rejectExcessiveConnection: false,
46
+ conflation: null,
47
+ format: 'application/json',
48
+ credentials: { sid: sid }
49
+ }, handleResult(function(stream) {
50
+ // After successfully opening the stream,
51
+ // listen for its events.
52
+ stream
53
+ // The stream will asynchronously callback with
54
+ // incoming market data messages.
55
+ .on("message", function(message) {
56
+ print(msgFmt.fmt(message), "dodgerblue")
57
+ })
58
+ // It's recommended to attach an error handler
59
+ // to help diagnose unexpected errors.
60
+ .on("error", function(err) {
61
+ print(err, "red");
62
+ }).on("close", function(msg) {
63
+ print("Closed: " + msg);
64
+ // To catch and handling the News messages
65
+ }).on("newsRemoteMessage", function(msg) {
66
+ print("newsRemoteMessage: " + msgFmt.fmt(msg), "green");
67
+ });
68
+
69
+ /**
70
+ * Supported filter parameters for Streaming News (as of now):
71
+ *
72
+ * @param src Array of news source identifiers (e.g., "djns", "bwi").
73
+ * @param topic Array of topic identifiers.
74
+ * @param symbol Array of stock symbols.
75
+ * @param excode Array of exchange codes.
76
+ * @param exgroup Array of exchange group identifiers.
77
+ *
78
+ * Additional parameters may be supported in future releases.
79
+ */
80
+
81
+ /**
82
+ * The Below filter will return the News from
83
+ * "source" djns OR bwi, and contains
84
+ * "topic" computer OR Games and Multimedia, and contains
85
+ * "symbol" GOOG AND AAPL, and contains
86
+ * "excode" OTO AND NYE, and contains
87
+ * "exgroup" DOW AND NSD.
88
+ */
89
+ const newsFilterExampleJson1 = [
90
+ { name: "src", value: ["djns", "bwi"], association: "OR" },
91
+ { name: "topic", value: ["Computer", "Games and Multimedia"], association: "OR" },
92
+ { name: "symbol", value: ["GOOG", "AAPL"], association: "AND" },
93
+ { name: "excode", value: ["OTO", "NYE"], association: "AND" },
94
+ { name: "exgroup", value: ["DOW", "NSD"], association: "AND" }
95
+ ];
96
+
97
+ /**
98
+ * The Below filter will return the News from
99
+ * "source" djns OR mtn OR bwi, and contains
100
+ * "topic" computer OR Games and Multimedia OR Entertainment, and contains
101
+ * "symbol" GOOG OR AAPL OR COST, and contains
102
+ * "excode" OTO OR NYE, and contains
103
+ * "exgroup" DOW OR NSD.
104
+ */
105
+ const newsFilterExampleJson2 = [
106
+ { name: "src", value: ["djns", "mtn", "bwi"], association: "OR" },
107
+ { name: "topic", value: ["Computer", "Games and Multimedia", "Entertainment"], association: "OR" },
108
+ { name: "symbol", value: ["GOOG", "AAPL", "COST"], association: "OR" },
109
+ { name: "excode", value: ["OTO", "NYE"], association: "OR" },
110
+ { name: "exgroup", value: ["DOW", "NSD"], association: "OR" }
111
+ ];
112
+
113
+ const filterId = crypto.randomUUID();
114
+ print("News FilterId: " + filterId, "green");
115
+
116
+ /**
117
+ * # Subscribe to News Filters.
118
+ *
119
+ * - News Filters: Should be provided as a JSON object.
120
+ * - Filter ID: A UUID that uniquely identifies each News filter.
121
+ * - skipHeavyInitialLoad: Optional. Indicates whether to skip initial heavy-load messages. Defaults to false.
122
+ */
123
+ stream.subscribeNews(newsFilterExampleJson1, filterId, { skipHeavyInitialLoad: false }, (err, result) => {
124
+ if (err) {
125
+ print("Failed to subscribe News filter", "red")
126
+ } else {
127
+ print("News Connection opened")
128
+ print("SubscribeResponse: " + JSON.stringify(result), "green");
129
+
130
+ setTimeout(() => {
131
+ print("Get Current Subscription Filter Status")
132
+ stream.fltGetNews((err) => {
133
+ if (err) {
134
+ print("err: " + err, "red")
135
+ }
136
+ })
137
+ }, 2000);
138
+
139
+ setTimeout(() => {
140
+ print("Update News Filter")
141
+ /**
142
+ * # Update to News Filters.
143
+ *
144
+ * - News Filters: Should be provided as a JSON object.
145
+ * - Filter ID: A UUID that uniquely identifies each News filter.
146
+ * - skipHeavyInitialLoad: Optional. Indicates whether to skip initial heavy-load messages. Defaults to false.
147
+ */
148
+ stream.fltUpdateNews(newsFilterExampleJson2, filterId, (err, result) => {
149
+ if (err) {
150
+ print("Failed to update News filter" + err, "red")
151
+ } else {
152
+ print("News filter updated")
153
+ print("Filter Update Response: " + JSON.stringify(result), "green");
154
+ }
155
+ });
156
+ }, 4000)
157
+
158
+ setTimeout(() => {
159
+ print("Get Current Subscription Filter Status")
160
+ stream.fltGetNews((err) => {
161
+ if (err) {
162
+ print("err: " + err, "red")
163
+ }
164
+ })
165
+ }, 6000);
166
+
167
+ setTimeout(() => {
168
+ print("Unsubscribe News Filter")
169
+ stream.fltDeleteNews(filterId, (err) => {
170
+ if (err) {
171
+ print("err: " + err, "red")
172
+ }
173
+ })
174
+ }, 8000);
175
+
176
+ setTimeout(() => {
177
+ print("Get Current Subscription Filter Status")
178
+ stream.fltGetNews((err) => {
179
+ if (err) {
180
+ print("err: " + err, "red")
181
+ }
182
+ })
183
+ }, 10000);
184
+ }
185
+
186
+ setTimeout(() => {
187
+ // Finally, close the stream.
188
+ stream.close(handleResult(function() {
189
+ print("Connection closed")
190
+ }));
191
+ }, 12000);
192
+
193
+ });
194
+
195
+ }));
196
+
197
+ }));
198
+
199
+ function print(msg, color) {
200
+ var el = document.createElement("div");
201
+ el.innerText = msg;
202
+ if (color) {
203
+ el.style.color = color;
204
+ }
205
+ document.body.appendChild(el);
206
+ }
207
+
208
+ function handleResult(onSuccess) {
209
+ return function(err, result) {
210
+ if (err) {
211
+ print(err, "red");
212
+ } else {
213
+ onSuccess(result);
214
+ }
215
+ }
216
+ }
217
+ };
218
+ </script>
219
+ </body>
220
+
221
+ </html>
@@ -1,7 +1,7 @@
1
1
  <html>
2
2
 
3
3
  <head>
4
- <script src="qmci-streamer-2.56.0.min.js"></script>
4
+ <script src="qmci-streamer-2.58.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.56.0.min.js"></script>
4
+ <script src="qmci-streamer-2.58.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.56.0",
3
+ "version": "2.58.0",
4
4
  "description": "A JavaScript client for QuoteMedia's streaming data service.",
5
5
  "main": "lib/index.js",
6
6
  "author": "QuoteMedia",