pmxt-core 2.43.11 → 2.43.13

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 (39) hide show
  1. package/dist/BaseExchange.d.ts +23 -1
  2. package/dist/BaseExchange.js +63 -1
  3. package/dist/exchanges/baozi/index.js +3 -0
  4. package/dist/exchanges/gemini-titan/index.js +3 -0
  5. package/dist/exchanges/hyperliquid/index.js +3 -0
  6. package/dist/exchanges/kalshi/api.d.ts +1 -1
  7. package/dist/exchanges/kalshi/api.js +1 -1
  8. package/dist/exchanges/kalshi/fetcher.js +4 -4
  9. package/dist/exchanges/kalshi/index.js +5 -0
  10. package/dist/exchanges/limitless/api.d.ts +1 -1
  11. package/dist/exchanges/limitless/api.js +1 -1
  12. package/dist/exchanges/limitless/index.js +3 -0
  13. package/dist/exchanges/mock/index.js +2 -0
  14. package/dist/exchanges/myriad/api.d.ts +1 -1
  15. package/dist/exchanges/myriad/api.js +1 -1
  16. package/dist/exchanges/myriad/fetcher.js +2 -1
  17. package/dist/exchanges/myriad/index.js +5 -0
  18. package/dist/exchanges/opinion/api.d.ts +1 -1
  19. package/dist/exchanges/opinion/api.js +1 -1
  20. package/dist/exchanges/opinion/index.js +3 -0
  21. package/dist/exchanges/polymarket/api-clob.d.ts +1 -1
  22. package/dist/exchanges/polymarket/api-clob.js +1 -1
  23. package/dist/exchanges/polymarket/api-data.d.ts +1 -1
  24. package/dist/exchanges/polymarket/api-data.js +1 -1
  25. package/dist/exchanges/polymarket/api-gamma.d.ts +1 -1
  26. package/dist/exchanges/polymarket/api-gamma.js +1 -1
  27. package/dist/exchanges/polymarket/fetcher.js +2 -0
  28. package/dist/exchanges/polymarket/index.js +4 -0
  29. package/dist/exchanges/polymarket_us/index.js +3 -0
  30. package/dist/exchanges/probable/api.d.ts +1 -1
  31. package/dist/exchanges/probable/api.js +1 -1
  32. package/dist/exchanges/probable/index.js +5 -0
  33. package/dist/exchanges/smarkets/fetcher.d.ts +1 -1
  34. package/dist/exchanges/smarkets/fetcher.js +6 -4
  35. package/dist/exchanges/smarkets/index.js +5 -0
  36. package/dist/server/openapi.yaml +17 -3
  37. package/dist/utils/validation.d.ts +1 -0
  38. package/dist/utils/validation.js +7 -0
  39. package/package.json +3 -3
@@ -103,12 +103,14 @@ export interface OHLCVParams {
103
103
  /**
104
104
  * Parameters for fetching trade history. No resolution parameter - trades are discrete events.
105
105
  */
106
+ /** Maximum allowed value for `TradesParams.limit`. */
107
+ export declare const MAX_TRADES_LIMIT = 1000;
106
108
  export interface TradesParams {
107
109
  /** Start of the time range */
108
110
  start?: Date;
109
111
  /** End of the time range */
110
112
  end?: Date;
111
- /** Maximum number of results to return */
113
+ /** Maximum number of results to return (max {@link MAX_TRADES_LIMIT}) */
112
114
  limit?: number;
113
115
  }
114
116
  export interface MyTradesParams {
@@ -126,6 +128,11 @@ export interface FetchOrderBookParams {
126
128
  /** Outcome side: 'yes' or 'no'. Required for exchanges like Limitless
127
129
  * where the API returns a single orderbook per market. */
128
130
  side?: 'yes' | 'no';
131
+ /** Outcome alias: 'yes' or 'no', or an outcome token ID. When set,
132
+ * the first argument is treated as a market ID and this value selects
133
+ * which outcome's order book to fetch. Accepts the literal strings
134
+ * 'yes'/'no' (resolved via a market lookup) or a raw outcome token ID. */
135
+ outcome?: string;
129
136
  /** Unix timestamp (ms) — fetch a historical snapshot at or before this
130
137
  * time, or the start of a range when combined with `until` (hosted API only). */
131
138
  since?: number;
@@ -451,6 +458,21 @@ export declare abstract class PredictionMarketExchange {
451
458
  * @throws MarketNotFound if no market matches the parameters
452
459
  */
453
460
  fetchMarket(params?: MarketFetchParams): Promise<UnifiedMarket>;
461
+ private cacheMarketLookup;
462
+ private marketMatchesIdentifier;
463
+ private getCachedMarketForOutcomeAlias;
464
+ private fetchMarketForOutcomeAlias;
465
+ /**
466
+ * Resolve an outcome alias ('yes'/'no') to an actual outcome token ID.
467
+ * When params.outcome is set, treats `id` as a market ID, looks up the
468
+ * market, and returns the resolved outcome token ID plus cleaned params.
469
+ * When params.outcome is already a token ID (not 'yes'/'no'), returns it
470
+ * directly. When params.outcome is not set, returns `id` unchanged.
471
+ */
472
+ protected resolveOutcomeAlias(id: string, params?: FetchOrderBookParams): Promise<{
473
+ outcomeId: string;
474
+ params?: FetchOrderBookParams;
475
+ }>;
454
476
  /**
455
477
  * Fetch a single event by lookup parameters.
456
478
  * Convenience wrapper around fetchEvents() that returns a single result or throws EventNotFound.
@@ -3,12 +3,17 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.PredictionMarketExchange = void 0;
6
+ exports.PredictionMarketExchange = exports.MAX_TRADES_LIMIT = void 0;
7
7
  const axios_1 = __importDefault(require("axios"));
8
8
  const errors_1 = require("./errors");
9
9
  const math_1 = require("./utils/math");
10
10
  const logger_1 = require("./utils/logger");
11
11
  const throttler_1 = require("./utils/throttler");
12
+ /**
13
+ * Parameters for fetching trade history. No resolution parameter - trades are discrete events.
14
+ */
15
+ /** Maximum allowed value for `TradesParams.limit`. */
16
+ exports.MAX_TRADES_LIMIT = 1000;
12
17
  // ----------------------------------------------------------------------------
13
18
  // Base Exchange Class
14
19
  // ----------------------------------------------------------------------------
@@ -381,6 +386,63 @@ class PredictionMarketExchange {
381
386
  }
382
387
  return markets[0];
383
388
  }
389
+ cacheMarketLookup(market) {
390
+ this.markets[market.marketId] = market;
391
+ if (market.slug) {
392
+ this.marketsBySlug[market.slug] = market;
393
+ }
394
+ }
395
+ marketMatchesIdentifier(market, id) {
396
+ return market.marketId === id
397
+ || market.slug === id
398
+ || market.contractAddress === id
399
+ || market.id === id;
400
+ }
401
+ getCachedMarketForOutcomeAlias(id) {
402
+ const direct = this.markets[id] ?? this.marketsBySlug[id];
403
+ if (direct && this.marketMatchesIdentifier(direct, id))
404
+ return direct;
405
+ return Object.values(this.markets).find((market) => this.marketMatchesIdentifier(market, id));
406
+ }
407
+ async fetchMarketForOutcomeAlias(id) {
408
+ const cached = this.getCachedMarketForOutcomeAlias(id);
409
+ if (cached)
410
+ return cached;
411
+ for (const params of [{ marketId: id }, { slug: id }]) {
412
+ const markets = await this.fetchMarkets(params);
413
+ const exact = markets.find((market) => this.marketMatchesIdentifier(market, id));
414
+ const market = exact ?? (markets.length === 1 ? markets[0] : undefined);
415
+ if (market) {
416
+ this.cacheMarketLookup(market);
417
+ return market;
418
+ }
419
+ }
420
+ throw new errors_1.MarketNotFound(id, this.name);
421
+ }
422
+ /**
423
+ * Resolve an outcome alias ('yes'/'no') to an actual outcome token ID.
424
+ * When params.outcome is set, treats `id` as a market ID, looks up the
425
+ * market, and returns the resolved outcome token ID plus cleaned params.
426
+ * When params.outcome is already a token ID (not 'yes'/'no'), returns it
427
+ * directly. When params.outcome is not set, returns `id` unchanged.
428
+ */
429
+ async resolveOutcomeAlias(id, params) {
430
+ if (!params?.outcome)
431
+ return { outcomeId: id, params };
432
+ const outcome = String(params.outcome);
433
+ const alias = outcome.toLowerCase();
434
+ const { outcome: _, ...rest } = params;
435
+ if (alias === 'yes' || alias === 'no') {
436
+ const market = await this.fetchMarketForOutcomeAlias(id);
437
+ const selected = alias === 'yes' ? market.yes : market.no;
438
+ if (!selected) {
439
+ throw new Error(`Market "${id}" has no '${alias}' outcome on ${this.name}`);
440
+ }
441
+ return { outcomeId: selected.outcomeId, params: rest };
442
+ }
443
+ // outcome is already a raw token ID — use it directly
444
+ return { outcomeId: outcome, params: rest };
445
+ }
384
446
  // ----------------------------------------------------------------------------
385
447
  // Implementation methods (to be overridden by exchanges)
386
448
  // ----------------------------------------------------------------------------
@@ -73,6 +73,9 @@ class BaoziExchange extends BaseExchange_1.PredictionMarketExchange {
73
73
  return [];
74
74
  }
75
75
  async fetchOrderBook(outcomeId, _limit, _params) {
76
+ const resolved = await this.resolveOutcomeAlias(outcomeId, _params);
77
+ outcomeId = resolved.outcomeId;
78
+ _params = resolved.params;
76
79
  const rawMarket = await this.fetcher.fetchRawOrderBook(outcomeId);
77
80
  return this.normalizer.normalizeOrderBook(rawMarket, outcomeId);
78
81
  }
@@ -68,6 +68,9 @@ class GeminiTitanExchange extends BaseExchange_1.PredictionMarketExchange {
68
68
  .filter((e) => e !== null);
69
69
  }
70
70
  async fetchOrderBook(outcomeId, _limit, _params) {
71
+ const resolved = await this.resolveOutcomeAlias(outcomeId, _params);
72
+ outcomeId = resolved.outcomeId;
73
+ _params = resolved.params;
71
74
  const { instrumentSymbol } = (0, utils_1.fromOutcomeId)(outcomeId);
72
75
  const raw = await this.fetcher.fetchRawOrderBook(instrumentSymbol);
73
76
  if (!raw) {
@@ -79,6 +79,9 @@ class HyperliquidExchange extends BaseExchange_1.PredictionMarketExchange {
79
79
  .filter((e) => e !== null);
80
80
  }
81
81
  async fetchOrderBook(outcomeId, _limit, _params) {
82
+ const resolved = await this.resolveOutcomeAlias(outcomeId, _params);
83
+ outcomeId = resolved.outcomeId;
84
+ _params = resolved.params;
82
85
  const raw = await this.fetcher.fetchRawOrderBook(outcomeId);
83
86
  return this.normalizer.normalizeOrderBook(raw, outcomeId);
84
87
  }
@@ -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-23T11:49:57.982Z
3
+ * Generated at: 2026-05-23T22:05:07.957Z
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-23T11:49:57.982Z
6
+ * Generated at: 2026-05-23T22:05:07.957Z
7
7
  * Do not edit manually -- run "npm run fetch:openapi" to regenerate.
8
8
  */
9
9
  exports.kalshiApiSpec = {
@@ -155,10 +155,10 @@ class KalshiFetcher {
155
155
  // -- Trades ----------------------------------------------------------------
156
156
  async fetchRawTrades(id, params) {
157
157
  const ticker = id.replace(/-NO$/, '');
158
- const data = await this.ctx.callApi('GetTrades', {
159
- ticker,
160
- limit: params.limit || 100,
161
- });
158
+ const query = { ticker };
159
+ if (params.limit)
160
+ query.limit = params.limit;
161
+ const data = await this.ctx.callApi('GetTrades', query);
162
162
  return data.trades || [];
163
163
  }
164
164
  // -- User data -------------------------------------------------------------
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.KalshiExchange = void 0;
4
4
  const BaseExchange_1 = require("../../BaseExchange");
5
5
  const errors_1 = require("../../errors");
6
+ const validation_1 = require("../../utils/validation");
6
7
  const openapi_1 = require("../../utils/openapi");
7
8
  const logger_1 = require("../../utils/logger");
8
9
  const api_1 = require("./api");
@@ -122,6 +123,9 @@ class KalshiExchange extends BaseExchange_1.PredictionMarketExchange {
122
123
  return this.normalizer.normalizeOHLCV(rawCandles, params);
123
124
  }
124
125
  async fetchOrderBook(outcomeId, _limit, _params) {
126
+ const resolved = await this.resolveOutcomeAlias(outcomeId, _params);
127
+ outcomeId = resolved.outcomeId;
128
+ _params = resolved.params;
125
129
  const raw = await this.fetcher.fetchRawOrderBook(outcomeId);
126
130
  return this.normalizer.normalizeOrderBook(raw, outcomeId);
127
131
  }
@@ -137,6 +141,7 @@ class KalshiExchange extends BaseExchange_1.PredictionMarketExchange {
137
141
  return response;
138
142
  }
139
143
  async fetchTrades(outcomeId, params) {
144
+ (0, validation_1.validateTradesLimit)(params.limit);
140
145
  if ('resolution' in params && params.resolution !== undefined) {
141
146
  logger_1.logger.warn('The "resolution" parameter is deprecated for fetchTrades() and will be ignored. ' +
142
147
  'It will be removed in v3.0.0. Please remove it from your code.');
@@ -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-23T11:49:58.021Z
3
+ * Generated at: 2026-05-23T22:05:08.004Z
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-23T11:49:58.021Z
6
+ * Generated at: 2026-05-23T22:05:08.004Z
7
7
  * Do not edit manually -- run "npm run fetch:openapi" to regenerate.
8
8
  */
9
9
  exports.limitlessApiSpec = {
@@ -156,6 +156,9 @@ class LimitlessExchange extends BaseExchange_1.PredictionMarketExchange {
156
156
  return this.normalizer.normalizeOHLCV(rawPrices, params);
157
157
  }
158
158
  async fetchOrderBook(outcomeId, limit, params) {
159
+ const resolved = await this.resolveOutcomeAlias(outcomeId, params);
160
+ outcomeId = resolved.outcomeId;
161
+ params = resolved.params;
159
162
  const slug = await this.resolveSlug(outcomeId);
160
163
  const rawOrderBook = await this.fetcher.fetchRawOrderBook(slug);
161
164
  const orderBook = this.normalizer.normalizeOrderBook(rawOrderBook, outcomeId);
@@ -279,6 +279,8 @@ class MockExchange extends BaseExchange_1.PredictionMarketExchange {
279
279
  return limit !== undefined ? events.slice(offset, offset + limit) : events.slice(offset);
280
280
  }
281
281
  async fetchOrderBook(id, _limit, _params) {
282
+ const resolved = await this.resolveOutcomeAlias(id, _params);
283
+ id = resolved.outcomeId;
282
284
  const f = new seededRng_1.SeededRng(id);
283
285
  const midPrice = round(f.float(0.1, 0.9), 3);
284
286
  const spread = round(f.float(0.005, 0.03), 3);
@@ -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-23T11:49:58.034Z
3
+ * Generated at: 2026-05-23T22:05:08.018Z
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-23T11:49:58.034Z
6
+ * Generated at: 2026-05-23T22:05:08.018Z
7
7
  * Do not edit manually -- run "npm run fetch:openapi" to regenerate.
8
8
  */
9
9
  exports.myriadApiSpec = {
@@ -166,8 +166,9 @@ class MyriadFetcher {
166
166
  id: marketId,
167
167
  network_id: Number(networkId),
168
168
  page: 1,
169
- limit: params.limit || 100,
170
169
  };
170
+ if (params.limit)
171
+ queryParams.limit = params.limit;
171
172
  if (params.start)
172
173
  queryParams.since = Math.floor(ensureDate(params.start).getTime() / 1000);
173
174
  if (params.end)
@@ -6,6 +6,7 @@ const auth_1 = require("./auth");
6
6
  const websocket_1 = require("./websocket");
7
7
  const errors_1 = require("./errors");
8
8
  const errors_2 = require("../../errors");
9
+ const validation_1 = require("../../utils/validation");
9
10
  const utils_1 = require("./utils");
10
11
  const openapi_1 = require("../../utils/openapi");
11
12
  const api_1 = require("./api");
@@ -90,6 +91,9 @@ class MyriadExchange extends BaseExchange_1.PredictionMarketExchange {
90
91
  return this.normalizer.normalizeOHLCV(rawMarket, params, parsedOutcomeId);
91
92
  }
92
93
  async fetchOrderBook(outcomeId, _limit, _params) {
94
+ const resolved = await this.resolveOutcomeAlias(outcomeId, _params);
95
+ outcomeId = resolved.outcomeId;
96
+ _params = resolved.params;
93
97
  const parts = outcomeId.split(':');
94
98
  if (parts.length >= 3) {
95
99
  const [networkId, marketId, oid] = parts;
@@ -109,6 +113,7 @@ class MyriadExchange extends BaseExchange_1.PredictionMarketExchange {
109
113
  return this.normalizer.normalizeOrderBook(rawMarket, outcomeId);
110
114
  }
111
115
  async fetchTrades(outcomeId, params) {
116
+ (0, validation_1.validateTradesLimit)(params.limit);
112
117
  if ('resolution' in params && params.resolution !== undefined) {
113
118
  logger_1.logger.warn('The "resolution" parameter is deprecated for fetchTrades() and will be ignored. ' +
114
119
  'It will be removed in v3.0.0. Please remove it from your code.');
@@ -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-23T11:49:58.038Z
3
+ * Generated at: 2026-05-23T22:05:08.023Z
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-23T11:49:58.038Z
6
+ * Generated at: 2026-05-23T22:05:08.023Z
7
7
  * Do not edit manually -- run "npm run fetch:openapi" to regenerate.
8
8
  */
9
9
  exports.opinionApiSpec = {
@@ -170,6 +170,9 @@ class OpinionExchange extends BaseExchange_1.PredictionMarketExchange {
170
170
  return this.normalizer.normalizeOHLCV({ history: rawPoints }, params);
171
171
  }
172
172
  async fetchOrderBook(outcomeId, _limit, _params) {
173
+ const resolved = await this.resolveOutcomeAlias(outcomeId, _params);
174
+ outcomeId = resolved.outcomeId;
175
+ _params = resolved.params;
173
176
  const raw = await this.fetcher.fetchRawOrderBook(outcomeId);
174
177
  return this.normalizer.normalizeOrderBook(raw, outcomeId);
175
178
  }
@@ -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-23T11:49:57.988Z
3
+ * Generated at: 2026-05-23T22:05:07.964Z
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-23T11:49:57.988Z
6
+ * Generated at: 2026-05-23T22:05:07.964Z
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-23T11:49:58.001Z
3
+ * Generated at: 2026-05-23T22:05:07.982Z
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-23T11:49:58.001Z
6
+ * Generated at: 2026-05-23T22:05:07.982Z
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-23T11:49:57.998Z
3
+ * Generated at: 2026-05-23T22:05:07.978Z
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-23T11:49:57.998Z
6
+ * Generated at: 2026-05-23T22:05:07.978Z
7
7
  * Do not edit manually -- run "npm run fetch:openapi" to regenerate.
8
8
  */
9
9
  exports.polymarketGammaSpec = {
@@ -193,6 +193,8 @@ class PolymarketFetcher {
193
193
  const queryParams = {
194
194
  asset_id: id,
195
195
  };
196
+ if (params.limit)
197
+ queryParams.limit = params.limit;
196
198
  if (params.start) {
197
199
  queryParams.after = Math.floor(ensureDate(params.start).getTime() / 1000);
198
200
  }
@@ -112,6 +112,9 @@ class PolymarketExchange extends BaseExchange_1.PredictionMarketExchange {
112
112
  return this.normalizer.normalizeOHLCV(raw, params);
113
113
  }
114
114
  async fetchOrderBook(outcomeId, _limit, _params) {
115
+ const resolved = await this.resolveOutcomeAlias(outcomeId, _params);
116
+ outcomeId = resolved.outcomeId;
117
+ _params = resolved.params;
115
118
  (0, validation_1.validateIdFormat)(outcomeId, 'OrderBook');
116
119
  (0, validation_1.validateOutcomeId)(outcomeId, 'OrderBook');
117
120
  const raw = await this.fetcher.fetchRawOrderBook(outcomeId);
@@ -135,6 +138,7 @@ class PolymarketExchange extends BaseExchange_1.PredictionMarketExchange {
135
138
  async fetchTrades(outcomeId, params) {
136
139
  (0, validation_1.validateIdFormat)(outcomeId, 'Trades');
137
140
  (0, validation_1.validateOutcomeId)(outcomeId, 'Trades');
141
+ (0, validation_1.validateTradesLimit)(params.limit);
138
142
  if ('resolution' in params && params.resolution !== undefined) {
139
143
  logger_1.logger.warn('The "resolution" parameter is deprecated for fetchTrades() and will be ignored. It will be removed in v3.0.0.');
140
144
  }
@@ -167,6 +167,9 @@ class PolymarketUSExchange extends BaseExchange_1.PredictionMarketExchange {
167
167
  });
168
168
  }
169
169
  async fetchOrderBook(outcomeId, _limit, _params) {
170
+ const resolved = await this.resolveOutcomeAlias(outcomeId, _params);
171
+ outcomeId = resolved.outcomeId;
172
+ _params = resolved.params;
170
173
  return this.run(async () => {
171
174
  const slug = this.slugFromId(outcomeId);
172
175
  const book = await this.client.markets.book(slug);
@@ -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-23T11:49:58.029Z
3
+ * Generated at: 2026-05-23T22:05:08.013Z
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-23T11:49:58.029Z
6
+ * Generated at: 2026-05-23T22:05:08.013Z
7
7
  * Do not edit manually -- run "npm run fetch:openapi" to regenerate.
8
8
  */
9
9
  exports.probableApiSpec = {
@@ -6,6 +6,7 @@ const auth_1 = require("./auth");
6
6
  const websocket_1 = require("./websocket");
7
7
  const errors_1 = require("./errors");
8
8
  const errors_2 = require("../../errors");
9
+ const validation_1 = require("../../utils/validation");
9
10
  const clob_1 = require("@prob/clob");
10
11
  const openapi_1 = require("../../utils/openapi");
11
12
  const api_1 = require("./api");
@@ -118,6 +119,9 @@ class ProbableExchange extends BaseExchange_1.PredictionMarketExchange {
118
119
  return event;
119
120
  }
120
121
  async fetchOrderBook(outcomeId, _limit, _params) {
122
+ const resolved = await this.resolveOutcomeAlias(outcomeId, _params);
123
+ outcomeId = resolved.outcomeId;
124
+ _params = resolved.params;
121
125
  const raw = await this.fetcher.fetchRawOrderBook(outcomeId);
122
126
  return this.normalizer.normalizeOrderBook(raw, outcomeId);
123
127
  }
@@ -135,6 +139,7 @@ class ProbableExchange extends BaseExchange_1.PredictionMarketExchange {
135
139
  return rawTrades.map((raw, i) => this.normalizer.normalizeUserTrade(raw, i));
136
140
  }
137
141
  async fetchTrades(outcomeId, params) {
142
+ (0, validation_1.validateTradesLimit)(params.limit);
138
143
  const auth = this.ensureAuth();
139
144
  const client = auth.getClobClient();
140
145
  // Use CLOB client directly for trades (legacy behaviour preserved)
@@ -158,7 +158,7 @@ export declare class SmarketsFetcher implements IExchangeFetcher<SmarketsRawEven
158
158
  fetchRawMarkets(params?: MarketFilterParams): Promise<SmarketsRawEventWithMarkets[]>;
159
159
  fetchRawEvents(params: EventFetchParams): Promise<SmarketsRawEventWithMarkets[]>;
160
160
  fetchRawOrderBook(id: string): Promise<Record<string, SmarketsRawQuote>>;
161
- fetchRawTradeActivity(marketId: string, _params: TradesParams): Promise<SmarketsRawActivityRow[]>;
161
+ fetchRawTradeActivity(marketId: string, params: TradesParams): Promise<SmarketsRawActivityRow[]>;
162
162
  fetchRawMyTradeActivity(params?: Record<string, any>): Promise<SmarketsRawActivityRow[]>;
163
163
  fetchRawBalance(): Promise<SmarketsRawBalance>;
164
164
  fetchRawOrders(queryParams?: Record<string, any>): Promise<SmarketsRawOrder[]>;
@@ -69,13 +69,15 @@ class SmarketsFetcher {
69
69
  return data;
70
70
  }
71
71
  // -- Trades (account activity) --------------------------------------------
72
- async fetchRawTradeActivity(marketId, _params) {
73
- const data = await this.ctx.callApi('get_activity', {
72
+ async fetchRawTradeActivity(marketId, params) {
73
+ const query = {
74
74
  market_id: [marketId],
75
75
  source: ['order.execute', 'order.execute.confirm'],
76
- limit: 100,
77
76
  sort: '-seq,-subseq',
78
- });
77
+ };
78
+ if (params.limit)
79
+ query.limit = params.limit;
80
+ const data = await this.ctx.callApi('get_activity', query);
79
81
  return (data.account_activity || []);
80
82
  }
81
83
  async fetchRawMyTradeActivity(params = {}) {
@@ -5,6 +5,7 @@ const BaseExchange_1 = require("../../BaseExchange");
5
5
  const auth_1 = require("./auth");
6
6
  const errors_1 = require("./errors");
7
7
  const errors_2 = require("../../errors");
8
+ const validation_1 = require("../../utils/validation");
8
9
  const openapi_1 = require("../../utils/openapi");
9
10
  const api_1 = require("./api");
10
11
  const config_1 = require("./config");
@@ -160,10 +161,14 @@ class SmarketsExchange extends BaseExchange_1.PredictionMarketExchange {
160
161
  .slice(0, limit);
161
162
  }
162
163
  async fetchOrderBook(outcomeId, _limit, _params) {
164
+ const resolved = await this.resolveOutcomeAlias(outcomeId, _params);
165
+ outcomeId = resolved.outcomeId;
166
+ _params = resolved.params;
163
167
  const raw = await this.fetcher.fetchRawOrderBook(outcomeId);
164
168
  return this.normalizer.normalizeOrderBook(raw, outcomeId);
165
169
  }
166
170
  async fetchTrades(outcomeId, params) {
171
+ (0, validation_1.validateTradesLimit)(params.limit);
167
172
  if ('resolution' in params && params.resolution !== undefined) {
168
173
  logger_1.logger.warn('The "resolution" parameter is deprecated for fetchTrades() and will be ignored. ' +
169
174
  'It will be removed in v3.0.0. Please remove it from your code.');
@@ -656,6 +656,15 @@ paths:
656
656
  description: >-
657
657
  Outcome side: 'yes' or 'no'. Required for exchanges like Limitless where the API returns a single orderbook
658
658
  per market.
659
+ - in: query
660
+ name: outcome
661
+ required: false
662
+ schema:
663
+ type: string
664
+ description: >-
665
+ Outcome alias: 'yes' or 'no', or an outcome token ID. When set, the first argument is treated as a market ID
666
+ and this value selects which outcome's order book to fetch. Accepts the literal strings 'yes'/'no' (resolved
667
+ via a market lookup) or a raw outcome token ID.
659
668
  - in: query
660
669
  name: since
661
670
  required: false
@@ -760,7 +769,7 @@ paths:
760
769
  required: false
761
770
  schema:
762
771
  type: number
763
- description: Maximum number of results to return
772
+ description: 'Maximum number of results to return (max {@link MAX_TRADES_LIMIT})'
764
773
  responses:
765
774
  '200':
766
775
  description: Fetch Trades response
@@ -3192,6 +3201,12 @@ components:
3192
3201
  description: >-
3193
3202
  Outcome side: 'yes' or 'no'. Required for exchanges like Limitless where the API returns a single orderbook
3194
3203
  per market.
3204
+ outcome:
3205
+ type: string
3206
+ description: >-
3207
+ Outcome alias: 'yes' or 'no', or an outcome token ID. When set, the first argument is treated as a market ID
3208
+ and this value selects which outcome's order book to fetch. Accepts the literal strings 'yes'/'no' (resolved
3209
+ via a market lookup) or a raw outcome token ID.
3195
3210
  since:
3196
3211
  type: number
3197
3212
  description: >-
@@ -3204,7 +3219,6 @@ components:
3204
3219
  reconstructed L2 OrderBook snapshots between `since` and `until` (hosted API only).
3205
3220
  TradesParams:
3206
3221
  type: object
3207
- description: Parameters for fetching trade history. No resolution parameter - trades are discrete events.
3208
3222
  properties:
3209
3223
  start:
3210
3224
  type: string
@@ -3216,7 +3230,7 @@ components:
3216
3230
  description: End of the time range
3217
3231
  limit:
3218
3232
  type: number
3219
- description: Maximum number of results to return
3233
+ description: 'Maximum number of results to return (max {@link MAX_TRADES_LIMIT})'
3220
3234
  CreateOrderParams:
3221
3235
  type: object
3222
3236
  properties:
@@ -4,3 +4,4 @@
4
4
  */
5
5
  export declare function validateOutcomeId(id: string, context: string): void;
6
6
  export declare function validateIdFormat(id: string, context: string): void;
7
+ export declare function validateTradesLimit(limit: number | undefined): void;
@@ -2,7 +2,9 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.validateOutcomeId = validateOutcomeId;
4
4
  exports.validateIdFormat = validateIdFormat;
5
+ exports.validateTradesLimit = validateTradesLimit;
5
6
  const errors_1 = require("../errors");
7
+ const BaseExchange_1 = require("../BaseExchange");
6
8
  /**
7
9
  * Validates that the provided ID is an outcomeId
8
10
  * Numeric IDs should be at least 10 digits (CLOB Token IDs for Polymarket)
@@ -21,3 +23,8 @@ function validateIdFormat(id, context) {
21
23
  throw new errors_1.ValidationError(`Invalid ID for ${context}: ID cannot be empty`, 'id');
22
24
  }
23
25
  }
26
+ function validateTradesLimit(limit) {
27
+ if (limit !== undefined && limit > BaseExchange_1.MAX_TRADES_LIMIT) {
28
+ throw new errors_1.ValidationError(`limit exceeds maximum of ${BaseExchange_1.MAX_TRADES_LIMIT}`, 'limit');
29
+ }
30
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pmxt-core",
3
- "version": "2.43.11",
3
+ "version": "2.43.13",
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.43.11,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.43.11,supportsES6=true,typescriptThreePlus=true && node ../sdks/typescript/scripts/fix-generated.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.43.13,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.43.13,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",