pmxtjs 2.38.0 → 2.39.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/esm/generated/src/apis/DefaultApi.d.ts +3 -3
- package/dist/esm/generated/src/apis/DefaultApi.js +12 -12
- package/dist/esm/pmxt/client.d.ts +16 -13
- package/dist/esm/pmxt/client.js +138 -177
- package/dist/esm/pmxt/models.d.ts +74 -0
- package/dist/generated/src/apis/DefaultApi.d.ts +3 -3
- package/dist/generated/src/apis/DefaultApi.js +12 -12
- package/dist/pmxt/client.d.ts +16 -13
- package/dist/pmxt/client.js +138 -177
- package/dist/pmxt/models.d.ts +74 -0
- package/generated/docs/DefaultApi.md +9 -9
- package/generated/package.json +1 -1
- package/generated/src/apis/DefaultApi.ts +18 -18
- package/package.json +2 -2
- package/pmxt/client.ts +141 -195
- package/pmxt/models.ts +87 -0
package/pmxt/client.ts
CHANGED
|
@@ -18,15 +18,19 @@ import {
|
|
|
18
18
|
Balance,
|
|
19
19
|
BuiltOrder,
|
|
20
20
|
CreateOrderParams,
|
|
21
|
+
EventFetchParams,
|
|
21
22
|
EventFilterCriteria,
|
|
22
23
|
EventFilterFunction,
|
|
23
24
|
ExecutionPriceResult,
|
|
25
|
+
MarketFetchParams,
|
|
24
26
|
MarketFilterCriteria,
|
|
25
27
|
MarketFilterFunction,
|
|
26
28
|
MarketList,
|
|
27
29
|
MarketOutcome,
|
|
30
|
+
MyTradesParams,
|
|
28
31
|
Order,
|
|
29
32
|
OrderBook,
|
|
33
|
+
OrderHistoryParams,
|
|
30
34
|
OrderLevel,
|
|
31
35
|
PaginatedMarketsResult,
|
|
32
36
|
PaginatedEventsResult,
|
|
@@ -98,178 +102,63 @@ function queryHasNestedObject(query: Record<string, unknown>): boolean {
|
|
|
98
102
|
|
|
99
103
|
// Converter functions
|
|
100
104
|
function convertMarket(raw: any): UnifiedMarket {
|
|
101
|
-
const outcomes: MarketOutcome[] = (raw.outcomes || []).map((o: any) => ({
|
|
102
|
-
outcomeId: o.outcomeId,
|
|
103
|
-
marketId: o.marketId,
|
|
104
|
-
label: o.label,
|
|
105
|
-
price: o.price,
|
|
106
|
-
priceChange24h: o.priceChange24h,
|
|
107
|
-
metadata: o.metadata,
|
|
108
|
-
}));
|
|
109
|
-
|
|
110
|
-
const convertOutcome = (o: any) => o ? ({
|
|
111
|
-
outcomeId: o.outcomeId,
|
|
112
|
-
marketId: o.marketId,
|
|
113
|
-
label: o.label,
|
|
114
|
-
price: o.price,
|
|
115
|
-
priceChange24h: o.priceChange24h,
|
|
116
|
-
metadata: o.metadata,
|
|
117
|
-
}) : undefined;
|
|
118
|
-
|
|
119
105
|
return {
|
|
120
|
-
|
|
121
|
-
title: raw.title,
|
|
122
|
-
slug: raw.slug,
|
|
123
|
-
outcomes,
|
|
124
|
-
volume24h: raw.volume24h || 0,
|
|
125
|
-
liquidity: raw.liquidity || 0,
|
|
126
|
-
url: raw.url,
|
|
127
|
-
description: raw.description,
|
|
106
|
+
...raw,
|
|
128
107
|
resolutionDate: raw.resolutionDate ? new Date(raw.resolutionDate) : undefined,
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
tickSize: raw.tickSize,
|
|
135
|
-
status: raw.status,
|
|
136
|
-
contractAddress: raw.contractAddress,
|
|
137
|
-
sourceExchange: raw.sourceExchange,
|
|
138
|
-
eventId: raw.eventId,
|
|
139
|
-
yes: convertOutcome(raw.yes),
|
|
140
|
-
no: convertOutcome(raw.no),
|
|
141
|
-
up: convertOutcome(raw.up),
|
|
142
|
-
down: convertOutcome(raw.down),
|
|
108
|
+
outcomes: (raw.outcomes || []).map((o: any) => ({ ...o })),
|
|
109
|
+
yes: raw.yes ? { ...raw.yes } : undefined,
|
|
110
|
+
no: raw.no ? { ...raw.no } : undefined,
|
|
111
|
+
up: raw.up ? { ...raw.up } : undefined,
|
|
112
|
+
down: raw.down ? { ...raw.down } : undefined,
|
|
143
113
|
};
|
|
144
114
|
}
|
|
145
115
|
|
|
146
116
|
|
|
147
117
|
function convertCandle(raw: any): PriceCandle {
|
|
148
|
-
return {
|
|
149
|
-
timestamp: raw.timestamp,
|
|
150
|
-
open: raw.open,
|
|
151
|
-
high: raw.high,
|
|
152
|
-
low: raw.low,
|
|
153
|
-
close: raw.close,
|
|
154
|
-
volume: raw.volume,
|
|
155
|
-
};
|
|
118
|
+
return { ...raw };
|
|
156
119
|
}
|
|
157
120
|
|
|
158
121
|
function convertOrderBook(raw: any): OrderBook {
|
|
159
|
-
const bids: OrderLevel[] = (raw.bids || []).map((b: any) => ({
|
|
160
|
-
price: b.price,
|
|
161
|
-
size: b.size,
|
|
162
|
-
}));
|
|
163
|
-
|
|
164
|
-
const asks: OrderLevel[] = (raw.asks || []).map((a: any) => ({
|
|
165
|
-
price: a.price,
|
|
166
|
-
size: a.size,
|
|
167
|
-
}));
|
|
168
|
-
|
|
169
122
|
return {
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
123
|
+
...raw,
|
|
124
|
+
bids: (raw.bids || []).map((b: any) => ({ ...b })),
|
|
125
|
+
asks: (raw.asks || []).map((a: any) => ({ ...a })),
|
|
173
126
|
};
|
|
174
127
|
}
|
|
175
128
|
|
|
176
129
|
function convertTrade(raw: any): Trade {
|
|
177
|
-
return {
|
|
178
|
-
id: raw.id,
|
|
179
|
-
timestamp: raw.timestamp,
|
|
180
|
-
price: raw.price,
|
|
181
|
-
amount: raw.amount,
|
|
182
|
-
side: raw.side || "unknown",
|
|
183
|
-
};
|
|
130
|
+
return { ...raw, side: raw.side || "unknown" };
|
|
184
131
|
}
|
|
185
132
|
|
|
186
133
|
function convertOrder(raw: any): Order {
|
|
187
|
-
return {
|
|
188
|
-
id: raw.id,
|
|
189
|
-
marketId: raw.marketId,
|
|
190
|
-
outcomeId: raw.outcomeId,
|
|
191
|
-
side: raw.side,
|
|
192
|
-
type: raw.type,
|
|
193
|
-
amount: raw.amount,
|
|
194
|
-
status: raw.status,
|
|
195
|
-
filled: raw.filled,
|
|
196
|
-
remaining: raw.remaining,
|
|
197
|
-
timestamp: raw.timestamp,
|
|
198
|
-
price: raw.price,
|
|
199
|
-
fee: raw.fee,
|
|
200
|
-
};
|
|
134
|
+
return { ...raw };
|
|
201
135
|
}
|
|
202
136
|
|
|
203
137
|
function convertPosition(raw: any): Position {
|
|
204
|
-
return {
|
|
205
|
-
marketId: raw.marketId,
|
|
206
|
-
outcomeId: raw.outcomeId,
|
|
207
|
-
outcomeLabel: raw.outcomeLabel,
|
|
208
|
-
size: raw.size,
|
|
209
|
-
entryPrice: raw.entryPrice,
|
|
210
|
-
currentPrice: raw.currentPrice,
|
|
211
|
-
unrealizedPnL: raw.unrealizedPnL,
|
|
212
|
-
realizedPnL: raw.realizedPnL,
|
|
213
|
-
};
|
|
138
|
+
return { ...raw };
|
|
214
139
|
}
|
|
215
140
|
|
|
216
141
|
function convertBalance(raw: any): Balance {
|
|
217
|
-
return {
|
|
218
|
-
currency: raw.currency,
|
|
219
|
-
total: raw.total,
|
|
220
|
-
available: raw.available,
|
|
221
|
-
locked: raw.locked,
|
|
222
|
-
};
|
|
142
|
+
return { ...raw };
|
|
223
143
|
}
|
|
224
144
|
|
|
225
145
|
function convertUserTrade(raw: any): UserTrade {
|
|
226
|
-
return {
|
|
227
|
-
id: raw.id,
|
|
228
|
-
price: raw.price,
|
|
229
|
-
amount: raw.amount,
|
|
230
|
-
side: raw.side || "unknown",
|
|
231
|
-
timestamp: raw.timestamp,
|
|
232
|
-
orderId: raw.orderId,
|
|
233
|
-
outcomeId: raw.outcomeId,
|
|
234
|
-
marketId: raw.marketId,
|
|
235
|
-
};
|
|
146
|
+
return { ...raw, side: raw.side || "unknown" };
|
|
236
147
|
}
|
|
237
148
|
|
|
238
149
|
function convertEvent(raw: any): UnifiedEvent {
|
|
239
150
|
const markets = MarketList.from((raw.markets || []).map(convertMarket)) as MarketList;
|
|
240
|
-
|
|
241
|
-
const event: UnifiedEvent = {
|
|
242
|
-
id: raw.id,
|
|
243
|
-
title: raw.title,
|
|
244
|
-
description: raw.description,
|
|
245
|
-
slug: raw.slug,
|
|
246
|
-
markets,
|
|
247
|
-
volume24h: raw.volume24h,
|
|
248
|
-
volume: raw.volume,
|
|
249
|
-
url: raw.url,
|
|
250
|
-
image: raw.image,
|
|
251
|
-
category: raw.category,
|
|
252
|
-
tags: raw.tags,
|
|
253
|
-
sourceExchange: raw.sourceExchange,
|
|
254
|
-
};
|
|
255
|
-
|
|
256
|
-
return event;
|
|
151
|
+
return { ...raw, markets };
|
|
257
152
|
}
|
|
258
153
|
|
|
259
154
|
|
|
260
155
|
function convertSubscriptionSnapshot(raw: any): SubscribedAddressSnapshot {
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
address: raw.address,
|
|
267
|
-
trades,
|
|
268
|
-
balances,
|
|
269
|
-
positions,
|
|
270
|
-
timestamp: raw.timestamp,
|
|
156
|
+
return {
|
|
157
|
+
...raw,
|
|
158
|
+
trades: (raw.trades ?? []).map(convertTrade),
|
|
159
|
+
balances: (raw.balances ?? []).map(convertBalance),
|
|
160
|
+
positions: (raw.positions ?? []).map(convertPosition),
|
|
271
161
|
};
|
|
272
|
-
return snapShot;
|
|
273
162
|
}
|
|
274
163
|
|
|
275
164
|
/**
|
|
@@ -729,7 +618,7 @@ export abstract class Exchange {
|
|
|
729
618
|
}
|
|
730
619
|
}
|
|
731
620
|
|
|
732
|
-
async fetchMarkets(params?:
|
|
621
|
+
async fetchMarkets(params?: MarketFetchParams): Promise<UnifiedMarket[]> {
|
|
733
622
|
await this.initPromise;
|
|
734
623
|
try {
|
|
735
624
|
const args: any[] = [];
|
|
@@ -785,7 +674,7 @@ export abstract class Exchange {
|
|
|
785
674
|
}
|
|
786
675
|
}
|
|
787
676
|
|
|
788
|
-
async fetchEvents(params?:
|
|
677
|
+
async fetchEvents(params?: EventFetchParams): Promise<UnifiedEvent[]> {
|
|
789
678
|
await this.initPromise;
|
|
790
679
|
try {
|
|
791
680
|
const args: any[] = [];
|
|
@@ -811,37 +700,7 @@ export abstract class Exchange {
|
|
|
811
700
|
}
|
|
812
701
|
}
|
|
813
702
|
|
|
814
|
-
async
|
|
815
|
-
await this.initPromise;
|
|
816
|
-
try {
|
|
817
|
-
const args: any[] = [];
|
|
818
|
-
if (params !== undefined) args.push(params);
|
|
819
|
-
const response = await this.fetchWithRetry(`${this.resolveBaseUrl()}/api/${this.exchangeName}/fetchEventsPaginated`, {
|
|
820
|
-
method: 'POST',
|
|
821
|
-
headers: { 'Content-Type': 'application/json', ...this.getAuthHeaders() },
|
|
822
|
-
body: JSON.stringify({ args, credentials: this.getCredentials() }),
|
|
823
|
-
});
|
|
824
|
-
if (!response.ok) {
|
|
825
|
-
const body = await response.json().catch(() => ({}));
|
|
826
|
-
if (body.error && typeof body.error === "object") {
|
|
827
|
-
throw fromServerError(body.error);
|
|
828
|
-
}
|
|
829
|
-
throw new PmxtError(body.error?.message || response.statusText);
|
|
830
|
-
}
|
|
831
|
-
const json = await response.json();
|
|
832
|
-
const data = this.handleResponse(json);
|
|
833
|
-
return {
|
|
834
|
-
data: (data.data || []).map(convertEvent),
|
|
835
|
-
total: data.total,
|
|
836
|
-
nextCursor: data.nextCursor,
|
|
837
|
-
};
|
|
838
|
-
} catch (error) {
|
|
839
|
-
if (error instanceof PmxtError) throw error;
|
|
840
|
-
throw new PmxtError(`Failed to fetchEventsPaginated: ${error}`);
|
|
841
|
-
}
|
|
842
|
-
}
|
|
843
|
-
|
|
844
|
-
async fetchMarket(params?: any): Promise<UnifiedMarket> {
|
|
703
|
+
async fetchMarket(params?: MarketFetchParams): Promise<UnifiedMarket> {
|
|
845
704
|
await this.initPromise;
|
|
846
705
|
try {
|
|
847
706
|
const args: any[] = [];
|
|
@@ -867,7 +726,7 @@ export abstract class Exchange {
|
|
|
867
726
|
}
|
|
868
727
|
}
|
|
869
728
|
|
|
870
|
-
async fetchEvent(params?:
|
|
729
|
+
async fetchEvent(params?: EventFetchParams): Promise<UnifiedEvent> {
|
|
871
730
|
await this.initPromise;
|
|
872
731
|
try {
|
|
873
732
|
const args: any[] = [];
|
|
@@ -893,11 +752,12 @@ export abstract class Exchange {
|
|
|
893
752
|
}
|
|
894
753
|
}
|
|
895
754
|
|
|
896
|
-
async fetchOrderBook(
|
|
755
|
+
async fetchOrderBook(outcomeId: string | MarketOutcome, side?: any): Promise<OrderBook> {
|
|
897
756
|
await this.initPromise;
|
|
898
757
|
try {
|
|
899
758
|
const args: any[] = [];
|
|
900
|
-
args.push(
|
|
759
|
+
args.push(resolveOutcomeId(outcomeId));
|
|
760
|
+
if (side !== undefined) args.push(side);
|
|
901
761
|
const response = await this.fetchWithRetry(`${this.resolveBaseUrl()}/api/${this.exchangeName}/fetchOrderBook`, {
|
|
902
762
|
method: 'POST',
|
|
903
763
|
headers: { 'Content-Type': 'application/json', ...this.getAuthHeaders() },
|
|
@@ -920,13 +780,6 @@ export abstract class Exchange {
|
|
|
920
780
|
}
|
|
921
781
|
|
|
922
782
|
async submitOrder(built: BuiltOrder): Promise<Order> {
|
|
923
|
-
if (this.isHosted) {
|
|
924
|
-
throw new PmxtError(
|
|
925
|
-
"Trade execution is not available through the hosted API. " +
|
|
926
|
-
"Use the local PMXT SDK with your venue credentials instead. " +
|
|
927
|
-
"See https://pmxt.dev/docs/quickstart for setup instructions."
|
|
928
|
-
);
|
|
929
|
-
}
|
|
930
783
|
await this.initPromise;
|
|
931
784
|
try {
|
|
932
785
|
const args: any[] = [];
|
|
@@ -953,13 +806,6 @@ export abstract class Exchange {
|
|
|
953
806
|
}
|
|
954
807
|
|
|
955
808
|
async cancelOrder(orderId: string): Promise<Order> {
|
|
956
|
-
if (this.isHosted) {
|
|
957
|
-
throw new PmxtError(
|
|
958
|
-
"Trade execution is not available through the hosted API. " +
|
|
959
|
-
"Use the local PMXT SDK with your venue credentials instead. " +
|
|
960
|
-
"See https://pmxt.dev/docs/quickstart for setup instructions."
|
|
961
|
-
);
|
|
962
|
-
}
|
|
963
809
|
await this.initPromise;
|
|
964
810
|
try {
|
|
965
811
|
const args: any[] = [];
|
|
@@ -1037,7 +883,7 @@ export abstract class Exchange {
|
|
|
1037
883
|
}
|
|
1038
884
|
}
|
|
1039
885
|
|
|
1040
|
-
async fetchMyTrades(params?:
|
|
886
|
+
async fetchMyTrades(params?: MyTradesParams): Promise<UserTrade[]> {
|
|
1041
887
|
await this.initPromise;
|
|
1042
888
|
try {
|
|
1043
889
|
const args: any[] = [];
|
|
@@ -1063,7 +909,7 @@ export abstract class Exchange {
|
|
|
1063
909
|
}
|
|
1064
910
|
}
|
|
1065
911
|
|
|
1066
|
-
async fetchClosedOrders(params?:
|
|
912
|
+
async fetchClosedOrders(params?: OrderHistoryParams): Promise<Order[]> {
|
|
1067
913
|
await this.initPromise;
|
|
1068
914
|
try {
|
|
1069
915
|
const args: any[] = [];
|
|
@@ -1089,7 +935,7 @@ export abstract class Exchange {
|
|
|
1089
935
|
}
|
|
1090
936
|
}
|
|
1091
937
|
|
|
1092
|
-
async fetchAllOrders(params?:
|
|
938
|
+
async fetchAllOrders(params?: OrderHistoryParams): Promise<Order[]> {
|
|
1093
939
|
await this.initPromise;
|
|
1094
940
|
try {
|
|
1095
941
|
const args: any[] = [];
|
|
@@ -1167,11 +1013,11 @@ export abstract class Exchange {
|
|
|
1167
1013
|
}
|
|
1168
1014
|
}
|
|
1169
1015
|
|
|
1170
|
-
async unwatchOrderBook(
|
|
1016
|
+
async unwatchOrderBook(outcomeId: string | MarketOutcome): Promise<void> {
|
|
1171
1017
|
await this.initPromise;
|
|
1172
1018
|
try {
|
|
1173
1019
|
const args: any[] = [];
|
|
1174
|
-
args.push(
|
|
1020
|
+
args.push(resolveOutcomeId(outcomeId));
|
|
1175
1021
|
const response = await this.fetchWithRetry(`${this.resolveBaseUrl()}/api/${this.exchangeName}/unwatchOrderBook`, {
|
|
1176
1022
|
method: 'POST',
|
|
1177
1023
|
headers: { 'Content-Type': 'application/json', ...this.getAuthHeaders() },
|
|
@@ -1217,6 +1063,31 @@ export abstract class Exchange {
|
|
|
1217
1063
|
}
|
|
1218
1064
|
}
|
|
1219
1065
|
|
|
1066
|
+
async testDummyMethod(param?: string): Promise<string> {
|
|
1067
|
+
await this.initPromise;
|
|
1068
|
+
try {
|
|
1069
|
+
const args: any[] = [];
|
|
1070
|
+
if (param !== undefined) args.push(param);
|
|
1071
|
+
const response = await this.fetchWithRetry(`${this.resolveBaseUrl()}/api/${this.exchangeName}/testDummyMethod`, {
|
|
1072
|
+
method: 'POST',
|
|
1073
|
+
headers: { 'Content-Type': 'application/json', ...this.getAuthHeaders() },
|
|
1074
|
+
body: JSON.stringify({ args, credentials: this.getCredentials() }),
|
|
1075
|
+
});
|
|
1076
|
+
if (!response.ok) {
|
|
1077
|
+
const body = await response.json().catch(() => ({}));
|
|
1078
|
+
if (body.error && typeof body.error === "object") {
|
|
1079
|
+
throw fromServerError(body.error);
|
|
1080
|
+
}
|
|
1081
|
+
throw new PmxtError(body.error?.message || response.statusText);
|
|
1082
|
+
}
|
|
1083
|
+
const json = await response.json();
|
|
1084
|
+
return this.handleResponse(json);
|
|
1085
|
+
} catch (error) {
|
|
1086
|
+
if (error instanceof PmxtError) throw error;
|
|
1087
|
+
throw new PmxtError(`Failed to testDummyMethod: ${error}`);
|
|
1088
|
+
}
|
|
1089
|
+
}
|
|
1090
|
+
|
|
1220
1091
|
async close(): Promise<void> {
|
|
1221
1092
|
await this.initPromise;
|
|
1222
1093
|
try {
|
|
@@ -1241,11 +1112,11 @@ export abstract class Exchange {
|
|
|
1241
1112
|
}
|
|
1242
1113
|
}
|
|
1243
1114
|
|
|
1244
|
-
async fetchMarketMatches(params
|
|
1115
|
+
async fetchMarketMatches(params?: any): Promise<any[]> {
|
|
1245
1116
|
await this.initPromise;
|
|
1246
1117
|
try {
|
|
1247
1118
|
const args: any[] = [];
|
|
1248
|
-
args.push(params);
|
|
1119
|
+
if (params !== undefined) args.push(params);
|
|
1249
1120
|
const response = await this.fetchWithRetry(`${this.resolveBaseUrl()}/api/${this.exchangeName}/fetchMarketMatches`, {
|
|
1250
1121
|
method: 'POST',
|
|
1251
1122
|
headers: { 'Content-Type': 'application/json', ...this.getAuthHeaders() },
|
|
@@ -1291,11 +1162,11 @@ export abstract class Exchange {
|
|
|
1291
1162
|
}
|
|
1292
1163
|
}
|
|
1293
1164
|
|
|
1294
|
-
async fetchEventMatches(params
|
|
1165
|
+
async fetchEventMatches(params?: any): Promise<any[]> {
|
|
1295
1166
|
await this.initPromise;
|
|
1296
1167
|
try {
|
|
1297
1168
|
const args: any[] = [];
|
|
1298
|
-
args.push(params);
|
|
1169
|
+
if (params !== undefined) args.push(params);
|
|
1299
1170
|
const response = await this.fetchWithRetry(`${this.resolveBaseUrl()}/api/${this.exchangeName}/fetchEventMatches`, {
|
|
1300
1171
|
method: 'POST',
|
|
1301
1172
|
headers: { 'Content-Type': 'application/json', ...this.getAuthHeaders() },
|
|
@@ -1341,6 +1212,81 @@ export abstract class Exchange {
|
|
|
1341
1212
|
}
|
|
1342
1213
|
}
|
|
1343
1214
|
|
|
1215
|
+
async fetchRelatedMarkets(params: any): Promise<any[]> {
|
|
1216
|
+
await this.initPromise;
|
|
1217
|
+
try {
|
|
1218
|
+
const args: any[] = [];
|
|
1219
|
+
args.push(params);
|
|
1220
|
+
const response = await this.fetchWithRetry(`${this.resolveBaseUrl()}/api/${this.exchangeName}/fetchRelatedMarkets`, {
|
|
1221
|
+
method: 'POST',
|
|
1222
|
+
headers: { 'Content-Type': 'application/json', ...this.getAuthHeaders() },
|
|
1223
|
+
body: JSON.stringify({ args, credentials: this.getCredentials() }),
|
|
1224
|
+
});
|
|
1225
|
+
if (!response.ok) {
|
|
1226
|
+
const body = await response.json().catch(() => ({}));
|
|
1227
|
+
if (body.error && typeof body.error === "object") {
|
|
1228
|
+
throw fromServerError(body.error);
|
|
1229
|
+
}
|
|
1230
|
+
throw new PmxtError(body.error?.message || response.statusText);
|
|
1231
|
+
}
|
|
1232
|
+
const json = await response.json();
|
|
1233
|
+
return this.handleResponse(json);
|
|
1234
|
+
} catch (error) {
|
|
1235
|
+
if (error instanceof PmxtError) throw error;
|
|
1236
|
+
throw new PmxtError(`Failed to fetchRelatedMarkets: ${error}`);
|
|
1237
|
+
}
|
|
1238
|
+
}
|
|
1239
|
+
|
|
1240
|
+
async fetchMatchedMarkets(params?: any): Promise<any[]> {
|
|
1241
|
+
await this.initPromise;
|
|
1242
|
+
try {
|
|
1243
|
+
const args: any[] = [];
|
|
1244
|
+
if (params !== undefined) args.push(params);
|
|
1245
|
+
const response = await this.fetchWithRetry(`${this.resolveBaseUrl()}/api/${this.exchangeName}/fetchMatchedMarkets`, {
|
|
1246
|
+
method: 'POST',
|
|
1247
|
+
headers: { 'Content-Type': 'application/json', ...this.getAuthHeaders() },
|
|
1248
|
+
body: JSON.stringify({ args, credentials: this.getCredentials() }),
|
|
1249
|
+
});
|
|
1250
|
+
if (!response.ok) {
|
|
1251
|
+
const body = await response.json().catch(() => ({}));
|
|
1252
|
+
if (body.error && typeof body.error === "object") {
|
|
1253
|
+
throw fromServerError(body.error);
|
|
1254
|
+
}
|
|
1255
|
+
throw new PmxtError(body.error?.message || response.statusText);
|
|
1256
|
+
}
|
|
1257
|
+
const json = await response.json();
|
|
1258
|
+
return this.handleResponse(json);
|
|
1259
|
+
} catch (error) {
|
|
1260
|
+
if (error instanceof PmxtError) throw error;
|
|
1261
|
+
throw new PmxtError(`Failed to fetchMatchedMarkets: ${error}`);
|
|
1262
|
+
}
|
|
1263
|
+
}
|
|
1264
|
+
|
|
1265
|
+
async fetchMatchedPrices(params?: any): Promise<any[]> {
|
|
1266
|
+
await this.initPromise;
|
|
1267
|
+
try {
|
|
1268
|
+
const args: any[] = [];
|
|
1269
|
+
if (params !== undefined) args.push(params);
|
|
1270
|
+
const response = await this.fetchWithRetry(`${this.resolveBaseUrl()}/api/${this.exchangeName}/fetchMatchedPrices`, {
|
|
1271
|
+
method: 'POST',
|
|
1272
|
+
headers: { 'Content-Type': 'application/json', ...this.getAuthHeaders() },
|
|
1273
|
+
body: JSON.stringify({ args, credentials: this.getCredentials() }),
|
|
1274
|
+
});
|
|
1275
|
+
if (!response.ok) {
|
|
1276
|
+
const body = await response.json().catch(() => ({}));
|
|
1277
|
+
if (body.error && typeof body.error === "object") {
|
|
1278
|
+
throw fromServerError(body.error);
|
|
1279
|
+
}
|
|
1280
|
+
throw new PmxtError(body.error?.message || response.statusText);
|
|
1281
|
+
}
|
|
1282
|
+
const json = await response.json();
|
|
1283
|
+
return this.handleResponse(json);
|
|
1284
|
+
} catch (error) {
|
|
1285
|
+
if (error instanceof PmxtError) throw error;
|
|
1286
|
+
throw new PmxtError(`Failed to fetchMatchedPrices: ${error}`);
|
|
1287
|
+
}
|
|
1288
|
+
}
|
|
1289
|
+
|
|
1344
1290
|
async fetchHedges(params: any): Promise<any[]> {
|
|
1345
1291
|
await this.initPromise;
|
|
1346
1292
|
try {
|
package/pmxt/models.ts
CHANGED
|
@@ -358,9 +358,33 @@ export interface MarketFilterParams {
|
|
|
358
358
|
/** Sort order */
|
|
359
359
|
sort?: SortOption;
|
|
360
360
|
|
|
361
|
+
/** Filter by market status (default: 'active') */
|
|
362
|
+
status?: 'active' | 'inactive' | 'closed' | 'all';
|
|
363
|
+
|
|
361
364
|
/** Where to search (for filterMarkets) */
|
|
362
365
|
searchIn?: SearchIn;
|
|
363
366
|
|
|
367
|
+
/** Keyword search query */
|
|
368
|
+
query?: string;
|
|
369
|
+
|
|
370
|
+
/** Slug/ticker lookup */
|
|
371
|
+
slug?: string;
|
|
372
|
+
|
|
373
|
+
/** Direct lookup by market ID */
|
|
374
|
+
marketId?: string;
|
|
375
|
+
|
|
376
|
+
/** Reverse lookup -- find market containing this outcome */
|
|
377
|
+
outcomeId?: string;
|
|
378
|
+
|
|
379
|
+
/** Find markets belonging to an event */
|
|
380
|
+
eventId?: string;
|
|
381
|
+
|
|
382
|
+
/** Pagination page (used by Limitless) */
|
|
383
|
+
page?: number;
|
|
384
|
+
|
|
385
|
+
/** Semantic search threshold (used by Limitless) */
|
|
386
|
+
similarityThreshold?: number;
|
|
387
|
+
|
|
364
388
|
/** Filter by market category (e.g. "sports", "politics", "crypto") */
|
|
365
389
|
category?: string;
|
|
366
390
|
|
|
@@ -452,6 +476,69 @@ export interface CreateOrderParams {
|
|
|
452
476
|
fee?: number;
|
|
453
477
|
}
|
|
454
478
|
|
|
479
|
+
/** Alias matching the core MarketFetchParams name. */
|
|
480
|
+
export type MarketFetchParams = MarketFilterParams;
|
|
481
|
+
|
|
482
|
+
/**
|
|
483
|
+
* Parameters for fetching OHLCV candle data.
|
|
484
|
+
*/
|
|
485
|
+
export interface OHLCVParams {
|
|
486
|
+
/** Candle resolution (e.g. '1m', '5m', '1h', '1d') */
|
|
487
|
+
resolution: CandleInterval;
|
|
488
|
+
/** Start of the time range */
|
|
489
|
+
start?: Date;
|
|
490
|
+
/** End of the time range */
|
|
491
|
+
end?: Date;
|
|
492
|
+
/** Maximum number of candles */
|
|
493
|
+
limit?: number;
|
|
494
|
+
}
|
|
495
|
+
|
|
496
|
+
/**
|
|
497
|
+
* Parameters for fetching public trades.
|
|
498
|
+
*/
|
|
499
|
+
export interface TradesParams {
|
|
500
|
+
/** Start of the time range */
|
|
501
|
+
start?: Date;
|
|
502
|
+
/** End of the time range */
|
|
503
|
+
end?: Date;
|
|
504
|
+
/** Maximum number of results */
|
|
505
|
+
limit?: number;
|
|
506
|
+
}
|
|
507
|
+
|
|
508
|
+
/**
|
|
509
|
+
* Parameters for fetching the authenticated user's trade history.
|
|
510
|
+
*/
|
|
511
|
+
export interface MyTradesParams {
|
|
512
|
+
/** Filter by outcome ID */
|
|
513
|
+
outcomeId?: string;
|
|
514
|
+
/** Filter by market ID */
|
|
515
|
+
marketId?: string;
|
|
516
|
+
/** Only return records after this date */
|
|
517
|
+
since?: Date;
|
|
518
|
+
/** Only return records before this date */
|
|
519
|
+
until?: Date;
|
|
520
|
+
/** Maximum number of results */
|
|
521
|
+
limit?: number;
|
|
522
|
+
/** Cursor for pagination */
|
|
523
|
+
cursor?: string;
|
|
524
|
+
}
|
|
525
|
+
|
|
526
|
+
/**
|
|
527
|
+
* Parameters for fetching closed/all order history.
|
|
528
|
+
*/
|
|
529
|
+
export interface OrderHistoryParams {
|
|
530
|
+
/** Filter by market ID */
|
|
531
|
+
marketId?: string;
|
|
532
|
+
/** Only return records after this date */
|
|
533
|
+
since?: Date;
|
|
534
|
+
/** Only return records before this date */
|
|
535
|
+
until?: Date;
|
|
536
|
+
/** Maximum number of results */
|
|
537
|
+
limit?: number;
|
|
538
|
+
/** Cursor for pagination */
|
|
539
|
+
cursor?: string;
|
|
540
|
+
}
|
|
541
|
+
|
|
455
542
|
/**
|
|
456
543
|
* An order payload built but not yet submitted to the exchange.
|
|
457
544
|
*/
|