pmxt-core 2.42.7 → 2.43.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.
Files changed (54) hide show
  1. package/dist/BaseExchange.d.ts +33 -12
  2. package/dist/BaseExchange.js +57 -17
  3. package/dist/exchanges/baozi/index.d.ts +2 -2
  4. package/dist/exchanges/baozi/index.js +2 -2
  5. package/dist/exchanges/gemini-titan/index.d.ts +2 -2
  6. package/dist/exchanges/gemini-titan/index.js +2 -2
  7. package/dist/exchanges/hyperliquid/index.d.ts +1 -1
  8. package/dist/exchanges/hyperliquid/index.js +1 -1
  9. package/dist/exchanges/kalshi/api.d.ts +32 -1
  10. package/dist/exchanges/kalshi/api.js +38 -1
  11. package/dist/exchanges/kalshi/fetcher.d.ts +11 -5
  12. package/dist/exchanges/kalshi/fetcher.js +12 -0
  13. package/dist/exchanges/kalshi/index.d.ts +7 -6
  14. package/dist/exchanges/kalshi/index.js +40 -31
  15. package/dist/exchanges/limitless/api.d.ts +1 -1
  16. package/dist/exchanges/limitless/api.js +1 -1
  17. package/dist/exchanges/limitless/index.d.ts +2 -2
  18. package/dist/exchanges/limitless/index.js +3 -2
  19. package/dist/exchanges/mock/index.d.ts +1 -1
  20. package/dist/exchanges/mock/index.js +1 -1
  21. package/dist/exchanges/myriad/api.d.ts +1 -1
  22. package/dist/exchanges/myriad/api.js +1 -1
  23. package/dist/exchanges/myriad/index.d.ts +2 -2
  24. package/dist/exchanges/myriad/index.js +2 -2
  25. package/dist/exchanges/opinion/api.d.ts +1 -1
  26. package/dist/exchanges/opinion/api.js +1 -1
  27. package/dist/exchanges/opinion/index.d.ts +2 -2
  28. package/dist/exchanges/opinion/index.js +2 -2
  29. package/dist/exchanges/polymarket/api-clob.d.ts +14 -1
  30. package/dist/exchanges/polymarket/api-clob.js +20 -1
  31. package/dist/exchanges/polymarket/api-data.d.ts +1 -1
  32. package/dist/exchanges/polymarket/api-data.js +1 -1
  33. package/dist/exchanges/polymarket/api-gamma.d.ts +1 -1
  34. package/dist/exchanges/polymarket/api-gamma.js +1 -1
  35. package/dist/exchanges/polymarket/fetcher.d.ts +2 -0
  36. package/dist/exchanges/polymarket/fetcher.js +24 -0
  37. package/dist/exchanges/polymarket/index.d.ts +3 -2
  38. package/dist/exchanges/polymarket/index.js +17 -2
  39. package/dist/exchanges/polymarket_us/index.d.ts +2 -2
  40. package/dist/exchanges/polymarket_us/index.js +2 -2
  41. package/dist/exchanges/probable/api.d.ts +1 -1
  42. package/dist/exchanges/probable/api.js +1 -1
  43. package/dist/exchanges/probable/index.d.ts +2 -2
  44. package/dist/exchanges/probable/index.js +2 -2
  45. package/dist/exchanges/smarkets/index.d.ts +1 -1
  46. package/dist/exchanges/smarkets/index.js +1 -1
  47. package/dist/router/Router.d.ts +1 -1
  48. package/dist/router/Router.js +4 -4
  49. package/dist/router/e2e-orderbook.d.ts +1 -0
  50. package/dist/router/e2e-orderbook.js +58 -0
  51. package/dist/server/method-verbs.json +27 -2
  52. package/dist/server/openapi.yaml +50 -4
  53. package/dist/types.d.ts +2 -0
  54. package/package.json +3 -3
@@ -202,6 +202,8 @@ export interface ExchangeHas {
202
202
  fetchOHLCV: ExchangeCapability;
203
203
  /** Whether this exchange supports fetching the order book. */
204
204
  fetchOrderBook: ExchangeCapability;
205
+ /** Whether this exchange supports fetching multiple market order books. */
206
+ fetchOrderBooks: ExchangeCapability;
205
207
  /** Whether this exchange supports fetching public trades. */
206
208
  fetchTrades: ExchangeCapability;
207
209
  /** Whether this exchange supports creating orders. */
@@ -459,17 +461,34 @@ export declare abstract class PredictionMarketExchange {
459
461
  */
460
462
  fetchOHLCV(outcomeId: string, params: OHLCVParams): Promise<PriceCandle[]>;
461
463
  /**
462
- * Fetch the current order book (bids/asks) for a specific outcome.
463
- * Essential for calculating spread, depth, and execution prices.
464
+ * Fetch the order book (bids/asks) for a specific outcome.
464
465
  *
465
466
  * @param outcomeId - The Outcome ID (outcomeId) or market slug
466
- * @param side - Optional 'yes' or 'no' to explicitly indicate the
467
- * outcome side. Required for exchanges where the API returns a
468
- * single orderbook per market (e.g. Limitless) and the caller
469
- * passes a slug instead of a token ID.
470
- * @returns Current order book with bids and asks
471
- */
472
- fetchOrderBook(outcomeId: string, side?: 'yes' | 'no'): Promise<OrderBook>;
467
+ * @param limit - Max number of bid/ask levels to return (CCXT-style).
468
+ * For range queries, limits the number of snapshots returned.
469
+ * @param params - Optional parameters:
470
+ * - `side`: 'yes' or 'no' explicitly indicate the outcome side
471
+ * (required for exchanges like Limitless where the API returns a
472
+ * single orderbook per market).
473
+ * - `since`: Unix timestamp (ms) fetch a historical snapshot from
474
+ * the archive at or before this time (hosted API only).
475
+ * - `until`: Unix timestamp (ms) — when combined with `since`,
476
+ * returns an array of OrderBook snapshots between `since` and
477
+ * `until` (hosted API only).
478
+ * @returns Order book with bids and asks. Returns OrderBook[] when
479
+ * both `since` and `until` are provided.
480
+ */
481
+ fetchOrderBook(outcomeId: string, limit?: number, params?: Record<string, any>): Promise<OrderBook>;
482
+ /**
483
+ * Batch variant of {@link fetchOrderBook}. Fetches order books for
484
+ * multiple outcomes in a single request where the exchange supports it.
485
+ *
486
+ * @param outcomeIds - List of Outcome IDs (outcomeId). Each id must be in the
487
+ * exchange's native format; market slugs are not accepted here.
488
+ * @returns A map keyed by the input id (preserving the caller's exact
489
+ * string) to its order book. Throws `NotFound` if any id has no book.
490
+ */
491
+ fetchOrderBooks(outcomeIds: string[]): Promise<Record<string, OrderBook>>;
473
492
  /**
474
493
  * Fetch raw trade history for a specific outcome.
475
494
  *
@@ -584,9 +603,10 @@ export declare abstract class PredictionMarketExchange {
584
603
  *
585
604
  * @param outcomeId - The Outcome ID to watch
586
605
  * @param limit - Optional limit for orderbook depth
606
+ * @param params - Optional exchange-specific parameters
587
607
  * @returns Promise that resolves with the current orderbook state
588
608
  */
589
- watchOrderBook(outcomeId: string, limit?: number): Promise<OrderBook>;
609
+ watchOrderBook(outcomeId: string, limit?: number, params?: Record<string, any>): Promise<OrderBook>;
590
610
  /**
591
611
  * Watch multiple order books simultaneously via WebSocket.
592
612
  * Returns a promise that resolves with a record of order book snapshots keyed by ID.
@@ -595,9 +615,10 @@ export declare abstract class PredictionMarketExchange {
595
615
  *
596
616
  * @param outcomeIds - Array of Outcome IDs to watch
597
617
  * @param limit - Optional limit for orderbook depth
618
+ * @param params - Optional exchange-specific parameters
598
619
  * @returns Promise that resolves with order books keyed by ID
599
620
  */
600
- watchOrderBooks(outcomeIds: string[], limit?: number): Promise<Record<string, OrderBook>>;
621
+ watchOrderBooks(outcomeIds: string[], limit?: number, params?: Record<string, any>): Promise<Record<string, OrderBook>>;
601
622
  /**
602
623
  * Unsubscribe from a previously watched order book stream.
603
624
  *
@@ -728,7 +749,7 @@ export declare abstract class PredictionMarketExchange {
728
749
  * Provides a typed entry point so unified methods can delegate to the implicit API
729
750
  * without casting to `any` everywhere.
730
751
  */
731
- protected callApi(operationId: string, params?: Record<string, any>): Promise<any>;
752
+ protected callApi(operationId: string, params?: Record<string, any> | any[]): Promise<any>;
732
753
  /**
733
754
  * Parse an API descriptor and generate callable methods on this instance.
734
755
  * Existing methods (unified API) are never overwritten.
@@ -54,7 +54,21 @@ class PredictionMarketExchange {
54
54
  this.http = axios_1.default.create({
55
55
  headers: {
56
56
  'User-Agent': `pmxt (https://github.com/pmxt-dev/pmxt)`
57
- }
57
+ },
58
+ paramsSerializer: {
59
+ serialize: (params) => {
60
+ const sp = new URLSearchParams();
61
+ for (const [k, v] of Object.entries(params)) {
62
+ if (v === undefined || v === null)
63
+ continue;
64
+ if (Array.isArray(v))
65
+ v.forEach((x) => sp.append(k, String(x)));
66
+ else
67
+ sp.append(k, String(v));
68
+ }
69
+ return sp.toString();
70
+ },
71
+ },
58
72
  });
59
73
  this._throttler = new throttler_1.Throttler({
60
74
  refillRate: 1 / this._rateLimit,
@@ -403,19 +417,38 @@ class PredictionMarketExchange {
403
417
  throw new Error("Method fetchOHLCV not implemented.");
404
418
  }
405
419
  /**
406
- * Fetch the current order book (bids/asks) for a specific outcome.
407
- * Essential for calculating spread, depth, and execution prices.
420
+ * Fetch the order book (bids/asks) for a specific outcome.
408
421
  *
409
422
  * @param outcomeId - The Outcome ID (outcomeId) or market slug
410
- * @param side - Optional 'yes' or 'no' to explicitly indicate the
411
- * outcome side. Required for exchanges where the API returns a
412
- * single orderbook per market (e.g. Limitless) and the caller
413
- * passes a slug instead of a token ID.
414
- * @returns Current order book with bids and asks
423
+ * @param limit - Max number of bid/ask levels to return (CCXT-style).
424
+ * For range queries, limits the number of snapshots returned.
425
+ * @param params - Optional parameters:
426
+ * - `side`: 'yes' or 'no' explicitly indicate the outcome side
427
+ * (required for exchanges like Limitless where the API returns a
428
+ * single orderbook per market).
429
+ * - `since`: Unix timestamp (ms) — fetch a historical snapshot from
430
+ * the archive at or before this time (hosted API only).
431
+ * - `until`: Unix timestamp (ms) — when combined with `since`,
432
+ * returns an array of OrderBook snapshots between `since` and
433
+ * `until` (hosted API only).
434
+ * @returns Order book with bids and asks. Returns OrderBook[] when
435
+ * both `since` and `until` are provided.
415
436
  */
416
- async fetchOrderBook(outcomeId, side) {
437
+ async fetchOrderBook(outcomeId, limit, params) {
417
438
  throw new Error("Method fetchOrderBook not implemented.");
418
439
  }
440
+ /**
441
+ * Batch variant of {@link fetchOrderBook}. Fetches order books for
442
+ * multiple outcomes in a single request where the exchange supports it.
443
+ *
444
+ * @param outcomeIds - List of Outcome IDs (outcomeId). Each id must be in the
445
+ * exchange's native format; market slugs are not accepted here.
446
+ * @returns A map keyed by the input id (preserving the caller's exact
447
+ * string) to its order book. Throws `NotFound` if any id has no book.
448
+ */
449
+ async fetchOrderBooks(outcomeIds) {
450
+ throw new Error("Method fetchOrderBooks not implemented.");
451
+ }
419
452
  /**
420
453
  * Fetch raw trade history for a specific outcome.
421
454
  *
@@ -763,9 +796,10 @@ class PredictionMarketExchange {
763
796
  *
764
797
  * @param outcomeId - The Outcome ID to watch
765
798
  * @param limit - Optional limit for orderbook depth
799
+ * @param params - Optional exchange-specific parameters
766
800
  * @returns Promise that resolves with the current orderbook state
767
801
  */
768
- async watchOrderBook(outcomeId, limit) {
802
+ async watchOrderBook(outcomeId, limit, params = {}) {
769
803
  throw new Error(`watchOrderBook() is not supported by ${this.name}`);
770
804
  }
771
805
  /**
@@ -776,14 +810,15 @@ class PredictionMarketExchange {
776
810
  *
777
811
  * @param outcomeIds - Array of Outcome IDs to watch
778
812
  * @param limit - Optional limit for orderbook depth
813
+ * @param params - Optional exchange-specific parameters
779
814
  * @returns Promise that resolves with order books keyed by ID
780
815
  */
781
- async watchOrderBooks(outcomeIds, limit) {
816
+ async watchOrderBooks(outcomeIds, limit, params = {}) {
782
817
  // Default implementation: subscribe to each ID individually.
783
818
  // Exchanges with native batch support (e.g. Kalshi) override this
784
819
  // to send a single subscribe message for all tickers.
785
820
  const entries = await Promise.all(outcomeIds.map(async (oid) => {
786
- const book = await this.watchOrderBook(oid, limit);
821
+ const book = await this.watchOrderBook(oid, limit, params);
787
822
  return [oid, book];
788
823
  }));
789
824
  const result = {};
@@ -1014,7 +1049,8 @@ class PredictionMarketExchange {
1014
1049
  */
1015
1050
  createImplicitMethod(name, endpoint, resolvedBaseUrl) {
1016
1051
  return async (params) => {
1017
- const allParams = { ...(params || {}) };
1052
+ const isArray = Array.isArray(params);
1053
+ const allParams = isArray ? {} : { ...(params || {}) };
1018
1054
  // Substitute path parameters like {ticker} from params
1019
1055
  let resolvedPath = endpoint.path.replace(/\{([^}]+)\}/g, (_match, key) => {
1020
1056
  const value = allParams[key];
@@ -1044,11 +1080,15 @@ class PredictionMarketExchange {
1044
1080
  });
1045
1081
  }
1046
1082
  else {
1047
- // POST/PUT/PATCH: remaining params go to JSON body
1083
+ // POST/PUT/PATCH: array payloads go through as-is; object
1084
+ // payloads send remaining params.
1085
+ const body = isArray
1086
+ ? params
1087
+ : (Object.keys(allParams).length > 0 ? allParams : undefined);
1048
1088
  response = await this.http.request({
1049
1089
  method: method,
1050
1090
  url,
1051
- data: Object.keys(allParams).length > 0 ? allParams : undefined,
1091
+ data: body,
1052
1092
  headers: { 'Content-Type': 'application/json', ...headers },
1053
1093
  });
1054
1094
  }
@@ -1064,7 +1104,7 @@ class PredictionMarketExchange {
1064
1104
  // ----------------------------------------------------------------------------
1065
1105
  /** All keys that appear in ExchangeHas -- kept in sync via the exhaustive check below. */
1066
1106
  static _capabilityKeys = [
1067
- 'fetchMarkets', 'fetchEvents', 'fetchOHLCV', 'fetchOrderBook',
1107
+ 'fetchMarkets', 'fetchEvents', 'fetchOHLCV', 'fetchOrderBook', 'fetchOrderBooks',
1068
1108
  'fetchTrades', 'createOrder', 'cancelOrder', 'fetchOrder',
1069
1109
  'fetchOpenOrders', 'fetchPositions', 'fetchBalance',
1070
1110
  'watchAddress', 'unwatchAddress', 'watchOrderBook', 'watchOrderBooks',
@@ -1077,7 +1117,7 @@ class PredictionMarketExchange {
1077
1117
  // ExchangeHas but is missing from _capabilityKeys above.
1078
1118
  static _exhaustiveCheck = {
1079
1119
  fetchMarkets: true, fetchEvents: true, fetchOHLCV: true,
1080
- fetchOrderBook: true, fetchTrades: true, createOrder: true,
1120
+ fetchOrderBook: true, fetchOrderBooks: true, fetchTrades: true, createOrder: true,
1081
1121
  cancelOrder: true, fetchOrder: true, fetchOpenOrders: true,
1082
1122
  fetchPositions: true, fetchBalance: true, watchAddress: true,
1083
1123
  unwatchAddress: true, watchOrderBook: true, watchOrderBooks: true, unwatchOrderBook: true,
@@ -23,7 +23,7 @@ export declare class BaoziExchange extends PredictionMarketExchange {
23
23
  protected fetchMarketsImpl(params?: MarketFetchParams): Promise<UnifiedMarket[]>;
24
24
  protected fetchEventsImpl(params: EventFetchParams): Promise<UnifiedEvent[]>;
25
25
  fetchOHLCV(): Promise<PriceCandle[]>;
26
- fetchOrderBook(outcomeId: string): Promise<OrderBook>;
26
+ fetchOrderBook(outcomeId: string, _limit?: number, _params?: Record<string, any>): Promise<OrderBook>;
27
27
  fetchTrades(): Promise<Trade[]>;
28
28
  fetchBalance(): Promise<Balance[]>;
29
29
  fetchPositions(): Promise<Position[]>;
@@ -31,7 +31,7 @@ export declare class BaoziExchange extends PredictionMarketExchange {
31
31
  cancelOrder(): Promise<Order>;
32
32
  fetchOrder(orderId: string): Promise<Order>;
33
33
  fetchOpenOrders(): Promise<Order[]>;
34
- watchOrderBook(outcomeId: string): Promise<OrderBook>;
34
+ watchOrderBook(outcomeId: string, _limit?: number, _params?: Record<string, any>): Promise<OrderBook>;
35
35
  watchTrades(): Promise<Trade[]>;
36
36
  close(): Promise<void>;
37
37
  private ensureAuth;
@@ -71,7 +71,7 @@ class BaoziExchange extends BaseExchange_1.PredictionMarketExchange {
71
71
  // Baozi has no historical price/trade API without a custom indexer
72
72
  return [];
73
73
  }
74
- async fetchOrderBook(outcomeId) {
74
+ async fetchOrderBook(outcomeId, _limit, _params) {
75
75
  const rawMarket = await this.fetcher.fetchRawOrderBook(outcomeId);
76
76
  return this.normalizer.normalizeOrderBook(rawMarket, outcomeId);
77
77
  }
@@ -315,7 +315,7 @@ class BaoziExchange extends BaseExchange_1.PredictionMarketExchange {
315
315
  // -----------------------------------------------------------------------
316
316
  // WebSocket
317
317
  // -----------------------------------------------------------------------
318
- async watchOrderBook(outcomeId) {
318
+ async watchOrderBook(outcomeId, _limit, _params = {}) {
319
319
  if (!this.ws) {
320
320
  this.ws = new websocket_1.BaoziWebSocket();
321
321
  }
@@ -15,7 +15,7 @@ export declare class GeminiTitanExchange extends PredictionMarketExchange {
15
15
  private requireAuth;
16
16
  protected fetchMarketsImpl(params?: MarketFilterParams): Promise<UnifiedMarket[]>;
17
17
  protected fetchEventsImpl(params: EventFetchParams): Promise<UnifiedEvent[]>;
18
- fetchOrderBook(outcomeId: string): Promise<OrderBook>;
18
+ fetchOrderBook(outcomeId: string, _limit?: number, _params?: Record<string, any>): Promise<OrderBook>;
19
19
  buildOrder(params: CreateOrderParams): Promise<BuiltOrder>;
20
20
  submitOrder(built: BuiltOrder): Promise<Order>;
21
21
  createOrder(params: CreateOrderParams): Promise<Order>;
@@ -25,7 +25,7 @@ export declare class GeminiTitanExchange extends PredictionMarketExchange {
25
25
  fetchAllOrders(): Promise<Order[]>;
26
26
  fetchPositions(): Promise<Position[]>;
27
27
  private ensureWebSocket;
28
- watchOrderBook(outcomeId: string): Promise<OrderBook>;
28
+ watchOrderBook(outcomeId: string, _limit?: number, _params?: Record<string, any>): Promise<OrderBook>;
29
29
  watchTrades(outcomeId: string): Promise<Trade[]>;
30
30
  close(): Promise<void>;
31
31
  }
@@ -67,7 +67,7 @@ class GeminiTitanExchange extends BaseExchange_1.PredictionMarketExchange {
67
67
  .map(e => this.normalizer.normalizeEventWithMarkets(e))
68
68
  .filter((e) => e !== null);
69
69
  }
70
- async fetchOrderBook(outcomeId) {
70
+ async fetchOrderBook(outcomeId, _limit, _params) {
71
71
  const { instrumentSymbol } = (0, utils_1.fromOutcomeId)(outcomeId);
72
72
  const raw = await this.fetcher.fetchRawOrderBook(instrumentSymbol);
73
73
  if (!raw) {
@@ -170,7 +170,7 @@ class GeminiTitanExchange extends BaseExchange_1.PredictionMarketExchange {
170
170
  }
171
171
  return this.geminiWs;
172
172
  }
173
- async watchOrderBook(outcomeId) {
173
+ async watchOrderBook(outcomeId, _limit, _params = {}) {
174
174
  const { instrumentSymbol } = (0, utils_1.fromOutcomeId)(outcomeId);
175
175
  return this.ensureWebSocket().watchOrderBook(instrumentSymbol);
176
176
  }
@@ -16,7 +16,7 @@ export declare class HyperliquidExchange extends PredictionMarketExchange {
16
16
  private requireAuth;
17
17
  protected fetchMarketsImpl(params?: MarketFilterParams): Promise<UnifiedMarket[]>;
18
18
  protected fetchEventsImpl(params: EventFetchParams): Promise<UnifiedEvent[]>;
19
- fetchOrderBook(outcomeId: string): Promise<OrderBook>;
19
+ fetchOrderBook(outcomeId: string, _limit?: number, _params?: Record<string, any>): Promise<OrderBook>;
20
20
  fetchOHLCV(outcomeId: string, params: OHLCVParams): Promise<PriceCandle[]>;
21
21
  fetchTrades(outcomeId: string, params?: TradesParams): Promise<Trade[]>;
22
22
  fetchBalance(): Promise<Balance[]>;
@@ -78,7 +78,7 @@ class HyperliquidExchange extends BaseExchange_1.PredictionMarketExchange {
78
78
  .map(q => this.normalizer.normalizeEventWithMarkets(q, meta, mids))
79
79
  .filter((e) => e !== null);
80
80
  }
81
- async fetchOrderBook(outcomeId) {
81
+ async fetchOrderBook(outcomeId, _limit, _params) {
82
82
  const raw = await this.fetcher.fetchRawOrderBook(outcomeId);
83
83
  return this.normalizer.normalizeOrderBook(raw, outcomeId);
84
84
  }
@@ -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-22T13:35:19.499Z
3
+ * Generated at: 2026-05-22T18:51:26.863Z
4
4
  * Do not edit manually -- run "npm run fetch:openapi" to regenerate.
5
5
  */
6
6
  export declare const kalshiApiSpec: {
@@ -1252,6 +1252,37 @@ export declare const kalshiApiSpec: {
1252
1252
  })[];
1253
1253
  };
1254
1254
  };
1255
+ "/markets/orderbooks": {
1256
+ get: {
1257
+ operationId: string;
1258
+ summary: string;
1259
+ tags: string[];
1260
+ security: {
1261
+ kalshiAccessKey: never[];
1262
+ kalshiAccessSignature: never[];
1263
+ kalshiAccessTimestamp: never[];
1264
+ }[];
1265
+ parameters: {
1266
+ name: string;
1267
+ in: string;
1268
+ required: boolean;
1269
+ schema: {
1270
+ type: string;
1271
+ items: {
1272
+ type: string;
1273
+ maxLength: number;
1274
+ };
1275
+ minItems: number;
1276
+ maxItems: number;
1277
+ };
1278
+ style: string;
1279
+ explode: boolean;
1280
+ "x-oapi-codegen-extra-tags": {
1281
+ validate: string;
1282
+ };
1283
+ }[];
1284
+ };
1285
+ };
1255
1286
  "/milestones/{milestone_id}": {
1256
1287
  get: {
1257
1288
  operationId: string;
@@ -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-22T13:35:19.499Z
6
+ * Generated at: 2026-05-22T18:51:26.863Z
7
7
  * Do not edit manually -- run "npm run fetch:openapi" to regenerate.
8
8
  */
9
9
  exports.kalshiApiSpec = {
@@ -1738,6 +1738,43 @@ exports.kalshiApiSpec = {
1738
1738
  ]
1739
1739
  }
1740
1740
  },
1741
+ "/markets/orderbooks": {
1742
+ "get": {
1743
+ "operationId": "GetMarketOrderbooks",
1744
+ "summary": "Get Multiple Market Orderbooks",
1745
+ "tags": [
1746
+ "market"
1747
+ ],
1748
+ "security": [
1749
+ {
1750
+ "kalshiAccessKey": [],
1751
+ "kalshiAccessSignature": [],
1752
+ "kalshiAccessTimestamp": []
1753
+ }
1754
+ ],
1755
+ "parameters": [
1756
+ {
1757
+ "name": "tickers",
1758
+ "in": "query",
1759
+ "required": true,
1760
+ "schema": {
1761
+ "type": "array",
1762
+ "items": {
1763
+ "type": "string",
1764
+ "maxLength": 200
1765
+ },
1766
+ "minItems": 1,
1767
+ "maxItems": 100
1768
+ },
1769
+ "style": "form",
1770
+ "explode": true,
1771
+ "x-oapi-codegen-extra-tags": {
1772
+ "validate": "required,min=1,max=100,dive,max=200"
1773
+ }
1774
+ }
1775
+ ]
1776
+ }
1777
+ },
1741
1778
  "/milestones/{milestone_id}": {
1742
1779
  "get": {
1743
1780
  "operationId": "GetMilestone",
@@ -1,5 +1,5 @@
1
- import { MarketFilterParams, EventFetchParams, OHLCVParams, TradesParams, MyTradesParams } from '../../BaseExchange';
2
- import { IExchangeFetcher, FetcherContext } from '../interfaces';
1
+ import { EventFetchParams, MarketFilterParams, MyTradesParams, OHLCVParams, TradesParams } from '../../BaseExchange';
2
+ import { FetcherContext, IExchangeFetcher } from '../interfaces';
3
3
  export interface KalshiRawMarket {
4
4
  ticker: string;
5
5
  last_price?: number;
@@ -63,6 +63,13 @@ export interface KalshiRawOrderBookFp {
63
63
  yes_dollars?: string[][];
64
64
  no_dollars?: string[][];
65
65
  }
66
+ export interface KalshiRawOrderBook {
67
+ ticker: string;
68
+ orderbook_fp: KalshiRawOrderBookFp;
69
+ }
70
+ export interface KalshiRawOrderBooks {
71
+ orderbooks: KalshiRawOrderBook[];
72
+ }
66
73
  export interface KalshiRawTrade {
67
74
  trade_id: string;
68
75
  created_time: string;
@@ -121,9 +128,8 @@ export declare class KalshiFetcher implements IExchangeFetcher<KalshiRawEvent, K
121
128
  fetchRawMarkets(params?: MarketFilterParams): Promise<KalshiRawEvent[]>;
122
129
  fetchRawEvents(params: EventFetchParams): Promise<KalshiRawEvent[]>;
123
130
  fetchRawOHLCV(id: string, params: OHLCVParams): Promise<KalshiRawCandlestick[]>;
124
- fetchRawOrderBook(id: string): Promise<{
125
- orderbook_fp: KalshiRawOrderBookFp;
126
- }>;
131
+ fetchRawOrderBook(id: string): Promise<KalshiRawOrderBook>;
132
+ fetchRawOrderBooks(ids: string[]): Promise<KalshiRawOrderBook[]>;
127
133
  fetchRawTrades(id: string, params: TradesParams): Promise<KalshiRawTrade[]>;
128
134
  fetchRawMyTrades(params: MyTradesParams): Promise<KalshiRawFill[]>;
129
135
  fetchRawPositions(): Promise<KalshiRawPosition[]>;
@@ -139,6 +139,18 @@ class KalshiFetcher {
139
139
  }
140
140
  return data;
141
141
  }
142
+ async fetchRawOrderBooks(ids) {
143
+ ids.forEach((id) => (0, validation_1.validateIdFormat)(id, 'OrderBook'));
144
+ const tickers = [...new Set(ids.map(id => id.replace(/-NO$/, '')))];
145
+ const data = await this.ctx.callApi('GetMarketOrderbooks', { tickers });
146
+ const orderBooks = data.orderbooks;
147
+ if (tickers.length !== orderBooks.length) {
148
+ const returned = new Set(orderBooks.map(item => item.ticker));
149
+ const missing = tickers.filter(t => !returned.has(t));
150
+ throw new errors_2.NotFound(`Order book not found for tickers ${missing.join(', ')}`, 'Kalshi');
151
+ }
152
+ return orderBooks;
153
+ }
142
154
  // -- Trades ----------------------------------------------------------------
143
155
  async fetchRawTrades(id, params) {
144
156
  const ticker = id.replace(/-NO$/, '');
@@ -1,6 +1,6 @@
1
- import { PredictionMarketExchange, MarketFilterParams, HistoryFilterParams, OHLCVParams, TradesParams, ExchangeCredentials, EventFetchParams, MyTradesParams, OrderHistoryParams } from "../../BaseExchange";
2
- import { UnifiedMarket, UnifiedEvent, PriceCandle, OrderBook, Trade, UserTrade, Balance, Order, Position, CreateOrderParams, BuiltOrder } from "../../types";
3
- import { KalshiWebSocketConfig } from "./websocket";
1
+ import { EventFetchParams, ExchangeCredentials, HistoryFilterParams, MarketFilterParams, MyTradesParams, OHLCVParams, OrderHistoryParams, PredictionMarketExchange, TradesParams } from '../../BaseExchange';
2
+ import { Balance, BuiltOrder, CreateOrderParams, Order, OrderBook, Position, PriceCandle, Trade, UnifiedEvent, UnifiedMarket, UserTrade } from '../../types';
3
+ import { KalshiWebSocketConfig } from './websocket';
4
4
  export type { KalshiWebSocketConfig };
5
5
  export interface KalshiExchangeOptions {
6
6
  credentials?: ExchangeCredentials;
@@ -24,7 +24,8 @@ export declare class KalshiExchange extends PredictionMarketExchange {
24
24
  protected fetchMarketsImpl(params?: MarketFilterParams): Promise<UnifiedMarket[]>;
25
25
  protected fetchEventsImpl(params: EventFetchParams): Promise<UnifiedEvent[]>;
26
26
  fetchOHLCV(outcomeId: string, params: OHLCVParams): Promise<PriceCandle[]>;
27
- fetchOrderBook(outcomeId: string): Promise<OrderBook>;
27
+ fetchOrderBook(outcomeId: string, _limit?: number, _params?: Record<string, any>): Promise<OrderBook>;
28
+ fetchOrderBooks(outcomeIds: string[]): Promise<Record<string, OrderBook>>;
28
29
  fetchTrades(outcomeId: string, params: TradesParams | HistoryFilterParams): Promise<Trade[]>;
29
30
  fetchBalance(): Promise<Balance[]>;
30
31
  fetchMyTrades(params?: MyTradesParams): Promise<UserTrade[]>;
@@ -38,8 +39,8 @@ export declare class KalshiExchange extends PredictionMarketExchange {
38
39
  fetchOrder(orderId: string): Promise<Order>;
39
40
  fetchOpenOrders(marketId?: string): Promise<Order[]>;
40
41
  private ws?;
41
- watchOrderBook(outcomeId: string, limit?: number): Promise<OrderBook>;
42
- watchOrderBooks(outcomeIds: string[], limit?: number): Promise<Record<string, OrderBook>>;
42
+ watchOrderBook(outcomeId: string, limit?: number, _params?: Record<string, any>): Promise<OrderBook>;
43
+ watchOrderBooks(outcomeIds: string[], limit?: number, _params?: Record<string, any>): Promise<Record<string, OrderBook>>;
43
44
  watchTrades(outcomeId: string, address?: string, since?: number, limit?: number): Promise<Trade[]>;
44
45
  close(): Promise<void>;
45
46
  }