pmxtjs 2.38.0 → 2.39.0
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
|
@@ -195,7 +195,7 @@ export interface FetchMyTradesRequest {
|
|
|
195
195
|
}
|
|
196
196
|
export interface FetchOHLCVRequest {
|
|
197
197
|
exchange: FetchOHLCVExchangeEnum;
|
|
198
|
-
|
|
198
|
+
outcomeId: string;
|
|
199
199
|
resolution?: string;
|
|
200
200
|
start?: Date;
|
|
201
201
|
end?: Date;
|
|
@@ -211,7 +211,7 @@ export interface FetchOrderRequest {
|
|
|
211
211
|
}
|
|
212
212
|
export interface FetchOrderBookRequest {
|
|
213
213
|
exchange: FetchOrderBookExchangeEnum;
|
|
214
|
-
|
|
214
|
+
outcomeId: string;
|
|
215
215
|
side?: string;
|
|
216
216
|
}
|
|
217
217
|
export interface FetchPositionsRequest {
|
|
@@ -235,7 +235,7 @@ export interface FetchRelatedMarketsRequest {
|
|
|
235
235
|
}
|
|
236
236
|
export interface FetchTradesRequest {
|
|
237
237
|
exchange: FetchTradesExchangeEnum;
|
|
238
|
-
|
|
238
|
+
outcomeId: string;
|
|
239
239
|
start?: Date;
|
|
240
240
|
end?: Date;
|
|
241
241
|
limit?: number;
|
|
@@ -957,12 +957,12 @@ export class DefaultApi extends runtime.BaseAPI {
|
|
|
957
957
|
if (requestParameters['exchange'] == null) {
|
|
958
958
|
throw new runtime.RequiredError('exchange', 'Required parameter "exchange" was null or undefined when calling fetchOHLCV().');
|
|
959
959
|
}
|
|
960
|
-
if (requestParameters['
|
|
961
|
-
throw new runtime.RequiredError('
|
|
960
|
+
if (requestParameters['outcomeId'] == null) {
|
|
961
|
+
throw new runtime.RequiredError('outcomeId', 'Required parameter "outcomeId" was null or undefined when calling fetchOHLCV().');
|
|
962
962
|
}
|
|
963
963
|
const queryParameters = {};
|
|
964
|
-
if (requestParameters['
|
|
965
|
-
queryParameters['
|
|
964
|
+
if (requestParameters['outcomeId'] != null) {
|
|
965
|
+
queryParameters['outcomeId'] = requestParameters['outcomeId'];
|
|
966
966
|
}
|
|
967
967
|
if (requestParameters['resolution'] != null) {
|
|
968
968
|
queryParameters['resolution'] = requestParameters['resolution'];
|
|
@@ -1068,12 +1068,12 @@ export class DefaultApi extends runtime.BaseAPI {
|
|
|
1068
1068
|
if (requestParameters['exchange'] == null) {
|
|
1069
1069
|
throw new runtime.RequiredError('exchange', 'Required parameter "exchange" was null or undefined when calling fetchOrderBook().');
|
|
1070
1070
|
}
|
|
1071
|
-
if (requestParameters['
|
|
1072
|
-
throw new runtime.RequiredError('
|
|
1071
|
+
if (requestParameters['outcomeId'] == null) {
|
|
1072
|
+
throw new runtime.RequiredError('outcomeId', 'Required parameter "outcomeId" was null or undefined when calling fetchOrderBook().');
|
|
1073
1073
|
}
|
|
1074
1074
|
const queryParameters = {};
|
|
1075
|
-
if (requestParameters['
|
|
1076
|
-
queryParameters['
|
|
1075
|
+
if (requestParameters['outcomeId'] != null) {
|
|
1076
|
+
queryParameters['outcomeId'] = requestParameters['outcomeId'];
|
|
1077
1077
|
}
|
|
1078
1078
|
if (requestParameters['side'] != null) {
|
|
1079
1079
|
queryParameters['side'] = requestParameters['side'];
|
|
@@ -1200,12 +1200,12 @@ export class DefaultApi extends runtime.BaseAPI {
|
|
|
1200
1200
|
if (requestParameters['exchange'] == null) {
|
|
1201
1201
|
throw new runtime.RequiredError('exchange', 'Required parameter "exchange" was null or undefined when calling fetchTrades().');
|
|
1202
1202
|
}
|
|
1203
|
-
if (requestParameters['
|
|
1204
|
-
throw new runtime.RequiredError('
|
|
1203
|
+
if (requestParameters['outcomeId'] == null) {
|
|
1204
|
+
throw new runtime.RequiredError('outcomeId', 'Required parameter "outcomeId" was null or undefined when calling fetchTrades().');
|
|
1205
1205
|
}
|
|
1206
1206
|
const queryParameters = {};
|
|
1207
|
-
if (requestParameters['
|
|
1208
|
-
queryParameters['
|
|
1207
|
+
if (requestParameters['outcomeId'] != null) {
|
|
1208
|
+
queryParameters['outcomeId'] = requestParameters['outcomeId'];
|
|
1209
1209
|
}
|
|
1210
1210
|
if (requestParameters['start'] != null) {
|
|
1211
1211
|
queryParameters['start'] = requestParameters['start'].toISOString();
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
* OpenAPI client, matching the Python API exactly.
|
|
6
6
|
*/
|
|
7
7
|
import { Configuration, DefaultApi, ExchangeCredentials } from "../generated/src/index.js";
|
|
8
|
-
import { Balance, BuiltOrder, CreateOrderParams, EventFilterCriteria, EventFilterFunction, ExecutionPriceResult, MarketFilterCriteria, MarketFilterFunction, MarketOutcome, Order, OrderBook,
|
|
8
|
+
import { Balance, BuiltOrder, CreateOrderParams, EventFetchParams, EventFilterCriteria, EventFilterFunction, ExecutionPriceResult, MarketFetchParams, MarketFilterCriteria, MarketFilterFunction, MarketOutcome, MyTradesParams, Order, OrderBook, OrderHistoryParams, PaginatedMarketsResult, Position, PriceCandle, SubscribedAddressSnapshot, SubscriptionOption, Trade, UnifiedEvent, UnifiedMarket, UserTrade } from "./models.js";
|
|
9
9
|
import { ServerManager } from "./server-manager.js";
|
|
10
10
|
/**
|
|
11
11
|
* Base exchange client options.
|
|
@@ -149,29 +149,32 @@ export declare abstract class Exchange {
|
|
|
149
149
|
*/
|
|
150
150
|
protected sidecarReadRequest(methodName: string, query: Record<string, unknown>, args: unknown[]): Promise<any>;
|
|
151
151
|
loadMarkets(reload?: boolean): Promise<Record<string, UnifiedMarket>>;
|
|
152
|
-
fetchMarkets(params?:
|
|
152
|
+
fetchMarkets(params?: MarketFetchParams): Promise<UnifiedMarket[]>;
|
|
153
153
|
fetchMarketsPaginated(params?: any): Promise<PaginatedMarketsResult>;
|
|
154
|
-
fetchEvents(params?:
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
fetchOrderBook(id: string): Promise<OrderBook>;
|
|
154
|
+
fetchEvents(params?: EventFetchParams): Promise<UnifiedEvent[]>;
|
|
155
|
+
fetchMarket(params?: MarketFetchParams): Promise<UnifiedMarket>;
|
|
156
|
+
fetchEvent(params?: EventFetchParams): Promise<UnifiedEvent>;
|
|
157
|
+
fetchOrderBook(outcomeId: string | MarketOutcome, side?: any): Promise<OrderBook>;
|
|
159
158
|
submitOrder(built: BuiltOrder): Promise<Order>;
|
|
160
159
|
cancelOrder(orderId: string): Promise<Order>;
|
|
161
160
|
fetchOrder(orderId: string): Promise<Order>;
|
|
162
161
|
fetchOpenOrders(marketId?: string): Promise<Order[]>;
|
|
163
|
-
fetchMyTrades(params?:
|
|
164
|
-
fetchClosedOrders(params?:
|
|
165
|
-
fetchAllOrders(params?:
|
|
162
|
+
fetchMyTrades(params?: MyTradesParams): Promise<UserTrade[]>;
|
|
163
|
+
fetchClosedOrders(params?: OrderHistoryParams): Promise<Order[]>;
|
|
164
|
+
fetchAllOrders(params?: OrderHistoryParams): Promise<Order[]>;
|
|
166
165
|
fetchPositions(address?: string): Promise<Position[]>;
|
|
167
166
|
fetchBalance(address?: string): Promise<Balance[]>;
|
|
168
|
-
unwatchOrderBook(
|
|
167
|
+
unwatchOrderBook(outcomeId: string | MarketOutcome): Promise<void>;
|
|
169
168
|
unwatchAddress(address: string): Promise<void>;
|
|
169
|
+
testDummyMethod(param?: string): Promise<string>;
|
|
170
170
|
close(): Promise<void>;
|
|
171
|
-
fetchMarketMatches(params
|
|
171
|
+
fetchMarketMatches(params?: any): Promise<any[]>;
|
|
172
172
|
fetchMatches(params: any): Promise<any[]>;
|
|
173
|
-
fetchEventMatches(params
|
|
173
|
+
fetchEventMatches(params?: any): Promise<any[]>;
|
|
174
174
|
compareMarketPrices(params: any): Promise<any[]>;
|
|
175
|
+
fetchRelatedMarkets(params: any): Promise<any[]>;
|
|
176
|
+
fetchMatchedMarkets(params?: any): Promise<any[]>;
|
|
177
|
+
fetchMatchedPrices(params?: any): Promise<any[]>;
|
|
175
178
|
fetchHedges(params: any): Promise<any[]>;
|
|
176
179
|
fetchArbitrage(params?: any): Promise<any[]>;
|
|
177
180
|
/**
|
package/dist/esm/pmxt/client.js
CHANGED
|
@@ -66,160 +66,52 @@ function queryHasNestedObject(query) {
|
|
|
66
66
|
}
|
|
67
67
|
// Converter functions
|
|
68
68
|
function convertMarket(raw) {
|
|
69
|
-
const outcomes = (raw.outcomes || []).map((o) => ({
|
|
70
|
-
outcomeId: o.outcomeId,
|
|
71
|
-
marketId: o.marketId,
|
|
72
|
-
label: o.label,
|
|
73
|
-
price: o.price,
|
|
74
|
-
priceChange24h: o.priceChange24h,
|
|
75
|
-
metadata: o.metadata,
|
|
76
|
-
}));
|
|
77
|
-
const convertOutcome = (o) => o ? ({
|
|
78
|
-
outcomeId: o.outcomeId,
|
|
79
|
-
marketId: o.marketId,
|
|
80
|
-
label: o.label,
|
|
81
|
-
price: o.price,
|
|
82
|
-
priceChange24h: o.priceChange24h,
|
|
83
|
-
metadata: o.metadata,
|
|
84
|
-
}) : undefined;
|
|
85
69
|
return {
|
|
86
|
-
|
|
87
|
-
title: raw.title,
|
|
88
|
-
slug: raw.slug,
|
|
89
|
-
outcomes,
|
|
90
|
-
volume24h: raw.volume24h || 0,
|
|
91
|
-
liquidity: raw.liquidity || 0,
|
|
92
|
-
url: raw.url,
|
|
93
|
-
description: raw.description,
|
|
70
|
+
...raw,
|
|
94
71
|
resolutionDate: raw.resolutionDate ? new Date(raw.resolutionDate) : undefined,
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
tickSize: raw.tickSize,
|
|
101
|
-
status: raw.status,
|
|
102
|
-
contractAddress: raw.contractAddress,
|
|
103
|
-
sourceExchange: raw.sourceExchange,
|
|
104
|
-
eventId: raw.eventId,
|
|
105
|
-
yes: convertOutcome(raw.yes),
|
|
106
|
-
no: convertOutcome(raw.no),
|
|
107
|
-
up: convertOutcome(raw.up),
|
|
108
|
-
down: convertOutcome(raw.down),
|
|
72
|
+
outcomes: (raw.outcomes || []).map((o) => ({ ...o })),
|
|
73
|
+
yes: raw.yes ? { ...raw.yes } : undefined,
|
|
74
|
+
no: raw.no ? { ...raw.no } : undefined,
|
|
75
|
+
up: raw.up ? { ...raw.up } : undefined,
|
|
76
|
+
down: raw.down ? { ...raw.down } : undefined,
|
|
109
77
|
};
|
|
110
78
|
}
|
|
111
79
|
function convertCandle(raw) {
|
|
112
|
-
return {
|
|
113
|
-
timestamp: raw.timestamp,
|
|
114
|
-
open: raw.open,
|
|
115
|
-
high: raw.high,
|
|
116
|
-
low: raw.low,
|
|
117
|
-
close: raw.close,
|
|
118
|
-
volume: raw.volume,
|
|
119
|
-
};
|
|
80
|
+
return { ...raw };
|
|
120
81
|
}
|
|
121
82
|
function convertOrderBook(raw) {
|
|
122
|
-
const bids = (raw.bids || []).map((b) => ({
|
|
123
|
-
price: b.price,
|
|
124
|
-
size: b.size,
|
|
125
|
-
}));
|
|
126
|
-
const asks = (raw.asks || []).map((a) => ({
|
|
127
|
-
price: a.price,
|
|
128
|
-
size: a.size,
|
|
129
|
-
}));
|
|
130
83
|
return {
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
84
|
+
...raw,
|
|
85
|
+
bids: (raw.bids || []).map((b) => ({ ...b })),
|
|
86
|
+
asks: (raw.asks || []).map((a) => ({ ...a })),
|
|
134
87
|
};
|
|
135
88
|
}
|
|
136
89
|
function convertTrade(raw) {
|
|
137
|
-
return {
|
|
138
|
-
id: raw.id,
|
|
139
|
-
timestamp: raw.timestamp,
|
|
140
|
-
price: raw.price,
|
|
141
|
-
amount: raw.amount,
|
|
142
|
-
side: raw.side || "unknown",
|
|
143
|
-
};
|
|
90
|
+
return { ...raw, side: raw.side || "unknown" };
|
|
144
91
|
}
|
|
145
92
|
function convertOrder(raw) {
|
|
146
|
-
return {
|
|
147
|
-
id: raw.id,
|
|
148
|
-
marketId: raw.marketId,
|
|
149
|
-
outcomeId: raw.outcomeId,
|
|
150
|
-
side: raw.side,
|
|
151
|
-
type: raw.type,
|
|
152
|
-
amount: raw.amount,
|
|
153
|
-
status: raw.status,
|
|
154
|
-
filled: raw.filled,
|
|
155
|
-
remaining: raw.remaining,
|
|
156
|
-
timestamp: raw.timestamp,
|
|
157
|
-
price: raw.price,
|
|
158
|
-
fee: raw.fee,
|
|
159
|
-
};
|
|
93
|
+
return { ...raw };
|
|
160
94
|
}
|
|
161
95
|
function convertPosition(raw) {
|
|
162
|
-
return {
|
|
163
|
-
marketId: raw.marketId,
|
|
164
|
-
outcomeId: raw.outcomeId,
|
|
165
|
-
outcomeLabel: raw.outcomeLabel,
|
|
166
|
-
size: raw.size,
|
|
167
|
-
entryPrice: raw.entryPrice,
|
|
168
|
-
currentPrice: raw.currentPrice,
|
|
169
|
-
unrealizedPnL: raw.unrealizedPnL,
|
|
170
|
-
realizedPnL: raw.realizedPnL,
|
|
171
|
-
};
|
|
96
|
+
return { ...raw };
|
|
172
97
|
}
|
|
173
98
|
function convertBalance(raw) {
|
|
174
|
-
return {
|
|
175
|
-
currency: raw.currency,
|
|
176
|
-
total: raw.total,
|
|
177
|
-
available: raw.available,
|
|
178
|
-
locked: raw.locked,
|
|
179
|
-
};
|
|
99
|
+
return { ...raw };
|
|
180
100
|
}
|
|
181
101
|
function convertUserTrade(raw) {
|
|
182
|
-
return {
|
|
183
|
-
id: raw.id,
|
|
184
|
-
price: raw.price,
|
|
185
|
-
amount: raw.amount,
|
|
186
|
-
side: raw.side || "unknown",
|
|
187
|
-
timestamp: raw.timestamp,
|
|
188
|
-
orderId: raw.orderId,
|
|
189
|
-
outcomeId: raw.outcomeId,
|
|
190
|
-
marketId: raw.marketId,
|
|
191
|
-
};
|
|
102
|
+
return { ...raw, side: raw.side || "unknown" };
|
|
192
103
|
}
|
|
193
104
|
function convertEvent(raw) {
|
|
194
105
|
const markets = MarketList.from((raw.markets || []).map(convertMarket));
|
|
195
|
-
|
|
196
|
-
id: raw.id,
|
|
197
|
-
title: raw.title,
|
|
198
|
-
description: raw.description,
|
|
199
|
-
slug: raw.slug,
|
|
200
|
-
markets,
|
|
201
|
-
volume24h: raw.volume24h,
|
|
202
|
-
volume: raw.volume,
|
|
203
|
-
url: raw.url,
|
|
204
|
-
image: raw.image,
|
|
205
|
-
category: raw.category,
|
|
206
|
-
tags: raw.tags,
|
|
207
|
-
sourceExchange: raw.sourceExchange,
|
|
208
|
-
};
|
|
209
|
-
return event;
|
|
106
|
+
return { ...raw, markets };
|
|
210
107
|
}
|
|
211
108
|
function convertSubscriptionSnapshot(raw) {
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
trades,
|
|
218
|
-
balances,
|
|
219
|
-
positions,
|
|
220
|
-
timestamp: raw.timestamp,
|
|
109
|
+
return {
|
|
110
|
+
...raw,
|
|
111
|
+
trades: (raw.trades ?? []).map(convertTrade),
|
|
112
|
+
balances: (raw.balances ?? []).map(convertBalance),
|
|
113
|
+
positions: (raw.positions ?? []).map(convertPosition),
|
|
221
114
|
};
|
|
222
|
-
return snapShot;
|
|
223
115
|
}
|
|
224
116
|
/**
|
|
225
117
|
* Base class for prediction market exchanges.
|
|
@@ -668,38 +560,6 @@ export class Exchange {
|
|
|
668
560
|
throw new PmxtError(`Failed to fetchEvents: ${error}`);
|
|
669
561
|
}
|
|
670
562
|
}
|
|
671
|
-
async fetchEventsPaginated(params) {
|
|
672
|
-
await this.initPromise;
|
|
673
|
-
try {
|
|
674
|
-
const args = [];
|
|
675
|
-
if (params !== undefined)
|
|
676
|
-
args.push(params);
|
|
677
|
-
const response = await this.fetchWithRetry(`${this.resolveBaseUrl()}/api/${this.exchangeName}/fetchEventsPaginated`, {
|
|
678
|
-
method: 'POST',
|
|
679
|
-
headers: { 'Content-Type': 'application/json', ...this.getAuthHeaders() },
|
|
680
|
-
body: JSON.stringify({ args, credentials: this.getCredentials() }),
|
|
681
|
-
});
|
|
682
|
-
if (!response.ok) {
|
|
683
|
-
const body = await response.json().catch(() => ({}));
|
|
684
|
-
if (body.error && typeof body.error === "object") {
|
|
685
|
-
throw fromServerError(body.error);
|
|
686
|
-
}
|
|
687
|
-
throw new PmxtError(body.error?.message || response.statusText);
|
|
688
|
-
}
|
|
689
|
-
const json = await response.json();
|
|
690
|
-
const data = this.handleResponse(json);
|
|
691
|
-
return {
|
|
692
|
-
data: (data.data || []).map(convertEvent),
|
|
693
|
-
total: data.total,
|
|
694
|
-
nextCursor: data.nextCursor,
|
|
695
|
-
};
|
|
696
|
-
}
|
|
697
|
-
catch (error) {
|
|
698
|
-
if (error instanceof PmxtError)
|
|
699
|
-
throw error;
|
|
700
|
-
throw new PmxtError(`Failed to fetchEventsPaginated: ${error}`);
|
|
701
|
-
}
|
|
702
|
-
}
|
|
703
563
|
async fetchMarket(params) {
|
|
704
564
|
await this.initPromise;
|
|
705
565
|
try {
|
|
@@ -756,11 +616,13 @@ export class Exchange {
|
|
|
756
616
|
throw new PmxtError(`Failed to fetchEvent: ${error}`);
|
|
757
617
|
}
|
|
758
618
|
}
|
|
759
|
-
async fetchOrderBook(
|
|
619
|
+
async fetchOrderBook(outcomeId, side) {
|
|
760
620
|
await this.initPromise;
|
|
761
621
|
try {
|
|
762
622
|
const args = [];
|
|
763
|
-
args.push(
|
|
623
|
+
args.push(resolveOutcomeId(outcomeId));
|
|
624
|
+
if (side !== undefined)
|
|
625
|
+
args.push(side);
|
|
764
626
|
const response = await this.fetchWithRetry(`${this.resolveBaseUrl()}/api/${this.exchangeName}/fetchOrderBook`, {
|
|
765
627
|
method: 'POST',
|
|
766
628
|
headers: { 'Content-Type': 'application/json', ...this.getAuthHeaders() },
|
|
@@ -784,11 +646,6 @@ export class Exchange {
|
|
|
784
646
|
}
|
|
785
647
|
}
|
|
786
648
|
async submitOrder(built) {
|
|
787
|
-
if (this.isHosted) {
|
|
788
|
-
throw new PmxtError("Trade execution is not available through the hosted API. " +
|
|
789
|
-
"Use the local PMXT SDK with your venue credentials instead. " +
|
|
790
|
-
"See https://pmxt.dev/docs/quickstart for setup instructions.");
|
|
791
|
-
}
|
|
792
649
|
await this.initPromise;
|
|
793
650
|
try {
|
|
794
651
|
const args = [];
|
|
@@ -816,11 +673,6 @@ export class Exchange {
|
|
|
816
673
|
}
|
|
817
674
|
}
|
|
818
675
|
async cancelOrder(orderId) {
|
|
819
|
-
if (this.isHosted) {
|
|
820
|
-
throw new PmxtError("Trade execution is not available through the hosted API. " +
|
|
821
|
-
"Use the local PMXT SDK with your venue credentials instead. " +
|
|
822
|
-
"See https://pmxt.dev/docs/quickstart for setup instructions.");
|
|
823
|
-
}
|
|
824
676
|
await this.initPromise;
|
|
825
677
|
try {
|
|
826
678
|
const args = [];
|
|
@@ -1042,11 +894,11 @@ export class Exchange {
|
|
|
1042
894
|
throw new PmxtError(`Failed to fetchBalance: ${error}`);
|
|
1043
895
|
}
|
|
1044
896
|
}
|
|
1045
|
-
async unwatchOrderBook(
|
|
897
|
+
async unwatchOrderBook(outcomeId) {
|
|
1046
898
|
await this.initPromise;
|
|
1047
899
|
try {
|
|
1048
900
|
const args = [];
|
|
1049
|
-
args.push(
|
|
901
|
+
args.push(resolveOutcomeId(outcomeId));
|
|
1050
902
|
const response = await this.fetchWithRetry(`${this.resolveBaseUrl()}/api/${this.exchangeName}/unwatchOrderBook`, {
|
|
1051
903
|
method: 'POST',
|
|
1052
904
|
headers: { 'Content-Type': 'application/json', ...this.getAuthHeaders() },
|
|
@@ -1094,6 +946,33 @@ export class Exchange {
|
|
|
1094
946
|
throw new PmxtError(`Failed to unwatchAddress: ${error}`);
|
|
1095
947
|
}
|
|
1096
948
|
}
|
|
949
|
+
async testDummyMethod(param) {
|
|
950
|
+
await this.initPromise;
|
|
951
|
+
try {
|
|
952
|
+
const args = [];
|
|
953
|
+
if (param !== undefined)
|
|
954
|
+
args.push(param);
|
|
955
|
+
const response = await this.fetchWithRetry(`${this.resolveBaseUrl()}/api/${this.exchangeName}/testDummyMethod`, {
|
|
956
|
+
method: 'POST',
|
|
957
|
+
headers: { 'Content-Type': 'application/json', ...this.getAuthHeaders() },
|
|
958
|
+
body: JSON.stringify({ args, credentials: this.getCredentials() }),
|
|
959
|
+
});
|
|
960
|
+
if (!response.ok) {
|
|
961
|
+
const body = await response.json().catch(() => ({}));
|
|
962
|
+
if (body.error && typeof body.error === "object") {
|
|
963
|
+
throw fromServerError(body.error);
|
|
964
|
+
}
|
|
965
|
+
throw new PmxtError(body.error?.message || response.statusText);
|
|
966
|
+
}
|
|
967
|
+
const json = await response.json();
|
|
968
|
+
return this.handleResponse(json);
|
|
969
|
+
}
|
|
970
|
+
catch (error) {
|
|
971
|
+
if (error instanceof PmxtError)
|
|
972
|
+
throw error;
|
|
973
|
+
throw new PmxtError(`Failed to testDummyMethod: ${error}`);
|
|
974
|
+
}
|
|
975
|
+
}
|
|
1097
976
|
async close() {
|
|
1098
977
|
await this.initPromise;
|
|
1099
978
|
try {
|
|
@@ -1123,7 +1002,8 @@ export class Exchange {
|
|
|
1123
1002
|
await this.initPromise;
|
|
1124
1003
|
try {
|
|
1125
1004
|
const args = [];
|
|
1126
|
-
|
|
1005
|
+
if (params !== undefined)
|
|
1006
|
+
args.push(params);
|
|
1127
1007
|
const response = await this.fetchWithRetry(`${this.resolveBaseUrl()}/api/${this.exchangeName}/fetchMarketMatches`, {
|
|
1128
1008
|
method: 'POST',
|
|
1129
1009
|
headers: { 'Content-Type': 'application/json', ...this.getAuthHeaders() },
|
|
@@ -1175,7 +1055,8 @@ export class Exchange {
|
|
|
1175
1055
|
await this.initPromise;
|
|
1176
1056
|
try {
|
|
1177
1057
|
const args = [];
|
|
1178
|
-
|
|
1058
|
+
if (params !== undefined)
|
|
1059
|
+
args.push(params);
|
|
1179
1060
|
const response = await this.fetchWithRetry(`${this.resolveBaseUrl()}/api/${this.exchangeName}/fetchEventMatches`, {
|
|
1180
1061
|
method: 'POST',
|
|
1181
1062
|
headers: { 'Content-Type': 'application/json', ...this.getAuthHeaders() },
|
|
@@ -1223,6 +1104,86 @@ export class Exchange {
|
|
|
1223
1104
|
throw new PmxtError(`Failed to compareMarketPrices: ${error}`);
|
|
1224
1105
|
}
|
|
1225
1106
|
}
|
|
1107
|
+
async fetchRelatedMarkets(params) {
|
|
1108
|
+
await this.initPromise;
|
|
1109
|
+
try {
|
|
1110
|
+
const args = [];
|
|
1111
|
+
args.push(params);
|
|
1112
|
+
const response = await this.fetchWithRetry(`${this.resolveBaseUrl()}/api/${this.exchangeName}/fetchRelatedMarkets`, {
|
|
1113
|
+
method: 'POST',
|
|
1114
|
+
headers: { 'Content-Type': 'application/json', ...this.getAuthHeaders() },
|
|
1115
|
+
body: JSON.stringify({ args, credentials: this.getCredentials() }),
|
|
1116
|
+
});
|
|
1117
|
+
if (!response.ok) {
|
|
1118
|
+
const body = await response.json().catch(() => ({}));
|
|
1119
|
+
if (body.error && typeof body.error === "object") {
|
|
1120
|
+
throw fromServerError(body.error);
|
|
1121
|
+
}
|
|
1122
|
+
throw new PmxtError(body.error?.message || response.statusText);
|
|
1123
|
+
}
|
|
1124
|
+
const json = await response.json();
|
|
1125
|
+
return this.handleResponse(json);
|
|
1126
|
+
}
|
|
1127
|
+
catch (error) {
|
|
1128
|
+
if (error instanceof PmxtError)
|
|
1129
|
+
throw error;
|
|
1130
|
+
throw new PmxtError(`Failed to fetchRelatedMarkets: ${error}`);
|
|
1131
|
+
}
|
|
1132
|
+
}
|
|
1133
|
+
async fetchMatchedMarkets(params) {
|
|
1134
|
+
await this.initPromise;
|
|
1135
|
+
try {
|
|
1136
|
+
const args = [];
|
|
1137
|
+
if (params !== undefined)
|
|
1138
|
+
args.push(params);
|
|
1139
|
+
const response = await this.fetchWithRetry(`${this.resolveBaseUrl()}/api/${this.exchangeName}/fetchMatchedMarkets`, {
|
|
1140
|
+
method: 'POST',
|
|
1141
|
+
headers: { 'Content-Type': 'application/json', ...this.getAuthHeaders() },
|
|
1142
|
+
body: JSON.stringify({ args, credentials: this.getCredentials() }),
|
|
1143
|
+
});
|
|
1144
|
+
if (!response.ok) {
|
|
1145
|
+
const body = await response.json().catch(() => ({}));
|
|
1146
|
+
if (body.error && typeof body.error === "object") {
|
|
1147
|
+
throw fromServerError(body.error);
|
|
1148
|
+
}
|
|
1149
|
+
throw new PmxtError(body.error?.message || response.statusText);
|
|
1150
|
+
}
|
|
1151
|
+
const json = await response.json();
|
|
1152
|
+
return this.handleResponse(json);
|
|
1153
|
+
}
|
|
1154
|
+
catch (error) {
|
|
1155
|
+
if (error instanceof PmxtError)
|
|
1156
|
+
throw error;
|
|
1157
|
+
throw new PmxtError(`Failed to fetchMatchedMarkets: ${error}`);
|
|
1158
|
+
}
|
|
1159
|
+
}
|
|
1160
|
+
async fetchMatchedPrices(params) {
|
|
1161
|
+
await this.initPromise;
|
|
1162
|
+
try {
|
|
1163
|
+
const args = [];
|
|
1164
|
+
if (params !== undefined)
|
|
1165
|
+
args.push(params);
|
|
1166
|
+
const response = await this.fetchWithRetry(`${this.resolveBaseUrl()}/api/${this.exchangeName}/fetchMatchedPrices`, {
|
|
1167
|
+
method: 'POST',
|
|
1168
|
+
headers: { 'Content-Type': 'application/json', ...this.getAuthHeaders() },
|
|
1169
|
+
body: JSON.stringify({ args, credentials: this.getCredentials() }),
|
|
1170
|
+
});
|
|
1171
|
+
if (!response.ok) {
|
|
1172
|
+
const body = await response.json().catch(() => ({}));
|
|
1173
|
+
if (body.error && typeof body.error === "object") {
|
|
1174
|
+
throw fromServerError(body.error);
|
|
1175
|
+
}
|
|
1176
|
+
throw new PmxtError(body.error?.message || response.statusText);
|
|
1177
|
+
}
|
|
1178
|
+
const json = await response.json();
|
|
1179
|
+
return this.handleResponse(json);
|
|
1180
|
+
}
|
|
1181
|
+
catch (error) {
|
|
1182
|
+
if (error instanceof PmxtError)
|
|
1183
|
+
throw error;
|
|
1184
|
+
throw new PmxtError(`Failed to fetchMatchedPrices: ${error}`);
|
|
1185
|
+
}
|
|
1186
|
+
}
|
|
1226
1187
|
async fetchHedges(params) {
|
|
1227
1188
|
await this.initPromise;
|
|
1228
1189
|
try {
|
|
@@ -266,8 +266,24 @@ export interface MarketFilterParams {
|
|
|
266
266
|
offset?: number;
|
|
267
267
|
/** Sort order */
|
|
268
268
|
sort?: SortOption;
|
|
269
|
+
/** Filter by market status (default: 'active') */
|
|
270
|
+
status?: 'active' | 'inactive' | 'closed' | 'all';
|
|
269
271
|
/** Where to search (for filterMarkets) */
|
|
270
272
|
searchIn?: SearchIn;
|
|
273
|
+
/** Keyword search query */
|
|
274
|
+
query?: string;
|
|
275
|
+
/** Slug/ticker lookup */
|
|
276
|
+
slug?: string;
|
|
277
|
+
/** Direct lookup by market ID */
|
|
278
|
+
marketId?: string;
|
|
279
|
+
/** Reverse lookup -- find market containing this outcome */
|
|
280
|
+
outcomeId?: string;
|
|
281
|
+
/** Find markets belonging to an event */
|
|
282
|
+
eventId?: string;
|
|
283
|
+
/** Pagination page (used by Limitless) */
|
|
284
|
+
page?: number;
|
|
285
|
+
/** Semantic search threshold (used by Limitless) */
|
|
286
|
+
similarityThreshold?: number;
|
|
271
287
|
/** Filter by market category (e.g. "sports", "politics", "crypto") */
|
|
272
288
|
category?: string;
|
|
273
289
|
/** Filter by tags attached to the market */
|
|
@@ -334,6 +350,64 @@ export interface CreateOrderParams {
|
|
|
334
350
|
/** Optional fee rate (e.g., 1000 for 0.1%) */
|
|
335
351
|
fee?: number;
|
|
336
352
|
}
|
|
353
|
+
/** Alias matching the core MarketFetchParams name. */
|
|
354
|
+
export type MarketFetchParams = MarketFilterParams;
|
|
355
|
+
/**
|
|
356
|
+
* Parameters for fetching OHLCV candle data.
|
|
357
|
+
*/
|
|
358
|
+
export interface OHLCVParams {
|
|
359
|
+
/** Candle resolution (e.g. '1m', '5m', '1h', '1d') */
|
|
360
|
+
resolution: CandleInterval;
|
|
361
|
+
/** Start of the time range */
|
|
362
|
+
start?: Date;
|
|
363
|
+
/** End of the time range */
|
|
364
|
+
end?: Date;
|
|
365
|
+
/** Maximum number of candles */
|
|
366
|
+
limit?: number;
|
|
367
|
+
}
|
|
368
|
+
/**
|
|
369
|
+
* Parameters for fetching public trades.
|
|
370
|
+
*/
|
|
371
|
+
export interface TradesParams {
|
|
372
|
+
/** Start of the time range */
|
|
373
|
+
start?: Date;
|
|
374
|
+
/** End of the time range */
|
|
375
|
+
end?: Date;
|
|
376
|
+
/** Maximum number of results */
|
|
377
|
+
limit?: number;
|
|
378
|
+
}
|
|
379
|
+
/**
|
|
380
|
+
* Parameters for fetching the authenticated user's trade history.
|
|
381
|
+
*/
|
|
382
|
+
export interface MyTradesParams {
|
|
383
|
+
/** Filter by outcome ID */
|
|
384
|
+
outcomeId?: string;
|
|
385
|
+
/** Filter by market ID */
|
|
386
|
+
marketId?: string;
|
|
387
|
+
/** Only return records after this date */
|
|
388
|
+
since?: Date;
|
|
389
|
+
/** Only return records before this date */
|
|
390
|
+
until?: Date;
|
|
391
|
+
/** Maximum number of results */
|
|
392
|
+
limit?: number;
|
|
393
|
+
/** Cursor for pagination */
|
|
394
|
+
cursor?: string;
|
|
395
|
+
}
|
|
396
|
+
/**
|
|
397
|
+
* Parameters for fetching closed/all order history.
|
|
398
|
+
*/
|
|
399
|
+
export interface OrderHistoryParams {
|
|
400
|
+
/** Filter by market ID */
|
|
401
|
+
marketId?: string;
|
|
402
|
+
/** Only return records after this date */
|
|
403
|
+
since?: Date;
|
|
404
|
+
/** Only return records before this date */
|
|
405
|
+
until?: Date;
|
|
406
|
+
/** Maximum number of results */
|
|
407
|
+
limit?: number;
|
|
408
|
+
/** Cursor for pagination */
|
|
409
|
+
cursor?: string;
|
|
410
|
+
}
|
|
337
411
|
/**
|
|
338
412
|
* An order payload built but not yet submitted to the exchange.
|
|
339
413
|
*/
|
|
@@ -195,7 +195,7 @@ export interface FetchMyTradesRequest {
|
|
|
195
195
|
}
|
|
196
196
|
export interface FetchOHLCVRequest {
|
|
197
197
|
exchange: FetchOHLCVExchangeEnum;
|
|
198
|
-
|
|
198
|
+
outcomeId: string;
|
|
199
199
|
resolution?: string;
|
|
200
200
|
start?: Date;
|
|
201
201
|
end?: Date;
|
|
@@ -211,7 +211,7 @@ export interface FetchOrderRequest {
|
|
|
211
211
|
}
|
|
212
212
|
export interface FetchOrderBookRequest {
|
|
213
213
|
exchange: FetchOrderBookExchangeEnum;
|
|
214
|
-
|
|
214
|
+
outcomeId: string;
|
|
215
215
|
side?: string;
|
|
216
216
|
}
|
|
217
217
|
export interface FetchPositionsRequest {
|
|
@@ -235,7 +235,7 @@ export interface FetchRelatedMarketsRequest {
|
|
|
235
235
|
}
|
|
236
236
|
export interface FetchTradesRequest {
|
|
237
237
|
exchange: FetchTradesExchangeEnum;
|
|
238
|
-
|
|
238
|
+
outcomeId: string;
|
|
239
239
|
start?: Date;
|
|
240
240
|
end?: Date;
|
|
241
241
|
limit?: number;
|