pmxt 1.5.2__py3-none-any.whl → 1.5.4__py3-none-any.whl

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.
pmxt/__init__.py CHANGED
@@ -33,7 +33,7 @@ from .models import (
33
33
  CreateOrderParams,
34
34
  )
35
35
 
36
- __version__ = "1.5.2"
36
+ __version__ = "1.5.4"
37
37
  __all__ = [
38
38
  # Exchanges
39
39
  "Polymarket",
@@ -38127,12 +38127,13 @@ var require_utils4 = __commonJS({
38127
38127
  "dist/exchanges/polymarket/utils.js"(exports2) {
38128
38128
  "use strict";
38129
38129
  Object.defineProperty(exports2, "__esModule", { value: true });
38130
- exports2.CLOB_API_URL = exports2.GAMMA_API_URL = void 0;
38130
+ exports2.DATA_API_URL = exports2.CLOB_API_URL = exports2.GAMMA_API_URL = void 0;
38131
38131
  exports2.mapMarketToUnified = mapMarketToUnified;
38132
38132
  exports2.mapIntervalToFidelity = mapIntervalToFidelity;
38133
38133
  var market_utils_1 = require_market_utils();
38134
38134
  exports2.GAMMA_API_URL = "https://gamma-api.polymarket.com/events";
38135
38135
  exports2.CLOB_API_URL = "https://clob.polymarket.com";
38136
+ exports2.DATA_API_URL = "https://data-api.polymarket.com";
38136
38137
  function mapMarketToUnified(event, market, options = {}) {
38137
38138
  if (!market)
38138
38139
  return null;
@@ -38284,7 +38285,7 @@ var require_searchMarkets = __commonJS({
38284
38285
  exports2.searchMarkets = searchMarkets;
38285
38286
  var fetchMarkets_1 = require_fetchMarkets();
38286
38287
  async function searchMarkets(query, params) {
38287
- const searchLimit = 1e5;
38288
+ const searchLimit = 5e3;
38288
38289
  try {
38289
38290
  const markets = await (0, fetchMarkets_1.fetchMarkets)({
38290
38291
  ...params,
@@ -38562,7 +38563,8 @@ var require_fetchTrades = __commonJS({
38562
38563
  }
38563
38564
  try {
38564
38565
  const queryParams = {
38565
- market: id
38566
+ asset_id: id
38567
+ // Uses asset_id for Token ID on Data API
38566
38568
  };
38567
38569
  if (params.start) {
38568
38570
  queryParams.after = Math.floor(params.start.getTime() / 1e3);
@@ -38570,7 +38572,7 @@ var require_fetchTrades = __commonJS({
38570
38572
  if (params.end) {
38571
38573
  queryParams.before = Math.floor(params.end.getTime() / 1e3);
38572
38574
  }
38573
- const response = await axios_1.default.get(`${utils_1.CLOB_API_URL}/trades`, {
38575
+ const response = await axios_1.default.get(`${utils_1.DATA_API_URL}/trades`, {
38574
38576
  params: queryParams
38575
38577
  });
38576
38578
  const trades = response.data || [];
@@ -38583,13 +38585,14 @@ var require_fetchTrades = __commonJS({
38583
38585
  side: trade.side === "BUY" ? "buy" : trade.side === "SELL" ? "sell" : "unknown"
38584
38586
  }));
38585
38587
  if (params.limit && mappedTrades.length > params.limit) {
38586
- return mappedTrades.slice(-params.limit);
38588
+ return mappedTrades.slice(0, params.limit);
38587
38589
  }
38588
38590
  return mappedTrades;
38589
38591
  } catch (error) {
38590
- if (axios_1.default.isAxiosError(error) && error.response) {
38591
- const apiError = error.response.data?.error || error.response.data?.message || "Unknown API Error";
38592
- throw new Error(`Polymarket Trades API Error (${error.response.status}): ${apiError}. Used ID: ${id}`);
38592
+ if (axios_1.default.isAxiosError(error)) {
38593
+ const apiError = error.response?.data?.error || error.response?.data?.message || error.message;
38594
+ console.error(`[Polymarket] fetchTrades failed for ID ${id}: ${apiError}`);
38595
+ throw new Error(`Polymarket Trades API Error: ${apiError}`);
38593
38596
  }
38594
38597
  console.error(`Unexpected error fetching Polymarket trades for ${id}:`, error);
38595
38598
  throw error;
@@ -38608,25 +38611,31 @@ var require_fetchPositions = __commonJS({
38608
38611
  Object.defineProperty(exports2, "__esModule", { value: true });
38609
38612
  exports2.fetchPositions = fetchPositions;
38610
38613
  var axios_1 = __importDefault(require_axios());
38611
- var DATA_API_URL = "https://data-api.polymarket.com";
38614
+ var utils_1 = require_utils4();
38612
38615
  async function fetchPositions(userAddress) {
38613
- const response = await axios_1.default.get(`${DATA_API_URL}/positions`, {
38614
- params: {
38615
- user: userAddress,
38616
- limit: 100
38617
- }
38618
- });
38619
- const data = Array.isArray(response.data) ? response.data : [];
38620
- return data.map((p) => ({
38621
- marketId: p.conditionId,
38622
- outcomeId: p.asset,
38623
- outcomeLabel: p.outcome || "Unknown",
38624
- size: parseFloat(p.size),
38625
- entryPrice: parseFloat(p.avgPrice),
38626
- currentPrice: parseFloat(p.curPrice || "0"),
38627
- unrealizedPnL: parseFloat(p.cashPnl || "0"),
38628
- realizedPnL: parseFloat(p.realizedPnl || "0")
38629
- }));
38616
+ try {
38617
+ const response = await axios_1.default.get(`${utils_1.DATA_API_URL}/positions`, {
38618
+ params: {
38619
+ user: userAddress,
38620
+ limit: 100
38621
+ }
38622
+ });
38623
+ const data = Array.isArray(response.data) ? response.data : [];
38624
+ return data.map((p) => ({
38625
+ marketId: p.conditionId,
38626
+ outcomeId: p.asset,
38627
+ outcomeLabel: p.outcome || "Unknown",
38628
+ size: parseFloat(p.size),
38629
+ entryPrice: parseFloat(p.avgPrice),
38630
+ currentPrice: parseFloat(p.curPrice || "0"),
38631
+ unrealizedPnL: parseFloat(p.cashPnl || "0"),
38632
+ realizedPnL: parseFloat(p.realizedPnl || "0")
38633
+ }));
38634
+ } catch (error) {
38635
+ const apiError = error.response?.data?.error || error.response?.data?.message || error.message;
38636
+ console.error(`[Polymarket] fetchPositions failed for ${userAddress}: ${apiError}`);
38637
+ throw new Error(`Polymarket Positions API Error: ${apiError}`);
38638
+ }
38630
38639
  }
38631
38640
  }
38632
38641
  });
@@ -104861,7 +104870,7 @@ var require_polymarket = __commonJS({
104861
104870
  tickSize
104862
104871
  });
104863
104872
  if (!response || !response.success) {
104864
- throw new Error(response?.errorMsg || "Order placement failed");
104873
+ throw new Error(`${response?.errorMsg || "Order placement failed"} (Response: ${JSON.stringify(response)})`);
104865
104874
  }
104866
104875
  return {
104867
104876
  id: response.orderID,
@@ -104946,8 +104955,7 @@ var require_polymarket = __commonJS({
104946
104955
  type: order.order_type === "GTC" ? "limit" : "market",
104947
104956
  price: parseFloat(order.price),
104948
104957
  amount: parseFloat(order.original_size),
104949
- status: order.status,
104950
- // Needs precise mapping
104958
+ status: typeof order.status === "string" ? order.status.toLowerCase() : order.status,
104951
104959
  filled: parseFloat(order.size_matched),
104952
104960
  remaining: parseFloat(order.original_size) - parseFloat(order.size_matched),
104953
104961
  timestamp: order.created_at * 1e3
@@ -105130,7 +105138,7 @@ var require_fetchMarkets2 = __commonJS({
105130
105138
  const unifiedMarkets = [];
105131
105139
  for (const market of markets) {
105132
105140
  const unifiedMarket = (0, utils_1.mapMarketToUnified)(market);
105133
- if (unifiedMarket) {
105141
+ if (unifiedMarket && unifiedMarket.outcomes.length > 0) {
105134
105142
  unifiedMarkets.push(unifiedMarket);
105135
105143
  }
105136
105144
  }
@@ -105167,8 +105175,22 @@ var require_searchMarkets2 = __commonJS({
105167
105175
  limit: params?.limit || 20
105168
105176
  }
105169
105177
  });
105170
- const markets = response.data?.markets || [];
105171
- return markets.map((m) => (0, utils_1.mapMarketToUnified)(m)).filter((m) => m !== null).slice(0, params?.limit || 20);
105178
+ const rawResults = response.data?.markets || [];
105179
+ const allMarkets = [];
105180
+ for (const res of rawResults) {
105181
+ if (res.markets && Array.isArray(res.markets)) {
105182
+ for (const child of res.markets) {
105183
+ const mapped = (0, utils_1.mapMarketToUnified)(child);
105184
+ if (mapped)
105185
+ allMarkets.push(mapped);
105186
+ }
105187
+ } else {
105188
+ const mapped = (0, utils_1.mapMarketToUnified)(res);
105189
+ if (mapped)
105190
+ allMarkets.push(mapped);
105191
+ }
105192
+ }
105193
+ return allMarkets.filter((m) => m !== null && m.outcomes.length > 0).slice(0, params?.limit || 20);
105172
105194
  } catch (error) {
105173
105195
  console.error("Error searching Limitless data:", error.message);
105174
105196
  return [];
@@ -105350,55 +105372,10 @@ var require_fetchOrderBook2 = __commonJS({
105350
105372
  var require_fetchTrades2 = __commonJS({
105351
105373
  "dist/exchanges/limitless/fetchTrades.js"(exports2) {
105352
105374
  "use strict";
105353
- var __importDefault = exports2 && exports2.__importDefault || function(mod) {
105354
- return mod && mod.__esModule ? mod : { "default": mod };
105355
- };
105356
105375
  Object.defineProperty(exports2, "__esModule", { value: true });
105357
105376
  exports2.fetchTrades = fetchTrades;
105358
- var axios_1 = __importDefault(require_axios());
105359
- var utils_1 = require_utils10();
105360
105377
  async function fetchTrades(id, params) {
105361
- try {
105362
- const url2 = `${utils_1.LIMITLESS_API_URL}/portfolio/trades`;
105363
- const requestParams = {
105364
- limit: params.limit || 100
105365
- };
105366
- if (params.start) {
105367
- requestParams.after = Math.floor(params.start.getTime() / 1e3);
105368
- }
105369
- if (params.end) {
105370
- requestParams.before = Math.floor(params.end.getTime() / 1e3);
105371
- }
105372
- const response = await axios_1.default.get(url2, {
105373
- params: requestParams
105374
- });
105375
- const tradesData = response.data?.data || response.data || [];
105376
- let trades = tradesData.map((trade) => {
105377
- const price = parseFloat(trade.price);
105378
- const timestamp = Number(trade.timestamp);
105379
- let side = "unknown";
105380
- const rawSide = trade.side?.toLowerCase();
105381
- if (rawSide === "buy")
105382
- side = "buy";
105383
- else if (rawSide === "sell")
105384
- side = "sell";
105385
- return {
105386
- id: trade.id || `${timestamp}-${price}`,
105387
- timestamp: timestamp * 1e3,
105388
- price,
105389
- amount: parseFloat(trade.size || trade.amount || 0),
105390
- side
105391
- };
105392
- });
105393
- trades.sort((a, b) => b.timestamp - a.timestamp);
105394
- if (params.limit) {
105395
- trades = trades.slice(0, params.limit);
105396
- }
105397
- return trades;
105398
- } catch (error) {
105399
- console.error(`Error fetching Limitless trades for ${id}:`, error.message);
105400
- return [];
105401
- }
105378
+ throw new Error("Limitless fetchTrades not implemented: No public market trades API available.");
105402
105379
  }
105403
105380
  }
105404
105381
  });
@@ -105524,6 +105501,176 @@ var require_auth2 = __commonJS({
105524
105501
  }
105525
105502
  });
105526
105503
 
105504
+ // dist/exchanges/limitless/client.js
105505
+ var require_client = __commonJS({
105506
+ "dist/exchanges/limitless/client.js"(exports2) {
105507
+ "use strict";
105508
+ var __importDefault = exports2 && exports2.__importDefault || function(mod) {
105509
+ return mod && mod.__esModule ? mod : { "default": mod };
105510
+ };
105511
+ Object.defineProperty(exports2, "__esModule", { value: true });
105512
+ exports2.LimitlessClient = void 0;
105513
+ var axios_1 = __importDefault(require_axios());
105514
+ var ethers_1 = require_lib36();
105515
+ var LIMITLESS_API_URL = "https://api.limitless.exchange";
105516
+ var BASE_CHAIN_ID = 8453;
105517
+ var ORDER_TYPES = {
105518
+ Order: [
105519
+ { name: "salt", type: "uint256" },
105520
+ { name: "maker", type: "address" },
105521
+ { name: "signer", type: "address" },
105522
+ { name: "taker", type: "address" },
105523
+ { name: "tokenId", type: "uint256" },
105524
+ { name: "makerAmount", type: "uint256" },
105525
+ { name: "takerAmount", type: "uint256" },
105526
+ { name: "expiration", type: "uint256" },
105527
+ { name: "nonce", type: "uint256" },
105528
+ { name: "feeRateBps", type: "uint256" },
105529
+ { name: "side", type: "uint8" },
105530
+ { name: "signatureType", type: "uint8" }
105531
+ ]
105532
+ };
105533
+ var LimitlessClient = class {
105534
+ constructor(privateKey) {
105535
+ this.marketCache = {};
105536
+ this.signer = new ethers_1.Wallet(privateKey);
105537
+ this.api = axios_1.default.create({
105538
+ baseURL: LIMITLESS_API_URL,
105539
+ headers: {
105540
+ "Content-Type": "application/json",
105541
+ "Accept": "application/json"
105542
+ }
105543
+ });
105544
+ }
105545
+ async ensureAuth() {
105546
+ if (this.sessionCookie && this.userId)
105547
+ return;
105548
+ const msgRes = await this.api.get("/auth/signing-message");
105549
+ const message = msgRes.data;
105550
+ const hexMessage = ethers_1.utils.hexlify(ethers_1.utils.toUtf8Bytes(message));
105551
+ const signature = await this.signer.signMessage(message);
105552
+ const loginRes = await this.api.post("/auth/login", {
105553
+ client: "eoa"
105554
+ }, {
105555
+ headers: {
105556
+ "x-account": this.signer.address,
105557
+ "x-signing-message": hexMessage,
105558
+ "x-signature": signature
105559
+ }
105560
+ });
105561
+ const setCookie = loginRes.headers["set-cookie"];
105562
+ if (setCookie) {
105563
+ const sessionMatch = setCookie.find((c) => c.startsWith("limitless_session="));
105564
+ if (sessionMatch) {
105565
+ this.sessionCookie = sessionMatch.split(";")[0];
105566
+ }
105567
+ }
105568
+ if (!this.sessionCookie) {
105569
+ throw new Error("Failed to retrieve session cookie from login response");
105570
+ }
105571
+ this.userId = loginRes.data.id;
105572
+ this.userData = loginRes.data;
105573
+ this.api.defaults.headers.common["Cookie"] = this.sessionCookie;
105574
+ }
105575
+ async getMarket(slug) {
105576
+ if (this.marketCache[slug])
105577
+ return this.marketCache[slug];
105578
+ const res = await this.api.get(`/markets/${slug}`);
105579
+ const market = res.data;
105580
+ if (!market)
105581
+ throw new Error(`Market not found: ${slug}`);
105582
+ this.marketCache[slug] = market;
105583
+ return market;
105584
+ }
105585
+ async createOrder(params) {
105586
+ await this.ensureAuth();
105587
+ const market = await this.getMarket(params.marketSlug);
105588
+ const venue = market.venue;
105589
+ if (!venue || !venue.exchange) {
105590
+ throw new Error(`Market ${params.marketSlug} has no venue exchange address`);
105591
+ }
105592
+ const SCALING_FACTOR = 1e6;
105593
+ let makerAmount;
105594
+ let takerAmount;
105595
+ const price = params.price;
105596
+ const amount = params.amount;
105597
+ if (params.side === "BUY") {
105598
+ const totalCost = price * amount;
105599
+ makerAmount = Math.round(totalCost * SCALING_FACTOR);
105600
+ takerAmount = Math.round(amount * SCALING_FACTOR);
105601
+ } else {
105602
+ const totalProceeds = price * amount;
105603
+ makerAmount = Math.round(amount * SCALING_FACTOR);
105604
+ takerAmount = Math.round(totalProceeds * SCALING_FACTOR);
105605
+ }
105606
+ const domain = {
105607
+ name: "Limitless CTF Exchange",
105608
+ version: "1",
105609
+ chainId: BASE_CHAIN_ID,
105610
+ // 8453
105611
+ verifyingContract: venue.exchange
105612
+ };
105613
+ const sideInt = params.side === "BUY" ? 0 : 1;
105614
+ const feeRateBps = this.userData?.rank?.feeRateBps ?? 0;
105615
+ const orderData = {
105616
+ salt: Date.now() + 864e5,
105617
+ // 24h expiry
105618
+ maker: this.signer.address,
105619
+ signer: this.signer.address,
105620
+ taker: "0x0000000000000000000000000000000000000000",
105621
+ tokenId: params.outcomeId,
105622
+ // Keep as string for now if big
105623
+ makerAmount,
105624
+ takerAmount,
105625
+ expiration: "0",
105626
+ nonce: 0,
105627
+ feeRateBps,
105628
+ side: sideInt,
105629
+ signatureType: 0
105630
+ // EOA
105631
+ };
105632
+ const signature = await this.signer._signTypedData(domain, ORDER_TYPES, orderData);
105633
+ const payload = {
105634
+ order: {
105635
+ ...orderData,
105636
+ price: params.price,
105637
+ // Send float as per API
105638
+ signature
105639
+ },
105640
+ ownerId: this.userId,
105641
+ orderType: "GTC",
105642
+ // Force Limit Orders for now
105643
+ marketSlug: params.marketSlug
105644
+ };
105645
+ const res = await this.api.post("/orders", payload);
105646
+ return res.data;
105647
+ }
105648
+ async cancelOrder(orderId) {
105649
+ await this.ensureAuth();
105650
+ const res = await this.api.delete(`/orders/${orderId}`, {
105651
+ data: {}
105652
+ });
105653
+ return res.data;
105654
+ }
105655
+ async cancelAllOrders(marketSlug) {
105656
+ await this.ensureAuth();
105657
+ const res = await this.api.delete(`/orders/all/${marketSlug}`);
105658
+ return res.data;
105659
+ }
105660
+ async getOrders(marketSlug, statuses) {
105661
+ await this.ensureAuth();
105662
+ const params = {};
105663
+ if (statuses && statuses.length > 0) {
105664
+ params.statuses = statuses;
105665
+ }
105666
+ const res = await this.api.get(`/markets/${marketSlug}/user-orders`, { params });
105667
+ return res.data.orders || [];
105668
+ }
105669
+ };
105670
+ exports2.LimitlessClient = LimitlessClient;
105671
+ }
105672
+ });
105673
+
105527
105674
  // dist/exchanges/limitless/websocket.js
105528
105675
  var require_websocket4 = __commonJS({
105529
105676
  "dist/exchanges/limitless/websocket.js"(exports2) {
@@ -105562,7 +105709,7 @@ var require_limitless = __commonJS({
105562
105709
  var fetchTrades_1 = require_fetchTrades2();
105563
105710
  var fetchPositions_1 = require_fetchPositions2();
105564
105711
  var auth_1 = require_auth2();
105565
- var clob_client_1 = (init_dist2(), __toCommonJS(dist_exports));
105712
+ var client_1 = require_client();
105566
105713
  var websocket_1 = require_websocket4();
105567
105714
  var LimitlessExchange = class extends BaseExchange_1.PredictionMarketExchange {
105568
105715
  constructor(options) {
@@ -105580,6 +105727,7 @@ var require_limitless = __commonJS({
105580
105727
  this.wsConfig = wsConfig;
105581
105728
  if (credentials?.privateKey) {
105582
105729
  this.auth = new auth_1.LimitlessAuth(credentials);
105730
+ this.client = new client_1.LimitlessClient(credentials.privateKey);
105583
105731
  }
105584
105732
  }
105585
105733
  get name() {
@@ -105609,6 +105757,12 @@ var require_limitless = __commonJS({
105609
105757
  // ----------------------------------------------------------------------------
105610
105758
  // Trading Methods
105611
105759
  // ----------------------------------------------------------------------------
105760
+ ensureClient() {
105761
+ if (!this.client) {
105762
+ throw new Error('Trading operations require authentication. Initialize LimitlessExchange with credentials: new LimitlessExchange({ privateKey: "0x..." })');
105763
+ }
105764
+ return this.client;
105765
+ }
105612
105766
  /**
105613
105767
  * Ensure authentication is initialized before trading operations.
105614
105768
  */
@@ -105619,44 +105773,29 @@ var require_limitless = __commonJS({
105619
105773
  return this.auth;
105620
105774
  }
105621
105775
  async createOrder(params) {
105622
- const auth = this.ensureAuth();
105623
- const client = await auth.getClobClient();
105624
- const side = params.side.toUpperCase() === "BUY" ? clob_client_1.Side.BUY : clob_client_1.Side.SELL;
105625
- if (params.type === "limit" && !params.price) {
105626
- throw new Error("Price is required for limit orders");
105627
- }
105628
- const price = params.price || (side === clob_client_1.Side.BUY ? 0.99 : 0.01);
105629
- let tickSize;
105630
- if (params.tickSize) {
105631
- tickSize = params.tickSize.toString();
105632
- } else {
105633
- try {
105634
- const orderBook = await this.fetchOrderBook(params.outcomeId);
105635
- tickSize = this.inferTickSize(orderBook);
105636
- } catch (error) {
105637
- tickSize = "0.001";
105638
- }
105639
- }
105776
+ const client = this.ensureClient();
105640
105777
  try {
105641
- const response = await client.createAndPostOrder({
105642
- tokenID: params.outcomeId,
105643
- price,
105778
+ const side = params.side.toUpperCase();
105779
+ const marketSlug = params.marketId;
105780
+ if (!params.price) {
105781
+ throw new Error("Limit orders require a price");
105782
+ }
105783
+ const response = await client.createOrder({
105784
+ marketSlug,
105785
+ outcomeId: params.outcomeId,
105644
105786
  side,
105645
- size: params.amount,
105646
- feeRateBps: 0
105647
- }, {
105648
- tickSize
105787
+ price: params.price,
105788
+ amount: params.amount,
105789
+ type: params.type
105649
105790
  });
105650
- if (!response || !response.success) {
105651
- throw new Error(response?.errorMsg || "Order placement failed");
105652
- }
105653
105791
  return {
105654
- id: response.orderID,
105792
+ id: response.id || "unknown",
105793
+ // Adjust based on actual response
105655
105794
  marketId: params.marketId,
105656
105795
  outcomeId: params.outcomeId,
105657
105796
  side: params.side,
105658
105797
  type: params.type,
105659
- price,
105798
+ price: params.price,
105660
105799
  amount: params.amount,
105661
105800
  status: "open",
105662
105801
  filled: 0,
@@ -105664,46 +105803,14 @@ var require_limitless = __commonJS({
105664
105803
  timestamp: Date.now()
105665
105804
  };
105666
105805
  } catch (error) {
105806
+ console.error("Limitless createOrder failed:", error.response?.data || error.message);
105667
105807
  throw error;
105668
105808
  }
105669
105809
  }
105670
- /**
105671
- * Infer the tick size from order book price levels.
105672
- * Analyzes the decimal precision of existing orders to determine the market's tick size.
105673
- */
105674
- inferTickSize(orderBook) {
105675
- const allPrices = [
105676
- ...orderBook.bids.map((b) => b.price),
105677
- ...orderBook.asks.map((a) => a.price)
105678
- ];
105679
- if (allPrices.length === 0) {
105680
- return "0.001";
105681
- }
105682
- let minIncrement = 1;
105683
- for (const price of allPrices) {
105684
- const priceStr = price.toString();
105685
- const decimalPart = priceStr.split(".")[1];
105686
- if (decimalPart) {
105687
- const decimals = decimalPart.length;
105688
- const increment = Math.pow(10, -decimals);
105689
- if (increment < minIncrement) {
105690
- minIncrement = increment;
105691
- }
105692
- }
105693
- }
105694
- if (minIncrement >= 0.1)
105695
- return "0.1";
105696
- if (minIncrement >= 0.01)
105697
- return "0.01";
105698
- if (minIncrement >= 1e-3)
105699
- return "0.001";
105700
- return "0.0001";
105701
- }
105702
105810
  async cancelOrder(orderId) {
105703
- const auth = this.ensureAuth();
105704
- const client = await auth.getClobClient();
105811
+ const client = this.ensureClient();
105705
105812
  try {
105706
- await client.cancelOrder({ orderID: orderId });
105813
+ await client.cancelOrder(orderId);
105707
105814
  return {
105708
105815
  id: orderId,
105709
105816
  marketId: "unknown",
@@ -105717,51 +105824,36 @@ var require_limitless = __commonJS({
105717
105824
  timestamp: Date.now()
105718
105825
  };
105719
105826
  } catch (error) {
105827
+ console.error("Limitless cancelOrder failed:", error.response?.data || error.message);
105720
105828
  throw error;
105721
105829
  }
105722
105830
  }
105723
105831
  async fetchOrder(orderId) {
105724
- const auth = this.ensureAuth();
105725
- const client = await auth.getClobClient();
105726
- try {
105727
- const order = await client.getOrder(orderId);
105728
- return {
105729
- id: order.id,
105730
- marketId: order.market || "unknown",
105731
- outcomeId: order.asset_id,
105732
- side: order.side.toLowerCase(),
105733
- type: order.order_type === "GTC" ? "limit" : "market",
105734
- price: parseFloat(order.price),
105735
- amount: parseFloat(order.original_size),
105736
- status: order.status,
105737
- // Needs precise mapping
105738
- filled: parseFloat(order.size_matched),
105739
- remaining: parseFloat(order.original_size) - parseFloat(order.size_matched),
105740
- timestamp: order.created_at * 1e3
105741
- };
105742
- } catch (error) {
105743
- throw error;
105744
- }
105832
+ throw new Error("Limitless: fetchOrder(id) is not supported directly. Use fetchOpenOrders(marketSlug).");
105745
105833
  }
105746
105834
  async fetchOpenOrders(marketId) {
105747
- const auth = this.ensureAuth();
105748
- const client = await auth.getClobClient();
105835
+ const client = this.ensureClient();
105749
105836
  try {
105750
- const orders = await client.getOpenOrders({
105751
- market: marketId
105752
- });
105837
+ if (!marketId) {
105838
+ console.warn("Limitless: fetchOpenOrders requires marketId (slug) to be efficient. Returning [].");
105839
+ return [];
105840
+ }
105841
+ const orders = await client.getOrders(marketId, ["LIVE"]);
105753
105842
  return orders.map((o) => ({
105754
105843
  id: o.id,
105755
- marketId: o.market || "unknown",
105756
- outcomeId: o.asset_id,
105844
+ marketId,
105845
+ outcomeId: "unknown",
105846
+ // API might not return this in the simplified list, need to check response
105757
105847
  side: o.side.toLowerCase(),
105758
105848
  type: "limit",
105759
105849
  price: parseFloat(o.price),
105760
- amount: parseFloat(o.original_size),
105850
+ amount: parseFloat(o.quantity),
105761
105851
  status: "open",
105762
- filled: parseFloat(o.size_matched),
105763
- remaining: parseFloat(o.size_left || parseFloat(o.original_size) - parseFloat(o.size_matched)),
105764
- timestamp: o.created_at * 1e3
105852
+ filled: 0,
105853
+ // Need to check if API returns filled amount in this view
105854
+ remaining: parseFloat(o.quantity),
105855
+ timestamp: Date.now()
105856
+ // API doesn't always return TS in summary
105765
105857
  }));
105766
105858
  } catch (error) {
105767
105859
  console.error("Error fetching Limitless open orders:", error.message);
@@ -105779,30 +105871,20 @@ var require_limitless = __commonJS({
105779
105871
  try {
105780
105872
  const USDC_DECIMALS = 6;
105781
105873
  const balRes = await client.getBalanceAllowance({
105782
- asset_type: clob_client_1.AssetType.COLLATERAL
105874
+ asset_type: "COLLATERAL"
105783
105875
  });
105784
105876
  const rawBalance = parseFloat(balRes.balance);
105785
105877
  const total = rawBalance / Math.pow(10, USDC_DECIMALS);
105786
- const openOrders = await client.getOpenOrders({});
105787
- let locked = 0;
105788
- if (openOrders && Array.isArray(openOrders)) {
105789
- for (const order of openOrders) {
105790
- if (order.side === clob_client_1.Side.BUY) {
105791
- const remainingSize = parseFloat(order.original_size) - parseFloat(order.size_matched);
105792
- const price = parseFloat(order.price);
105793
- locked += remainingSize * price;
105794
- }
105795
- }
105796
- }
105797
105878
  return [{
105798
105879
  currency: "USDC",
105799
105880
  total,
105800
- available: total - locked,
105801
- // Available for new trades
105802
- locked
105881
+ available: total,
105882
+ // Approximate
105883
+ locked: 0
105803
105884
  }];
105804
105885
  } catch (error) {
105805
- throw error;
105886
+ console.warn("fetchBalance failed via CLOB client", error.message);
105887
+ return [{ currency: "USDC", total: 0, available: 0, locked: 0 }];
105806
105888
  }
105807
105889
  }
105808
105890
  async watchOrderBook(id, limit) {
@@ -106061,9 +106143,9 @@ var require_searchMarkets3 = __commonJS({
106061
106143
  exports2.searchMarkets = searchMarkets;
106062
106144
  var fetchMarkets_1 = require_fetchMarkets3();
106063
106145
  async function searchMarkets(query, params) {
106064
- const fetchLimit = 1e5;
106146
+ const searchLimit = 5e3;
106065
106147
  try {
106066
- const markets = await (0, fetchMarkets_1.fetchMarkets)({ ...params, limit: fetchLimit });
106148
+ const markets = await (0, fetchMarkets_1.fetchMarkets)({ ...params, limit: searchLimit });
106067
106149
  const lowerQuery = query.toLowerCase();
106068
106150
  const searchIn = params?.searchIn || "title";
106069
106151
  const filtered = markets.filter((market) => {
@@ -106802,6 +106884,9 @@ var require_kalshi = __commonJS({
106802
106884
  get name() {
106803
106885
  return "Kalshi";
106804
106886
  }
106887
+ getBaseUrl() {
106888
+ return "https://api.elections.kalshi.com";
106889
+ }
106805
106890
  // ----------------------------------------------------------------------------
106806
106891
  // Helpers
106807
106892
  // ----------------------------------------------------------------------------
@@ -106841,7 +106926,7 @@ var require_kalshi = __commonJS({
106841
106926
  async fetchBalance() {
106842
106927
  const auth = this.ensureAuth();
106843
106928
  const path = "/trade-api/v2/portfolio/balance";
106844
- const baseUrl = "https://trading-api.kalshi.com";
106929
+ const baseUrl = this.getBaseUrl();
106845
106930
  const headers = auth.getHeaders("GET", path);
106846
106931
  try {
106847
106932
  const response = await axios_1.default.get(`${baseUrl}${path}`, { headers });
@@ -106869,7 +106954,7 @@ var require_kalshi = __commonJS({
106869
106954
  async createOrder(params) {
106870
106955
  const auth = this.ensureAuth();
106871
106956
  const path = "/trade-api/v2/portfolio/orders";
106872
- const baseUrl = "https://trading-api.kalshi.com";
106957
+ const baseUrl = this.getBaseUrl();
106873
106958
  const headers = auth.getHeaders("POST", path);
106874
106959
  const isYesSide = params.side === "buy";
106875
106960
  const kalshiOrder = {
@@ -106907,13 +106992,13 @@ var require_kalshi = __commonJS({
106907
106992
  timestamp: new Date(order.created_time).getTime()
106908
106993
  };
106909
106994
  } catch (error) {
106910
- throw error;
106995
+ throw new Error(`${error.response?.data?.error?.message || error.message} (Status: ${error.response?.status} - ${JSON.stringify(error.response?.data || {})})`);
106911
106996
  }
106912
106997
  }
106913
106998
  async cancelOrder(orderId) {
106914
106999
  const auth = this.ensureAuth();
106915
107000
  const path = `/trade-api/v2/portfolio/orders/${orderId}`;
106916
- const baseUrl = "https://trading-api.kalshi.com";
107001
+ const baseUrl = this.getBaseUrl();
106917
107002
  const headers = auth.getHeaders("DELETE", path);
106918
107003
  try {
106919
107004
  const response = await axios_1.default.delete(`${baseUrl}${path}`, { headers });
@@ -106937,7 +107022,7 @@ var require_kalshi = __commonJS({
106937
107022
  async fetchOrder(orderId) {
106938
107023
  const auth = this.ensureAuth();
106939
107024
  const path = `/trade-api/v2/portfolio/orders/${orderId}`;
106940
- const baseUrl = "https://trading-api.kalshi.com";
107025
+ const baseUrl = this.getBaseUrl();
106941
107026
  const headers = auth.getHeaders("GET", path);
106942
107027
  try {
106943
107028
  const response = await axios_1.default.get(`${baseUrl}${path}`, { headers });
@@ -106966,7 +107051,7 @@ var require_kalshi = __commonJS({
106966
107051
  if (marketId) {
106967
107052
  queryParams += `&ticker=${marketId}`;
106968
107053
  }
106969
- const baseUrl = "https://trading-api.kalshi.com";
107054
+ const baseUrl = this.getBaseUrl();
106970
107055
  const headers = auth.getHeaders("GET", basePath);
106971
107056
  try {
106972
107057
  const response = await axios_1.default.get(`${baseUrl}${basePath}${queryParams}`, { headers });
@@ -106991,7 +107076,7 @@ var require_kalshi = __commonJS({
106991
107076
  async fetchPositions() {
106992
107077
  const auth = this.ensureAuth();
106993
107078
  const path = "/trade-api/v2/portfolio/positions";
106994
- const baseUrl = "https://trading-api.kalshi.com";
107079
+ const baseUrl = this.getBaseUrl();
106995
107080
  const headers = auth.getHeaders("GET", path);
106996
107081
  try {
106997
107082
  const response = await axios_1.default.get(`${baseUrl}${path}`, { headers });
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: pmxt
3
- Version: 1.5.2
3
+ Version: 1.5.4
4
4
  Summary: Unified prediction market data API - The ccxt for prediction markets
5
5
  Author: PMXT Contributors
6
6
  License: MIT
@@ -1,15 +1,15 @@
1
- pmxt/__init__.py,sha256=paszN64bZUmov6Xstbx--iHnq7dajljWFQOj8bwTG28,1178
1
+ pmxt/__init__.py,sha256=514Ya5ykWH3muf7V__O3Mdo8u62XFMuVVccY9udTlRw,1178
2
2
  pmxt/client.py,sha256=YEArwWnyDbd5Hb_HxMWXIqsihUD0RZDaTrBZh4hOlq4,34026
3
3
  pmxt/models.py,sha256=-jiQ9mmv_qnF6mzj3DrvNgEA77tE_Pl0RCblM1VbV7o,8581
4
4
  pmxt/server_manager.py,sha256=6uS1LIZ2d5d_K-MtbMUAlCZvbvhZ_iyofKok55HEofc,11606
5
5
  pmxt/_server/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
6
6
  pmxt/_server/bin/pmxt-ensure-server,sha256=kXIond0UbxS52FAVQD7kHmSBaL_s6cbIyapLRr4KZJw,4544
7
7
  pmxt/_server/bin/pmxt-ensure-server.js,sha256=kXIond0UbxS52FAVQD7kHmSBaL_s6cbIyapLRr4KZJw,4544
8
- pmxt/_server/server/bundled.js,sha256=YMUXCGZZZCnoroBJb0VY3mFN_SeMO0TZPWHU-sSUFQI,4229211
9
- pmxt_internal/__init__.py,sha256=g4Xvuf1ct--iqBOJfjonb8NJUDkYzqxyp9B7CWa0Ed4,7578
10
- pmxt_internal/api_client.py,sha256=J77BQ7Qr80D0tSRKLo6f8Uw4hN644FfswtFC7zREtog,27889
8
+ pmxt/_server/server/bundled.js,sha256=OGyrocIIrgT1FLzQ1xJo4c4-rmO3IJMhIpU4oJ22sjs,4232813
9
+ pmxt_internal/__init__.py,sha256=PrpXrNXiMvHMKpJIPUF_9TIlaLReA_f3SQF-q_evsNk,7578
10
+ pmxt_internal/api_client.py,sha256=u3baftkgR0VZRwgGQh4EcIkJeJ3UiTIuJOgm_FQ6aHU,27889
11
11
  pmxt_internal/api_response.py,sha256=eMxw1mpmJcoGZ3gs9z6jM4oYoZ10Gjk333s9sKxGv7s,652
12
- pmxt_internal/configuration.py,sha256=0ZIq43H06952X8CqiYmRQ-jZpBssvlRq3IE3U78Hhgs,18320
12
+ pmxt_internal/configuration.py,sha256=2h6DJrgjaiwNgARfyN4NjKXmsY0c7PUcVfYAiNFwKo8,18320
13
13
  pmxt_internal/exceptions.py,sha256=txF8A7vlan57JS69kFPs-IZF-Qhp7IZobBTJVa4fOaM,6644
14
14
  pmxt_internal/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
15
15
  pmxt_internal/rest.py,sha256=FMj4yaV6XLr842u_ScWHSzQsTFdk0jaUeuWLJoRbogQ,9760
@@ -65,7 +65,7 @@ pmxt_internal/models/unified_market.py,sha256=DoYhiH4HycYGlq858PEeB-CIA7haT6rxmJ
65
65
  pmxt_internal/models/watch_order_book_request.py,sha256=kavGUI-SLz2-Kam_jcJ_h0GDe0-9UkxqCmVsAi6Uios,3726
66
66
  pmxt_internal/models/watch_order_book_request_args_inner.py,sha256=ZHrjmFDGxRG5MXbuz4mUp9KFfo3XS7zuXWTyMNgi4xI,5464
67
67
  pmxt_internal/models/watch_trades_request.py,sha256=brrg8JbEe-aeg7mIe_Y2HzRPogp-IfRhkXChrxzqoLU,3722
68
- pmxt-1.5.2.dist-info/METADATA,sha256=rEfVz-9U84IYfzvtRQjfeQtHnJjs-_KVf9bJZ0xyAyc,6449
69
- pmxt-1.5.2.dist-info/WHEEL,sha256=wUyA8OaulRlbfwMtmQsvNngGrxQHAvkKcvRmdizlJi0,92
70
- pmxt-1.5.2.dist-info/top_level.txt,sha256=J_jrcouJ-x-5lpcXMxeW0GOSi1HsBVR5_PdSfvigVrw,19
71
- pmxt-1.5.2.dist-info/RECORD,,
68
+ pmxt-1.5.4.dist-info/METADATA,sha256=c647vHjvAz-yn2wtXg3xtf6nZCD269MgK3zo7Dfkycg,6449
69
+ pmxt-1.5.4.dist-info/WHEEL,sha256=wUyA8OaulRlbfwMtmQsvNngGrxQHAvkKcvRmdizlJi0,92
70
+ pmxt-1.5.4.dist-info/top_level.txt,sha256=J_jrcouJ-x-5lpcXMxeW0GOSi1HsBVR5_PdSfvigVrw,19
71
+ pmxt-1.5.4.dist-info/RECORD,,
pmxt_internal/__init__.py CHANGED
@@ -14,7 +14,7 @@
14
14
  """ # noqa: E501
15
15
 
16
16
 
17
- __version__ = "1.5.2"
17
+ __version__ = "1.5.4"
18
18
 
19
19
  # Define package exports
20
20
  __all__ = [
@@ -91,7 +91,7 @@ class ApiClient:
91
91
  self.default_headers[header_name] = header_value
92
92
  self.cookie = cookie
93
93
  # Set default User-Agent.
94
- self.user_agent = 'OpenAPI-Generator/1.5.2/python'
94
+ self.user_agent = 'OpenAPI-Generator/1.5.4/python'
95
95
  self.client_side_validation = configuration.client_side_validation
96
96
 
97
97
  def __enter__(self):
@@ -506,7 +506,7 @@ class Configuration:
506
506
  "OS: {env}\n"\
507
507
  "Python Version: {pyversion}\n"\
508
508
  "Version of the API: 0.4.4\n"\
509
- "SDK Package Version: 1.5.2".\
509
+ "SDK Package Version: 1.5.4".\
510
510
  format(env=sys.platform, pyversion=sys.version)
511
511
 
512
512
  def get_host_settings(self) -> List[HostSetting]:
File without changes