@quotemedia.com/streamer 2.64.0 → 2.66.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,49 +1,152 @@
1
- # Overview
1
+ # QuoteMedia Streaming Data Service - JavaScript Client
2
+
2
3
  JavaScript streaming client that provides easy-to-use client APIs to connect and subscribe to QuoteMedia's market data streaming services.
3
4
 
4
5
  https://quotemedia.com/
6
+
5
7
  ## 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.
8
+
9
+ The JavaScript streaming client is a library that contains all the necessary dependencies to run in both `browser` and `Node.js` environments.
7
10
 
8
11
  ### Browser Usage
9
- To use the library in your browser project simply include the library file in your HTML page as a script.
12
+
13
+ Include the library file in your HTML page:
14
+ ```html
15
+ <script src="qmci-streamer-2.65.0.min.js"></script>
16
+ <script>
17
+ var Streamer = qmci.Streamer;
18
+ </script>
19
+ ```
10
20
 
11
21
  ### 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:
22
+
23
+ Since the `window` object is not available in `Node.js`, it will need to be mocked before importing the library:
24
+
25
+ 1. Mock the window object:
14
26
  ```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:
27
+ if (typeof global.window === 'undefined') {
28
+ var window = {
29
+ navigator: { userAgent: "atmosphere.js" },
30
+ document: {},
31
+ location: { protocol: 'https:' },
32
+ JSON: JSON
33
+ };
34
+
35
+ window.WebSocket = require("ws");
36
+ window.EventSource = require("eventsource");
37
+ window.XMLHttpRequest = require("xmlhttprequest").XMLHttpRequest;
38
+
39
+ global.window = window;
40
+ global.location = window.location;
41
+ global.WebSocket = window.WebSocket;
42
+ global.EventSource = window.EventSource;
43
+ global.navigator = window.navigator;
44
+ global.document = window.document;
45
+ }
46
+ ```
47
+
48
+ 2. Import the library:
37
49
  ```javascript
38
50
  var Streamer = require("<path to the library>");
39
51
  ```
52
+
40
53
  3. The library is ready for use in your `Node.js` project.
41
54
 
55
+ ## Quick Start
56
+
57
+ ```javascript
58
+ var Streamer = qmci.Streamer;
59
+
60
+ // Optional: enable debug logging (may impact performance)
61
+ // Streamer.logger = console;
62
+
63
+ Streamer.login({
64
+ host: 'https://app.quotemedia.com/auth',
65
+ credentials: {
66
+ wmid: 'YOUR_WMID',
67
+ username: 'YOUR_USERNAME',
68
+ password: 'YOUR_PASSWORD'
69
+ }
70
+ }, function(err, sid) {
71
+ if (err) { console.error(err); return; }
72
+
73
+ Streamer.open({
74
+ host: 'https://app.quotemedia.com/cache',
75
+ cors: true,
76
+ format: 'application/json',
77
+ credentials: { sid: sid }
78
+ }, function(err, stream) {
79
+ if (err) { console.error(err); return; }
80
+
81
+ stream.on('message', function(msg) {
82
+ switch (Streamer.marketDataTypes.get(msg)) {
83
+ case Streamer.marketDataTypes.PRICEDATA:
84
+ console.log('Price:', msg.last, msg.change);
85
+ break;
86
+ case Streamer.marketDataTypes.TRADE:
87
+ console.log('Trade:', msg.last, msg.volume);
88
+ break;
89
+ }
90
+ });
91
+
92
+ stream.on('error', function(err) {
93
+ console.error('Stream error:', err);
94
+ });
95
+
96
+ stream.on('close', function() {
97
+ console.log('Stream closed');
98
+ });
99
+
100
+ stream.subscribe(['AAPL', 'MSFT'], ['PRICEDATA', 'TRADE'], function(result) {
101
+ console.log('Subscribed:', result.subscribed);
102
+ });
103
+ });
104
+ });
105
+ ```
106
+
107
+ ## API Reference
108
+
109
+ ### Stream Methods
110
+
111
+ #### Market Data
112
+ ```javascript
113
+ stream.subscribe(symbols, types, [opts], callback)
114
+ stream.unsubscribe(symbols, types, [opts], callback)
115
+ stream.subscribeExchange(exchanges, [opts], callback)
116
+ stream.unsubscribeExchange(exchanges, [opts], callback)
117
+ ```
118
+
119
+
120
+ ## Subscription Types
121
+
122
+ Use these with `stream.subscribe()`:
123
+
124
+ `QUOTE` · `PRICEDATA` · `TRADE` · `MMQUOTE` · `ORDERBOOK` · `INTERVAL` · `NETHOUSEPOSITION` · `LASTSALE` · `LIMITUPLIMITDOWN` · `IVGREEKS` · `IMBALANCESTATUS` · `ORDEREXECUTED`
125
+
126
+ > **Note:** `ORDERBOOK` subscription generates `BOOKORDER`, `BOOKDELETE`, `PURGEBOOK`, `PRICELEVEL`, and `MMPRICELEVEL` message types.
127
+
128
+ ## Market Data Message Types
129
+
130
+ Use `Streamer.marketDataTypes.get(msg)` to identify incoming messages:
131
+
132
+ `QUOTE` · `PRICEDATA` · `TRADE` · `INTERVAL` · `LASTSALE` · `SYMBOLINFO` · `SYMBOLSTATUS` · `MMQUOTE` · `PRICELEVEL` · `MMPRICELEVEL` · `BOOKORDER` · `BOOKDELETE` · `PURGEBOOK` · `DERIVATIVEINFO` · `LIMITUPLIMITDOWN` · `IVGREEKS` · `IMBALANCESTATUS` · `NETHOUSEPOSITION` · `NEWS` · `ALERT` · `TRADENOTIFICATION` · `DIVIDEND` · `ORDEREXECUTED`
133
+
134
+ ## Formatting
135
+
136
+ Use the built-in formatter to produce human-readable message strings:
137
+ ```javascript
138
+ var formatter = new Streamer.formatting.Formatter();
139
+ var readable = formatter.fmt(message);
140
+ ```
141
+
42
142
  ## Examples
43
143
 
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.
144
+ The following example HTML files are included in the package:
145
+
146
+ - **enterprise-token-example.html** - Connect and subscribe using enterprise token authentication.
147
+ - **enduser-example.html** - Authenticate with end-user credentials (username/password) and subscribe to market data.
148
+ - **oauth-token-example.html** - Connect and subscribe using OAuth token authentication.
149
+ - **wmid-example.html** - Connect using webmaster ID (IP-based authentication).
150
+ - **subscription-example.html** - Subscribe and unsubscribe to trade data with detailed message handling.
151
+ - **reconnect-example.html** - Configure automatic reconnection on connection loss.
152
+ - **streaming-news-example.html** - Subscribe to news filters and handle incoming news messages.
@@ -1,7 +1,7 @@
1
1
  <html>
2
2
 
3
3
  <head>
4
- <script src="qmci-streamer-2.64.0.min.js"></script>
4
+ <script src="qmci-streamer-2.66.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.64.0.min.js"></script>
4
+ <script src="qmci-streamer-2.66.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.64.0.min.js"></script>
4
+ <script src="qmci-streamer-2.66.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.64.0.min.js"></script>
4
+ <script src="qmci-streamer-2.66.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.64.0.min.js"></script>
5
+ <script src="qmci-streamer-2.66.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