pmxtjs 2.35.4 → 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/generated/src/apis/DefaultApi.d.ts +0 -50
- package/dist/esm/generated/src/apis/DefaultApi.js +0 -79
- 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/generated/src/apis/DefaultApi.d.ts +0 -50
- package/dist/generated/src/apis/DefaultApi.js +2 -81
- 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/docs/DefaultApi.md +0 -90
- package/generated/package.json +1 -1
- package/generated/src/apis/DefaultApi.ts +0 -112
- package/package.json +2 -2
- package/pmxt/models.ts +6 -4
- package/pmxt/router.ts +72 -35
|
@@ -160,17 +160,6 @@ export interface FetchMarketsPaginatedRequest {
|
|
|
160
160
|
cursor?: string;
|
|
161
161
|
filter?: MarketFilterCriteria;
|
|
162
162
|
}
|
|
163
|
-
export interface FetchMatchesRequest {
|
|
164
|
-
exchange: FetchMatchesExchangeEnum;
|
|
165
|
-
market?: UnifiedMarket;
|
|
166
|
-
marketId?: string;
|
|
167
|
-
slug?: string;
|
|
168
|
-
url?: string;
|
|
169
|
-
relation?: FetchMatchesRelationEnum;
|
|
170
|
-
minConfidence?: number;
|
|
171
|
-
limit?: number;
|
|
172
|
-
includePrices?: boolean;
|
|
173
|
-
}
|
|
174
163
|
export interface FetchMyTradesRequest {
|
|
175
164
|
exchange: FetchMyTradesExchangeEnum;
|
|
176
165
|
outcomeId?: string;
|
|
@@ -435,16 +424,6 @@ export declare class DefaultApi extends runtime.BaseAPI {
|
|
|
435
424
|
* Fetch Markets Paginated
|
|
436
425
|
*/
|
|
437
426
|
fetchMarketsPaginated(requestParameters: FetchMarketsPaginatedRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<FetchMarketsPaginated200Response>;
|
|
438
|
-
/**
|
|
439
|
-
* Find Similar Markets (Deprecated)
|
|
440
|
-
* @deprecated
|
|
441
|
-
*/
|
|
442
|
-
fetchMatchesRaw(requestParameters: FetchMatchesRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<runtime.ApiResponse<FetchMarketMatches200Response>>;
|
|
443
|
-
/**
|
|
444
|
-
* Find Similar Markets (Deprecated)
|
|
445
|
-
* @deprecated
|
|
446
|
-
*/
|
|
447
|
-
fetchMatches(requestParameters: FetchMatchesRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<FetchMarketMatches200Response>;
|
|
448
427
|
/**
|
|
449
428
|
* Fetch My Trades
|
|
450
429
|
*/
|
|
@@ -1112,35 +1091,6 @@ export declare const FetchMarketsPaginatedExchangeEnum: {
|
|
|
1112
1091
|
readonly Router: "router";
|
|
1113
1092
|
};
|
|
1114
1093
|
export type FetchMarketsPaginatedExchangeEnum = typeof FetchMarketsPaginatedExchangeEnum[keyof typeof FetchMarketsPaginatedExchangeEnum];
|
|
1115
|
-
/**
|
|
1116
|
-
* @export
|
|
1117
|
-
*/
|
|
1118
|
-
export declare const FetchMatchesExchangeEnum: {
|
|
1119
|
-
readonly Polymarket: "polymarket";
|
|
1120
|
-
readonly Kalshi: "kalshi";
|
|
1121
|
-
readonly KalshiDemo: "kalshi-demo";
|
|
1122
|
-
readonly Limitless: "limitless";
|
|
1123
|
-
readonly Probable: "probable";
|
|
1124
|
-
readonly Baozi: "baozi";
|
|
1125
|
-
readonly Myriad: "myriad";
|
|
1126
|
-
readonly Opinion: "opinion";
|
|
1127
|
-
readonly Metaculus: "metaculus";
|
|
1128
|
-
readonly Smarkets: "smarkets";
|
|
1129
|
-
readonly PolymarketUs: "polymarket_us";
|
|
1130
|
-
readonly Router: "router";
|
|
1131
|
-
};
|
|
1132
|
-
export type FetchMatchesExchangeEnum = typeof FetchMatchesExchangeEnum[keyof typeof FetchMatchesExchangeEnum];
|
|
1133
|
-
/**
|
|
1134
|
-
* @export
|
|
1135
|
-
*/
|
|
1136
|
-
export declare const FetchMatchesRelationEnum: {
|
|
1137
|
-
readonly Identity: "identity";
|
|
1138
|
-
readonly Subset: "subset";
|
|
1139
|
-
readonly Superset: "superset";
|
|
1140
|
-
readonly Overlap: "overlap";
|
|
1141
|
-
readonly Disjoint: "disjoint";
|
|
1142
|
-
};
|
|
1143
|
-
export type FetchMatchesRelationEnum = typeof FetchMatchesRelationEnum[keyof typeof FetchMatchesRelationEnum];
|
|
1144
1094
|
/**
|
|
1145
1095
|
* @export
|
|
1146
1096
|
*/
|
|
@@ -797,58 +797,6 @@ export class DefaultApi extends runtime.BaseAPI {
|
|
|
797
797
|
const response = await this.fetchMarketsPaginatedRaw(requestParameters, initOverrides);
|
|
798
798
|
return await response.value();
|
|
799
799
|
}
|
|
800
|
-
/**
|
|
801
|
-
* Find Similar Markets (Deprecated)
|
|
802
|
-
* @deprecated
|
|
803
|
-
*/
|
|
804
|
-
async fetchMatchesRaw(requestParameters, initOverrides) {
|
|
805
|
-
if (requestParameters['exchange'] == null) {
|
|
806
|
-
throw new runtime.RequiredError('exchange', 'Required parameter "exchange" was null or undefined when calling fetchMatches().');
|
|
807
|
-
}
|
|
808
|
-
const queryParameters = {};
|
|
809
|
-
if (requestParameters['market'] != null) {
|
|
810
|
-
queryParameters['market'] = requestParameters['market'];
|
|
811
|
-
}
|
|
812
|
-
if (requestParameters['marketId'] != null) {
|
|
813
|
-
queryParameters['marketId'] = requestParameters['marketId'];
|
|
814
|
-
}
|
|
815
|
-
if (requestParameters['slug'] != null) {
|
|
816
|
-
queryParameters['slug'] = requestParameters['slug'];
|
|
817
|
-
}
|
|
818
|
-
if (requestParameters['url'] != null) {
|
|
819
|
-
queryParameters['url'] = requestParameters['url'];
|
|
820
|
-
}
|
|
821
|
-
if (requestParameters['relation'] != null) {
|
|
822
|
-
queryParameters['relation'] = requestParameters['relation'];
|
|
823
|
-
}
|
|
824
|
-
if (requestParameters['minConfidence'] != null) {
|
|
825
|
-
queryParameters['minConfidence'] = requestParameters['minConfidence'];
|
|
826
|
-
}
|
|
827
|
-
if (requestParameters['limit'] != null) {
|
|
828
|
-
queryParameters['limit'] = requestParameters['limit'];
|
|
829
|
-
}
|
|
830
|
-
if (requestParameters['includePrices'] != null) {
|
|
831
|
-
queryParameters['includePrices'] = requestParameters['includePrices'];
|
|
832
|
-
}
|
|
833
|
-
const headerParameters = {};
|
|
834
|
-
let urlPath = `/api/{exchange}/fetchMatches`;
|
|
835
|
-
urlPath = urlPath.replace(`{${"exchange"}}`, encodeURIComponent(String(requestParameters['exchange'])));
|
|
836
|
-
const response = await this.request({
|
|
837
|
-
path: urlPath,
|
|
838
|
-
method: 'GET',
|
|
839
|
-
headers: headerParameters,
|
|
840
|
-
query: queryParameters,
|
|
841
|
-
}, initOverrides);
|
|
842
|
-
return new runtime.JSONApiResponse(response, (jsonValue) => FetchMarketMatches200ResponseFromJSON(jsonValue));
|
|
843
|
-
}
|
|
844
|
-
/**
|
|
845
|
-
* Find Similar Markets (Deprecated)
|
|
846
|
-
* @deprecated
|
|
847
|
-
*/
|
|
848
|
-
async fetchMatches(requestParameters, initOverrides) {
|
|
849
|
-
const response = await this.fetchMatchesRaw(requestParameters, initOverrides);
|
|
850
|
-
return await response.value();
|
|
851
|
-
}
|
|
852
800
|
/**
|
|
853
801
|
* Fetch My Trades
|
|
854
802
|
*/
|
|
@@ -1911,33 +1859,6 @@ export const FetchMarketsPaginatedExchangeEnum = {
|
|
|
1911
1859
|
PolymarketUs: 'polymarket_us',
|
|
1912
1860
|
Router: 'router'
|
|
1913
1861
|
};
|
|
1914
|
-
/**
|
|
1915
|
-
* @export
|
|
1916
|
-
*/
|
|
1917
|
-
export const FetchMatchesExchangeEnum = {
|
|
1918
|
-
Polymarket: 'polymarket',
|
|
1919
|
-
Kalshi: 'kalshi',
|
|
1920
|
-
KalshiDemo: 'kalshi-demo',
|
|
1921
|
-
Limitless: 'limitless',
|
|
1922
|
-
Probable: 'probable',
|
|
1923
|
-
Baozi: 'baozi',
|
|
1924
|
-
Myriad: 'myriad',
|
|
1925
|
-
Opinion: 'opinion',
|
|
1926
|
-
Metaculus: 'metaculus',
|
|
1927
|
-
Smarkets: 'smarkets',
|
|
1928
|
-
PolymarketUs: 'polymarket_us',
|
|
1929
|
-
Router: 'router'
|
|
1930
|
-
};
|
|
1931
|
-
/**
|
|
1932
|
-
* @export
|
|
1933
|
-
*/
|
|
1934
|
-
export const FetchMatchesRelationEnum = {
|
|
1935
|
-
Identity: 'identity',
|
|
1936
|
-
Subset: 'subset',
|
|
1937
|
-
Superset: 'superset',
|
|
1938
|
-
Overlap: 'overlap',
|
|
1939
|
-
Disjoint: 'disjoint'
|
|
1940
|
-
};
|
|
1941
1862
|
/**
|
|
1942
1863
|
* @export
|
|
1943
1864
|
*/
|
|
@@ -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;
|
|
@@ -160,17 +160,6 @@ export interface FetchMarketsPaginatedRequest {
|
|
|
160
160
|
cursor?: string;
|
|
161
161
|
filter?: MarketFilterCriteria;
|
|
162
162
|
}
|
|
163
|
-
export interface FetchMatchesRequest {
|
|
164
|
-
exchange: FetchMatchesExchangeEnum;
|
|
165
|
-
market?: UnifiedMarket;
|
|
166
|
-
marketId?: string;
|
|
167
|
-
slug?: string;
|
|
168
|
-
url?: string;
|
|
169
|
-
relation?: FetchMatchesRelationEnum;
|
|
170
|
-
minConfidence?: number;
|
|
171
|
-
limit?: number;
|
|
172
|
-
includePrices?: boolean;
|
|
173
|
-
}
|
|
174
163
|
export interface FetchMyTradesRequest {
|
|
175
164
|
exchange: FetchMyTradesExchangeEnum;
|
|
176
165
|
outcomeId?: string;
|
|
@@ -435,16 +424,6 @@ export declare class DefaultApi extends runtime.BaseAPI {
|
|
|
435
424
|
* Fetch Markets Paginated
|
|
436
425
|
*/
|
|
437
426
|
fetchMarketsPaginated(requestParameters: FetchMarketsPaginatedRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<FetchMarketsPaginated200Response>;
|
|
438
|
-
/**
|
|
439
|
-
* Find Similar Markets (Deprecated)
|
|
440
|
-
* @deprecated
|
|
441
|
-
*/
|
|
442
|
-
fetchMatchesRaw(requestParameters: FetchMatchesRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<runtime.ApiResponse<FetchMarketMatches200Response>>;
|
|
443
|
-
/**
|
|
444
|
-
* Find Similar Markets (Deprecated)
|
|
445
|
-
* @deprecated
|
|
446
|
-
*/
|
|
447
|
-
fetchMatches(requestParameters: FetchMatchesRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<FetchMarketMatches200Response>;
|
|
448
427
|
/**
|
|
449
428
|
* Fetch My Trades
|
|
450
429
|
*/
|
|
@@ -1112,35 +1091,6 @@ export declare const FetchMarketsPaginatedExchangeEnum: {
|
|
|
1112
1091
|
readonly Router: "router";
|
|
1113
1092
|
};
|
|
1114
1093
|
export type FetchMarketsPaginatedExchangeEnum = typeof FetchMarketsPaginatedExchangeEnum[keyof typeof FetchMarketsPaginatedExchangeEnum];
|
|
1115
|
-
/**
|
|
1116
|
-
* @export
|
|
1117
|
-
*/
|
|
1118
|
-
export declare const FetchMatchesExchangeEnum: {
|
|
1119
|
-
readonly Polymarket: "polymarket";
|
|
1120
|
-
readonly Kalshi: "kalshi";
|
|
1121
|
-
readonly KalshiDemo: "kalshi-demo";
|
|
1122
|
-
readonly Limitless: "limitless";
|
|
1123
|
-
readonly Probable: "probable";
|
|
1124
|
-
readonly Baozi: "baozi";
|
|
1125
|
-
readonly Myriad: "myriad";
|
|
1126
|
-
readonly Opinion: "opinion";
|
|
1127
|
-
readonly Metaculus: "metaculus";
|
|
1128
|
-
readonly Smarkets: "smarkets";
|
|
1129
|
-
readonly PolymarketUs: "polymarket_us";
|
|
1130
|
-
readonly Router: "router";
|
|
1131
|
-
};
|
|
1132
|
-
export type FetchMatchesExchangeEnum = typeof FetchMatchesExchangeEnum[keyof typeof FetchMatchesExchangeEnum];
|
|
1133
|
-
/**
|
|
1134
|
-
* @export
|
|
1135
|
-
*/
|
|
1136
|
-
export declare const FetchMatchesRelationEnum: {
|
|
1137
|
-
readonly Identity: "identity";
|
|
1138
|
-
readonly Subset: "subset";
|
|
1139
|
-
readonly Superset: "superset";
|
|
1140
|
-
readonly Overlap: "overlap";
|
|
1141
|
-
readonly Disjoint: "disjoint";
|
|
1142
|
-
};
|
|
1143
|
-
export type FetchMatchesRelationEnum = typeof FetchMatchesRelationEnum[keyof typeof FetchMatchesRelationEnum];
|
|
1144
1094
|
/**
|
|
1145
1095
|
* @export
|
|
1146
1096
|
*/
|
|
@@ -46,8 +46,8 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
46
46
|
};
|
|
47
47
|
})();
|
|
48
48
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
49
|
-
exports.LoadMarketsOperationExchangeEnum = exports.GetExecutionPriceDetailedOperationExchangeEnum = exports.GetExecutionPriceOperationExchangeEnum = exports.FilterMarketsOperationExchangeEnum = exports.FilterEventsOperationExchangeEnum = exports.FetchTradesExchangeEnum = exports.FetchPositionsExchangeEnum = exports.FetchOrderBookExchangeEnum = exports.FetchOrderExchangeEnum = exports.FetchOpenOrdersExchangeEnum = exports.FetchOHLCVResolutionEnum = exports.FetchOHLCVExchangeEnum = exports.FetchMyTradesExchangeEnum = exports.
|
|
50
|
-
exports.WatchTradesOperationExchangeEnum = exports.WatchOrderBookOperationExchangeEnum = exports.WatchAddressOperationExchangeEnum = exports.UnwatchOrderBookOperationExchangeEnum =
|
|
49
|
+
exports.UnwatchAddressOperationExchangeEnum = exports.SubmitOrderOperationExchangeEnum = exports.LoadMarketsOperationExchangeEnum = exports.GetExecutionPriceDetailedOperationExchangeEnum = exports.GetExecutionPriceOperationExchangeEnum = exports.FilterMarketsOperationExchangeEnum = exports.FilterEventsOperationExchangeEnum = exports.FetchTradesExchangeEnum = exports.FetchPositionsExchangeEnum = exports.FetchOrderBookExchangeEnum = exports.FetchOrderExchangeEnum = exports.FetchOpenOrdersExchangeEnum = exports.FetchOHLCVResolutionEnum = exports.FetchOHLCVExchangeEnum = exports.FetchMyTradesExchangeEnum = exports.FetchMarketsPaginatedExchangeEnum = exports.FetchMarketsSearchInEnum = exports.FetchMarketsStatusEnum = exports.FetchMarketsSortEnum = exports.FetchMarketsExchangeEnum = exports.FetchMarketMatchesRelationEnum = exports.FetchMarketMatchesExchangeEnum = exports.FetchMarketSearchInEnum = exports.FetchMarketStatusEnum = exports.FetchMarketSortEnum = exports.FetchMarketExchangeEnum = exports.FetchHedgesRelationEnum = exports.FetchHedgesExchangeEnum = exports.FetchEventsPaginatedExchangeEnum = exports.FetchEventsSearchInEnum = exports.FetchEventsStatusEnum = exports.FetchEventsSortEnum = exports.FetchEventsExchangeEnum = exports.FetchEventMatchesRelationEnum = exports.FetchEventMatchesExchangeEnum = exports.FetchEventSearchInEnum = exports.FetchEventStatusEnum = exports.FetchEventSortEnum = exports.FetchEventExchangeEnum = exports.FetchClosedOrdersExchangeEnum = exports.FetchBalanceExchangeEnum = exports.FetchArbitrageRelationsEnum = exports.FetchArbitrageExchangeEnum = exports.FetchAllOrdersExchangeEnum = exports.CreateOrderOperationExchangeEnum = exports.CompareMarketPricesOperationExchangeEnum = exports.CloseOperationExchangeEnum = exports.CancelOrderOperationExchangeEnum = exports.BuildOrderOperationExchangeEnum = exports.DefaultApi = void 0;
|
|
50
|
+
exports.WatchTradesOperationExchangeEnum = exports.WatchOrderBookOperationExchangeEnum = exports.WatchAddressOperationExchangeEnum = exports.UnwatchOrderBookOperationExchangeEnum = void 0;
|
|
51
51
|
const runtime = __importStar(require("../runtime"));
|
|
52
52
|
const index_1 = require("../models/index");
|
|
53
53
|
/**
|
|
@@ -834,58 +834,6 @@ class DefaultApi extends runtime.BaseAPI {
|
|
|
834
834
|
const response = await this.fetchMarketsPaginatedRaw(requestParameters, initOverrides);
|
|
835
835
|
return await response.value();
|
|
836
836
|
}
|
|
837
|
-
/**
|
|
838
|
-
* Find Similar Markets (Deprecated)
|
|
839
|
-
* @deprecated
|
|
840
|
-
*/
|
|
841
|
-
async fetchMatchesRaw(requestParameters, initOverrides) {
|
|
842
|
-
if (requestParameters['exchange'] == null) {
|
|
843
|
-
throw new runtime.RequiredError('exchange', 'Required parameter "exchange" was null or undefined when calling fetchMatches().');
|
|
844
|
-
}
|
|
845
|
-
const queryParameters = {};
|
|
846
|
-
if (requestParameters['market'] != null) {
|
|
847
|
-
queryParameters['market'] = requestParameters['market'];
|
|
848
|
-
}
|
|
849
|
-
if (requestParameters['marketId'] != null) {
|
|
850
|
-
queryParameters['marketId'] = requestParameters['marketId'];
|
|
851
|
-
}
|
|
852
|
-
if (requestParameters['slug'] != null) {
|
|
853
|
-
queryParameters['slug'] = requestParameters['slug'];
|
|
854
|
-
}
|
|
855
|
-
if (requestParameters['url'] != null) {
|
|
856
|
-
queryParameters['url'] = requestParameters['url'];
|
|
857
|
-
}
|
|
858
|
-
if (requestParameters['relation'] != null) {
|
|
859
|
-
queryParameters['relation'] = requestParameters['relation'];
|
|
860
|
-
}
|
|
861
|
-
if (requestParameters['minConfidence'] != null) {
|
|
862
|
-
queryParameters['minConfidence'] = requestParameters['minConfidence'];
|
|
863
|
-
}
|
|
864
|
-
if (requestParameters['limit'] != null) {
|
|
865
|
-
queryParameters['limit'] = requestParameters['limit'];
|
|
866
|
-
}
|
|
867
|
-
if (requestParameters['includePrices'] != null) {
|
|
868
|
-
queryParameters['includePrices'] = requestParameters['includePrices'];
|
|
869
|
-
}
|
|
870
|
-
const headerParameters = {};
|
|
871
|
-
let urlPath = `/api/{exchange}/fetchMatches`;
|
|
872
|
-
urlPath = urlPath.replace(`{${"exchange"}}`, encodeURIComponent(String(requestParameters['exchange'])));
|
|
873
|
-
const response = await this.request({
|
|
874
|
-
path: urlPath,
|
|
875
|
-
method: 'GET',
|
|
876
|
-
headers: headerParameters,
|
|
877
|
-
query: queryParameters,
|
|
878
|
-
}, initOverrides);
|
|
879
|
-
return new runtime.JSONApiResponse(response, (jsonValue) => (0, index_1.FetchMarketMatches200ResponseFromJSON)(jsonValue));
|
|
880
|
-
}
|
|
881
|
-
/**
|
|
882
|
-
* Find Similar Markets (Deprecated)
|
|
883
|
-
* @deprecated
|
|
884
|
-
*/
|
|
885
|
-
async fetchMatches(requestParameters, initOverrides) {
|
|
886
|
-
const response = await this.fetchMatchesRaw(requestParameters, initOverrides);
|
|
887
|
-
return await response.value();
|
|
888
|
-
}
|
|
889
837
|
/**
|
|
890
838
|
* Fetch My Trades
|
|
891
839
|
*/
|
|
@@ -1949,33 +1897,6 @@ exports.FetchMarketsPaginatedExchangeEnum = {
|
|
|
1949
1897
|
PolymarketUs: 'polymarket_us',
|
|
1950
1898
|
Router: 'router'
|
|
1951
1899
|
};
|
|
1952
|
-
/**
|
|
1953
|
-
* @export
|
|
1954
|
-
*/
|
|
1955
|
-
exports.FetchMatchesExchangeEnum = {
|
|
1956
|
-
Polymarket: 'polymarket',
|
|
1957
|
-
Kalshi: 'kalshi',
|
|
1958
|
-
KalshiDemo: 'kalshi-demo',
|
|
1959
|
-
Limitless: 'limitless',
|
|
1960
|
-
Probable: 'probable',
|
|
1961
|
-
Baozi: 'baozi',
|
|
1962
|
-
Myriad: 'myriad',
|
|
1963
|
-
Opinion: 'opinion',
|
|
1964
|
-
Metaculus: 'metaculus',
|
|
1965
|
-
Smarkets: 'smarkets',
|
|
1966
|
-
PolymarketUs: 'polymarket_us',
|
|
1967
|
-
Router: 'router'
|
|
1968
|
-
};
|
|
1969
|
-
/**
|
|
1970
|
-
* @export
|
|
1971
|
-
*/
|
|
1972
|
-
exports.FetchMatchesRelationEnum = {
|
|
1973
|
-
Identity: 'identity',
|
|
1974
|
-
Subset: 'subset',
|
|
1975
|
-
Superset: 'superset',
|
|
1976
|
-
Overlap: 'overlap',
|
|
1977
|
-
Disjoint: 'disjoint'
|
|
1978
|
-
};
|
|
1979
1900
|
/**
|
|
1980
1901
|
* @export
|
|
1981
1902
|
*/
|
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;
|
|
@@ -22,7 +22,6 @@ All URIs are relative to *http://localhost:3847*
|
|
|
22
22
|
| [**fetchMarketMatches**](DefaultApi.md#fetchmarketmatches) | **GET** /api/{exchange}/fetchMarketMatches | Find Similar Markets |
|
|
23
23
|
| [**fetchMarkets**](DefaultApi.md#fetchmarkets) | **GET** /api/{exchange}/fetchMarkets | Fetch Markets |
|
|
24
24
|
| [**fetchMarketsPaginated**](DefaultApi.md#fetchmarketspaginated) | **GET** /api/{exchange}/fetchMarketsPaginated | Fetch Markets Paginated |
|
|
25
|
-
| [**fetchMatches**](DefaultApi.md#fetchmatches) | **GET** /api/{exchange}/fetchMatches | Find Similar Markets (Deprecated) |
|
|
26
25
|
| [**fetchMyTrades**](DefaultApi.md#fetchmytrades) | **GET** /api/{exchange}/fetchMyTrades | Fetch My Trades |
|
|
27
26
|
| [**fetchOHLCV**](DefaultApi.md#fetchohlcv) | **GET** /api/{exchange}/fetchOHLCV | Fetch OHLCV |
|
|
28
27
|
| [**fetchOpenOrders**](DefaultApi.md#fetchopenorders) | **GET** /api/{exchange}/fetchOpenOrders | Fetch Open Orders |
|
|
@@ -1532,95 +1531,6 @@ No authorization required
|
|
|
1532
1531
|
[[Back to top]](#) [[Back to API list]](../README.md#api-endpoints) [[Back to Model list]](../README.md#models) [[Back to README]](../README.md)
|
|
1533
1532
|
|
|
1534
1533
|
|
|
1535
|
-
## fetchMatches
|
|
1536
|
-
|
|
1537
|
-
> FetchMarketMatches200Response fetchMatches(exchange, market, marketId, slug, url, relation, minConfidence, limit, includePrices)
|
|
1538
|
-
|
|
1539
|
-
Find Similar Markets (Deprecated)
|
|
1540
|
-
|
|
1541
|
-
### Example
|
|
1542
|
-
|
|
1543
|
-
```ts
|
|
1544
|
-
import {
|
|
1545
|
-
Configuration,
|
|
1546
|
-
DefaultApi,
|
|
1547
|
-
} from 'pmxtjs';
|
|
1548
|
-
import type { FetchMatchesRequest } from 'pmxtjs';
|
|
1549
|
-
|
|
1550
|
-
async function example() {
|
|
1551
|
-
console.log("🚀 Testing pmxtjs SDK...");
|
|
1552
|
-
const api = new DefaultApi();
|
|
1553
|
-
|
|
1554
|
-
const body = {
|
|
1555
|
-
// 'polymarket' | 'kalshi' | 'kalshi-demo' | 'limitless' | 'probable' | 'baozi' | 'myriad' | 'opinion' | 'metaculus' | 'smarkets' | 'polymarket_us' | 'router' | The prediction market exchange to target.
|
|
1556
|
-
exchange: exchange_example,
|
|
1557
|
-
// UnifiedMarket | Pass a UnifiedMarket directly instead of marketId/slug/url. (optional)
|
|
1558
|
-
market: ...,
|
|
1559
|
-
// string (optional)
|
|
1560
|
-
marketId: marketId_example,
|
|
1561
|
-
// string (optional)
|
|
1562
|
-
slug: slug_example,
|
|
1563
|
-
// string (optional)
|
|
1564
|
-
url: url_example,
|
|
1565
|
-
// 'identity' | 'subset' | 'superset' | 'overlap' | 'disjoint' (optional)
|
|
1566
|
-
relation: relation_example,
|
|
1567
|
-
// number (optional)
|
|
1568
|
-
minConfidence: 8.14,
|
|
1569
|
-
// number (optional)
|
|
1570
|
-
limit: 8.14,
|
|
1571
|
-
// boolean (optional)
|
|
1572
|
-
includePrices: true,
|
|
1573
|
-
} satisfies FetchMatchesRequest;
|
|
1574
|
-
|
|
1575
|
-
try {
|
|
1576
|
-
const data = await api.fetchMatches(body);
|
|
1577
|
-
console.log(data);
|
|
1578
|
-
} catch (error) {
|
|
1579
|
-
console.error(error);
|
|
1580
|
-
}
|
|
1581
|
-
}
|
|
1582
|
-
|
|
1583
|
-
// Run the test
|
|
1584
|
-
example().catch(console.error);
|
|
1585
|
-
```
|
|
1586
|
-
|
|
1587
|
-
### Parameters
|
|
1588
|
-
|
|
1589
|
-
|
|
1590
|
-
| Name | Type | Description | Notes |
|
|
1591
|
-
|------------- | ------------- | ------------- | -------------|
|
|
1592
|
-
| **exchange** | `polymarket`, `kalshi`, `kalshi-demo`, `limitless`, `probable`, `baozi`, `myriad`, `opinion`, `metaculus`, `smarkets`, `polymarket_us`, `router` | The prediction market exchange to target. | [Defaults to `undefined`] [Enum: polymarket, kalshi, kalshi-demo, limitless, probable, baozi, myriad, opinion, metaculus, smarkets, polymarket_us, router] |
|
|
1593
|
-
| **market** | [](.md) | Pass a UnifiedMarket directly instead of marketId/slug/url. | [Optional] [Defaults to `undefined`] |
|
|
1594
|
-
| **marketId** | `string` | | [Optional] [Defaults to `undefined`] |
|
|
1595
|
-
| **slug** | `string` | | [Optional] [Defaults to `undefined`] |
|
|
1596
|
-
| **url** | `string` | | [Optional] [Defaults to `undefined`] |
|
|
1597
|
-
| **relation** | `identity`, `subset`, `superset`, `overlap`, `disjoint` | | [Optional] [Defaults to `undefined`] [Enum: identity, subset, superset, overlap, disjoint] |
|
|
1598
|
-
| **minConfidence** | `number` | | [Optional] [Defaults to `undefined`] |
|
|
1599
|
-
| **limit** | `number` | | [Optional] [Defaults to `undefined`] |
|
|
1600
|
-
| **includePrices** | `boolean` | | [Optional] [Defaults to `undefined`] |
|
|
1601
|
-
|
|
1602
|
-
### Return type
|
|
1603
|
-
|
|
1604
|
-
[**FetchMarketMatches200Response**](FetchMarketMatches200Response.md)
|
|
1605
|
-
|
|
1606
|
-
### Authorization
|
|
1607
|
-
|
|
1608
|
-
No authorization required
|
|
1609
|
-
|
|
1610
|
-
### HTTP request headers
|
|
1611
|
-
|
|
1612
|
-
- **Content-Type**: Not defined
|
|
1613
|
-
- **Accept**: `application/json`
|
|
1614
|
-
|
|
1615
|
-
|
|
1616
|
-
### HTTP response details
|
|
1617
|
-
| Status code | Description | Response headers |
|
|
1618
|
-
|-------------|-------------|------------------|
|
|
1619
|
-
| **200** | Find Similar Markets (Deprecated) response | - |
|
|
1620
|
-
|
|
1621
|
-
[[Back to top]](#) [[Back to API list]](../README.md#api-endpoints) [[Back to Model list]](../README.md#models) [[Back to README]](../README.md)
|
|
1622
|
-
|
|
1623
|
-
|
|
1624
1534
|
## fetchMyTrades
|
|
1625
1535
|
|
|
1626
1536
|
> FetchMyTrades200Response fetchMyTrades(exchange, outcomeId, marketId, since, until, limit, cursor)
|
package/generated/package.json
CHANGED
|
@@ -321,18 +321,6 @@ export interface FetchMarketsPaginatedRequest {
|
|
|
321
321
|
filter?: MarketFilterCriteria;
|
|
322
322
|
}
|
|
323
323
|
|
|
324
|
-
export interface FetchMatchesRequest {
|
|
325
|
-
exchange: FetchMatchesExchangeEnum;
|
|
326
|
-
market?: UnifiedMarket;
|
|
327
|
-
marketId?: string;
|
|
328
|
-
slug?: string;
|
|
329
|
-
url?: string;
|
|
330
|
-
relation?: FetchMatchesRelationEnum;
|
|
331
|
-
minConfidence?: number;
|
|
332
|
-
limit?: number;
|
|
333
|
-
includePrices?: boolean;
|
|
334
|
-
}
|
|
335
|
-
|
|
336
324
|
export interface FetchMyTradesRequest {
|
|
337
325
|
exchange: FetchMyTradesExchangeEnum;
|
|
338
326
|
outcomeId?: string;
|
|
@@ -1513,77 +1501,6 @@ export class DefaultApi extends runtime.BaseAPI {
|
|
|
1513
1501
|
return await response.value();
|
|
1514
1502
|
}
|
|
1515
1503
|
|
|
1516
|
-
/**
|
|
1517
|
-
* Find Similar Markets (Deprecated)
|
|
1518
|
-
* @deprecated
|
|
1519
|
-
*/
|
|
1520
|
-
async fetchMatchesRaw(requestParameters: FetchMatchesRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<runtime.ApiResponse<FetchMarketMatches200Response>> {
|
|
1521
|
-
if (requestParameters['exchange'] == null) {
|
|
1522
|
-
throw new runtime.RequiredError(
|
|
1523
|
-
'exchange',
|
|
1524
|
-
'Required parameter "exchange" was null or undefined when calling fetchMatches().'
|
|
1525
|
-
);
|
|
1526
|
-
}
|
|
1527
|
-
|
|
1528
|
-
const queryParameters: any = {};
|
|
1529
|
-
|
|
1530
|
-
if (requestParameters['market'] != null) {
|
|
1531
|
-
queryParameters['market'] = requestParameters['market'];
|
|
1532
|
-
}
|
|
1533
|
-
|
|
1534
|
-
if (requestParameters['marketId'] != null) {
|
|
1535
|
-
queryParameters['marketId'] = requestParameters['marketId'];
|
|
1536
|
-
}
|
|
1537
|
-
|
|
1538
|
-
if (requestParameters['slug'] != null) {
|
|
1539
|
-
queryParameters['slug'] = requestParameters['slug'];
|
|
1540
|
-
}
|
|
1541
|
-
|
|
1542
|
-
if (requestParameters['url'] != null) {
|
|
1543
|
-
queryParameters['url'] = requestParameters['url'];
|
|
1544
|
-
}
|
|
1545
|
-
|
|
1546
|
-
if (requestParameters['relation'] != null) {
|
|
1547
|
-
queryParameters['relation'] = requestParameters['relation'];
|
|
1548
|
-
}
|
|
1549
|
-
|
|
1550
|
-
if (requestParameters['minConfidence'] != null) {
|
|
1551
|
-
queryParameters['minConfidence'] = requestParameters['minConfidence'];
|
|
1552
|
-
}
|
|
1553
|
-
|
|
1554
|
-
if (requestParameters['limit'] != null) {
|
|
1555
|
-
queryParameters['limit'] = requestParameters['limit'];
|
|
1556
|
-
}
|
|
1557
|
-
|
|
1558
|
-
if (requestParameters['includePrices'] != null) {
|
|
1559
|
-
queryParameters['includePrices'] = requestParameters['includePrices'];
|
|
1560
|
-
}
|
|
1561
|
-
|
|
1562
|
-
const headerParameters: runtime.HTTPHeaders = {};
|
|
1563
|
-
|
|
1564
|
-
|
|
1565
|
-
let urlPath = `/api/{exchange}/fetchMatches`;
|
|
1566
|
-
urlPath = urlPath.replace(`{${"exchange"}}`, encodeURIComponent(String(requestParameters['exchange'])));
|
|
1567
|
-
|
|
1568
|
-
const response = await this.request({
|
|
1569
|
-
path: urlPath,
|
|
1570
|
-
method: 'GET',
|
|
1571
|
-
headers: headerParameters,
|
|
1572
|
-
query: queryParameters,
|
|
1573
|
-
}, initOverrides);
|
|
1574
|
-
|
|
1575
|
-
return new runtime.JSONApiResponse(response, (jsonValue) => FetchMarketMatches200ResponseFromJSON(jsonValue));
|
|
1576
|
-
}
|
|
1577
|
-
|
|
1578
|
-
/**
|
|
1579
|
-
* Find Similar Markets (Deprecated)
|
|
1580
|
-
* @deprecated
|
|
1581
|
-
*/
|
|
1582
|
-
async fetchMatches(requestParameters: FetchMatchesRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<FetchMarketMatches200Response> {
|
|
1583
|
-
const response = await this.fetchMatchesRaw(requestParameters, initOverrides);
|
|
1584
|
-
return await response.value();
|
|
1585
|
-
}
|
|
1586
|
-
|
|
1587
1504
|
/**
|
|
1588
1505
|
* Fetch My Trades
|
|
1589
1506
|
*/
|
|
@@ -2932,35 +2849,6 @@ export const FetchMarketsPaginatedExchangeEnum = {
|
|
|
2932
2849
|
Router: 'router'
|
|
2933
2850
|
} as const;
|
|
2934
2851
|
export type FetchMarketsPaginatedExchangeEnum = typeof FetchMarketsPaginatedExchangeEnum[keyof typeof FetchMarketsPaginatedExchangeEnum];
|
|
2935
|
-
/**
|
|
2936
|
-
* @export
|
|
2937
|
-
*/
|
|
2938
|
-
export const FetchMatchesExchangeEnum = {
|
|
2939
|
-
Polymarket: 'polymarket',
|
|
2940
|
-
Kalshi: 'kalshi',
|
|
2941
|
-
KalshiDemo: 'kalshi-demo',
|
|
2942
|
-
Limitless: 'limitless',
|
|
2943
|
-
Probable: 'probable',
|
|
2944
|
-
Baozi: 'baozi',
|
|
2945
|
-
Myriad: 'myriad',
|
|
2946
|
-
Opinion: 'opinion',
|
|
2947
|
-
Metaculus: 'metaculus',
|
|
2948
|
-
Smarkets: 'smarkets',
|
|
2949
|
-
PolymarketUs: 'polymarket_us',
|
|
2950
|
-
Router: 'router'
|
|
2951
|
-
} as const;
|
|
2952
|
-
export type FetchMatchesExchangeEnum = typeof FetchMatchesExchangeEnum[keyof typeof FetchMatchesExchangeEnum];
|
|
2953
|
-
/**
|
|
2954
|
-
* @export
|
|
2955
|
-
*/
|
|
2956
|
-
export const FetchMatchesRelationEnum = {
|
|
2957
|
-
Identity: 'identity',
|
|
2958
|
-
Subset: 'subset',
|
|
2959
|
-
Superset: 'superset',
|
|
2960
|
-
Overlap: 'overlap',
|
|
2961
|
-
Disjoint: 'disjoint'
|
|
2962
|
-
} as const;
|
|
2963
|
-
export type FetchMatchesRelationEnum = typeof FetchMatchesRelationEnum[keyof typeof FetchMatchesRelationEnum];
|
|
2964
2852
|
/**
|
|
2965
2853
|
* @export
|
|
2966
2854
|
*/
|
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;
|