pmxt-core 2.37.0 → 2.37.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.
- package/dist/exchanges/kalshi/api.d.ts +1 -1
- package/dist/exchanges/kalshi/api.js +1 -1
- package/dist/exchanges/kalshi/websocket.js +36 -17
- package/dist/exchanges/limitless/api.d.ts +1 -1
- package/dist/exchanges/limitless/api.js +1 -1
- package/dist/exchanges/myriad/api.d.ts +1 -1
- package/dist/exchanges/myriad/api.js +1 -1
- package/dist/exchanges/opinion/api.d.ts +1 -1
- package/dist/exchanges/opinion/api.js +1 -1
- package/dist/exchanges/opinion/websocket.js +18 -4
- package/dist/exchanges/polymarket/api-clob.d.ts +1 -1
- package/dist/exchanges/polymarket/api-clob.js +1 -1
- package/dist/exchanges/polymarket/api-data.d.ts +1 -1
- package/dist/exchanges/polymarket/api-data.js +1 -1
- package/dist/exchanges/polymarket/api-gamma.d.ts +1 -1
- package/dist/exchanges/polymarket/api-gamma.js +1 -1
- package/dist/exchanges/probable/api.d.ts +1 -1
- package/dist/exchanges/probable/api.js +1 -1
- package/dist/server/ws-handler.js +12 -3
- package/package.json +3 -3
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Auto-generated from /home/runner/work/pmxt/pmxt/core/specs/kalshi/Kalshi.yaml
|
|
3
|
-
* Generated at: 2026-05-03T09:
|
|
3
|
+
* Generated at: 2026-05-03T09:04:43.064Z
|
|
4
4
|
* Do not edit manually -- run "npm run fetch:openapi" to regenerate.
|
|
5
5
|
*/
|
|
6
6
|
export declare const kalshiApiSpec: {
|
|
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.kalshiApiSpec = void 0;
|
|
4
4
|
/**
|
|
5
5
|
* Auto-generated from /home/runner/work/pmxt/pmxt/core/specs/kalshi/Kalshi.yaml
|
|
6
|
-
* Generated at: 2026-05-03T09:
|
|
6
|
+
* Generated at: 2026-05-03T09:04:43.064Z
|
|
7
7
|
* Do not edit manually -- run "npm run fetch:openapi" to regenerate.
|
|
8
8
|
*/
|
|
9
9
|
exports.kalshiApiSpec = {
|
|
@@ -317,13 +317,26 @@ class KalshiWebSocket {
|
|
|
317
317
|
}
|
|
318
318
|
}
|
|
319
319
|
async watchOrderBook(ticker) {
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
await this.connect();
|
|
320
|
+
if (this.isTerminated) {
|
|
321
|
+
throw new Error(`WebSocket terminated, cannot watch ${ticker}`);
|
|
323
322
|
}
|
|
324
|
-
//
|
|
323
|
+
// Track the subscription regardless of connection state.
|
|
324
|
+
// When (re)connected, the open handler resubscribes automatically.
|
|
325
325
|
if (!this.subscribedOrderBookTickers.has(ticker)) {
|
|
326
326
|
this.subscribedOrderBookTickers.add(ticker);
|
|
327
|
+
}
|
|
328
|
+
// Attempt connection — if it fails, scheduleReconnect handles recovery.
|
|
329
|
+
// The resolver will be fulfilled once the connection is (re)established
|
|
330
|
+
// and data arrives.
|
|
331
|
+
if (!this.isConnected) {
|
|
332
|
+
this.connect().catch(() => {
|
|
333
|
+
// Connection failed — scheduleReconnect is already queued via the
|
|
334
|
+
// close handler, so we intentionally swallow here. The pending
|
|
335
|
+
// resolver will be resolved when data arrives on the next connection.
|
|
336
|
+
});
|
|
337
|
+
}
|
|
338
|
+
else {
|
|
339
|
+
// Already connected — ensure subscription message is sent
|
|
327
340
|
this.subscribeToOrderbook([ticker]);
|
|
328
341
|
}
|
|
329
342
|
// Return a promise that resolves on the next orderbook update
|
|
@@ -335,18 +348,21 @@ class KalshiWebSocket {
|
|
|
335
348
|
});
|
|
336
349
|
}
|
|
337
350
|
async watchOrderBooks(tickers) {
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
await this.connect();
|
|
351
|
+
if (this.isTerminated) {
|
|
352
|
+
throw new Error("WebSocket terminated, cannot watch orderbooks");
|
|
341
353
|
}
|
|
342
|
-
//
|
|
354
|
+
// Track subscriptions regardless of connection state.
|
|
343
355
|
const newTickers = tickers.filter((t) => !this.subscribedOrderBookTickers.has(t));
|
|
344
|
-
// Add all new tickers to the subscription set
|
|
345
356
|
for (const t of newTickers) {
|
|
346
357
|
this.subscribedOrderBookTickers.add(t);
|
|
347
358
|
}
|
|
348
|
-
//
|
|
349
|
-
if (
|
|
359
|
+
// Attempt connection — if it fails, scheduleReconnect handles recovery.
|
|
360
|
+
if (!this.isConnected) {
|
|
361
|
+
this.connect().catch(() => {
|
|
362
|
+
// Swallow — scheduleReconnect will retry. Resolvers stay pending.
|
|
363
|
+
});
|
|
364
|
+
}
|
|
365
|
+
else if (newTickers.length > 0) {
|
|
350
366
|
this.subscribeToOrderbook(newTickers);
|
|
351
367
|
}
|
|
352
368
|
// Wait for all tickers to receive at least one snapshot/update
|
|
@@ -356,7 +372,6 @@ class KalshiWebSocket {
|
|
|
356
372
|
}
|
|
357
373
|
this.orderBookResolvers.get(ticker).push({
|
|
358
374
|
resolve: (book) => {
|
|
359
|
-
// Unwrap PromiseLike if needed, but in practice it is always OrderBook
|
|
360
375
|
Promise.resolve(book).then((b) => resolve([ticker, b]));
|
|
361
376
|
},
|
|
362
377
|
reject,
|
|
@@ -369,16 +384,20 @@ class KalshiWebSocket {
|
|
|
369
384
|
return result;
|
|
370
385
|
}
|
|
371
386
|
async watchTrades(ticker) {
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
await this.connect();
|
|
387
|
+
if (this.isTerminated) {
|
|
388
|
+
throw new Error(`WebSocket terminated, cannot watch trades for ${ticker}`);
|
|
375
389
|
}
|
|
376
|
-
// Subscribe if not already subscribed
|
|
377
390
|
if (!this.subscribedTradeTickers.has(ticker)) {
|
|
378
391
|
this.subscribedTradeTickers.add(ticker);
|
|
392
|
+
}
|
|
393
|
+
if (!this.isConnected) {
|
|
394
|
+
this.connect().catch(() => {
|
|
395
|
+
// Swallow — scheduleReconnect will retry. Resolvers stay pending.
|
|
396
|
+
});
|
|
397
|
+
}
|
|
398
|
+
else {
|
|
379
399
|
this.subscribeToTrades([ticker]);
|
|
380
400
|
}
|
|
381
|
-
// Return a promise that resolves on the next trade
|
|
382
401
|
return new Promise((resolve, reject) => {
|
|
383
402
|
if (!this.tradeResolvers.has(ticker)) {
|
|
384
403
|
this.tradeResolvers.set(ticker, []);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Auto-generated from /home/runner/work/pmxt/pmxt/core/specs/limitless/Limitless.yaml
|
|
3
|
-
* Generated at: 2026-05-03T09:
|
|
3
|
+
* Generated at: 2026-05-03T09:04:43.109Z
|
|
4
4
|
* Do not edit manually -- run "npm run fetch:openapi" to regenerate.
|
|
5
5
|
*/
|
|
6
6
|
export declare const limitlessApiSpec: {
|
|
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.limitlessApiSpec = void 0;
|
|
4
4
|
/**
|
|
5
5
|
* Auto-generated from /home/runner/work/pmxt/pmxt/core/specs/limitless/Limitless.yaml
|
|
6
|
-
* Generated at: 2026-05-03T09:
|
|
6
|
+
* Generated at: 2026-05-03T09:04:43.109Z
|
|
7
7
|
* Do not edit manually -- run "npm run fetch:openapi" to regenerate.
|
|
8
8
|
*/
|
|
9
9
|
exports.limitlessApiSpec = {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Auto-generated from /home/runner/work/pmxt/pmxt/core/specs/myriad/myriad.yaml
|
|
3
|
-
* Generated at: 2026-05-03T09:
|
|
3
|
+
* Generated at: 2026-05-03T09:04:43.127Z
|
|
4
4
|
* Do not edit manually -- run "npm run fetch:openapi" to regenerate.
|
|
5
5
|
*/
|
|
6
6
|
export declare const myriadApiSpec: {
|
|
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.myriadApiSpec = void 0;
|
|
4
4
|
/**
|
|
5
5
|
* Auto-generated from /home/runner/work/pmxt/pmxt/core/specs/myriad/myriad.yaml
|
|
6
|
-
* Generated at: 2026-05-03T09:
|
|
6
|
+
* Generated at: 2026-05-03T09:04:43.127Z
|
|
7
7
|
* Do not edit manually -- run "npm run fetch:openapi" to regenerate.
|
|
8
8
|
*/
|
|
9
9
|
exports.myriadApiSpec = {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Auto-generated from /home/runner/work/pmxt/pmxt/core/specs/opinion/opinion-openapi.yaml
|
|
3
|
-
* Generated at: 2026-05-03T09:
|
|
3
|
+
* Generated at: 2026-05-03T09:04:43.132Z
|
|
4
4
|
* Do not edit manually -- run "npm run fetch:openapi" to regenerate.
|
|
5
5
|
*/
|
|
6
6
|
export declare const opinionApiSpec: {
|
|
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.opinionApiSpec = void 0;
|
|
4
4
|
/**
|
|
5
5
|
* Auto-generated from /home/runner/work/pmxt/pmxt/core/specs/opinion/opinion-openapi.yaml
|
|
6
|
-
* Generated at: 2026-05-03T09:
|
|
6
|
+
* Generated at: 2026-05-03T09:04:43.132Z
|
|
7
7
|
* Do not edit manually -- run "npm run fetch:openapi" to regenerate.
|
|
8
8
|
*/
|
|
9
9
|
exports.opinionApiSpec = {
|
|
@@ -248,11 +248,18 @@ class OpinionWebSocket {
|
|
|
248
248
|
* Returns a promise that resolves on the next orderbook update.
|
|
249
249
|
*/
|
|
250
250
|
async watchOrderBook(marketId) {
|
|
251
|
-
if (
|
|
252
|
-
|
|
251
|
+
if (this.isTerminated) {
|
|
252
|
+
throw new Error(`WebSocket terminated, cannot watch market ${marketId}`);
|
|
253
253
|
}
|
|
254
254
|
if (!this.subscribedDepthMarketIds.has(marketId)) {
|
|
255
255
|
this.subscribedDepthMarketIds.add(marketId);
|
|
256
|
+
}
|
|
257
|
+
if (!this.isConnected) {
|
|
258
|
+
this.connect().catch(() => {
|
|
259
|
+
// Swallow — scheduleReconnect will retry. Resolvers stay pending.
|
|
260
|
+
});
|
|
261
|
+
}
|
|
262
|
+
else {
|
|
256
263
|
this.sendSubscribe("market.depth.diff", marketId);
|
|
257
264
|
}
|
|
258
265
|
return new Promise((resolve, reject) => {
|
|
@@ -267,11 +274,18 @@ class OpinionWebSocket {
|
|
|
267
274
|
* Returns a promise that resolves on the next trade.
|
|
268
275
|
*/
|
|
269
276
|
async watchTrades(marketId) {
|
|
270
|
-
if (
|
|
271
|
-
|
|
277
|
+
if (this.isTerminated) {
|
|
278
|
+
throw new Error(`WebSocket terminated, cannot watch trades for market ${marketId}`);
|
|
272
279
|
}
|
|
273
280
|
if (!this.subscribedTradeMarketIds.has(marketId)) {
|
|
274
281
|
this.subscribedTradeMarketIds.add(marketId);
|
|
282
|
+
}
|
|
283
|
+
if (!this.isConnected) {
|
|
284
|
+
this.connect().catch(() => {
|
|
285
|
+
// Swallow — scheduleReconnect will retry. Resolvers stay pending.
|
|
286
|
+
});
|
|
287
|
+
}
|
|
288
|
+
else {
|
|
275
289
|
this.sendSubscribe("market.last.trade", marketId);
|
|
276
290
|
}
|
|
277
291
|
return new Promise((resolve, reject) => {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Auto-generated from /home/runner/work/pmxt/pmxt/core/specs/polymarket/PolymarketClobAPI.yaml
|
|
3
|
-
* Generated at: 2026-05-03T09:
|
|
3
|
+
* Generated at: 2026-05-03T09:04:43.075Z
|
|
4
4
|
* Do not edit manually -- run "npm run fetch:openapi" to regenerate.
|
|
5
5
|
*/
|
|
6
6
|
export declare const polymarketClobSpec: {
|
|
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.polymarketClobSpec = void 0;
|
|
4
4
|
/**
|
|
5
5
|
* Auto-generated from /home/runner/work/pmxt/pmxt/core/specs/polymarket/PolymarketClobAPI.yaml
|
|
6
|
-
* Generated at: 2026-05-03T09:
|
|
6
|
+
* Generated at: 2026-05-03T09:04:43.075Z
|
|
7
7
|
* Do not edit manually -- run "npm run fetch:openapi" to regenerate.
|
|
8
8
|
*/
|
|
9
9
|
exports.polymarketClobSpec = {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Auto-generated from /home/runner/work/pmxt/pmxt/core/specs/polymarket/Polymarket_Data_API.yaml
|
|
3
|
-
* Generated at: 2026-05-03T09:
|
|
3
|
+
* Generated at: 2026-05-03T09:04:43.088Z
|
|
4
4
|
* Do not edit manually -- run "npm run fetch:openapi" to regenerate.
|
|
5
5
|
*/
|
|
6
6
|
export declare const polymarketDataSpec: {
|
|
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.polymarketDataSpec = void 0;
|
|
4
4
|
/**
|
|
5
5
|
* Auto-generated from /home/runner/work/pmxt/pmxt/core/specs/polymarket/Polymarket_Data_API.yaml
|
|
6
|
-
* Generated at: 2026-05-03T09:
|
|
6
|
+
* Generated at: 2026-05-03T09:04:43.088Z
|
|
7
7
|
* Do not edit manually -- run "npm run fetch:openapi" to regenerate.
|
|
8
8
|
*/
|
|
9
9
|
exports.polymarketDataSpec = {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Auto-generated from /home/runner/work/pmxt/pmxt/core/specs/polymarket/PolymarketGammaAPI.yaml
|
|
3
|
-
* Generated at: 2026-05-03T09:
|
|
3
|
+
* Generated at: 2026-05-03T09:04:43.086Z
|
|
4
4
|
* Do not edit manually -- run "npm run fetch:openapi" to regenerate.
|
|
5
5
|
*/
|
|
6
6
|
export declare const polymarketGammaSpec: {
|
|
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.polymarketGammaSpec = void 0;
|
|
4
4
|
/**
|
|
5
5
|
* Auto-generated from /home/runner/work/pmxt/pmxt/core/specs/polymarket/PolymarketGammaAPI.yaml
|
|
6
|
-
* Generated at: 2026-05-03T09:
|
|
6
|
+
* Generated at: 2026-05-03T09:04:43.086Z
|
|
7
7
|
* Do not edit manually -- run "npm run fetch:openapi" to regenerate.
|
|
8
8
|
*/
|
|
9
9
|
exports.polymarketGammaSpec = {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Auto-generated from /home/runner/work/pmxt/pmxt/core/specs/probable/probable.yaml
|
|
3
|
-
* Generated at: 2026-05-03T09:
|
|
3
|
+
* Generated at: 2026-05-03T09:04:43.115Z
|
|
4
4
|
* Do not edit manually -- run "npm run fetch:openapi" to regenerate.
|
|
5
5
|
*/
|
|
6
6
|
export declare const probableApiSpec: {
|
|
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.probableApiSpec = void 0;
|
|
4
4
|
/**
|
|
5
5
|
* Auto-generated from /home/runner/work/pmxt/pmxt/core/specs/probable/probable.yaml
|
|
6
|
-
* Generated at: 2026-05-03T09:
|
|
6
|
+
* Generated at: 2026-05-03T09:04:43.115Z
|
|
7
7
|
* Do not edit manually -- run "npm run fetch:openapi" to regenerate.
|
|
8
8
|
*/
|
|
9
9
|
exports.probableApiSpec = {
|
|
@@ -34,6 +34,10 @@ function subscriptionKey(msg) {
|
|
|
34
34
|
/**
|
|
35
35
|
* Start a streaming loop for a single-ticker watch method
|
|
36
36
|
* (watchOrderBook, watchTrades).
|
|
37
|
+
*
|
|
38
|
+
* The exchange layer owns connection lifecycle — watchOrderBook() blocks until
|
|
39
|
+
* data arrives, transparently handling reconnection. This loop is a simple
|
|
40
|
+
* consumer that only terminates on abort or fatal errors.
|
|
37
41
|
*/
|
|
38
42
|
async function streamSingle(exchange, method, args, id, ws, signal) {
|
|
39
43
|
const symbol = typeof args[0] === "string" ? args[0] : String(args[0]);
|
|
@@ -56,14 +60,18 @@ async function streamSingle(exchange, method, args, id, ws, signal) {
|
|
|
56
60
|
: "Unknown streaming error";
|
|
57
61
|
const code = err instanceof errors_1.BaseError ? err.code : undefined;
|
|
58
62
|
sendError(ws, id, message, code);
|
|
59
|
-
//
|
|
60
|
-
|
|
63
|
+
// Fatal error from exchange (terminated, auth failure, etc.) — stop streaming.
|
|
64
|
+
// The exchange layer handles transient reconnection internally and should
|
|
65
|
+
// never throw for recoverable connection drops.
|
|
66
|
+
break;
|
|
61
67
|
}
|
|
62
68
|
}
|
|
63
69
|
}
|
|
64
70
|
/**
|
|
65
71
|
* Start a streaming loop for the batch watchOrderBooks method.
|
|
66
72
|
* Each update is sent as an individual data message per symbol.
|
|
73
|
+
*
|
|
74
|
+
* Same lifecycle contract as streamSingle — the exchange owns reconnection.
|
|
67
75
|
*/
|
|
68
76
|
async function streamBatch(exchange, method, args, id, ws, signal) {
|
|
69
77
|
const ids = Array.isArray(args[0]) ? args[0] : [];
|
|
@@ -87,7 +95,8 @@ async function streamBatch(exchange, method, args, id, ws, signal) {
|
|
|
87
95
|
: "Unknown streaming error";
|
|
88
96
|
const code = err instanceof errors_1.BaseError ? err.code : undefined;
|
|
89
97
|
sendError(ws, id, message, code);
|
|
90
|
-
|
|
98
|
+
// Fatal error — stop streaming. Exchange handles transient reconnection.
|
|
99
|
+
break;
|
|
91
100
|
}
|
|
92
101
|
}
|
|
93
102
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pmxt-core",
|
|
3
|
-
"version": "2.37.
|
|
3
|
+
"version": "2.37.1",
|
|
4
4
|
"description": "pmxt is a unified prediction market data API. The ccxt for prediction markets.",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -29,8 +29,8 @@
|
|
|
29
29
|
"test": "jest -c jest.config.js",
|
|
30
30
|
"server": "tsx watch src/server/index.ts",
|
|
31
31
|
"server:prod": "node dist/server/index.js",
|
|
32
|
-
"generate:sdk:python": "npx @openapitools/openapi-generator-cli generate -i src/server/openapi.yaml -g python -o ../sdks/python/generated --package-name pmxt_internal --additional-properties=projectName=pmxt-internal,packageVersion=2.37.
|
|
33
|
-
"generate:sdk:typescript": "npx @openapitools/openapi-generator-cli generate -i src/server/openapi.yaml -g typescript-fetch -o ../sdks/typescript/generated --additional-properties=npmName=pmxtjs,npmVersion=2.37.
|
|
32
|
+
"generate:sdk:python": "npx @openapitools/openapi-generator-cli generate -i src/server/openapi.yaml -g python -o ../sdks/python/generated --package-name pmxt_internal --additional-properties=projectName=pmxt-internal,packageVersion=2.37.1,library=urllib3",
|
|
33
|
+
"generate:sdk:typescript": "npx @openapitools/openapi-generator-cli generate -i src/server/openapi.yaml -g typescript-fetch -o ../sdks/typescript/generated --additional-properties=npmName=pmxtjs,npmVersion=2.37.1,supportsES6=true,typescriptThreePlus=true && node ../sdks/typescript/scripts/fix-generated.js",
|
|
34
34
|
"fetch:openapi": "node scripts/fetch-openapi-specs.js",
|
|
35
35
|
"extract:jsdoc": "node ../scripts/extract-jsdoc.js",
|
|
36
36
|
"generate:docs": "npm run extract:jsdoc && node ../scripts/generate-api-docs.js",
|