From 9f2e4cc5727a8ebc445afe000c15787c9b735016 Mon Sep 17 00:00:00 2001 From: Michael Villari <147255440+mikevillari@users.noreply.github.com> Date: Wed, 9 Sep 2026 00:30:44 -0400 Subject: [PATCH 1/2] docs: use native package for core error examples --- core/docs/ERRORS.md | 32 +++++++++++++++++--------------- 1 file changed, 17 insertions(+), 15 deletions(-) diff --git a/core/docs/ERRORS.md b/core/docs/ERRORS.md index 76456844..d371cd81 100644 --- a/core/docs/ERRORS.md +++ b/core/docs/ERRORS.md @@ -2,6 +2,8 @@ PMXT implements CCXT-style unified error handling across supported exchanges and venues. All errors follow a consistent structure with HTTP status codes, error codes, and retry semantics. +This guide describes the native TypeScript library (`npm install pmxt-core`). Its `BaseError`, `NotFound`, and `status` property belong to `pmxt-core`. The sidecar TypeScript SDK (`pmxtjs`) instead exports `PmxtError` and `NotFoundError`; see the [SDK error reference](../../docs/api-reference/errors.mdx) for that API. + ## Table of Contents - [Error Class Hierarchy](#error-class-hierarchy) @@ -21,7 +23,7 @@ All PMXT errors extend from `BaseError`, which provides consistent properties ac Generic bad request error. Base class for more specific validation errors. ```typescript -import { BadRequest } from 'pmxt'; +import { BadRequest } from 'pmxt-core'; throw new BadRequest('Invalid parameter', 'Polymarket'); ``` @@ -30,7 +32,7 @@ throw new BadRequest('Invalid parameter', 'Polymarket'); Authentication credentials are missing or invalid. ```typescript -import { AuthenticationError } from 'pmxt'; +import { AuthenticationError } from 'pmxt-core'; throw new AuthenticationError('Invalid API key', 'Polymarket'); ``` @@ -39,7 +41,7 @@ throw new AuthenticationError('Invalid API key', 'Polymarket'); The authenticated user doesn't have permission for this operation. ```typescript -import { PermissionDenied } from 'pmxt'; +import { PermissionDenied } from 'pmxt-core'; throw new PermissionDenied('Insufficient permissions', 'Kalshi'); ``` @@ -48,7 +50,7 @@ throw new PermissionDenied('Insufficient permissions', 'Kalshi'); The requested resource doesn't exist. ```typescript -import { NotFound, OrderNotFound, MarketNotFound } from 'pmxt'; +import { NotFound, OrderNotFound, MarketNotFound } from 'pmxt-core'; // Generic not found throw new NotFound('Resource not found', 'Limitless'); @@ -64,7 +66,7 @@ throw new MarketNotFound('market-456', 'Kalshi'); Rate limit exceeded. This error is retryable and may include `retryAfter` seconds. ```typescript -import { RateLimitExceeded } from 'pmxt'; +import { RateLimitExceeded } from 'pmxt-core'; // With retry-after header throw new RateLimitExceeded('Too many requests', 60, 'Polymarket'); @@ -77,7 +79,7 @@ throw new RateLimitExceeded('Rate limit exceeded', undefined, 'Kalshi'); Order parameters are invalid (price, size, tick size, etc.). ```typescript -import { InvalidOrder } from 'pmxt'; +import { InvalidOrder } from 'pmxt-core'; throw new InvalidOrder('Invalid tick size: must be 0.01', 'Polymarket'); ``` @@ -86,7 +88,7 @@ throw new InvalidOrder('Invalid tick size: must be 0.01', 'Polymarket'); Insufficient funds to complete the operation. ```typescript -import { InsufficientFunds } from 'pmxt'; +import { InsufficientFunds } from 'pmxt-core'; throw new InsufficientFunds('Insufficient balance: need $100, have $50', 'Kalshi'); ``` @@ -95,7 +97,7 @@ throw new InsufficientFunds('Insufficient balance: need $100, have $50', 'Kalshi Input validation failed. Includes optional `field` property. ```typescript -import { ValidationError } from 'pmxt'; +import { ValidationError } from 'pmxt-core'; throw new ValidationError('ID cannot be empty', 'id'); ``` @@ -106,7 +108,7 @@ throw new ValidationError('ID cannot be empty', 'id'); Network connectivity issues. This error is retryable. ```typescript -import { NetworkError } from 'pmxt'; +import { NetworkError } from 'pmxt-core'; throw new NetworkError('Connection timeout', 'Polymarket'); ``` @@ -115,7 +117,7 @@ throw new NetworkError('Connection timeout', 'Polymarket'); Exchange is down or unreachable. This error is retryable. ```typescript -import { ExchangeNotAvailable } from 'pmxt'; +import { ExchangeNotAvailable } from 'pmxt-core'; throw new ExchangeNotAvailable('Exchange is temporarily unavailable', 'Limitless'); ``` @@ -163,7 +165,7 @@ Additional properties for specific errors: ### Basic Error Handling ```typescript -import { Polymarket, AuthenticationError, InsufficientFunds } from 'pmxt'; +import { Polymarket, AuthenticationError, InsufficientFunds } from 'pmxt-core'; const exchange = new Polymarket({ privateKey: '0x...' }); @@ -190,9 +192,9 @@ try { ### Retry Logic for Retryable Errors ```typescript -import { Polymarket, BaseError, RateLimitExceeded } from 'pmxt'; +import { Polymarket, BaseError, RateLimitExceeded } from 'pmxt-core'; -async function fetchMarketsWithRetry(exchange: Polymarket, maxRetries = 3) { +async function fetchMarketsWithRetry(exchange: InstanceType, maxRetries = 3) { let retries = 0; while (retries < maxRetries) { @@ -291,7 +293,7 @@ Uses CLOB client (similar to Polymarket): ### Before (v1.6.0 and earlier) ```typescript -import { Polymarket } from 'pmxt'; +import { Polymarket } from 'pmxt-core'; const exchange = new Polymarket({ privateKey: '0x...' }); @@ -310,7 +312,7 @@ try { ### After (v1.7.0+) ```typescript -import { Polymarket, NetworkError, AuthenticationError, BaseError } from 'pmxt'; +import { Polymarket, NetworkError, AuthenticationError, BaseError } from 'pmxt-core'; const exchange = new Polymarket({ privateKey: '0x...' }); From 49691f001aa9ea48fab615f975350927f44eba16 Mon Sep 17 00:00:00 2001 From: Michael Villari <147255440+mikevillari@users.noreply.github.com> Date: Wed, 9 Sep 2026 00:32:13 -0400 Subject: [PATCH 2/2] docs: correct Kalshi TypeScript SDK initialization --- core/docs/SETUP_KALSHI.md | 26 ++++++++++++-------------- 1 file changed, 12 insertions(+), 14 deletions(-) diff --git a/core/docs/SETUP_KALSHI.md b/core/docs/SETUP_KALSHI.md index 8de84542..9dd3a6d5 100644 --- a/core/docs/SETUP_KALSHI.md +++ b/core/docs/SETUP_KALSHI.md @@ -90,19 +90,19 @@ balance = kalshi_demo.fetch_balance() ## 5. Initialization (TypeScript) +Install the TypeScript SDK with `npm install pmxtjs`. Its classes are `Kalshi` and `KalshiDemo`; `KalshiExchange` and `KalshiDemoExchange` are native `pmxt-core` exports. + ```typescript -import { KalshiExchange } from 'pmxt'; +import { Kalshi, KalshiDemo } from 'pmxtjs'; // ── Public data — no credentials needed ────────────────────────────────────── -const kalshi = new KalshiExchange(); -const markets = await kalshi.fetchMarkets({ query: 'Fed rates' }); +const publicKalshi = new Kalshi(); +const markets = await publicKalshi.fetchMarkets({ query: 'Fed rates' }); // ── Production trading ──────────────────────────────────────────────────────── -const kalshi = new KalshiExchange({ - credentials: { - apiKey: process.env.KALSHI_API_KEY, - privateKey: process.env.KALSHI_PRIVATE_KEY, - }, +const kalshi = new Kalshi({ + apiKey: process.env.KALSHI_API_KEY, + privateKey: process.env.KALSHI_PRIVATE_KEY, }); const balance = await kalshi.fetchBalance(); @@ -110,6 +110,7 @@ console.log(`Available: ${balance[0].available}`); const order = await kalshi.createOrder({ marketId: 'FED-25JAN29-B4.75', + outcomeId: 'outcome-id-from-fetchMarkets', // Choose the desired market outcome side: 'buy', type: 'limit', price: 0.55, @@ -118,13 +119,10 @@ const order = await kalshi.createOrder({ // ── Demo / paper-trading environment ───────────────────────────────────────── // Use demo credentials generated on demo.kalshi.com -import { KalshiDemoExchange } from 'pmxt'; -const kalshiDemo = new KalshiDemoExchange({ - credentials: { - apiKey: process.env.KALSHI_API_KEY, // demo API key - privateKey: process.env.KALSHI_PRIVATE_KEY, - }, +const kalshiDemo = new KalshiDemo({ + apiKey: process.env.KALSHI_API_KEY, // demo API key + privateKey: process.env.KALSHI_PRIVATE_KEY, }); const demoBalance = await kalshiDemo.fetchBalance();