pmxtjs 2.35.5 → 2.35.6
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/models.d.ts +6 -4
- package/dist/esm/pmxt/router.d.ts +10 -24
- package/dist/esm/pmxt/router.js +22 -63
- package/dist/pmxt/models.d.ts +6 -4
- package/dist/pmxt/router.d.ts +10 -24
- package/dist/pmxt/router.js +22 -63
- package/generated/package.json +1 -1
- package/package.json +2 -2
- package/pmxt/models.ts +6 -4
- package/pmxt/router.ts +72 -35
|
@@ -500,8 +500,9 @@ export interface SubscribedAddressSnapshot {
|
|
|
500
500
|
}
|
|
501
501
|
/** Set-theoretic relation between two markets' resolution conditions. */
|
|
502
502
|
export type MatchRelation = 'identity' | 'subset' | 'superset' | 'overlap' | 'disjoint';
|
|
503
|
-
/** A cross-venue market match with relation classification.
|
|
504
|
-
|
|
503
|
+
/** A cross-venue market match with relation classification.
|
|
504
|
+
* Market properties (title, slug, url, etc.) are accessible directly on the result. */
|
|
505
|
+
export interface MatchResult extends Readonly<UnifiedMarket> {
|
|
505
506
|
/** The matched market on another venue. */
|
|
506
507
|
market: UnifiedMarket;
|
|
507
508
|
/** Set-theoretic relation between the source and matched market. */
|
|
@@ -515,8 +516,9 @@ export interface MatchResult {
|
|
|
515
516
|
/** Best ask price on the matched venue (when includePrices=true). */
|
|
516
517
|
bestAsk?: number;
|
|
517
518
|
}
|
|
518
|
-
/** A cross-venue event match with constituent market matches.
|
|
519
|
-
|
|
519
|
+
/** A cross-venue event match with constituent market matches.
|
|
520
|
+
* Event properties (title, slug, url, etc.) are accessible directly on the result. */
|
|
521
|
+
export interface EventMatchResult extends Readonly<UnifiedEvent> {
|
|
520
522
|
/** The matched event on another venue. */
|
|
521
523
|
event: UnifiedEvent;
|
|
522
524
|
/** Cross-venue market matches within this event. */
|
|
@@ -28,7 +28,7 @@ export interface RouterOptions {
|
|
|
28
28
|
*
|
|
29
29
|
* const router = new pmxt.Router({ pmxtApiKey: "pmxt_live_..." });
|
|
30
30
|
* const markets = await router.fetchMarkets({ query: "election" });
|
|
31
|
-
* const matches = await router.fetchMarketMatches(
|
|
31
|
+
* const matches = await router.fetchMarketMatches(markets[0]);
|
|
32
32
|
* ```
|
|
33
33
|
*/
|
|
34
34
|
export declare class Router extends Exchange {
|
|
@@ -36,15 +36,9 @@ export declare class Router extends Exchange {
|
|
|
36
36
|
/**
|
|
37
37
|
* Find markets on other venues that correspond to a given market.
|
|
38
38
|
*
|
|
39
|
-
* @param
|
|
40
|
-
* @param params.marketId - PMXT market ID.
|
|
41
|
-
* @param params.slug - Market slug (alternative to marketId).
|
|
42
|
-
* @param params.url - Market URL on the source venue.
|
|
43
|
-
* @param params.relation - Filter to a specific relation type.
|
|
44
|
-
* @param params.minConfidence - Minimum confidence threshold (0–1).
|
|
45
|
-
* @param params.limit - Maximum number of matches to return.
|
|
46
|
-
* @param params.includePrices - Attach live bestBid/bestAsk to each match.
|
|
39
|
+
* @param marketOrParams - A UnifiedMarket, or an options object.
|
|
47
40
|
*/
|
|
41
|
+
fetchMarketMatches(market: UnifiedMarket): Promise<MatchResult[]>;
|
|
48
42
|
fetchMarketMatches(params?: {
|
|
49
43
|
market?: UnifiedMarket;
|
|
50
44
|
marketId?: string;
|
|
@@ -58,6 +52,7 @@ export declare class Router extends Exchange {
|
|
|
58
52
|
/**
|
|
59
53
|
* @deprecated Use {@link fetchMarketMatches} instead.
|
|
60
54
|
*/
|
|
55
|
+
fetchMatches(market: UnifiedMarket): Promise<MatchResult[]>;
|
|
61
56
|
fetchMatches(params?: {
|
|
62
57
|
market?: UnifiedMarket;
|
|
63
58
|
marketId?: string;
|
|
@@ -71,14 +66,9 @@ export declare class Router extends Exchange {
|
|
|
71
66
|
/**
|
|
72
67
|
* Match an entire event across venues.
|
|
73
68
|
*
|
|
74
|
-
* @param
|
|
75
|
-
* @param params.eventId - PMXT event ID.
|
|
76
|
-
* @param params.slug - Event slug.
|
|
77
|
-
* @param params.relation - Filter market matches to a specific relation type.
|
|
78
|
-
* @param params.minConfidence - Minimum confidence threshold (0–1).
|
|
79
|
-
* @param params.limit - Maximum number of event matches to return.
|
|
80
|
-
* @param params.includePrices - Attach live prices to each market match.
|
|
69
|
+
* @param eventOrParams - A UnifiedEvent, or an options object.
|
|
81
70
|
*/
|
|
71
|
+
fetchEventMatches(event: UnifiedEvent): Promise<EventMatchResult[]>;
|
|
82
72
|
fetchEventMatches(params?: {
|
|
83
73
|
event?: UnifiedEvent;
|
|
84
74
|
eventId?: string;
|
|
@@ -91,11 +81,9 @@ export declare class Router extends Exchange {
|
|
|
91
81
|
/**
|
|
92
82
|
* Compare prices for the same market across venues.
|
|
93
83
|
*
|
|
94
|
-
* @param
|
|
95
|
-
* @param params.marketId - PMXT market ID.
|
|
96
|
-
* @param params.slug - Market slug.
|
|
97
|
-
* @param params.url - Market URL.
|
|
84
|
+
* @param marketOrParams - A UnifiedMarket, or an options object.
|
|
98
85
|
*/
|
|
86
|
+
compareMarketPrices(market: UnifiedMarket): Promise<PriceComparison[]>;
|
|
99
87
|
compareMarketPrices(params?: {
|
|
100
88
|
market?: UnifiedMarket;
|
|
101
89
|
marketId?: string;
|
|
@@ -105,11 +93,9 @@ export declare class Router extends Exchange {
|
|
|
105
93
|
/**
|
|
106
94
|
* Find markets that partially hedge a position.
|
|
107
95
|
*
|
|
108
|
-
* @param
|
|
109
|
-
* @param params.marketId - PMXT market ID.
|
|
110
|
-
* @param params.slug - Market slug.
|
|
111
|
-
* @param params.url - Market URL.
|
|
96
|
+
* @param marketOrParams - A UnifiedMarket, or an options object.
|
|
112
97
|
*/
|
|
98
|
+
fetchHedges(market: UnifiedMarket): Promise<PriceComparison[]>;
|
|
113
99
|
fetchHedges(params?: {
|
|
114
100
|
market?: UnifiedMarket;
|
|
115
101
|
marketId?: string;
|
package/dist/esm/pmxt/router.js
CHANGED
|
@@ -66,8 +66,10 @@ function convertEvent(raw) {
|
|
|
66
66
|
}
|
|
67
67
|
function parseMatchResult(raw) {
|
|
68
68
|
const marketData = raw.market || {};
|
|
69
|
+
const market = convertMarket(marketData);
|
|
69
70
|
return {
|
|
70
|
-
market
|
|
71
|
+
...market,
|
|
72
|
+
market,
|
|
71
73
|
relation: raw.relation || 'identity',
|
|
72
74
|
confidence: raw.confidence || 0,
|
|
73
75
|
reasoning: raw.reasoning,
|
|
@@ -88,29 +90,15 @@ function parseMatchResult(raw) {
|
|
|
88
90
|
*
|
|
89
91
|
* const router = new pmxt.Router({ pmxtApiKey: "pmxt_live_..." });
|
|
90
92
|
* const markets = await router.fetchMarkets({ query: "election" });
|
|
91
|
-
* const matches = await router.fetchMarketMatches(
|
|
93
|
+
* const matches = await router.fetchMarketMatches(markets[0]);
|
|
92
94
|
* ```
|
|
93
95
|
*/
|
|
94
96
|
export class Router extends Exchange {
|
|
95
97
|
constructor(options = {}) {
|
|
96
98
|
super("router", options);
|
|
97
99
|
}
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
// ------------------------------------------------------------------
|
|
101
|
-
/**
|
|
102
|
-
* Find markets on other venues that correspond to a given market.
|
|
103
|
-
*
|
|
104
|
-
* @param params.market - A UnifiedMarket object (extracts marketId automatically).
|
|
105
|
-
* @param params.marketId - PMXT market ID.
|
|
106
|
-
* @param params.slug - Market slug (alternative to marketId).
|
|
107
|
-
* @param params.url - Market URL on the source venue.
|
|
108
|
-
* @param params.relation - Filter to a specific relation type.
|
|
109
|
-
* @param params.minConfidence - Minimum confidence threshold (0–1).
|
|
110
|
-
* @param params.limit - Maximum number of matches to return.
|
|
111
|
-
* @param params.includePrices - Attach live bestBid/bestAsk to each match.
|
|
112
|
-
*/
|
|
113
|
-
async fetchMarketMatches(params = {}) {
|
|
100
|
+
async fetchMarketMatches(marketOrParams = {}) {
|
|
101
|
+
const params = 'title' in marketOrParams ? { market: marketOrParams } : marketOrParams;
|
|
114
102
|
await this.initPromise;
|
|
115
103
|
const query = {};
|
|
116
104
|
const marketId = params.marketId ?? params.market?.marketId;
|
|
@@ -141,25 +129,12 @@ export class Router extends Exchange {
|
|
|
141
129
|
throw new Error(`Failed to fetchMarketMatches: ${error}`);
|
|
142
130
|
}
|
|
143
131
|
}
|
|
144
|
-
|
|
145
|
-
* @deprecated Use {@link fetchMarketMatches} instead.
|
|
146
|
-
*/
|
|
147
|
-
async fetchMatches(params = {}) {
|
|
132
|
+
async fetchMatches(marketOrParams = {}) {
|
|
148
133
|
console.warn('[pmxt] fetchMatches is deprecated, use fetchMarketMatches instead');
|
|
149
|
-
return this.fetchMarketMatches(
|
|
134
|
+
return this.fetchMarketMatches(marketOrParams);
|
|
150
135
|
}
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
*
|
|
154
|
-
* @param params.event - A UnifiedEvent object (extracts id automatically).
|
|
155
|
-
* @param params.eventId - PMXT event ID.
|
|
156
|
-
* @param params.slug - Event slug.
|
|
157
|
-
* @param params.relation - Filter market matches to a specific relation type.
|
|
158
|
-
* @param params.minConfidence - Minimum confidence threshold (0–1).
|
|
159
|
-
* @param params.limit - Maximum number of event matches to return.
|
|
160
|
-
* @param params.includePrices - Attach live prices to each market match.
|
|
161
|
-
*/
|
|
162
|
-
async fetchEventMatches(params = {}) {
|
|
136
|
+
async fetchEventMatches(eventOrParams = {}) {
|
|
137
|
+
const params = 'title' in eventOrParams && 'markets' in eventOrParams ? { event: eventOrParams } : eventOrParams;
|
|
163
138
|
await this.initPromise;
|
|
164
139
|
const query = {};
|
|
165
140
|
const eventId = params.eventId ?? params.event?.id;
|
|
@@ -180,10 +155,14 @@ export class Router extends Exchange {
|
|
|
180
155
|
const data = this.handleResponse(json);
|
|
181
156
|
if (!data)
|
|
182
157
|
return [];
|
|
183
|
-
return data.map((entry) =>
|
|
184
|
-
event
|
|
185
|
-
|
|
186
|
-
|
|
158
|
+
return data.map((entry) => {
|
|
159
|
+
const event = convertEvent(entry.event || {});
|
|
160
|
+
return {
|
|
161
|
+
...event,
|
|
162
|
+
event,
|
|
163
|
+
marketMatches: (entry.marketMatches || []).map(parseMatchResult),
|
|
164
|
+
};
|
|
165
|
+
});
|
|
187
166
|
}
|
|
188
167
|
catch (error) {
|
|
189
168
|
if (error instanceof Error)
|
|
@@ -191,18 +170,8 @@ export class Router extends Exchange {
|
|
|
191
170
|
throw new Error(`Failed to fetchEventMatches: ${error}`);
|
|
192
171
|
}
|
|
193
172
|
}
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
// ------------------------------------------------------------------
|
|
197
|
-
/**
|
|
198
|
-
* Compare prices for the same market across venues.
|
|
199
|
-
*
|
|
200
|
-
* @param params.market - A UnifiedMarket object (extracts marketId automatically).
|
|
201
|
-
* @param params.marketId - PMXT market ID.
|
|
202
|
-
* @param params.slug - Market slug.
|
|
203
|
-
* @param params.url - Market URL.
|
|
204
|
-
*/
|
|
205
|
-
async compareMarketPrices(params = {}) {
|
|
173
|
+
async compareMarketPrices(marketOrParams = {}) {
|
|
174
|
+
const params = 'title' in marketOrParams ? { market: marketOrParams } : marketOrParams;
|
|
206
175
|
await this.initPromise;
|
|
207
176
|
const query = {};
|
|
208
177
|
const marketId = params.marketId ?? params.market?.marketId;
|
|
@@ -247,18 +216,8 @@ export class Router extends Exchange {
|
|
|
247
216
|
throw new Error(`Failed to compareMarketPrices: ${error}`);
|
|
248
217
|
}
|
|
249
218
|
}
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
// ------------------------------------------------------------------
|
|
253
|
-
/**
|
|
254
|
-
* Find markets that partially hedge a position.
|
|
255
|
-
*
|
|
256
|
-
* @param params.market - A UnifiedMarket object (extracts marketId automatically).
|
|
257
|
-
* @param params.marketId - PMXT market ID.
|
|
258
|
-
* @param params.slug - Market slug.
|
|
259
|
-
* @param params.url - Market URL.
|
|
260
|
-
*/
|
|
261
|
-
async fetchHedges(params = {}) {
|
|
219
|
+
async fetchHedges(marketOrParams = {}) {
|
|
220
|
+
const params = 'title' in marketOrParams ? { market: marketOrParams } : marketOrParams;
|
|
262
221
|
await this.initPromise;
|
|
263
222
|
const query = {};
|
|
264
223
|
const marketId = params.marketId ?? params.market?.marketId;
|
package/dist/pmxt/models.d.ts
CHANGED
|
@@ -500,8 +500,9 @@ export interface SubscribedAddressSnapshot {
|
|
|
500
500
|
}
|
|
501
501
|
/** Set-theoretic relation between two markets' resolution conditions. */
|
|
502
502
|
export type MatchRelation = 'identity' | 'subset' | 'superset' | 'overlap' | 'disjoint';
|
|
503
|
-
/** A cross-venue market match with relation classification.
|
|
504
|
-
|
|
503
|
+
/** A cross-venue market match with relation classification.
|
|
504
|
+
* Market properties (title, slug, url, etc.) are accessible directly on the result. */
|
|
505
|
+
export interface MatchResult extends Readonly<UnifiedMarket> {
|
|
505
506
|
/** The matched market on another venue. */
|
|
506
507
|
market: UnifiedMarket;
|
|
507
508
|
/** Set-theoretic relation between the source and matched market. */
|
|
@@ -515,8 +516,9 @@ export interface MatchResult {
|
|
|
515
516
|
/** Best ask price on the matched venue (when includePrices=true). */
|
|
516
517
|
bestAsk?: number;
|
|
517
518
|
}
|
|
518
|
-
/** A cross-venue event match with constituent market matches.
|
|
519
|
-
|
|
519
|
+
/** A cross-venue event match with constituent market matches.
|
|
520
|
+
* Event properties (title, slug, url, etc.) are accessible directly on the result. */
|
|
521
|
+
export interface EventMatchResult extends Readonly<UnifiedEvent> {
|
|
520
522
|
/** The matched event on another venue. */
|
|
521
523
|
event: UnifiedEvent;
|
|
522
524
|
/** Cross-venue market matches within this event. */
|
package/dist/pmxt/router.d.ts
CHANGED
|
@@ -28,7 +28,7 @@ export interface RouterOptions {
|
|
|
28
28
|
*
|
|
29
29
|
* const router = new pmxt.Router({ pmxtApiKey: "pmxt_live_..." });
|
|
30
30
|
* const markets = await router.fetchMarkets({ query: "election" });
|
|
31
|
-
* const matches = await router.fetchMarketMatches(
|
|
31
|
+
* const matches = await router.fetchMarketMatches(markets[0]);
|
|
32
32
|
* ```
|
|
33
33
|
*/
|
|
34
34
|
export declare class Router extends Exchange {
|
|
@@ -36,15 +36,9 @@ export declare class Router extends Exchange {
|
|
|
36
36
|
/**
|
|
37
37
|
* Find markets on other venues that correspond to a given market.
|
|
38
38
|
*
|
|
39
|
-
* @param
|
|
40
|
-
* @param params.marketId - PMXT market ID.
|
|
41
|
-
* @param params.slug - Market slug (alternative to marketId).
|
|
42
|
-
* @param params.url - Market URL on the source venue.
|
|
43
|
-
* @param params.relation - Filter to a specific relation type.
|
|
44
|
-
* @param params.minConfidence - Minimum confidence threshold (0–1).
|
|
45
|
-
* @param params.limit - Maximum number of matches to return.
|
|
46
|
-
* @param params.includePrices - Attach live bestBid/bestAsk to each match.
|
|
39
|
+
* @param marketOrParams - A UnifiedMarket, or an options object.
|
|
47
40
|
*/
|
|
41
|
+
fetchMarketMatches(market: UnifiedMarket): Promise<MatchResult[]>;
|
|
48
42
|
fetchMarketMatches(params?: {
|
|
49
43
|
market?: UnifiedMarket;
|
|
50
44
|
marketId?: string;
|
|
@@ -58,6 +52,7 @@ export declare class Router extends Exchange {
|
|
|
58
52
|
/**
|
|
59
53
|
* @deprecated Use {@link fetchMarketMatches} instead.
|
|
60
54
|
*/
|
|
55
|
+
fetchMatches(market: UnifiedMarket): Promise<MatchResult[]>;
|
|
61
56
|
fetchMatches(params?: {
|
|
62
57
|
market?: UnifiedMarket;
|
|
63
58
|
marketId?: string;
|
|
@@ -71,14 +66,9 @@ export declare class Router extends Exchange {
|
|
|
71
66
|
/**
|
|
72
67
|
* Match an entire event across venues.
|
|
73
68
|
*
|
|
74
|
-
* @param
|
|
75
|
-
* @param params.eventId - PMXT event ID.
|
|
76
|
-
* @param params.slug - Event slug.
|
|
77
|
-
* @param params.relation - Filter market matches to a specific relation type.
|
|
78
|
-
* @param params.minConfidence - Minimum confidence threshold (0–1).
|
|
79
|
-
* @param params.limit - Maximum number of event matches to return.
|
|
80
|
-
* @param params.includePrices - Attach live prices to each market match.
|
|
69
|
+
* @param eventOrParams - A UnifiedEvent, or an options object.
|
|
81
70
|
*/
|
|
71
|
+
fetchEventMatches(event: UnifiedEvent): Promise<EventMatchResult[]>;
|
|
82
72
|
fetchEventMatches(params?: {
|
|
83
73
|
event?: UnifiedEvent;
|
|
84
74
|
eventId?: string;
|
|
@@ -91,11 +81,9 @@ export declare class Router extends Exchange {
|
|
|
91
81
|
/**
|
|
92
82
|
* Compare prices for the same market across venues.
|
|
93
83
|
*
|
|
94
|
-
* @param
|
|
95
|
-
* @param params.marketId - PMXT market ID.
|
|
96
|
-
* @param params.slug - Market slug.
|
|
97
|
-
* @param params.url - Market URL.
|
|
84
|
+
* @param marketOrParams - A UnifiedMarket, or an options object.
|
|
98
85
|
*/
|
|
86
|
+
compareMarketPrices(market: UnifiedMarket): Promise<PriceComparison[]>;
|
|
99
87
|
compareMarketPrices(params?: {
|
|
100
88
|
market?: UnifiedMarket;
|
|
101
89
|
marketId?: string;
|
|
@@ -105,11 +93,9 @@ export declare class Router extends Exchange {
|
|
|
105
93
|
/**
|
|
106
94
|
* Find markets that partially hedge a position.
|
|
107
95
|
*
|
|
108
|
-
* @param
|
|
109
|
-
* @param params.marketId - PMXT market ID.
|
|
110
|
-
* @param params.slug - Market slug.
|
|
111
|
-
* @param params.url - Market URL.
|
|
96
|
+
* @param marketOrParams - A UnifiedMarket, or an options object.
|
|
112
97
|
*/
|
|
98
|
+
fetchHedges(market: UnifiedMarket): Promise<PriceComparison[]>;
|
|
113
99
|
fetchHedges(params?: {
|
|
114
100
|
market?: UnifiedMarket;
|
|
115
101
|
marketId?: string;
|
package/dist/pmxt/router.js
CHANGED
|
@@ -102,8 +102,10 @@ function convertEvent(raw) {
|
|
|
102
102
|
}
|
|
103
103
|
function parseMatchResult(raw) {
|
|
104
104
|
const marketData = raw.market || {};
|
|
105
|
+
const market = convertMarket(marketData);
|
|
105
106
|
return {
|
|
106
|
-
market
|
|
107
|
+
...market,
|
|
108
|
+
market,
|
|
107
109
|
relation: raw.relation || 'identity',
|
|
108
110
|
confidence: raw.confidence || 0,
|
|
109
111
|
reasoning: raw.reasoning,
|
|
@@ -124,29 +126,15 @@ function parseMatchResult(raw) {
|
|
|
124
126
|
*
|
|
125
127
|
* const router = new pmxt.Router({ pmxtApiKey: "pmxt_live_..." });
|
|
126
128
|
* const markets = await router.fetchMarkets({ query: "election" });
|
|
127
|
-
* const matches = await router.fetchMarketMatches(
|
|
129
|
+
* const matches = await router.fetchMarketMatches(markets[0]);
|
|
128
130
|
* ```
|
|
129
131
|
*/
|
|
130
132
|
class Router extends client_js_1.Exchange {
|
|
131
133
|
constructor(options = {}) {
|
|
132
134
|
super("router", options);
|
|
133
135
|
}
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
// ------------------------------------------------------------------
|
|
137
|
-
/**
|
|
138
|
-
* Find markets on other venues that correspond to a given market.
|
|
139
|
-
*
|
|
140
|
-
* @param params.market - A UnifiedMarket object (extracts marketId automatically).
|
|
141
|
-
* @param params.marketId - PMXT market ID.
|
|
142
|
-
* @param params.slug - Market slug (alternative to marketId).
|
|
143
|
-
* @param params.url - Market URL on the source venue.
|
|
144
|
-
* @param params.relation - Filter to a specific relation type.
|
|
145
|
-
* @param params.minConfidence - Minimum confidence threshold (0–1).
|
|
146
|
-
* @param params.limit - Maximum number of matches to return.
|
|
147
|
-
* @param params.includePrices - Attach live bestBid/bestAsk to each match.
|
|
148
|
-
*/
|
|
149
|
-
async fetchMarketMatches(params = {}) {
|
|
136
|
+
async fetchMarketMatches(marketOrParams = {}) {
|
|
137
|
+
const params = 'title' in marketOrParams ? { market: marketOrParams } : marketOrParams;
|
|
150
138
|
await this.initPromise;
|
|
151
139
|
const query = {};
|
|
152
140
|
const marketId = params.marketId ?? params.market?.marketId;
|
|
@@ -177,25 +165,12 @@ class Router extends client_js_1.Exchange {
|
|
|
177
165
|
throw new Error(`Failed to fetchMarketMatches: ${error}`);
|
|
178
166
|
}
|
|
179
167
|
}
|
|
180
|
-
|
|
181
|
-
* @deprecated Use {@link fetchMarketMatches} instead.
|
|
182
|
-
*/
|
|
183
|
-
async fetchMatches(params = {}) {
|
|
168
|
+
async fetchMatches(marketOrParams = {}) {
|
|
184
169
|
console.warn('[pmxt] fetchMatches is deprecated, use fetchMarketMatches instead');
|
|
185
|
-
return this.fetchMarketMatches(
|
|
170
|
+
return this.fetchMarketMatches(marketOrParams);
|
|
186
171
|
}
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
*
|
|
190
|
-
* @param params.event - A UnifiedEvent object (extracts id automatically).
|
|
191
|
-
* @param params.eventId - PMXT event ID.
|
|
192
|
-
* @param params.slug - Event slug.
|
|
193
|
-
* @param params.relation - Filter market matches to a specific relation type.
|
|
194
|
-
* @param params.minConfidence - Minimum confidence threshold (0–1).
|
|
195
|
-
* @param params.limit - Maximum number of event matches to return.
|
|
196
|
-
* @param params.includePrices - Attach live prices to each market match.
|
|
197
|
-
*/
|
|
198
|
-
async fetchEventMatches(params = {}) {
|
|
172
|
+
async fetchEventMatches(eventOrParams = {}) {
|
|
173
|
+
const params = 'title' in eventOrParams && 'markets' in eventOrParams ? { event: eventOrParams } : eventOrParams;
|
|
199
174
|
await this.initPromise;
|
|
200
175
|
const query = {};
|
|
201
176
|
const eventId = params.eventId ?? params.event?.id;
|
|
@@ -216,10 +191,14 @@ class Router extends client_js_1.Exchange {
|
|
|
216
191
|
const data = this.handleResponse(json);
|
|
217
192
|
if (!data)
|
|
218
193
|
return [];
|
|
219
|
-
return data.map((entry) =>
|
|
220
|
-
event
|
|
221
|
-
|
|
222
|
-
|
|
194
|
+
return data.map((entry) => {
|
|
195
|
+
const event = convertEvent(entry.event || {});
|
|
196
|
+
return {
|
|
197
|
+
...event,
|
|
198
|
+
event,
|
|
199
|
+
marketMatches: (entry.marketMatches || []).map(parseMatchResult),
|
|
200
|
+
};
|
|
201
|
+
});
|
|
223
202
|
}
|
|
224
203
|
catch (error) {
|
|
225
204
|
if (error instanceof Error)
|
|
@@ -227,18 +206,8 @@ class Router extends client_js_1.Exchange {
|
|
|
227
206
|
throw new Error(`Failed to fetchEventMatches: ${error}`);
|
|
228
207
|
}
|
|
229
208
|
}
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
// ------------------------------------------------------------------
|
|
233
|
-
/**
|
|
234
|
-
* Compare prices for the same market across venues.
|
|
235
|
-
*
|
|
236
|
-
* @param params.market - A UnifiedMarket object (extracts marketId automatically).
|
|
237
|
-
* @param params.marketId - PMXT market ID.
|
|
238
|
-
* @param params.slug - Market slug.
|
|
239
|
-
* @param params.url - Market URL.
|
|
240
|
-
*/
|
|
241
|
-
async compareMarketPrices(params = {}) {
|
|
209
|
+
async compareMarketPrices(marketOrParams = {}) {
|
|
210
|
+
const params = 'title' in marketOrParams ? { market: marketOrParams } : marketOrParams;
|
|
242
211
|
await this.initPromise;
|
|
243
212
|
const query = {};
|
|
244
213
|
const marketId = params.marketId ?? params.market?.marketId;
|
|
@@ -283,18 +252,8 @@ class Router extends client_js_1.Exchange {
|
|
|
283
252
|
throw new Error(`Failed to compareMarketPrices: ${error}`);
|
|
284
253
|
}
|
|
285
254
|
}
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
// ------------------------------------------------------------------
|
|
289
|
-
/**
|
|
290
|
-
* Find markets that partially hedge a position.
|
|
291
|
-
*
|
|
292
|
-
* @param params.market - A UnifiedMarket object (extracts marketId automatically).
|
|
293
|
-
* @param params.marketId - PMXT market ID.
|
|
294
|
-
* @param params.slug - Market slug.
|
|
295
|
-
* @param params.url - Market URL.
|
|
296
|
-
*/
|
|
297
|
-
async fetchHedges(params = {}) {
|
|
255
|
+
async fetchHedges(marketOrParams = {}) {
|
|
256
|
+
const params = 'title' in marketOrParams ? { market: marketOrParams } : marketOrParams;
|
|
298
257
|
await this.initPromise;
|
|
299
258
|
const query = {};
|
|
300
259
|
const marketId = params.marketId ?? params.market?.marketId;
|
package/generated/package.json
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pmxtjs",
|
|
3
|
-
"version": "2.35.
|
|
3
|
+
"version": "2.35.6",
|
|
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.35.
|
|
46
|
+
"pmxt-core": "2.35.6"
|
|
47
47
|
},
|
|
48
48
|
"devDependencies": {
|
|
49
49
|
"@types/jest": "^30.0.0",
|
package/pmxt/models.ts
CHANGED
|
@@ -692,8 +692,9 @@ export interface SubscribedAddressSnapshot {
|
|
|
692
692
|
/** Set-theoretic relation between two markets' resolution conditions. */
|
|
693
693
|
export type MatchRelation = 'identity' | 'subset' | 'superset' | 'overlap' | 'disjoint';
|
|
694
694
|
|
|
695
|
-
/** A cross-venue market match with relation classification.
|
|
696
|
-
|
|
695
|
+
/** A cross-venue market match with relation classification.
|
|
696
|
+
* Market properties (title, slug, url, etc.) are accessible directly on the result. */
|
|
697
|
+
export interface MatchResult extends Readonly<UnifiedMarket> {
|
|
697
698
|
/** The matched market on another venue. */
|
|
698
699
|
market: UnifiedMarket;
|
|
699
700
|
|
|
@@ -713,8 +714,9 @@ export interface MatchResult {
|
|
|
713
714
|
bestAsk?: number;
|
|
714
715
|
}
|
|
715
716
|
|
|
716
|
-
/** A cross-venue event match with constituent market matches.
|
|
717
|
-
|
|
717
|
+
/** A cross-venue event match with constituent market matches.
|
|
718
|
+
* Event properties (title, slug, url, etc.) are accessible directly on the result. */
|
|
719
|
+
export interface EventMatchResult extends Readonly<UnifiedEvent> {
|
|
718
720
|
/** The matched event on another venue. */
|
|
719
721
|
event: UnifiedEvent;
|
|
720
722
|
|
package/pmxt/router.ts
CHANGED
|
@@ -81,8 +81,10 @@ function convertEvent(raw: any): UnifiedEvent {
|
|
|
81
81
|
|
|
82
82
|
function parseMatchResult(raw: any): MatchResult {
|
|
83
83
|
const marketData = raw.market || {};
|
|
84
|
+
const market = convertMarket(marketData);
|
|
84
85
|
return {
|
|
85
|
-
market
|
|
86
|
+
...market,
|
|
87
|
+
market,
|
|
86
88
|
relation: raw.relation || 'identity',
|
|
87
89
|
confidence: raw.confidence || 0,
|
|
88
90
|
reasoning: raw.reasoning,
|
|
@@ -116,7 +118,7 @@ export interface RouterOptions {
|
|
|
116
118
|
*
|
|
117
119
|
* const router = new pmxt.Router({ pmxtApiKey: "pmxt_live_..." });
|
|
118
120
|
* const markets = await router.fetchMarkets({ query: "election" });
|
|
119
|
-
* const matches = await router.fetchMarketMatches(
|
|
121
|
+
* const matches = await router.fetchMarketMatches(markets[0]);
|
|
120
122
|
* ```
|
|
121
123
|
*/
|
|
122
124
|
export class Router extends Exchange {
|
|
@@ -131,16 +133,20 @@ export class Router extends Exchange {
|
|
|
131
133
|
/**
|
|
132
134
|
* Find markets on other venues that correspond to a given market.
|
|
133
135
|
*
|
|
134
|
-
* @param
|
|
135
|
-
* @param params.marketId - PMXT market ID.
|
|
136
|
-
* @param params.slug - Market slug (alternative to marketId).
|
|
137
|
-
* @param params.url - Market URL on the source venue.
|
|
138
|
-
* @param params.relation - Filter to a specific relation type.
|
|
139
|
-
* @param params.minConfidence - Minimum confidence threshold (0–1).
|
|
140
|
-
* @param params.limit - Maximum number of matches to return.
|
|
141
|
-
* @param params.includePrices - Attach live bestBid/bestAsk to each match.
|
|
136
|
+
* @param marketOrParams - A UnifiedMarket, or an options object.
|
|
142
137
|
*/
|
|
143
|
-
async fetchMarketMatches(
|
|
138
|
+
async fetchMarketMatches(market: UnifiedMarket): Promise<MatchResult[]>;
|
|
139
|
+
async fetchMarketMatches(params?: {
|
|
140
|
+
market?: UnifiedMarket;
|
|
141
|
+
marketId?: string;
|
|
142
|
+
slug?: string;
|
|
143
|
+
url?: string;
|
|
144
|
+
relation?: MatchRelation;
|
|
145
|
+
minConfidence?: number;
|
|
146
|
+
limit?: number;
|
|
147
|
+
includePrices?: boolean;
|
|
148
|
+
}): Promise<MatchResult[]>;
|
|
149
|
+
async fetchMarketMatches(marketOrParams: UnifiedMarket | {
|
|
144
150
|
market?: UnifiedMarket;
|
|
145
151
|
marketId?: string;
|
|
146
152
|
slug?: string;
|
|
@@ -150,6 +156,7 @@ export class Router extends Exchange {
|
|
|
150
156
|
limit?: number;
|
|
151
157
|
includePrices?: boolean;
|
|
152
158
|
} = {}): Promise<MatchResult[]> {
|
|
159
|
+
const params = 'title' in marketOrParams ? { market: marketOrParams as UnifiedMarket } : marketOrParams;
|
|
153
160
|
await this.initPromise;
|
|
154
161
|
const query: Record<string, unknown> = {};
|
|
155
162
|
const marketId = params.marketId ?? params.market?.marketId;
|
|
@@ -175,7 +182,18 @@ export class Router extends Exchange {
|
|
|
175
182
|
/**
|
|
176
183
|
* @deprecated Use {@link fetchMarketMatches} instead.
|
|
177
184
|
*/
|
|
178
|
-
async fetchMatches(
|
|
185
|
+
async fetchMatches(market: UnifiedMarket): Promise<MatchResult[]>;
|
|
186
|
+
async fetchMatches(params?: {
|
|
187
|
+
market?: UnifiedMarket;
|
|
188
|
+
marketId?: string;
|
|
189
|
+
slug?: string;
|
|
190
|
+
url?: string;
|
|
191
|
+
relation?: MatchRelation;
|
|
192
|
+
minConfidence?: number;
|
|
193
|
+
limit?: number;
|
|
194
|
+
includePrices?: boolean;
|
|
195
|
+
}): Promise<MatchResult[]>;
|
|
196
|
+
async fetchMatches(marketOrParams: UnifiedMarket | {
|
|
179
197
|
market?: UnifiedMarket;
|
|
180
198
|
marketId?: string;
|
|
181
199
|
slug?: string;
|
|
@@ -186,21 +204,25 @@ export class Router extends Exchange {
|
|
|
186
204
|
includePrices?: boolean;
|
|
187
205
|
} = {}): Promise<MatchResult[]> {
|
|
188
206
|
console.warn('[pmxt] fetchMatches is deprecated, use fetchMarketMatches instead');
|
|
189
|
-
return this.fetchMarketMatches(
|
|
207
|
+
return this.fetchMarketMatches(marketOrParams as any);
|
|
190
208
|
}
|
|
191
209
|
|
|
192
210
|
/**
|
|
193
211
|
* Match an entire event across venues.
|
|
194
212
|
*
|
|
195
|
-
* @param
|
|
196
|
-
* @param params.eventId - PMXT event ID.
|
|
197
|
-
* @param params.slug - Event slug.
|
|
198
|
-
* @param params.relation - Filter market matches to a specific relation type.
|
|
199
|
-
* @param params.minConfidence - Minimum confidence threshold (0–1).
|
|
200
|
-
* @param params.limit - Maximum number of event matches to return.
|
|
201
|
-
* @param params.includePrices - Attach live prices to each market match.
|
|
213
|
+
* @param eventOrParams - A UnifiedEvent, or an options object.
|
|
202
214
|
*/
|
|
203
|
-
async fetchEventMatches(
|
|
215
|
+
async fetchEventMatches(event: UnifiedEvent): Promise<EventMatchResult[]>;
|
|
216
|
+
async fetchEventMatches(params?: {
|
|
217
|
+
event?: UnifiedEvent;
|
|
218
|
+
eventId?: string;
|
|
219
|
+
slug?: string;
|
|
220
|
+
relation?: MatchRelation;
|
|
221
|
+
minConfidence?: number;
|
|
222
|
+
limit?: number;
|
|
223
|
+
includePrices?: boolean;
|
|
224
|
+
}): Promise<EventMatchResult[]>;
|
|
225
|
+
async fetchEventMatches(eventOrParams: UnifiedEvent | {
|
|
204
226
|
event?: UnifiedEvent;
|
|
205
227
|
eventId?: string;
|
|
206
228
|
slug?: string;
|
|
@@ -209,6 +231,7 @@ export class Router extends Exchange {
|
|
|
209
231
|
limit?: number;
|
|
210
232
|
includePrices?: boolean;
|
|
211
233
|
} = {}): Promise<EventMatchResult[]> {
|
|
234
|
+
const params = 'title' in eventOrParams && 'markets' in eventOrParams ? { event: eventOrParams as UnifiedEvent } : eventOrParams;
|
|
212
235
|
await this.initPromise;
|
|
213
236
|
const query: Record<string, unknown> = {};
|
|
214
237
|
const eventId = params.eventId ?? params.event?.id;
|
|
@@ -223,10 +246,14 @@ export class Router extends Exchange {
|
|
|
223
246
|
const json = await this.sidecarReadRequest('fetchEventMatches', query, [query]);
|
|
224
247
|
const data = this.handleResponse(json);
|
|
225
248
|
if (!data) return [];
|
|
226
|
-
return (data as any[]).map((entry) =>
|
|
227
|
-
event
|
|
228
|
-
|
|
229
|
-
|
|
249
|
+
return (data as any[]).map((entry) => {
|
|
250
|
+
const event = convertEvent(entry.event || {});
|
|
251
|
+
return {
|
|
252
|
+
...event,
|
|
253
|
+
event,
|
|
254
|
+
marketMatches: (entry.marketMatches || []).map(parseMatchResult),
|
|
255
|
+
};
|
|
256
|
+
});
|
|
230
257
|
} catch (error) {
|
|
231
258
|
if (error instanceof Error) throw error;
|
|
232
259
|
throw new Error(`Failed to fetchEventMatches: ${error}`);
|
|
@@ -240,17 +267,22 @@ export class Router extends Exchange {
|
|
|
240
267
|
/**
|
|
241
268
|
* Compare prices for the same market across venues.
|
|
242
269
|
*
|
|
243
|
-
* @param
|
|
244
|
-
* @param params.marketId - PMXT market ID.
|
|
245
|
-
* @param params.slug - Market slug.
|
|
246
|
-
* @param params.url - Market URL.
|
|
270
|
+
* @param marketOrParams - A UnifiedMarket, or an options object.
|
|
247
271
|
*/
|
|
248
|
-
async compareMarketPrices(
|
|
272
|
+
async compareMarketPrices(market: UnifiedMarket): Promise<PriceComparison[]>;
|
|
273
|
+
async compareMarketPrices(params?: {
|
|
274
|
+
market?: UnifiedMarket;
|
|
275
|
+
marketId?: string;
|
|
276
|
+
slug?: string;
|
|
277
|
+
url?: string;
|
|
278
|
+
}): Promise<PriceComparison[]>;
|
|
279
|
+
async compareMarketPrices(marketOrParams: UnifiedMarket | {
|
|
249
280
|
market?: UnifiedMarket;
|
|
250
281
|
marketId?: string;
|
|
251
282
|
slug?: string;
|
|
252
283
|
url?: string;
|
|
253
284
|
} = {}): Promise<PriceComparison[]> {
|
|
285
|
+
const params = 'title' in marketOrParams ? { market: marketOrParams as UnifiedMarket } : marketOrParams;
|
|
254
286
|
await this.initPromise;
|
|
255
287
|
const query: Record<string, unknown> = {};
|
|
256
288
|
const marketId = params.marketId ?? params.market?.marketId;
|
|
@@ -298,17 +330,22 @@ export class Router extends Exchange {
|
|
|
298
330
|
/**
|
|
299
331
|
* Find markets that partially hedge a position.
|
|
300
332
|
*
|
|
301
|
-
* @param
|
|
302
|
-
* @param params.marketId - PMXT market ID.
|
|
303
|
-
* @param params.slug - Market slug.
|
|
304
|
-
* @param params.url - Market URL.
|
|
333
|
+
* @param marketOrParams - A UnifiedMarket, or an options object.
|
|
305
334
|
*/
|
|
306
|
-
async fetchHedges(
|
|
335
|
+
async fetchHedges(market: UnifiedMarket): Promise<PriceComparison[]>;
|
|
336
|
+
async fetchHedges(params?: {
|
|
337
|
+
market?: UnifiedMarket;
|
|
338
|
+
marketId?: string;
|
|
339
|
+
slug?: string;
|
|
340
|
+
url?: string;
|
|
341
|
+
}): Promise<PriceComparison[]>;
|
|
342
|
+
async fetchHedges(marketOrParams: UnifiedMarket | {
|
|
307
343
|
market?: UnifiedMarket;
|
|
308
344
|
marketId?: string;
|
|
309
345
|
slug?: string;
|
|
310
346
|
url?: string;
|
|
311
347
|
} = {}): Promise<PriceComparison[]> {
|
|
348
|
+
const params = 'title' in marketOrParams ? { market: marketOrParams as UnifiedMarket } : marketOrParams;
|
|
312
349
|
await this.initPromise;
|
|
313
350
|
const query: Record<string, unknown> = {};
|
|
314
351
|
const marketId = params.marketId ?? params.market?.marketId;
|