pmxtjs 2.42.7 → 2.43.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.
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 +103 -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 +107 -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 +111 -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.1",
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.1",
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,16 @@ 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 | 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) {
776
+ if (limit === undefined) args.push(null);
777
+ args.push(params);
778
+ }
775
779
  const response = await this.fetchWithRetry(`${this.resolveBaseUrl()}/api/${this.exchangeName}/fetchOrderBook`, {
776
780
  method: 'POST',
777
781
  headers: { 'Content-Type': 'application/json', ...this.getAuthHeaders() },
@@ -786,6 +790,9 @@ export abstract class Exchange {
786
790
  }
787
791
  const json = await response.json();
788
792
  const data = this.handleResponse(json);
793
+ if (Array.isArray(data)) {
794
+ return data.map(convertOrderBook);
795
+ }
789
796
  return convertOrderBook(data);
790
797
  } catch (error) {
791
798
  if (error instanceof PmxtError) throw error;
@@ -793,6 +800,36 @@ export abstract class Exchange {
793
800
  }
794
801
  }
795
802
 
803
+ async fetchOrderBooks(outcomeIds: (string | MarketOutcome)[]): Promise<Record<string, OrderBook>> {
804
+ await this.initPromise;
805
+ try {
806
+ const args: any[] = [];
807
+ args.push(outcomeIds.map(resolveOutcomeId));
808
+ const response = await this.fetchWithRetry(`${this.resolveBaseUrl()}/api/${this.exchangeName}/fetchOrderBooks`, {
809
+ method: 'POST',
810
+ headers: { 'Content-Type': 'application/json', ...this.getAuthHeaders() },
811
+ body: JSON.stringify({ args, credentials: this.getCredentials() }),
812
+ });
813
+ if (!response.ok) {
814
+ const body = await response.json().catch(() => ({}));
815
+ if (body.error && typeof body.error === "object") {
816
+ throw fromServerError(body.error);
817
+ }
818
+ throw new PmxtError(body.error?.message || response.statusText);
819
+ }
820
+ const json = await response.json();
821
+ const data = this.handleResponse(json);
822
+ const result: Record<string, OrderBook> = {};
823
+ for (const [key, value] of Object.entries(data as any)) {
824
+ result[key] = convertOrderBook(value);
825
+ }
826
+ return result;
827
+ } catch (error) {
828
+ if (error instanceof PmxtError) throw error;
829
+ throw new PmxtError(`Failed to fetchOrderBooks: ${error}`);
830
+ }
831
+ }
832
+
796
833
  async submitOrder(built: BuiltOrder): Promise<Order> {
797
834
  await this.initPromise;
798
835
  try {
@@ -1359,7 +1396,7 @@ export abstract class Exchange {
1359
1396
  * @param outcomeId - Outcome ID (from market.outcomes[].outcomeId)
1360
1397
  * @param params - History filter parameters
1361
1398
  * @returns List of price candles
1362
- *
1399
+ *
1363
1400
  * @example
1364
1401
  * ```typescript
1365
1402
  * const markets = await exchange.fetchMarkets({ query: "Trump" });
@@ -1444,14 +1481,15 @@ export abstract class Exchange {
1444
1481
 
1445
1482
  /**
1446
1483
  * Watch real-time order book updates via WebSocket.
1447
- *
1484
+ *
1448
1485
  * Returns a promise that resolves with the next order book update.
1449
1486
  * Call repeatedly in a loop to stream updates (CCXT Pro pattern).
1450
- *
1487
+ *
1451
1488
  * @param outcomeId - Outcome ID to watch
1452
1489
  * @param limit - Optional depth limit for order book
1490
+ * @param params - Optional exchange-specific parameters
1453
1491
  * @returns Next order book update
1454
- *
1492
+ *
1455
1493
  * @example
1456
1494
  * ```typescript
1457
1495
  * // Stream order book updates
@@ -1462,13 +1500,19 @@ export abstract class Exchange {
1462
1500
  * }
1463
1501
  * ```
1464
1502
  */
1465
- async watchOrderBook(outcomeId: string | MarketOutcome, limit?: number): Promise<OrderBook> {
1503
+ async watchOrderBook(outcomeId: string | MarketOutcome, limit?: number, params: Record<string, any> = {}): Promise<OrderBook> {
1466
1504
  await this.initPromise;
1467
1505
  const resolvedOutcomeId = resolveOutcomeId(outcomeId);
1468
1506
  const args: any[] = [resolvedOutcomeId];
1469
1507
  if (limit !== undefined) {
1470
1508
  args.push(limit);
1471
1509
  }
1510
+ if (Object.keys(params).length > 0) {
1511
+ if (limit === undefined) {
1512
+ args.push(undefined);
1513
+ }
1514
+ args.push(params);
1515
+ }
1472
1516
 
1473
1517
  // Try WebSocket transport first
1474
1518
  const wsData = await this.watchViaWs("watchOrderBook", args);
@@ -1511,6 +1555,7 @@ export abstract class Exchange {
1511
1555
  *
1512
1556
  * @param outcomeIds - Array of outcome IDs (or MarketOutcome objects)
1513
1557
  * @param limit - Optional depth limit for each order book
1558
+ * @param params - Optional exchange-specific parameters
1514
1559
  * @returns Record mapping ticker to OrderBook
1515
1560
  *
1516
1561
  * @example
@@ -1527,6 +1572,7 @@ export abstract class Exchange {
1527
1572
  async watchOrderBooks(
1528
1573
  outcomeIds: (string | MarketOutcome)[],
1529
1574
  limit?: number,
1575
+ params: Record<string, any> = {},
1530
1576
  ): Promise<Record<string, OrderBook>> {
1531
1577
  await this.initPromise;
1532
1578
  const resolvedIds = outcomeIds.map(resolveOutcomeId);
@@ -1534,6 +1580,12 @@ export abstract class Exchange {
1534
1580
  if (limit !== undefined) {
1535
1581
  args.push(limit);
1536
1582
  }
1583
+ if (Object.keys(params).length > 0) {
1584
+ if (limit === undefined) {
1585
+ args.push(undefined);
1586
+ }
1587
+ args.push(params);
1588
+ }
1537
1589
 
1538
1590
  // Try WebSocket transport first
1539
1591
  const ws = await this.getOrCreateWs();
@@ -2009,7 +2061,7 @@ export abstract class Exchange {
2009
2061
  /**
2010
2062
  * Calculate the average execution price for a given amount by walking the order book.
2011
2063
  * Uses the sidecar server for calculation to ensure consistency.
2012
- *
2064
+ *
2013
2065
  * @param orderBook - The current order book
2014
2066
  * @param side - 'buy' or 'sell'
2015
2067
  * @param amount - The amount to execute
@@ -2023,7 +2075,7 @@ export abstract class Exchange {
2023
2075
  /**
2024
2076
  * Calculate detailed execution price information.
2025
2077
  * Uses the sidecar server for calculation to ensure consistency.
2026
- *
2078
+ *
2027
2079
  * @param orderBook - The current order book
2028
2080
  * @param side - 'buy' or 'sell'
2029
2081
  * @param amount - The amount to execute
@@ -2614,3 +2666,51 @@ export class PolymarketUS extends Exchange {
2614
2666
  super("polymarket_us", options);
2615
2667
  }
2616
2668
  }
2669
+
2670
+ /**
2671
+ * Gemini Titan exchange client.
2672
+ *
2673
+ * @example
2674
+ * ```typescript
2675
+ * const titan = new GeminiTitan();
2676
+ * const markets = await titan.fetchMarkets();
2677
+ * ```
2678
+ */
2679
+ export class GeminiTitan extends Exchange {
2680
+ constructor(options: ExchangeOptions = {}) {
2681
+ super("gemini-titan", options);
2682
+ }
2683
+ }
2684
+
2685
+ /**
2686
+ * Hyperliquid exchange client.
2687
+ *
2688
+ * @example
2689
+ * ```typescript
2690
+ * const hl = new Hyperliquid();
2691
+ * const markets = await hl.fetchMarkets();
2692
+ * ```
2693
+ */
2694
+ export class Hyperliquid extends Exchange {
2695
+ constructor(options: ExchangeOptions = {}) {
2696
+ super("hyperliquid", options);
2697
+ }
2698
+ }
2699
+
2700
+ /**
2701
+ * Mock exchange client.
2702
+ *
2703
+ * Offline deterministic exchange for testing and development.
2704
+ * No credentials required.
2705
+ *
2706
+ * @example
2707
+ * ```typescript
2708
+ * const mock = new Mock();
2709
+ * const markets = await mock.fetchMarkets();
2710
+ * ```
2711
+ */
2712
+ export class Mock extends Exchange {
2713
+ constructor(options: ExchangeOptions = {}) {
2714
+ super("mock", options);
2715
+ }
2716
+ }
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
  /**