@quotemedia.com/streamer 2.5.0 → 2.18.1

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,139 +1,180 @@
1
- <html>
2
-
3
- <head>
4
- <script src="qmci-streamer-2.5.0.min.js"></script>
5
- </head>
6
-
7
- <body>
8
- <script type="text/javascript">
9
- window.onload = function() {
10
- var Streamer = qmci.Streamer;
11
-
12
- // Log in to get an SID.
13
- // This can be done by directly calling to QuoteMedia's auth service.
14
- Streamer.login({
15
- host: 'https://app.quotemedia.com/auth',
16
- credentials: {
17
- wmid: "YourWebmasterID",
18
- username: "YourUsername",
19
- password: "YourPassword"
20
- }
21
- }, then(function(sid) {
22
- // After obtaining the SID, use it to authenticate
23
- // and open a data stream.
24
- // Set rejectExcessiveConnection:true to reject new connections when limit is reached. If not specified or value is false,
25
- // first open connection will be closed instead.
26
- // If needed, there is ability to specify conflation value per connection. When conflation value is null
27
- // or not specified, default conflation is used.
28
- // Set format value to 'application/qitch' to use this binary protocol.
29
- // Please note that although QITCH protocol uses less bandwidth it can cause significant performance degradation.
30
- // In case if no format was specified JSON will be used by default.
31
- Streamer.open({
32
- host: 'http://app.quotemedia.com/cache',
33
- cors: true,
34
- rejectExcessiveConnection: false,
35
- conflation: null,
36
- format: 'application/json',
37
- credentials: { sid: sid }
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.dataTypes.get(message)) {
46
- case Streamer.dataTypes.PRICEDATA:
47
- print("Price data: " + message.symbol, "blue");
48
- break;
49
- }
50
- })
51
-
52
- // It's recommended to attach an error handler
53
- // to help diagnose unexpected errors.
54
- .on("error", function(err) {
55
- print(err, "red");
56
- })
57
- .on("stats", function(msg) {
58
- print("STATS. Number of l1 symbols available: " + msg.numberOfAvailableSymbolsL1 +
59
- ", number of l2 symbols available " + msg.numberOfAvailableSymbolsL2 +
60
- ", number of available connections: " + msg.numberOfAvailableConnections, "green");
61
- })
62
- .on("slow", function(msg) {
63
- print("Slow -> TimesExceeded: " + msg.timesExceeded + " MaxExceed: " + msg.maxExceed);
64
- })
65
- .on("initialDataSent", function(msg) {
66
- print("Initial data sent. Timestamp: " + msg.timestamp);
67
- })
68
- .on("resubscribeMessage", function(msg) {
69
- print("Resubscription has been triggered. Timestamp: " + msg.timestamp);
70
- })
71
- // Due to network hiccups or other unexepected errors,
72
- // the stream may be unexpectedly closed.
73
- // For robustness, it's recommended to add reconnection logic.
74
- .on("close", function(msg) {
75
- print("Closed: " + msg);
76
- });
77
-
78
- // Subscribe for symbols and data types.
79
- // These can be either single strings or arrays of strings.
80
- // See Object.keys(Streamer.datatTypes) for available types.
81
- // An optional options object can also be passed in. Current available options include:
82
- // - skipHeavyInitialLoad: whether to skip initial heavy loads (e.g., previous trades and intervals), defaults to false.
83
- // - conflation: Override default connection conflation, default to null. A matching conflation must be supplied when unsubscribing.
84
- stream.subscribe(["GOOG"], [Streamer.dataTypes.PRICEDATA], { skipHeavyInitialLoad: false }, then(function(result) {
85
- // The subscription result will include the successful subscriptions
86
- // as well as the unentitled and rejected subscriptions and invalid symbols.
87
- var subscribed = result.subscribed;
88
- for (var i = 0; i < subscribed.length; ++i) {
89
- print("Subscribed: " + subscribed[i].symbol + " - " + subscribed[i].type + " (" + subscribed[i].entitlement + ")");
90
- }
91
-
92
- // Retrieve available number of symbols and connections, number of currently open connections and subscribed symbols.
93
- stream.getSessionStats();
94
-
95
- setTimeout(function() {
96
- // Unsubscribe for symbols and data types.
97
- // These can be either single strings or arrays of strings.
98
- // An optional options object can also be passed in. Current available options include:
99
- // - conflation: Override default connection conflation, default to null. Should match a subscribe conflation.
100
- stream.unsubscribe(["GOOG"], [Streamer.dataTypes.PRICEDATA], {}, then(function(result) {
101
- // The unsubscription result will include the unsubscriptions.
102
- var unsubscribed = result.unsubscribed;
103
- for (var i = 0; i < unsubscribed.length; ++i) {
104
- print("Unsubscribed: " + unsubscribed[i].symbol + " - " + unsubscribed[i].type);
105
- }
106
-
107
- // Finally, close the stream.
108
- stream.close(then(function() {
109
-
110
- }));
111
- }));
112
- }, 5000);
113
- }));
114
- }));
115
- }));
116
-
117
- function print(msg, color) {
118
- var el = document.createElement("div");
119
- el.innerText = msg;
120
- if (color) {
121
- el.style.color = color;
122
- }
123
- document.body.appendChild(el);
124
- }
125
-
126
- function then(onSuccess) {
127
- return function(err, result) {
128
- if (err) {
129
- print(err, "red");
130
- } else {
131
- onSuccess(result);
132
- }
133
- }
134
- }
135
- };
136
- </script>
137
- </body>
138
-
1
+ <html>
2
+
3
+ <head>
4
+ <script src="qmci-streamer-2.18.1.min.js"></script>
5
+ </head>
6
+
7
+ <body>
8
+ <script type="text/javascript">
9
+ window.onload = function() {
10
+ var Streamer = qmci.Streamer;
11
+
12
+ // Log in to get an SID.
13
+ // This can be done by directly calling to QuoteMedia's auth service.
14
+ Streamer.login({
15
+ host: 'https://app.quotemedia.com/auth',
16
+ credentials: {
17
+ wmid: "YourWebmasterID",
18
+ username: "YourUsername",
19
+ password: "YourPassword"
20
+ }
21
+ }, then(function(sid) {
22
+ // After obtaining the SID, use it to authenticate
23
+ // and open a data stream.
24
+ // Set rejectExcessiveConnection:true to reject new connections when limit is reached. If not specified or value is false,
25
+ // first open connection will be closed instead.
26
+ // If needed, there is ability to specify conflation value per connection. When conflation value is null
27
+ // or not specified, default conflation is used.
28
+ // Set format value to 'application/qitch' to use this binary protocol.
29
+ // Please note that although QITCH protocol uses less bandwidth it can cause significant performance degradation.
30
+ // In case if no format was specified JSON will be used by default.
31
+
32
+ // Can also enable the built-in logging by setting the browser console as the logger.
33
+ // Must be set before calling open(). NOTE: May cause performance degradation.
34
+ // Streamer.logger = console;
35
+ Streamer.open({
36
+ host: 'http://app.quotemedia.com/cache',
37
+ cors: true,
38
+ rejectExcessiveConnection: false,
39
+ conflation: null,
40
+ format: 'application/json',
41
+ credentials: { sid: sid }
42
+ }, then(function(stream) {
43
+ // After successfully opening the stream,
44
+ // listen for its events.
45
+ stream
46
+ // The stream will asynchronously callback with
47
+ // incoming market data messages.
48
+ .on("message", function(message) {
49
+ switch (Streamer.dataTypes.get(message)) {
50
+ case Streamer.dataTypes.PRICEDATA:
51
+ print("Price data: " + message.symbol, "blue");
52
+ break;
53
+ }
54
+ })
55
+
56
+ // It's recommended to attach an error handler
57
+ // to help diagnose unexpected errors.
58
+ .on("error", function(err) {
59
+ print(err, "red");
60
+ })
61
+ .on("stats", function(msg) {
62
+ print("STATS. Number of l1 symbols available: " + msg.numberOfAvailableSymbolsL1 +
63
+ ", number of l2 symbols available " + msg.numberOfAvailableSymbolsL2 +
64
+ ", number of subscribed exchanges: " + msg.numberOfSubscribedExchanges +
65
+ ", number of available connections: " + msg.numberOfAvailableConnections, "green");
66
+ })
67
+ .on("slow", function(msg) {
68
+ print("Slow -> TimesExceeded: " + msg.timesExceeded + " MaxExceed: " + msg.maxExceed);
69
+ })
70
+ .on("initialDataSent", function(msg) {
71
+ print("Initial data sent. Timestamp: " + msg.timestamp);
72
+ })
73
+ .on("resubscribeMessage", function(msg) {
74
+ print("Resubscription has been triggered. Timestamp: " + msg.timestamp);
75
+ })
76
+ // Due to network hiccups or other unexepected errors,
77
+ // the stream may be unexpectedly closed.
78
+ // For robustness, it's recommended to add reconnection logic.
79
+ .on("close", function(msg) {
80
+ print("Closed: " + msg);
81
+ });
82
+
83
+ // Subscribe for symbols and data types.
84
+ // These can be either single strings or arrays of strings.
85
+ // See Object.keys(Streamer.datatTypes) for available types.
86
+ // An optional options object can also be passed in. Current available options include:
87
+ // - skipHeavyInitialLoad: whether to skip initial heavy loads (e.g., previous trades and intervals), defaults to false.
88
+ // - conflation: Override default connection conflation, default to null. A matching conflation must be supplied when unsubscribing.
89
+ stream.subscribe(["GOOG"], [Streamer.dataTypes.PRICEDATA], { skipHeavyInitialLoad: false }, then(function(result) {
90
+ // The subscription result will include the successful subscriptions
91
+ // as well as the unentitled and rejected subscriptions and invalid symbols.
92
+ var subscribed = result.subscribed;
93
+ for (var i = 0; i < subscribed.length; ++i) {
94
+ print("Subscribed: " + subscribed[i].symbol + " - " + subscribed[i].type + " (" + subscribed[i].entitlement + ")");
95
+ }
96
+
97
+ // Retrieve available number of symbols and connections, number of currently open connections and subscribed symbols.
98
+ stream.getSessionStats();
99
+
100
+ setTimeout(function() {
101
+ // Unsubscribe for symbols and data types.
102
+ // These can be either single strings or arrays of strings.
103
+ // An optional options object can also be passed in. Current available options include:
104
+ // - conflation: Override default connection conflation, default to null. Should match a subscribe conflation.
105
+ stream.unsubscribe(["GOOG"], [Streamer.dataTypes.PRICEDATA], {}, then(function(result) {
106
+ // The unsubscription result will include the unsubscriptions.
107
+ var unsubscribed = result.unsubscribed;
108
+ for (var i = 0; i < unsubscribed.length; ++i) {
109
+ print("Unsubscribed: " + unsubscribed[i].symbol + " - " + unsubscribed[i].type);
110
+ }
111
+
112
+ // Finally, close the stream.
113
+ //stream.close(then(function(){
114
+ //
115
+ //}));
116
+ }));
117
+ }, 5000);
118
+ }));
119
+
120
+ /**
121
+ * Subscription to an exchange to receive stock status messages containing data such as halt,
122
+ * resume, regSHO.
123
+ * ************** NOTE: **************
124
+ * The stock status by exchange feature in the streaming datafeed api is considered a premium service
125
+ * that requires additional entitlements for clients to have access to the service and helps active traders
126
+ * to monitor the market. If you are entitled to this premium service and you want exchange data,
127
+ * you can uncomment the code below.
128
+ *
129
+ * Please inquire about your account if you need further information in this regard.
130
+ * @see https://quotemediasupport.freshdesk.com/support/solutions/articles/13000088921-exchange-level-subscriptions-only-stock-status-halt-regsho-is-supported
131
+ * ***********************************
132
+ *
133
+ * An optional options object can also be passed in. Current available options include:
134
+ * - conflation: Override default connection conflation, default to null.
135
+ */
136
+
137
+ // stream.subscribeExchange("NYE", then(function(result) {
138
+ // print("Subscribed Exchange: " + result.exchange);
139
+
140
+ // setTimeout(function() {
141
+ // // Unsubscribe from the exchange.
142
+ // // An optional options object can also be passed in. Current available options include:
143
+ // // - conflation: Override default connection conflation, default to null. Should match a subscribe conflation.
144
+ // stream.unsubscribeExchange("NYE", then(function(result) {
145
+ // print("Unsubscribed Exchange: " + result.exchange);
146
+
147
+ // // Finally, close the stream.
148
+ // stream.close(then(function() {
149
+
150
+ // }));
151
+ // }));
152
+ // }, 5000);
153
+ // }));
154
+ }));
155
+
156
+ }));
157
+
158
+ function print(msg, color) {
159
+ var el = document.createElement("div");
160
+ el.innerText = msg;
161
+ if (color) {
162
+ el.style.color = color;
163
+ }
164
+ document.body.appendChild(el);
165
+ }
166
+
167
+ function then(onSuccess) {
168
+ return function(err, result) {
169
+ if (err) {
170
+ print(err, "red");
171
+ } else {
172
+ onSuccess(result);
173
+ }
174
+ }
175
+ }
176
+ };
177
+ </script>
178
+ </body>
179
+
139
180
  </html>
@@ -1,122 +1,159 @@
1
- <html>
2
-
3
- <head>
4
- <script src="qmci-streamer-2.5.0.min.js"></script>
5
- </head>
6
-
7
- <body>
8
- <script type="text/javascript">
9
- window.onload = function() {
10
- var Streamer = qmci.Streamer;
11
-
12
- Streamer.open({
13
- host: 'http://app.quotemedia.com/cache',
14
- cors: true,
15
- rejectExcessiveConnection: false,
16
- conflation: null,
17
- format: 'application/json',
18
- credentials: {
19
- wmid: "YourWebmasterID",
20
- token: "YourToken"
21
- }
22
- }, then(function(stream) {
23
- // After successfully opening the stream,
24
- // listen for its events.
25
- stream
26
- // The stream will asynchronously callback with
27
- // incoming market data messages.
28
- .on("message", function(message) {
29
- switch (Streamer.dataTypes.get(message)) {
30
- case Streamer.dataTypes.PRICEDATA:
31
- print("Price data: " + message.symbol, "blue");
32
- break;
33
- }
34
- })
35
-
36
- // It's recommended to attach an error handler
37
- // to help diagnose unexpected errors.
38
- .on("error", function(err) {
39
- print(err, "red");
40
- })
41
- .on("stats", function(msg) {
42
- print("STATS. Number of l1 symbols available: " + msg.numberOfAvailableSymbolsL1 +
43
- ", number of l2 symbols available " + msg.numberOfAvailableSymbolsL2 +
44
- ", number of available connections: " + msg.numberOfAvailableConnections, "green");
45
- })
46
- .on("slow", function(msg) {
47
- print("Slow -> TimesExceeded: " + msg.timesExceeded + " MaxExceed: " + msg.maxExceed);
48
- })
49
- .on("initialDataSent", function(msg) {
50
- print("Initial data sent. Timestamp: " + msg.timestamp);
51
- })
52
- .on("resubscribeMessage", function(msg) {
53
- print("Resubscription has been triggered. Timestamp: " + msg.timestamp);
54
- })
55
- // Due to network hiccups or other unexepected errors,
56
- // the stream may be unexpectedly closed.
57
- // For robustness, it's recommended to add reconnection logic.
58
- .on("close", function(msg) {
59
- print("Closed: " + msg);
60
- });
61
-
62
- // Subscribe for symbols and data types.
63
- // These can be either single strings or arrays of strings.
64
- // See Object.keys(Streamer.datatTypes) for available types.
65
- // An optional options object can also be passed in. Current available options include:
66
- // - skipHeavyInitialLoad: whether to skip initial heavy loads (e.g., previous trades and intervals), defaults to false.
67
- // - conflation: Override default connection conflation, default to null. A matching conflation must be supplied when unsubscribing.
68
- stream.subscribe(["GOOG"], [Streamer.dataTypes.PRICEDATA], { skipHeavyInitialLoad: false }, then(function(result) {
69
- // The subscription result will include the successful subscriptions
70
- // as well as the unentitled and rejected subscriptions and invalid symbols.
71
- var subscribed = result.subscribed;
72
- for (var i = 0; i < subscribed.length; ++i) {
73
- print("Subscribed: " + subscribed[i].symbol + " - " + subscribed[i].type + " (" + subscribed[i].entitlement + ")");
74
- }
75
-
76
- // Retrieve available number of symbols and connections, number of currently open connections and subscribed symbols.
77
- stream.getSessionStats();
78
-
79
- setTimeout(function() {
80
- // Unsubscribe for symbols and data types.
81
- // These can be either single strings or arrays of strings.
82
- // An optional options object can also be passed in. Current available options include:
83
- // - conflation: Override default connection conflation, default to null. Should match a subscribe conflation.
84
- stream.unsubscribe(["GOOG"], [Streamer.dataTypes.PRICEDATA], {}, then(function(result) {
85
- // The unsubscription result will include the unsubscriptions.
86
- var unsubscribed = result.unsubscribed;
87
- for (var i = 0; i < unsubscribed.length; ++i) {
88
- print("Unsubscribed: " + unsubscribed[i].symbol + " - " + unsubscribed[i].type);
89
- }
90
-
91
- // Finally, close the stream.
92
- stream.close(then(function() {
93
-
94
- }));
95
- }));
96
- }, 5000);
97
- }));
98
- }));
99
-
100
- function print(msg, color) {
101
- var el = document.createElement("div");
102
- el.innerText = msg;
103
- if (color) {
104
- el.style.color = color;
105
- }
106
- document.body.appendChild(el);
107
- }
108
-
109
- function then(onSuccess) {
110
- return function(err, result) {
111
- if (err) {
112
- print(err, "red");
113
- } else {
114
- onSuccess(result);
115
- }
116
- }
117
- }
118
- };
119
- </script>
120
- </body>
121
-
1
+ <html>
2
+
3
+ <head>
4
+ <script src="qmci-streamer-2.18.1.min.js"></script>
5
+ </head>
6
+
7
+ <body>
8
+ <script type="text/javascript">
9
+ window.onload = function() {
10
+ var Streamer = qmci.Streamer;
11
+
12
+ Streamer.open({
13
+ host: 'http://app.quotemedia.com/cache',
14
+ cors: true,
15
+ rejectExcessiveConnection: false,
16
+ conflation: null,
17
+ format: 'application/json',
18
+ credentials: {
19
+ wmid: "YourWebmasterID",
20
+ token: "YourToken"
21
+ }
22
+ }, then(function(stream) {
23
+ // After successfully opening the stream,
24
+ // listen for its events.
25
+ stream
26
+ // The stream will asynchronously callback with
27
+ // incoming market data messages.
28
+ .on("message", function(message) {
29
+ switch (Streamer.dataTypes.get(message)) {
30
+ case Streamer.dataTypes.PRICEDATA:
31
+ print("Price data: " + message.symbol, "blue");
32
+ break;
33
+ }
34
+ })
35
+
36
+ // It's recommended to attach an error handler
37
+ // to help diagnose unexpected errors.
38
+ .on("error", function(err) {
39
+ print(err, "red");
40
+ })
41
+ .on("stats", function(msg) {
42
+ print("STATS. Number of l1 symbols available: " + msg.numberOfAvailableSymbolsL1 +
43
+ ", number of l2 symbols available " + msg.numberOfAvailableSymbolsL2 +
44
+ ", number of subscribed exchanges: " + msg.numberOfSubscribedExchanges +
45
+ ", number of available connections: " + msg.numberOfAvailableConnections, "green");
46
+ })
47
+ .on("slow", function(msg) {
48
+ print("Slow -> TimesExceeded: " + msg.timesExceeded + " MaxExceed: " + msg.maxExceed);
49
+ })
50
+ .on("initialDataSent", function(msg) {
51
+ print("Initial data sent. Timestamp: " + msg.timestamp);
52
+ })
53
+ .on("resubscribeMessage", function(msg) {
54
+ print("Resubscription has been triggered. Timestamp: " + msg.timestamp);
55
+ })
56
+ // Due to network hiccups or other unexepected errors,
57
+ // the stream may be unexpectedly closed.
58
+ // For robustness, it's recommended to add reconnection logic.
59
+ .on("close", function(msg) {
60
+ print("Closed: " + msg);
61
+ });
62
+
63
+ // Subscribe for symbols and data types.
64
+ // These can be either single strings or arrays of strings.
65
+ // See Object.keys(Streamer.datatTypes) for available types.
66
+ // An optional options object can also be passed in. Current available options include:
67
+ // - skipHeavyInitialLoad: whether to skip initial heavy loads (e.g., previous trades and intervals), defaults to false.
68
+ // - conflation: Override default connection conflation, default to null. A matching conflation must be supplied when unsubscribing.
69
+ stream.subscribe(["GOOG"], [Streamer.dataTypes.PRICEDATA], { skipHeavyInitialLoad: false }, then(function(result) {
70
+ // The subscription result will include the successful subscriptions
71
+ // as well as the unentitled and rejected subscriptions and invalid symbols.
72
+ var subscribed = result.subscribed;
73
+ for (var i = 0; i < subscribed.length; ++i) {
74
+ print("Subscribed: " + subscribed[i].symbol + " - " + subscribed[i].type + " (" + subscribed[i].entitlement + ")");
75
+ }
76
+
77
+ // Retrieve available number of symbols and connections, number of currently open connections and subscribed symbols.
78
+ stream.getSessionStats();
79
+
80
+ setTimeout(function() {
81
+ // Unsubscribe for symbols and data types.
82
+ // These can be either single strings or arrays of strings.
83
+ // An optional options object can also be passed in. Current available options include:
84
+ // - conflation: Override default connection conflation, default to null. Should match a subscribe conflation.
85
+ stream.unsubscribe(["GOOG"], [Streamer.dataTypes.PRICEDATA], {}, then(function(result) {
86
+ // The unsubscription result will include the unsubscriptions.
87
+ var unsubscribed = result.unsubscribed;
88
+ for (var i = 0; i < unsubscribed.length; ++i) {
89
+ print("Unsubscribed: " + unsubscribed[i].symbol + " - " + unsubscribed[i].type);
90
+ }
91
+
92
+ // Finally, close the stream.
93
+ //stream.close(then(function(){
94
+ //
95
+ //}));
96
+ }));
97
+ }, 5000);
98
+ }));
99
+
100
+ /**
101
+ * Subscription to an exchange to receive stock status messages containing data such as halt,
102
+ * resume, regSHO.
103
+ * ************** NOTE: **************
104
+ * The stock status by exchange feature in the streaming datafeed api is considered a premium service
105
+ * that requires additional entitlements for clients to have access to the service and helps active traders
106
+ * to monitor the market. If you are entitled to this premium service and you want exchange data,
107
+ * you can uncomment the code below.
108
+ *
109
+ * Please inquire about your account if you need further information in this regard.
110
+ * @see https://quotemediasupport.freshdesk.com/support/solutions/articles/13000088921-exchange-level-subscriptions-only-stock-status-halt-regsho-is-supported
111
+ * ***********************************
112
+ *
113
+ * An optional options object can also be passed in. Current available options include:
114
+ * - conflation: Override default connection conflation, default to null.
115
+ */
116
+
117
+ // stream.subscribeExchange("NYE", then(function(result) {
118
+ // print("Subscribed Exchange: " + result.exchange);
119
+
120
+ // setTimeout(function() {
121
+ // // Unsubscribe from the exchange.
122
+ // // An optional options object can also be passed in. Current available options include:
123
+ // // - conflation: Override default connection conflation, default to null. Should match a subscribe conflation.
124
+ // stream.unsubscribeExchange("NYE", then(function(result) {
125
+ // print("Unsubscribed Exchange: " + result.exchange);
126
+
127
+ // // Finally, close the stream.
128
+ // stream.close(then(function() {
129
+
130
+ // }));
131
+ // }));
132
+ // }, 5000);
133
+ // }));
134
+ }));
135
+
136
+
137
+ function print(msg, color) {
138
+ var el = document.createElement("div");
139
+ el.innerText = msg;
140
+ if (color) {
141
+ el.style.color = color;
142
+ }
143
+ document.body.appendChild(el);
144
+ }
145
+
146
+ function then(onSuccess) {
147
+ return function(err, result) {
148
+ if (err) {
149
+ print(err, "red");
150
+ } else {
151
+ onSuccess(result);
152
+ }
153
+ }
154
+ }
155
+ };
156
+ </script>
157
+ </body>
158
+
122
159
  </html>