pmxt-core 2.0.4 → 2.0.7
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/API_REFERENCE.md +0 -1
- package/dist/BaseExchange.d.ts +16 -2
- package/dist/BaseExchange.js +8 -0
- package/dist/exchanges/kalshi/auth.js +5 -1
- package/dist/exchanges/kalshi/fetchOHLCV.d.ts +2 -2
- package/dist/exchanges/kalshi/fetchOHLCV.js +4 -0
- package/dist/exchanges/kalshi/fetchTrades.d.ts +2 -2
- package/dist/exchanges/kalshi/index.d.ts +3 -3
- package/dist/exchanges/kalshi/index.js +5 -0
- package/dist/exchanges/limitless/auth.js +6 -1
- package/dist/exchanges/limitless/client.d.ts +1 -0
- package/dist/exchanges/limitless/client.js +15 -0
- package/dist/exchanges/limitless/fetchOHLCV.d.ts +2 -2
- package/dist/exchanges/limitless/fetchOHLCV.js +4 -0
- package/dist/exchanges/limitless/fetchTrades.d.ts +2 -2
- package/dist/exchanges/limitless/index.d.ts +3 -3
- package/dist/exchanges/limitless/index.js +10 -3
- package/dist/exchanges/limitless/utils.js +4 -2
- package/dist/exchanges/polymarket/auth.js +6 -1
- package/dist/exchanges/polymarket/fetchMarkets.js +3 -1
- package/dist/exchanges/polymarket/fetchOHLCV.d.ts +2 -2
- package/dist/exchanges/polymarket/fetchOHLCV.js +4 -0
- package/dist/exchanges/polymarket/fetchTrades.d.ts +2 -2
- package/dist/exchanges/polymarket/index.d.ts +3 -3
- package/dist/exchanges/polymarket/index.js +5 -0
- package/package.json +3 -3
package/API_REFERENCE.md
CHANGED
package/dist/BaseExchange.d.ts
CHANGED
|
@@ -19,11 +19,22 @@ export interface EventFetchParams {
|
|
|
19
19
|
searchIn?: 'title' | 'description' | 'both';
|
|
20
20
|
}
|
|
21
21
|
export interface HistoryFilterParams {
|
|
22
|
+
resolution?: CandleInterval;
|
|
23
|
+
start?: Date;
|
|
24
|
+
end?: Date;
|
|
25
|
+
limit?: number;
|
|
26
|
+
}
|
|
27
|
+
export interface OHLCVParams {
|
|
22
28
|
resolution: CandleInterval;
|
|
23
29
|
start?: Date;
|
|
24
30
|
end?: Date;
|
|
25
31
|
limit?: number;
|
|
26
32
|
}
|
|
33
|
+
export interface TradesParams {
|
|
34
|
+
start?: Date;
|
|
35
|
+
end?: Date;
|
|
36
|
+
limit?: number;
|
|
37
|
+
}
|
|
27
38
|
export type MarketFilterCriteria = {
|
|
28
39
|
text?: string;
|
|
29
40
|
searchIn?: ('title' | 'description' | 'category' | 'tags' | 'outcomes')[];
|
|
@@ -140,8 +151,9 @@ export declare abstract class PredictionMarketExchange {
|
|
|
140
151
|
/**
|
|
141
152
|
* Fetch historical price data for a specific market outcome.
|
|
142
153
|
* @param id - The Outcome ID (MarketOutcome.id). This should be the ID of the specific tradeable asset.
|
|
154
|
+
* @param params - OHLCV parameters including resolution (required)
|
|
143
155
|
*/
|
|
144
|
-
fetchOHLCV(id: string, params: HistoryFilterParams): Promise<PriceCandle[]>;
|
|
156
|
+
fetchOHLCV(id: string, params: OHLCVParams | HistoryFilterParams): Promise<PriceCandle[]>;
|
|
145
157
|
/**
|
|
146
158
|
* Fetch the current order book (bids/asks) for a specific outcome.
|
|
147
159
|
* Essential for calculating localized spread and depth.
|
|
@@ -149,8 +161,10 @@ export declare abstract class PredictionMarketExchange {
|
|
|
149
161
|
fetchOrderBook(id: string): Promise<OrderBook>;
|
|
150
162
|
/**
|
|
151
163
|
* Fetch raw trade history.
|
|
164
|
+
* @param id - The Outcome ID
|
|
165
|
+
* @param params - Trade filter parameters (resolution is deprecated and ignored)
|
|
152
166
|
*/
|
|
153
|
-
fetchTrades(id: string, params: HistoryFilterParams): Promise<Trade[]>;
|
|
167
|
+
fetchTrades(id: string, params: TradesParams | HistoryFilterParams): Promise<Trade[]>;
|
|
154
168
|
/**
|
|
155
169
|
* Place a new order.
|
|
156
170
|
*/
|
package/dist/BaseExchange.js
CHANGED
|
@@ -75,6 +75,7 @@ class PredictionMarketExchange {
|
|
|
75
75
|
/**
|
|
76
76
|
* Fetch historical price data for a specific market outcome.
|
|
77
77
|
* @param id - The Outcome ID (MarketOutcome.id). This should be the ID of the specific tradeable asset.
|
|
78
|
+
* @param params - OHLCV parameters including resolution (required)
|
|
78
79
|
*/
|
|
79
80
|
async fetchOHLCV(id, params) {
|
|
80
81
|
throw new Error("Method fetchOHLCV not implemented.");
|
|
@@ -88,8 +89,15 @@ class PredictionMarketExchange {
|
|
|
88
89
|
}
|
|
89
90
|
/**
|
|
90
91
|
* Fetch raw trade history.
|
|
92
|
+
* @param id - The Outcome ID
|
|
93
|
+
* @param params - Trade filter parameters (resolution is deprecated and ignored)
|
|
91
94
|
*/
|
|
92
95
|
async fetchTrades(id, params) {
|
|
96
|
+
// Deprecation warning for resolution parameter
|
|
97
|
+
if ('resolution' in params && params.resolution !== undefined) {
|
|
98
|
+
console.warn('[pmxt] Warning: The "resolution" parameter is deprecated for fetchTrades() and will be ignored. ' +
|
|
99
|
+
'It will be removed in v3.0.0. Please remove it from your code.');
|
|
100
|
+
}
|
|
93
101
|
throw new Error("Method fetchTrades not implemented.");
|
|
94
102
|
}
|
|
95
103
|
// ----------------------------------------------------------------------------
|
|
@@ -82,7 +82,11 @@ class KalshiAuth {
|
|
|
82
82
|
// Allow input of private key in both raw string or PEM format
|
|
83
83
|
// If it's a raw key without headers, accessing it might be tricky with implicit types,
|
|
84
84
|
// but standard PEM is best. We assume the user provides a valid PEM.
|
|
85
|
-
|
|
85
|
+
let privateKey = this.credentials.privateKey;
|
|
86
|
+
// Fix for common .env issue where newlines are escaped
|
|
87
|
+
if (privateKey.includes('\\n')) {
|
|
88
|
+
privateKey = privateKey.replace(/\\n/g, '\n');
|
|
89
|
+
}
|
|
86
90
|
// Kalshi uses RSA-PSS for signing
|
|
87
91
|
const signature = signer.sign({
|
|
88
92
|
key: privateKey,
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { HistoryFilterParams } from '../../BaseExchange';
|
|
1
|
+
import { HistoryFilterParams, OHLCVParams } from '../../BaseExchange';
|
|
2
2
|
import { PriceCandle } from '../../types';
|
|
3
|
-
export declare function fetchOHLCV(id: string, params: HistoryFilterParams): Promise<PriceCandle[]>;
|
|
3
|
+
export declare function fetchOHLCV(id: string, params: OHLCVParams | HistoryFilterParams): Promise<PriceCandle[]>;
|
|
@@ -10,6 +10,10 @@ const validation_1 = require("../../utils/validation");
|
|
|
10
10
|
const errors_1 = require("./errors");
|
|
11
11
|
async function fetchOHLCV(id, params) {
|
|
12
12
|
(0, validation_1.validateIdFormat)(id, 'OHLCV');
|
|
13
|
+
// Validate resolution is provided
|
|
14
|
+
if (!params.resolution) {
|
|
15
|
+
throw new Error('fetchOHLCV requires a resolution parameter. Use OHLCVParams with resolution specified.');
|
|
16
|
+
}
|
|
13
17
|
try {
|
|
14
18
|
// Kalshi API expects uppercase tickers
|
|
15
19
|
// Handle virtual "-NO" suffix by stripping it (fetching the underlying market history)
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { HistoryFilterParams } from '../../BaseExchange';
|
|
1
|
+
import { HistoryFilterParams, TradesParams } from '../../BaseExchange';
|
|
2
2
|
import { Trade } from '../../types';
|
|
3
|
-
export declare function fetchTrades(id: string, params: HistoryFilterParams): Promise<Trade[]>;
|
|
3
|
+
export declare function fetchTrades(id: string, params: TradesParams | HistoryFilterParams): Promise<Trade[]>;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { PredictionMarketExchange, MarketFilterParams, HistoryFilterParams, ExchangeCredentials, EventFetchParams } from '../../BaseExchange';
|
|
1
|
+
import { PredictionMarketExchange, MarketFilterParams, HistoryFilterParams, OHLCVParams, TradesParams, ExchangeCredentials, EventFetchParams } from '../../BaseExchange';
|
|
2
2
|
import { UnifiedMarket, UnifiedEvent, PriceCandle, OrderBook, Trade, Balance, Order, Position, CreateOrderParams } from '../../types';
|
|
3
3
|
import { KalshiWebSocketConfig } from './websocket';
|
|
4
4
|
export type { KalshiWebSocketConfig };
|
|
@@ -15,9 +15,9 @@ export declare class KalshiExchange extends PredictionMarketExchange {
|
|
|
15
15
|
private ensureAuth;
|
|
16
16
|
protected fetchMarketsImpl(params?: MarketFilterParams): Promise<UnifiedMarket[]>;
|
|
17
17
|
protected fetchEventsImpl(params: EventFetchParams): Promise<UnifiedEvent[]>;
|
|
18
|
-
fetchOHLCV(id: string, params: HistoryFilterParams): Promise<PriceCandle[]>;
|
|
18
|
+
fetchOHLCV(id: string, params: OHLCVParams | HistoryFilterParams): Promise<PriceCandle[]>;
|
|
19
19
|
fetchOrderBook(id: string): Promise<OrderBook>;
|
|
20
|
-
fetchTrades(id: string, params: HistoryFilterParams): Promise<Trade[]>;
|
|
20
|
+
fetchTrades(id: string, params: TradesParams | HistoryFilterParams): Promise<Trade[]>;
|
|
21
21
|
fetchBalance(): Promise<Balance[]>;
|
|
22
22
|
createOrder(params: CreateOrderParams): Promise<Order>;
|
|
23
23
|
cancelOrder(orderId: string): Promise<Order>;
|
|
@@ -67,6 +67,11 @@ class KalshiExchange extends BaseExchange_1.PredictionMarketExchange {
|
|
|
67
67
|
return (0, fetchOrderBook_1.fetchOrderBook)(id);
|
|
68
68
|
}
|
|
69
69
|
async fetchTrades(id, params) {
|
|
70
|
+
// Deprecation warning
|
|
71
|
+
if ('resolution' in params && params.resolution !== undefined) {
|
|
72
|
+
console.warn('[pmxt] Warning: The "resolution" parameter is deprecated for fetchTrades() and will be ignored. ' +
|
|
73
|
+
'It will be removed in v3.0.0. Please remove it from your code.');
|
|
74
|
+
}
|
|
70
75
|
return (0, fetchTrades_1.fetchTrades)(id, params);
|
|
71
76
|
}
|
|
72
77
|
// ----------------------------------------------------------------------------
|
|
@@ -19,7 +19,12 @@ class LimitlessAuth {
|
|
|
19
19
|
}
|
|
20
20
|
// Initialize signer if private key is provided (needed for order signing)
|
|
21
21
|
if (credentials.privateKey) {
|
|
22
|
-
|
|
22
|
+
let privateKey = credentials.privateKey;
|
|
23
|
+
// Fix for common .env issue where newlines are escaped
|
|
24
|
+
if (privateKey.includes('\\n')) {
|
|
25
|
+
privateKey = privateKey.replace(/\\n/g, '\n');
|
|
26
|
+
}
|
|
27
|
+
this.signer = new ethers_1.Wallet(privateKey);
|
|
23
28
|
}
|
|
24
29
|
}
|
|
25
30
|
/**
|
|
@@ -11,6 +11,10 @@ const LIMITLESS_API_URL = 'https://api.limitless.exchange';
|
|
|
11
11
|
class LimitlessClient {
|
|
12
12
|
constructor(privateKey, apiKey) {
|
|
13
13
|
this.marketCache = {};
|
|
14
|
+
// Fix for common .env issue where newlines are escaped
|
|
15
|
+
if (privateKey.includes('\\n')) {
|
|
16
|
+
privateKey = privateKey.replace(/\\n/g, '\n');
|
|
17
|
+
}
|
|
14
18
|
this.signer = new ethers_1.Wallet(privateKey);
|
|
15
19
|
// Initialize HTTP client with API key
|
|
16
20
|
this.httpClient = new sdk_1.HttpClient({
|
|
@@ -127,5 +131,16 @@ class LimitlessClient {
|
|
|
127
131
|
clearMarketCache() {
|
|
128
132
|
this.marketCache = {};
|
|
129
133
|
}
|
|
134
|
+
async getBalance() {
|
|
135
|
+
// USDC on Base
|
|
136
|
+
const USDC_ADDRESS = "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913";
|
|
137
|
+
const ABI = ["function balanceOf(address) view returns (uint256)", "function decimals() view returns (uint8)"];
|
|
138
|
+
// Use a public RPC for Base
|
|
139
|
+
const provider = new ethers_1.providers.JsonRpcProvider('https://mainnet.base.org');
|
|
140
|
+
const contract = new ethers_1.Contract(USDC_ADDRESS, ABI, provider);
|
|
141
|
+
const balance = await contract.balanceOf(this.signer.address);
|
|
142
|
+
const decimals = await contract.decimals(); // Should be 6
|
|
143
|
+
return parseFloat(ethers_1.utils.formatUnits(balance, decimals));
|
|
144
|
+
}
|
|
130
145
|
}
|
|
131
146
|
exports.LimitlessClient = LimitlessClient;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { HistoryFilterParams } from '../../BaseExchange';
|
|
1
|
+
import { HistoryFilterParams, OHLCVParams } from '../../BaseExchange';
|
|
2
2
|
import { PriceCandle } from '../../types';
|
|
3
3
|
/**
|
|
4
4
|
* Fetch historical price data (candles) for a specific market.
|
|
5
5
|
* @param id - The market slug
|
|
6
6
|
*/
|
|
7
|
-
export declare function fetchOHLCV(id: string, params: HistoryFilterParams): Promise<PriceCandle[]>;
|
|
7
|
+
export declare function fetchOHLCV(id: string, params: OHLCVParams | HistoryFilterParams): Promise<PriceCandle[]>;
|
|
@@ -14,6 +14,10 @@ const errors_1 = require("./errors");
|
|
|
14
14
|
*/
|
|
15
15
|
async function fetchOHLCV(id, params) {
|
|
16
16
|
(0, validation_1.validateIdFormat)(id, 'OHLCV');
|
|
17
|
+
// Validate resolution is provided
|
|
18
|
+
if (!params.resolution) {
|
|
19
|
+
throw new Error('fetchOHLCV requires a resolution parameter. Use OHLCVParams with resolution specified.');
|
|
20
|
+
}
|
|
17
21
|
try {
|
|
18
22
|
const fidelity = (0, utils_1.mapIntervalToFidelity)(params.resolution);
|
|
19
23
|
// New API endpoint: /markets/{slug}/historical-price
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { HistoryFilterParams } from '../../BaseExchange';
|
|
1
|
+
import { HistoryFilterParams, TradesParams } from '../../BaseExchange';
|
|
2
2
|
import { Trade } from '../../types';
|
|
3
3
|
/**
|
|
4
4
|
* Fetch trade history for a specific market or user.
|
|
5
5
|
* @param id - The market slug or wallet address
|
|
6
6
|
*/
|
|
7
|
-
export declare function fetchTrades(id: string, params: HistoryFilterParams): Promise<Trade[]>;
|
|
7
|
+
export declare function fetchTrades(id: string, params: TradesParams | HistoryFilterParams): Promise<Trade[]>;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { PredictionMarketExchange, MarketFetchParams, HistoryFilterParams, ExchangeCredentials, EventFetchParams } from '../../BaseExchange';
|
|
1
|
+
import { PredictionMarketExchange, MarketFetchParams, HistoryFilterParams, OHLCVParams, TradesParams, ExchangeCredentials, EventFetchParams } from '../../BaseExchange';
|
|
2
2
|
import { UnifiedMarket, UnifiedEvent, PriceCandle, OrderBook, Trade, Order, Position, Balance, CreateOrderParams } from '../../types';
|
|
3
3
|
import { LimitlessWebSocketConfig } from './websocket';
|
|
4
4
|
export type { LimitlessWebSocketConfig };
|
|
@@ -14,9 +14,9 @@ export declare class LimitlessExchange extends PredictionMarketExchange {
|
|
|
14
14
|
get name(): string;
|
|
15
15
|
protected fetchMarketsImpl(params?: MarketFetchParams): Promise<UnifiedMarket[]>;
|
|
16
16
|
protected fetchEventsImpl(params: EventFetchParams): Promise<UnifiedEvent[]>;
|
|
17
|
-
fetchOHLCV(id: string, params: HistoryFilterParams): Promise<PriceCandle[]>;
|
|
17
|
+
fetchOHLCV(id: string, params: OHLCVParams | HistoryFilterParams): Promise<PriceCandle[]>;
|
|
18
18
|
fetchOrderBook(id: string): Promise<OrderBook>;
|
|
19
|
-
fetchTrades(id: string, params: HistoryFilterParams): Promise<Trade[]>;
|
|
19
|
+
fetchTrades(id: string, params: TradesParams | HistoryFilterParams): Promise<Trade[]>;
|
|
20
20
|
private ensureClient;
|
|
21
21
|
/**
|
|
22
22
|
* Ensure authentication is initialized before trading operations.
|
|
@@ -74,6 +74,11 @@ class LimitlessExchange extends BaseExchange_1.PredictionMarketExchange {
|
|
|
74
74
|
return (0, fetchOrderBook_1.fetchOrderBook)(id);
|
|
75
75
|
}
|
|
76
76
|
async fetchTrades(id, params) {
|
|
77
|
+
// Deprecation warning
|
|
78
|
+
if ('resolution' in params && params.resolution !== undefined) {
|
|
79
|
+
console.warn('[pmxt] Warning: The "resolution" parameter is deprecated for fetchTrades() and will be ignored. ' +
|
|
80
|
+
'It will be removed in v3.0.0. Please remove it from your code.');
|
|
81
|
+
}
|
|
77
82
|
return (0, fetchTrades_1.fetchTrades)(id, params);
|
|
78
83
|
}
|
|
79
84
|
// ----------------------------------------------------------------------------
|
|
@@ -106,11 +111,13 @@ class LimitlessExchange extends BaseExchange_1.PredictionMarketExchange {
|
|
|
106
111
|
if (!params.price) {
|
|
107
112
|
throw new Error('Limit orders require a price');
|
|
108
113
|
}
|
|
114
|
+
// Limitless (USDC on Base) supports 6 decimals max.
|
|
115
|
+
const price = Math.round(params.price * 1000000) / 1000000;
|
|
109
116
|
const response = await client.createOrder({
|
|
110
117
|
marketSlug: marketSlug,
|
|
111
118
|
outcomeId: params.outcomeId,
|
|
112
119
|
side: side,
|
|
113
|
-
price:
|
|
120
|
+
price: price,
|
|
114
121
|
amount: params.amount,
|
|
115
122
|
type: params.type,
|
|
116
123
|
});
|
|
@@ -175,7 +182,7 @@ class LimitlessExchange extends BaseExchange_1.PredictionMarketExchange {
|
|
|
175
182
|
return orders.map((o) => ({
|
|
176
183
|
id: o.id,
|
|
177
184
|
marketId: marketId,
|
|
178
|
-
outcomeId: 'unknown',
|
|
185
|
+
outcomeId: o.tokenId || 'unknown',
|
|
179
186
|
side: o.side.toLowerCase(),
|
|
180
187
|
type: 'limit',
|
|
181
188
|
price: parseFloat(o.price),
|
|
@@ -199,7 +206,7 @@ class LimitlessExchange extends BaseExchange_1.PredictionMarketExchange {
|
|
|
199
206
|
const auth = this.ensureAuth();
|
|
200
207
|
try {
|
|
201
208
|
// Query USDC balance directly from the blockchain
|
|
202
|
-
// Base chain RPC
|
|
209
|
+
// Base chain RPC (not Polygon)
|
|
203
210
|
const provider = new ethers_1.providers.JsonRpcProvider('https://mainnet.base.org');
|
|
204
211
|
const address = auth.getAddress();
|
|
205
212
|
// Get USDC contract address for Base
|
|
@@ -12,10 +12,12 @@ function mapMarketToUnified(market) {
|
|
|
12
12
|
// The new API provides 'tokens' and 'prices'
|
|
13
13
|
// tokens: { no: "...", yes: "..." }
|
|
14
14
|
// prices: [noPrice, yesPrice]
|
|
15
|
-
if (market.tokens
|
|
15
|
+
if (market.tokens) {
|
|
16
16
|
const tokenEntries = Object.entries(market.tokens);
|
|
17
|
+
// Ensure prices array exists, otherwise default to empty
|
|
18
|
+
const prices = Array.isArray(market.prices) ? market.prices : [];
|
|
17
19
|
tokenEntries.forEach(([label, tokenId], index) => {
|
|
18
|
-
const outcomePrice =
|
|
20
|
+
const outcomePrice = prices[index] || 0;
|
|
19
21
|
const outcomeIdValue = tokenId;
|
|
20
22
|
outcomes.push({
|
|
21
23
|
outcomeId: outcomeIdValue,
|
|
@@ -21,7 +21,12 @@ class PolymarketAuth {
|
|
|
21
21
|
throw new Error('Polymarket requires a privateKey for authentication');
|
|
22
22
|
}
|
|
23
23
|
// Initialize the signer
|
|
24
|
-
|
|
24
|
+
let privateKey = credentials.privateKey;
|
|
25
|
+
// Fix for common .env issue where newlines are escaped
|
|
26
|
+
if (privateKey.includes('\\n')) {
|
|
27
|
+
privateKey = privateKey.replace(/\\n/g, '\n');
|
|
28
|
+
}
|
|
29
|
+
this.signer = new ethers_1.Wallet(privateKey);
|
|
25
30
|
}
|
|
26
31
|
/**
|
|
27
32
|
* Get or create API credentials using L1 authentication.
|
|
@@ -90,7 +90,9 @@ async function fetchMarketsDefault(params) {
|
|
|
90
90
|
// queryParams.order = 'liquidity';
|
|
91
91
|
}
|
|
92
92
|
else {
|
|
93
|
-
// Default
|
|
93
|
+
// Default to volume sort to ensure we get active markets
|
|
94
|
+
queryParams.order = 'volume';
|
|
95
|
+
queryParams.ascending = 'false';
|
|
94
96
|
}
|
|
95
97
|
try {
|
|
96
98
|
// Fetch active events from Gamma
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { HistoryFilterParams } from '../../BaseExchange';
|
|
1
|
+
import { HistoryFilterParams, OHLCVParams } from '../../BaseExchange';
|
|
2
2
|
import { PriceCandle } from '../../types';
|
|
3
3
|
/**
|
|
4
4
|
* Fetch historical price data (OHLCV candles) for a specific token.
|
|
5
5
|
* @param id - The CLOB token ID (e.g., outcome token ID)
|
|
6
6
|
*/
|
|
7
|
-
export declare function fetchOHLCV(id: string, params: HistoryFilterParams): Promise<PriceCandle[]>;
|
|
7
|
+
export declare function fetchOHLCV(id: string, params: OHLCVParams | HistoryFilterParams): Promise<PriceCandle[]>;
|
|
@@ -15,6 +15,10 @@ const errors_1 = require("./errors");
|
|
|
15
15
|
async function fetchOHLCV(id, params) {
|
|
16
16
|
(0, validation_1.validateIdFormat)(id, 'OHLCV');
|
|
17
17
|
(0, validation_1.validateOutcomeId)(id, 'OHLCV');
|
|
18
|
+
// Validate resolution is provided
|
|
19
|
+
if (!params.resolution) {
|
|
20
|
+
throw new Error('fetchOHLCV requires a resolution parameter. Use OHLCVParams with resolution specified.');
|
|
21
|
+
}
|
|
18
22
|
try {
|
|
19
23
|
const fidelity = (0, utils_1.mapIntervalToFidelity)(params.resolution);
|
|
20
24
|
const nowTs = Math.floor(Date.now() / 1000);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { HistoryFilterParams } from '../../BaseExchange';
|
|
1
|
+
import { HistoryFilterParams, TradesParams } from '../../BaseExchange';
|
|
2
2
|
import { Trade } from '../../types';
|
|
3
3
|
/**
|
|
4
4
|
* Fetch raw trade history for a specific token.
|
|
@@ -6,4 +6,4 @@ import { Trade } from '../../types';
|
|
|
6
6
|
*
|
|
7
7
|
* NOTE: Uses Polymarket Data API (public) to fetch trades.
|
|
8
8
|
*/
|
|
9
|
-
export declare function fetchTrades(id: string, params: HistoryFilterParams): Promise<Trade[]>;
|
|
9
|
+
export declare function fetchTrades(id: string, params: TradesParams | HistoryFilterParams): Promise<Trade[]>;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { PredictionMarketExchange, MarketFilterParams, HistoryFilterParams, ExchangeCredentials, EventFetchParams } from '../../BaseExchange';
|
|
1
|
+
import { PredictionMarketExchange, MarketFilterParams, HistoryFilterParams, OHLCVParams, TradesParams, ExchangeCredentials, EventFetchParams } from '../../BaseExchange';
|
|
2
2
|
import { UnifiedMarket, UnifiedEvent, PriceCandle, OrderBook, Trade, Order, Position, Balance, CreateOrderParams } from '../../types';
|
|
3
3
|
import { PolymarketWebSocketConfig } from './websocket';
|
|
4
4
|
export type { PolymarketWebSocketConfig };
|
|
@@ -13,9 +13,9 @@ export declare class PolymarketExchange extends PredictionMarketExchange {
|
|
|
13
13
|
get name(): string;
|
|
14
14
|
protected fetchMarketsImpl(params?: MarketFilterParams): Promise<UnifiedMarket[]>;
|
|
15
15
|
protected fetchEventsImpl(params: EventFetchParams): Promise<UnifiedEvent[]>;
|
|
16
|
-
fetchOHLCV(id: string, params: HistoryFilterParams): Promise<PriceCandle[]>;
|
|
16
|
+
fetchOHLCV(id: string, params: OHLCVParams | HistoryFilterParams): Promise<PriceCandle[]>;
|
|
17
17
|
fetchOrderBook(id: string): Promise<OrderBook>;
|
|
18
|
-
fetchTrades(id: string, params: HistoryFilterParams): Promise<Trade[]>;
|
|
18
|
+
fetchTrades(id: string, params: TradesParams | HistoryFilterParams): Promise<Trade[]>;
|
|
19
19
|
/**
|
|
20
20
|
* Ensure authentication is initialized before trading operations.
|
|
21
21
|
*/
|
|
@@ -53,6 +53,11 @@ class PolymarketExchange extends BaseExchange_1.PredictionMarketExchange {
|
|
|
53
53
|
return (0, fetchOrderBook_1.fetchOrderBook)(id);
|
|
54
54
|
}
|
|
55
55
|
async fetchTrades(id, params) {
|
|
56
|
+
// Deprecation warning (also in base class, but adding here for consistency)
|
|
57
|
+
if ('resolution' in params && params.resolution !== undefined) {
|
|
58
|
+
console.warn('[pmxt] Warning: The "resolution" parameter is deprecated for fetchTrades() and will be ignored. ' +
|
|
59
|
+
'It will be removed in v3.0.0. Please remove it from your code.');
|
|
60
|
+
}
|
|
56
61
|
return (0, fetchTrades_1.fetchTrades)(id, params);
|
|
57
62
|
}
|
|
58
63
|
// ----------------------------------------------------------------------------
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pmxt-core",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.7",
|
|
4
4
|
"description": "pmxt is a unified prediction market data API. The ccxt for prediction markets.",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -29,8 +29,8 @@
|
|
|
29
29
|
"test": "jest -c jest.config.js",
|
|
30
30
|
"server": "tsx watch src/server/index.ts",
|
|
31
31
|
"server:prod": "node dist/server/index.js",
|
|
32
|
-
"generate:sdk:python": "npx @openapitools/openapi-generator-cli generate -i src/server/openapi.yaml -g python -o ../sdks/python/generated --package-name pmxt_internal --additional-properties=projectName=pmxt-internal,packageVersion=2.0.
|
|
33
|
-
"generate:sdk:typescript": "npx @openapitools/openapi-generator-cli generate -i src/server/openapi.yaml -g typescript-fetch -o ../sdks/typescript/generated --additional-properties=npmName=pmxtjs,npmVersion=2.0.
|
|
32
|
+
"generate:sdk:python": "npx @openapitools/openapi-generator-cli generate -i src/server/openapi.yaml -g python -o ../sdks/python/generated --package-name pmxt_internal --additional-properties=projectName=pmxt-internal,packageVersion=2.0.7,library=urllib3",
|
|
33
|
+
"generate:sdk:typescript": "npx @openapitools/openapi-generator-cli generate -i src/server/openapi.yaml -g typescript-fetch -o ../sdks/typescript/generated --additional-properties=npmName=pmxtjs,npmVersion=2.0.7,supportsES6=true,typescriptThreePlus=true && node ../sdks/typescript/scripts/fix-generated.js",
|
|
34
34
|
"generate:docs": "node ../scripts/generate-api-docs.js",
|
|
35
35
|
"generate:sdk:all": "npm run generate:sdk:python && npm run generate:sdk:typescript && npm run generate:docs"
|
|
36
36
|
},
|