pmxtjs 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 (46) hide show
  1. package/dist/esm/generated/src/apis/DefaultApi.d.ts +120 -4
  2. package/dist/esm/generated/src/apis/DefaultApi.js +136 -5
  3. package/dist/esm/generated/src/models/FetchOrderBooks200Response.d.ts +48 -0
  4. package/dist/esm/generated/src/models/FetchOrderBooks200Response.js +48 -0
  5. package/dist/esm/generated/src/models/FetchOrderBooksRequest.d.ts +39 -0
  6. package/dist/esm/generated/src/models/FetchOrderBooksRequest.js +46 -0
  7. package/dist/esm/generated/src/models/OrderBook.d.ts +6 -0
  8. package/dist/esm/generated/src/models/OrderBook.js +2 -0
  9. package/dist/esm/generated/src/models/index.d.ts +2 -0
  10. package/dist/esm/generated/src/models/index.js +2 -0
  11. package/dist/esm/index.d.ts +5 -2
  12. package/dist/esm/index.js +5 -2
  13. package/dist/esm/pmxt/client.d.ts +45 -3
  14. package/dist/esm/pmxt/client.js +97 -5
  15. package/dist/esm/pmxt/models.d.ts +3 -1
  16. package/dist/generated/src/apis/DefaultApi.d.ts +120 -4
  17. package/dist/generated/src/apis/DefaultApi.js +137 -6
  18. package/dist/generated/src/models/FetchOrderBooks200Response.d.ts +48 -0
  19. package/dist/generated/src/models/FetchOrderBooks200Response.js +55 -0
  20. package/dist/generated/src/models/FetchOrderBooksRequest.d.ts +39 -0
  21. package/dist/generated/src/models/FetchOrderBooksRequest.js +53 -0
  22. package/dist/generated/src/models/OrderBook.d.ts +6 -0
  23. package/dist/generated/src/models/OrderBook.js +2 -0
  24. package/dist/generated/src/models/index.d.ts +2 -0
  25. package/dist/generated/src/models/index.js +2 -0
  26. package/dist/index.d.ts +5 -2
  27. package/dist/index.js +7 -1
  28. package/dist/pmxt/client.d.ts +45 -3
  29. package/dist/pmxt/client.js +101 -6
  30. package/dist/pmxt/models.d.ts +3 -1
  31. package/generated/.openapi-generator/FILES +4 -0
  32. package/generated/docs/DefaultApi.md +130 -59
  33. package/generated/docs/FetchOrderBooks200Response.md +38 -0
  34. package/generated/docs/FetchOrderBooksRequest.md +36 -0
  35. package/generated/docs/GetExecutionPriceRequestArgsInner.md +2 -0
  36. package/generated/docs/OrderBook.md +2 -0
  37. package/generated/package.json +1 -1
  38. package/generated/src/apis/DefaultApi.ts +160 -5
  39. package/generated/src/models/FetchOrderBooks200Response.ts +96 -0
  40. package/generated/src/models/FetchOrderBooksRequest.ts +82 -0
  41. package/generated/src/models/OrderBook.ts +8 -0
  42. package/generated/src/models/index.ts +2 -0
  43. package/index.ts +5 -2
  44. package/package.json +2 -2
  45. package/pmxt/client.ts +105 -11
  46. package/pmxt/models.ts +4 -1
@@ -45,6 +45,12 @@ export interface OrderBook {
45
45
  * @memberof OrderBook
46
46
  */
47
47
  timestamp?: number;
48
+ /**
49
+ * ISO 8601 datetime string of the snapshot (CCXT-compatible).
50
+ * @type {string}
51
+ * @memberof OrderBook
52
+ */
53
+ datetime?: string;
48
54
  }
49
55
 
50
56
  /**
@@ -69,6 +75,7 @@ export function OrderBookFromJSONTyped(json: any, ignoreDiscriminator: boolean):
69
75
  'bids': ((json['bids'] as Array<any>).map(OrderLevelFromJSON)),
70
76
  'asks': ((json['asks'] as Array<any>).map(OrderLevelFromJSON)),
71
77
  'timestamp': json['timestamp'] == null ? undefined : json['timestamp'],
78
+ 'datetime': json['datetime'] == null ? undefined : json['datetime'],
72
79
  };
73
80
  }
74
81
 
@@ -86,6 +93,7 @@ export function OrderBookToJSONTyped(value?: OrderBook | null, ignoreDiscriminat
86
93
  'bids': ((value['bids'] as Array<any>).map(OrderLevelToJSON)),
87
94
  'asks': ((value['asks'] as Array<any>).map(OrderLevelToJSON)),
88
95
  'timestamp': value['timestamp'],
96
+ 'datetime': value['datetime'],
89
97
  };
90
98
  }
91
99
 
@@ -56,6 +56,8 @@ export * from './FetchMyTrades200Response';
56
56
  export * from './FetchOHLCV200Response';
57
57
  export * from './FetchOpenOrders200Response';
58
58
  export * from './FetchOrderBook200Response';
59
+ export * from './FetchOrderBooks200Response';
60
+ export * from './FetchOrderBooksRequest';
59
61
  export * from './FetchPositions200Response';
60
62
  export * from './FetchTrades200Response';
61
63
  export * from './FilterEventsRequest';
package/index.ts CHANGED
@@ -19,13 +19,13 @@
19
19
  */
20
20
 
21
21
 
22
- import { Exchange, Polymarket, Kalshi, KalshiDemo, Limitless, Myriad, Probable, Baozi, Opinion, Metaculus, Smarkets, PolymarketUS } from "./pmxt/client.js";
22
+ import { Exchange, Polymarket, Kalshi, KalshiDemo, Limitless, Myriad, Probable, Baozi, Opinion, Metaculus, Smarkets, PolymarketUS, GeminiTitan, Hyperliquid, Mock } from "./pmxt/client.js";
23
23
  import { Router } from "./pmxt/router.js";
24
24
  import { ServerManager } from "./pmxt/server-manager.js";
25
25
  import * as models from "./pmxt/models.js";
26
26
  import * as errors from "./pmxt/errors.js";
27
27
 
28
- export { Exchange, Polymarket, Kalshi, KalshiDemo, Limitless, Myriad, Probable, Baozi, Opinion, Metaculus, Smarkets, PolymarketUS, PolymarketOptions } from "./pmxt/client.js";
28
+ export { Exchange, Polymarket, Kalshi, KalshiDemo, Limitless, Myriad, Probable, Baozi, Opinion, Metaculus, Smarkets, PolymarketUS, GeminiTitan, Hyperliquid, Mock, PolymarketOptions } from "./pmxt/client.js";
29
29
  export { Router } from "./pmxt/router.js";
30
30
  export { ServerManager } from "./pmxt/server-manager.js";
31
31
  export { MarketList } from "./pmxt/models.js";
@@ -79,6 +79,9 @@ const pmxt = {
79
79
  Metaculus,
80
80
  Smarkets,
81
81
  PolymarketUS,
82
+ GeminiTitan,
83
+ Hyperliquid,
84
+ Mock,
82
85
  Router,
83
86
  ServerManager,
84
87
  server,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pmxtjs",
3
- "version": "2.42.7",
3
+ "version": "2.43.0",
4
4
  "description": "Unified prediction market data API - The ccxt for prediction markets",
5
5
  "author": "PMXT Contributors",
6
6
  "repository": {
@@ -43,7 +43,7 @@
43
43
  "unified"
44
44
  ],
45
45
  "dependencies": {
46
- "pmxt-core": "2.42.7",
46
+ "pmxt-core": "2.43.0",
47
47
  "ws": "^8.18.0"
48
48
  },
49
49
  "devDependencies": {
package/pmxt/client.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * Exchange client implementations.
3
- *
3
+ *
4
4
  * This module provides clean, TypeScript-friendly wrappers around the auto-generated
5
5
  * OpenAPI client, matching the Python API exactly.
6
6
  */
@@ -214,7 +214,7 @@ export interface ExchangeOptions {
214
214
 
215
215
  /**
216
216
  * Base class for prediction market exchanges.
217
- *
217
+ *
218
218
  * This provides a unified interface for interacting with different
219
219
  * prediction market platforms (Polymarket, Kalshi, etc.).
220
220
  */
@@ -766,12 +766,13 @@ export abstract class Exchange {
766
766
  }
767
767
  }
768
768
 
769
- async fetchOrderBook(outcomeId: string | MarketOutcome, side?: any): Promise<OrderBook> {
769
+ async fetchOrderBook(outcomeId: string | MarketOutcome, limit?: number, params?: Record<string, any>): Promise<OrderBook> {
770
770
  await this.initPromise;
771
771
  try {
772
772
  const args: any[] = [];
773
773
  args.push(resolveOutcomeId(outcomeId));
774
- if (side !== undefined) args.push(side);
774
+ if (limit !== undefined) args.push(limit);
775
+ if (params !== undefined) args.push(params);
775
776
  const response = await this.fetchWithRetry(`${this.resolveBaseUrl()}/api/${this.exchangeName}/fetchOrderBook`, {
776
777
  method: 'POST',
777
778
  headers: { 'Content-Type': 'application/json', ...this.getAuthHeaders() },
@@ -793,6 +794,36 @@ export abstract class Exchange {
793
794
  }
794
795
  }
795
796
 
797
+ async fetchOrderBooks(outcomeIds: (string | MarketOutcome)[]): Promise<Record<string, OrderBook>> {
798
+ await this.initPromise;
799
+ try {
800
+ const args: any[] = [];
801
+ args.push(outcomeIds.map(resolveOutcomeId));
802
+ const response = await this.fetchWithRetry(`${this.resolveBaseUrl()}/api/${this.exchangeName}/fetchOrderBooks`, {
803
+ method: 'POST',
804
+ headers: { 'Content-Type': 'application/json', ...this.getAuthHeaders() },
805
+ body: JSON.stringify({ args, credentials: this.getCredentials() }),
806
+ });
807
+ if (!response.ok) {
808
+ const body = await response.json().catch(() => ({}));
809
+ if (body.error && typeof body.error === "object") {
810
+ throw fromServerError(body.error);
811
+ }
812
+ throw new PmxtError(body.error?.message || response.statusText);
813
+ }
814
+ const json = await response.json();
815
+ const data = this.handleResponse(json);
816
+ const result: Record<string, OrderBook> = {};
817
+ for (const [key, value] of Object.entries(data as any)) {
818
+ result[key] = convertOrderBook(value);
819
+ }
820
+ return result;
821
+ } catch (error) {
822
+ if (error instanceof PmxtError) throw error;
823
+ throw new PmxtError(`Failed to fetchOrderBooks: ${error}`);
824
+ }
825
+ }
826
+
796
827
  async submitOrder(built: BuiltOrder): Promise<Order> {
797
828
  await this.initPromise;
798
829
  try {
@@ -1359,7 +1390,7 @@ export abstract class Exchange {
1359
1390
  * @param outcomeId - Outcome ID (from market.outcomes[].outcomeId)
1360
1391
  * @param params - History filter parameters
1361
1392
  * @returns List of price candles
1362
- *
1393
+ *
1363
1394
  * @example
1364
1395
  * ```typescript
1365
1396
  * const markets = await exchange.fetchMarkets({ query: "Trump" });
@@ -1444,14 +1475,15 @@ export abstract class Exchange {
1444
1475
 
1445
1476
  /**
1446
1477
  * Watch real-time order book updates via WebSocket.
1447
- *
1478
+ *
1448
1479
  * Returns a promise that resolves with the next order book update.
1449
1480
  * Call repeatedly in a loop to stream updates (CCXT Pro pattern).
1450
- *
1481
+ *
1451
1482
  * @param outcomeId - Outcome ID to watch
1452
1483
  * @param limit - Optional depth limit for order book
1484
+ * @param params - Optional exchange-specific parameters
1453
1485
  * @returns Next order book update
1454
- *
1486
+ *
1455
1487
  * @example
1456
1488
  * ```typescript
1457
1489
  * // Stream order book updates
@@ -1462,13 +1494,19 @@ export abstract class Exchange {
1462
1494
  * }
1463
1495
  * ```
1464
1496
  */
1465
- async watchOrderBook(outcomeId: string | MarketOutcome, limit?: number): Promise<OrderBook> {
1497
+ async watchOrderBook(outcomeId: string | MarketOutcome, limit?: number, params: Record<string, any> = {}): Promise<OrderBook> {
1466
1498
  await this.initPromise;
1467
1499
  const resolvedOutcomeId = resolveOutcomeId(outcomeId);
1468
1500
  const args: any[] = [resolvedOutcomeId];
1469
1501
  if (limit !== undefined) {
1470
1502
  args.push(limit);
1471
1503
  }
1504
+ if (Object.keys(params).length > 0) {
1505
+ if (limit === undefined) {
1506
+ args.push(undefined);
1507
+ }
1508
+ args.push(params);
1509
+ }
1472
1510
 
1473
1511
  // Try WebSocket transport first
1474
1512
  const wsData = await this.watchViaWs("watchOrderBook", args);
@@ -1511,6 +1549,7 @@ export abstract class Exchange {
1511
1549
  *
1512
1550
  * @param outcomeIds - Array of outcome IDs (or MarketOutcome objects)
1513
1551
  * @param limit - Optional depth limit for each order book
1552
+ * @param params - Optional exchange-specific parameters
1514
1553
  * @returns Record mapping ticker to OrderBook
1515
1554
  *
1516
1555
  * @example
@@ -1527,6 +1566,7 @@ export abstract class Exchange {
1527
1566
  async watchOrderBooks(
1528
1567
  outcomeIds: (string | MarketOutcome)[],
1529
1568
  limit?: number,
1569
+ params: Record<string, any> = {},
1530
1570
  ): Promise<Record<string, OrderBook>> {
1531
1571
  await this.initPromise;
1532
1572
  const resolvedIds = outcomeIds.map(resolveOutcomeId);
@@ -1534,6 +1574,12 @@ export abstract class Exchange {
1534
1574
  if (limit !== undefined) {
1535
1575
  args.push(limit);
1536
1576
  }
1577
+ if (Object.keys(params).length > 0) {
1578
+ if (limit === undefined) {
1579
+ args.push(undefined);
1580
+ }
1581
+ args.push(params);
1582
+ }
1537
1583
 
1538
1584
  // Try WebSocket transport first
1539
1585
  const ws = await this.getOrCreateWs();
@@ -2009,7 +2055,7 @@ export abstract class Exchange {
2009
2055
  /**
2010
2056
  * Calculate the average execution price for a given amount by walking the order book.
2011
2057
  * Uses the sidecar server for calculation to ensure consistency.
2012
- *
2058
+ *
2013
2059
  * @param orderBook - The current order book
2014
2060
  * @param side - 'buy' or 'sell'
2015
2061
  * @param amount - The amount to execute
@@ -2023,7 +2069,7 @@ export abstract class Exchange {
2023
2069
  /**
2024
2070
  * Calculate detailed execution price information.
2025
2071
  * Uses the sidecar server for calculation to ensure consistency.
2026
- *
2072
+ *
2027
2073
  * @param orderBook - The current order book
2028
2074
  * @param side - 'buy' or 'sell'
2029
2075
  * @param amount - The amount to execute
@@ -2614,3 +2660,51 @@ export class PolymarketUS extends Exchange {
2614
2660
  super("polymarket_us", options);
2615
2661
  }
2616
2662
  }
2663
+
2664
+ /**
2665
+ * Gemini Titan exchange client.
2666
+ *
2667
+ * @example
2668
+ * ```typescript
2669
+ * const titan = new GeminiTitan();
2670
+ * const markets = await titan.fetchMarkets();
2671
+ * ```
2672
+ */
2673
+ export class GeminiTitan extends Exchange {
2674
+ constructor(options: ExchangeOptions = {}) {
2675
+ super("gemini-titan", options);
2676
+ }
2677
+ }
2678
+
2679
+ /**
2680
+ * Hyperliquid exchange client.
2681
+ *
2682
+ * @example
2683
+ * ```typescript
2684
+ * const hl = new Hyperliquid();
2685
+ * const markets = await hl.fetchMarkets();
2686
+ * ```
2687
+ */
2688
+ export class Hyperliquid extends Exchange {
2689
+ constructor(options: ExchangeOptions = {}) {
2690
+ super("hyperliquid", options);
2691
+ }
2692
+ }
2693
+
2694
+ /**
2695
+ * Mock exchange client.
2696
+ *
2697
+ * Offline deterministic exchange for testing and development.
2698
+ * No credentials required.
2699
+ *
2700
+ * @example
2701
+ * ```typescript
2702
+ * const mock = new Mock();
2703
+ * const markets = await mock.fetchMarkets();
2704
+ * ```
2705
+ */
2706
+ export class Mock extends Exchange {
2707
+ constructor(options: ExchangeOptions = {}) {
2708
+ super("mock", options);
2709
+ }
2710
+ }
package/pmxt/models.ts CHANGED
@@ -140,7 +140,7 @@ export interface OrderLevel {
140
140
  }
141
141
 
142
142
  /**
143
- * Current order book for an outcome.
143
+ * Order book for an outcome.
144
144
  */
145
145
  export interface OrderBook {
146
146
  /** Bid orders (sorted high to low) */
@@ -151,6 +151,9 @@ export interface OrderBook {
151
151
 
152
152
  /** Unix timestamp (milliseconds) */
153
153
  timestamp?: number;
154
+
155
+ /** ISO 8601 datetime string of the snapshot (CCXT-compatible) */
156
+ datetime?: string;
154
157
  }
155
158
 
156
159
  /**