@nevuamarkets/poly-websockets 0.1.1 → 0.1.3
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 +17 -19
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -22,22 +22,24 @@ npm install @nevuamarkets/poly-websockets
|
|
|
22
22
|
## Quick Start
|
|
23
23
|
|
|
24
24
|
```typescript
|
|
25
|
-
import {
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
25
|
+
import {
|
|
26
|
+
WSSubscriptionManager,
|
|
27
|
+
WebSocketHandlers
|
|
28
|
+
} from '@nevuamarkets/poly-websockets';
|
|
29
|
+
|
|
30
|
+
// Create the subscription manager with your own handlers
|
|
31
|
+
const manager = new WSSubscriptionManager({
|
|
32
|
+
onBook: async (events: BookEvent[]) => {
|
|
33
|
+
for (const event of events) {
|
|
34
|
+
console.log('book event', JSON.stringify(event, null, 2))
|
|
35
|
+
}
|
|
33
36
|
},
|
|
34
|
-
|
|
35
|
-
|
|
37
|
+
onPriceChange: async (events: PriceChangeEvent[]) => {
|
|
38
|
+
for (const event of events) {
|
|
39
|
+
console.log('price change event', JSON.stringify(event, null, 2))
|
|
40
|
+
}
|
|
36
41
|
}
|
|
37
|
-
};
|
|
38
|
-
|
|
39
|
-
// Create the subscription manager
|
|
40
|
-
const manager = new WSSubscriptionManager(handlers);
|
|
42
|
+
});
|
|
41
43
|
|
|
42
44
|
// Subscribe to assets
|
|
43
45
|
await manager.addSubscriptions(['asset-id-1', 'asset-id-2']);
|
|
@@ -148,10 +150,7 @@ const manager = new WSSubscriptionManager(handlers, {
|
|
|
148
150
|
|
|
149
151
|
## Examples
|
|
150
152
|
|
|
151
|
-
Check the [examples](./examples) folder for complete working examples
|
|
152
|
-
- Basic price monitoring
|
|
153
|
-
- Market data aggregation
|
|
154
|
-
- Real-time trading interfaces
|
|
153
|
+
Check the [examples](./examples) folder for complete working examples
|
|
155
154
|
|
|
156
155
|
## Error Handling
|
|
157
156
|
|
|
@@ -164,7 +163,6 @@ The library includes error handling:
|
|
|
164
163
|
Respects Polymarket's API rate limits:
|
|
165
164
|
- Default: 5 requests per second burst limit
|
|
166
165
|
- Configurable through custom Bottleneck instances
|
|
167
|
-
- Automatic backoff on rate limit hits
|
|
168
166
|
|
|
169
167
|
## License
|
|
170
168
|
|