pmxtjs 2.43.17 → 2.43.18
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/esm/pmxt/client.d.ts +6 -2
- package/dist/esm/pmxt/client.js +21 -4
- package/dist/esm/pmxt/models.d.ts +6 -0
- package/dist/pmxt/client.d.ts +6 -2
- package/dist/pmxt/client.js +21 -4
- package/dist/pmxt/models.d.ts +6 -0
- package/generated/package.json +1 -1
- package/package.json +3 -3
- package/pmxt/client.ts +26 -5
- package/pmxt/models.ts +9 -0
|
@@ -152,7 +152,7 @@ export declare abstract class Exchange {
|
|
|
152
152
|
protected sidecarReadRequest(methodName: string, query: Record<string, unknown>, args: unknown[]): Promise<any>;
|
|
153
153
|
loadMarkets(reload?: boolean): Promise<Record<string, UnifiedMarket>>;
|
|
154
154
|
fetchMarkets(params?: MarketFetchParams): Promise<UnifiedMarket[]>;
|
|
155
|
-
fetchMarketsPaginated(params?:
|
|
155
|
+
fetchMarketsPaginated(params?: MarketFetchParams): Promise<PaginatedMarketsResult>;
|
|
156
156
|
fetchEvents(params?: EventFetchParams): Promise<UnifiedEvent[]>;
|
|
157
157
|
fetchMarket(params?: MarketFetchParams): Promise<UnifiedMarket>;
|
|
158
158
|
fetchEvent(params?: EventFetchParams): Promise<UnifiedEvent>;
|
|
@@ -388,7 +388,7 @@ export declare abstract class Exchange {
|
|
|
388
388
|
* @param amount - The amount to execute
|
|
389
389
|
* @returns The volume-weighted average price, or 0 if insufficient liquidity
|
|
390
390
|
*/
|
|
391
|
-
getExecutionPrice(orderBook: OrderBook, side: 'buy' | 'sell', amount: number):
|
|
391
|
+
getExecutionPrice(orderBook: OrderBook, side: 'buy' | 'sell', amount: number): number;
|
|
392
392
|
/**
|
|
393
393
|
* Calculate detailed execution price information.
|
|
394
394
|
* Uses the sidecar server for calculation to ensure consistency.
|
|
@@ -463,8 +463,12 @@ export declare abstract class Exchange {
|
|
|
463
463
|
* Options for initializing Polymarket client.
|
|
464
464
|
*/
|
|
465
465
|
export interface PolymarketOptions {
|
|
466
|
+
/** Venue-specific API key (e.g. Polymarket CLOB key). Optional. */
|
|
467
|
+
apiKey?: string;
|
|
466
468
|
/** Private key for authentication (optional) */
|
|
467
469
|
privateKey?: string;
|
|
470
|
+
/** Hosted pmxt API key. Enables hosted mode when set. */
|
|
471
|
+
pmxtApiKey?: string;
|
|
468
472
|
/** Base URL of the PMXT sidecar server */
|
|
469
473
|
baseUrl?: string;
|
|
470
474
|
/** Automatically start server if not running (default: true) */
|
package/dist/esm/pmxt/client.js
CHANGED
|
@@ -66,7 +66,7 @@ function queryHasNestedObject(query) {
|
|
|
66
66
|
}
|
|
67
67
|
// Converter functions
|
|
68
68
|
function convertMarket(raw) {
|
|
69
|
-
|
|
69
|
+
const market = {
|
|
70
70
|
...raw,
|
|
71
71
|
resolutionDate: raw.resolutionDate ? new Date(raw.resolutionDate) : undefined,
|
|
72
72
|
outcomes: (raw.outcomes || []).map((o) => ({ ...o })),
|
|
@@ -75,6 +75,12 @@ function convertMarket(raw) {
|
|
|
75
75
|
up: raw.up ? { ...raw.up } : undefined,
|
|
76
76
|
down: raw.down ? { ...raw.down } : undefined,
|
|
77
77
|
};
|
|
78
|
+
Object.defineProperty(market, 'question', {
|
|
79
|
+
get() { return this.title; },
|
|
80
|
+
enumerable: false,
|
|
81
|
+
configurable: true,
|
|
82
|
+
});
|
|
83
|
+
return market;
|
|
78
84
|
}
|
|
79
85
|
function convertCandle(raw) {
|
|
80
86
|
return { ...raw };
|
|
@@ -1899,9 +1905,20 @@ export class Exchange {
|
|
|
1899
1905
|
* @param amount - The amount to execute
|
|
1900
1906
|
* @returns The volume-weighted average price, or 0 if insufficient liquidity
|
|
1901
1907
|
*/
|
|
1902
|
-
|
|
1903
|
-
const
|
|
1904
|
-
|
|
1908
|
+
getExecutionPrice(orderBook, side, amount) {
|
|
1909
|
+
const levels = side === 'buy' ? orderBook.asks : orderBook.bids;
|
|
1910
|
+
let remaining = amount;
|
|
1911
|
+
let totalCost = 0;
|
|
1912
|
+
for (const level of levels) {
|
|
1913
|
+
const fill = Math.min(remaining, level.size);
|
|
1914
|
+
totalCost += fill * level.price;
|
|
1915
|
+
remaining -= fill;
|
|
1916
|
+
if (remaining <= 0)
|
|
1917
|
+
break;
|
|
1918
|
+
}
|
|
1919
|
+
if (remaining > 0)
|
|
1920
|
+
return 0;
|
|
1921
|
+
return totalCost / amount;
|
|
1905
1922
|
}
|
|
1906
1923
|
/**
|
|
1907
1924
|
* Calculate detailed execution price information.
|
|
@@ -23,6 +23,10 @@ export interface MarketOutcome {
|
|
|
23
23
|
priceChange24h?: number;
|
|
24
24
|
/** Exchange-specific metadata */
|
|
25
25
|
metadata?: Record<string, any>;
|
|
26
|
+
/** Best bid price from the order book (when includePrices=True) */
|
|
27
|
+
bestBid?: number;
|
|
28
|
+
/** Best ask price from the order book (when includePrices=True) */
|
|
29
|
+
bestAsk?: number;
|
|
26
30
|
}
|
|
27
31
|
/**
|
|
28
32
|
* A unified market representation across exchanges.
|
|
@@ -74,6 +78,8 @@ export interface UnifiedMarket {
|
|
|
74
78
|
up?: MarketOutcome;
|
|
75
79
|
/** Convenience access to the Down outcome for binary markets. */
|
|
76
80
|
down?: MarketOutcome;
|
|
81
|
+
/** Alias for `title`. Matches the Python SDK's `market.question` property. */
|
|
82
|
+
readonly question?: string;
|
|
77
83
|
}
|
|
78
84
|
/**
|
|
79
85
|
* OHLCV price candle.
|
package/dist/pmxt/client.d.ts
CHANGED
|
@@ -152,7 +152,7 @@ export declare abstract class Exchange {
|
|
|
152
152
|
protected sidecarReadRequest(methodName: string, query: Record<string, unknown>, args: unknown[]): Promise<any>;
|
|
153
153
|
loadMarkets(reload?: boolean): Promise<Record<string, UnifiedMarket>>;
|
|
154
154
|
fetchMarkets(params?: MarketFetchParams): Promise<UnifiedMarket[]>;
|
|
155
|
-
fetchMarketsPaginated(params?:
|
|
155
|
+
fetchMarketsPaginated(params?: MarketFetchParams): Promise<PaginatedMarketsResult>;
|
|
156
156
|
fetchEvents(params?: EventFetchParams): Promise<UnifiedEvent[]>;
|
|
157
157
|
fetchMarket(params?: MarketFetchParams): Promise<UnifiedMarket>;
|
|
158
158
|
fetchEvent(params?: EventFetchParams): Promise<UnifiedEvent>;
|
|
@@ -388,7 +388,7 @@ export declare abstract class Exchange {
|
|
|
388
388
|
* @param amount - The amount to execute
|
|
389
389
|
* @returns The volume-weighted average price, or 0 if insufficient liquidity
|
|
390
390
|
*/
|
|
391
|
-
getExecutionPrice(orderBook: OrderBook, side: 'buy' | 'sell', amount: number):
|
|
391
|
+
getExecutionPrice(orderBook: OrderBook, side: 'buy' | 'sell', amount: number): number;
|
|
392
392
|
/**
|
|
393
393
|
* Calculate detailed execution price information.
|
|
394
394
|
* Uses the sidecar server for calculation to ensure consistency.
|
|
@@ -463,8 +463,12 @@ export declare abstract class Exchange {
|
|
|
463
463
|
* Options for initializing Polymarket client.
|
|
464
464
|
*/
|
|
465
465
|
export interface PolymarketOptions {
|
|
466
|
+
/** Venue-specific API key (e.g. Polymarket CLOB key). Optional. */
|
|
467
|
+
apiKey?: string;
|
|
466
468
|
/** Private key for authentication (optional) */
|
|
467
469
|
privateKey?: string;
|
|
470
|
+
/** Hosted pmxt API key. Enables hosted mode when set. */
|
|
471
|
+
pmxtApiKey?: string;
|
|
468
472
|
/** Base URL of the PMXT sidecar server */
|
|
469
473
|
baseUrl?: string;
|
|
470
474
|
/** Automatically start server if not running (default: true) */
|
package/dist/pmxt/client.js
CHANGED
|
@@ -69,7 +69,7 @@ function queryHasNestedObject(query) {
|
|
|
69
69
|
}
|
|
70
70
|
// Converter functions
|
|
71
71
|
function convertMarket(raw) {
|
|
72
|
-
|
|
72
|
+
const market = {
|
|
73
73
|
...raw,
|
|
74
74
|
resolutionDate: raw.resolutionDate ? new Date(raw.resolutionDate) : undefined,
|
|
75
75
|
outcomes: (raw.outcomes || []).map((o) => ({ ...o })),
|
|
@@ -78,6 +78,12 @@ function convertMarket(raw) {
|
|
|
78
78
|
up: raw.up ? { ...raw.up } : undefined,
|
|
79
79
|
down: raw.down ? { ...raw.down } : undefined,
|
|
80
80
|
};
|
|
81
|
+
Object.defineProperty(market, 'question', {
|
|
82
|
+
get() { return this.title; },
|
|
83
|
+
enumerable: false,
|
|
84
|
+
configurable: true,
|
|
85
|
+
});
|
|
86
|
+
return market;
|
|
81
87
|
}
|
|
82
88
|
function convertCandle(raw) {
|
|
83
89
|
return { ...raw };
|
|
@@ -1902,9 +1908,20 @@ class Exchange {
|
|
|
1902
1908
|
* @param amount - The amount to execute
|
|
1903
1909
|
* @returns The volume-weighted average price, or 0 if insufficient liquidity
|
|
1904
1910
|
*/
|
|
1905
|
-
|
|
1906
|
-
const
|
|
1907
|
-
|
|
1911
|
+
getExecutionPrice(orderBook, side, amount) {
|
|
1912
|
+
const levels = side === 'buy' ? orderBook.asks : orderBook.bids;
|
|
1913
|
+
let remaining = amount;
|
|
1914
|
+
let totalCost = 0;
|
|
1915
|
+
for (const level of levels) {
|
|
1916
|
+
const fill = Math.min(remaining, level.size);
|
|
1917
|
+
totalCost += fill * level.price;
|
|
1918
|
+
remaining -= fill;
|
|
1919
|
+
if (remaining <= 0)
|
|
1920
|
+
break;
|
|
1921
|
+
}
|
|
1922
|
+
if (remaining > 0)
|
|
1923
|
+
return 0;
|
|
1924
|
+
return totalCost / amount;
|
|
1908
1925
|
}
|
|
1909
1926
|
/**
|
|
1910
1927
|
* Calculate detailed execution price information.
|
package/dist/pmxt/models.d.ts
CHANGED
|
@@ -23,6 +23,10 @@ export interface MarketOutcome {
|
|
|
23
23
|
priceChange24h?: number;
|
|
24
24
|
/** Exchange-specific metadata */
|
|
25
25
|
metadata?: Record<string, any>;
|
|
26
|
+
/** Best bid price from the order book (when includePrices=True) */
|
|
27
|
+
bestBid?: number;
|
|
28
|
+
/** Best ask price from the order book (when includePrices=True) */
|
|
29
|
+
bestAsk?: number;
|
|
26
30
|
}
|
|
27
31
|
/**
|
|
28
32
|
* A unified market representation across exchanges.
|
|
@@ -74,6 +78,8 @@ export interface UnifiedMarket {
|
|
|
74
78
|
up?: MarketOutcome;
|
|
75
79
|
/** Convenience access to the Down outcome for binary markets. */
|
|
76
80
|
down?: MarketOutcome;
|
|
81
|
+
/** Alias for `title`. Matches the Python SDK's `market.question` property. */
|
|
82
|
+
readonly question?: string;
|
|
77
83
|
}
|
|
78
84
|
/**
|
|
79
85
|
* OHLCV price candle.
|
package/generated/package.json
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pmxtjs",
|
|
3
|
-
"version": "2.43.
|
|
3
|
+
"version": "2.43.18",
|
|
4
4
|
"description": "Unified prediction market data API - The ccxt for prediction markets",
|
|
5
5
|
"author": "PMXT Contributors",
|
|
6
6
|
"repository": {
|
|
@@ -43,14 +43,14 @@
|
|
|
43
43
|
"unified"
|
|
44
44
|
],
|
|
45
45
|
"dependencies": {
|
|
46
|
-
"pmxt-core": "2.43.
|
|
46
|
+
"pmxt-core": "2.43.18",
|
|
47
47
|
"ws": "^8.18.0"
|
|
48
48
|
},
|
|
49
49
|
"devDependencies": {
|
|
50
50
|
"@types/jest": "^30.0.0",
|
|
51
51
|
"@types/node": "^20.0.0",
|
|
52
52
|
"jest": "^30.4.2",
|
|
53
|
-
"ts-jest": "^29.4.
|
|
53
|
+
"ts-jest": "^29.4.11",
|
|
54
54
|
"typescript": "^5.0.0"
|
|
55
55
|
}
|
|
56
56
|
}
|
package/pmxt/client.ts
CHANGED
|
@@ -104,7 +104,7 @@ function queryHasNestedObject(query: Record<string, unknown>): boolean {
|
|
|
104
104
|
|
|
105
105
|
// Converter functions
|
|
106
106
|
function convertMarket(raw: any): UnifiedMarket {
|
|
107
|
-
|
|
107
|
+
const market: UnifiedMarket = {
|
|
108
108
|
...raw,
|
|
109
109
|
resolutionDate: raw.resolutionDate ? new Date(raw.resolutionDate) : undefined,
|
|
110
110
|
outcomes: (raw.outcomes || []).map((o: any) => ({ ...o })),
|
|
@@ -113,6 +113,12 @@ function convertMarket(raw: any): UnifiedMarket {
|
|
|
113
113
|
up: raw.up ? { ...raw.up } : undefined,
|
|
114
114
|
down: raw.down ? { ...raw.down } : undefined,
|
|
115
115
|
};
|
|
116
|
+
Object.defineProperty(market, 'question', {
|
|
117
|
+
get() { return this.title; },
|
|
118
|
+
enumerable: false,
|
|
119
|
+
configurable: true,
|
|
120
|
+
});
|
|
121
|
+
return market;
|
|
116
122
|
}
|
|
117
123
|
|
|
118
124
|
|
|
@@ -659,7 +665,7 @@ export abstract class Exchange {
|
|
|
659
665
|
}
|
|
660
666
|
}
|
|
661
667
|
|
|
662
|
-
async fetchMarketsPaginated(params?:
|
|
668
|
+
async fetchMarketsPaginated(params?: MarketFetchParams): Promise<PaginatedMarketsResult> {
|
|
663
669
|
await this.initPromise;
|
|
664
670
|
try {
|
|
665
671
|
const args: any[] = [];
|
|
@@ -2043,9 +2049,18 @@ export abstract class Exchange {
|
|
|
2043
2049
|
* @param amount - The amount to execute
|
|
2044
2050
|
* @returns The volume-weighted average price, or 0 if insufficient liquidity
|
|
2045
2051
|
*/
|
|
2046
|
-
|
|
2047
|
-
const
|
|
2048
|
-
|
|
2052
|
+
getExecutionPrice(orderBook: OrderBook, side: 'buy' | 'sell', amount: number): number {
|
|
2053
|
+
const levels = side === 'buy' ? orderBook.asks : orderBook.bids;
|
|
2054
|
+
let remaining = amount;
|
|
2055
|
+
let totalCost = 0;
|
|
2056
|
+
for (const level of levels) {
|
|
2057
|
+
const fill = Math.min(remaining, level.size);
|
|
2058
|
+
totalCost += fill * level.price;
|
|
2059
|
+
remaining -= fill;
|
|
2060
|
+
if (remaining <= 0) break;
|
|
2061
|
+
}
|
|
2062
|
+
if (remaining > 0) return 0;
|
|
2063
|
+
return totalCost / amount;
|
|
2049
2064
|
}
|
|
2050
2065
|
|
|
2051
2066
|
/**
|
|
@@ -2400,9 +2415,15 @@ export abstract class Exchange {
|
|
|
2400
2415
|
* Options for initializing Polymarket client.
|
|
2401
2416
|
*/
|
|
2402
2417
|
export interface PolymarketOptions {
|
|
2418
|
+
/** Venue-specific API key (e.g. Polymarket CLOB key). Optional. */
|
|
2419
|
+
apiKey?: string;
|
|
2420
|
+
|
|
2403
2421
|
/** Private key for authentication (optional) */
|
|
2404
2422
|
privateKey?: string;
|
|
2405
2423
|
|
|
2424
|
+
/** Hosted pmxt API key. Enables hosted mode when set. */
|
|
2425
|
+
pmxtApiKey?: string;
|
|
2426
|
+
|
|
2406
2427
|
/** Base URL of the PMXT sidecar server */
|
|
2407
2428
|
baseUrl?: string;
|
|
2408
2429
|
|
package/pmxt/models.ts
CHANGED
|
@@ -29,6 +29,12 @@ export interface MarketOutcome {
|
|
|
29
29
|
|
|
30
30
|
/** Exchange-specific metadata */
|
|
31
31
|
metadata?: Record<string, any>;
|
|
32
|
+
|
|
33
|
+
/** Best bid price from the order book (when includePrices=True) */
|
|
34
|
+
bestBid?: number;
|
|
35
|
+
|
|
36
|
+
/** Best ask price from the order book (when includePrices=True) */
|
|
37
|
+
bestAsk?: number;
|
|
32
38
|
}
|
|
33
39
|
|
|
34
40
|
/**
|
|
@@ -103,6 +109,9 @@ export interface UnifiedMarket {
|
|
|
103
109
|
|
|
104
110
|
/** Convenience access to the Down outcome for binary markets. */
|
|
105
111
|
down?: MarketOutcome;
|
|
112
|
+
|
|
113
|
+
/** Alias for `title`. Matches the Python SDK's `market.question` property. */
|
|
114
|
+
readonly question?: string;
|
|
106
115
|
}
|
|
107
116
|
|
|
108
117
|
/**
|