Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion core/api-doc-config.generated.json
Original file line number Diff line number Diff line change
Expand Up @@ -1011,4 +1011,4 @@
"python": "import pmxt\nimport os\n\nexchange = pmxt.Polymarket(\n private_key=os.getenv('POLYMARKET_PRIVATE_KEY')\n)\n\n# 1. Check balance\nbalances = exchange.fetch_balance()\nif balances:\n balance = balances[0]\n print(f'Available: ${balance.available}')\n\n# 2. Search for a market\nmarkets = exchange.fetch_markets(query='Trump')\nmarket = markets[0]\noutcome = market.yes\n\nprint(f'{market.title}')\nprint(f'Price: {outcome.price * 100:.1f}%')\n\n# 3. Place a limit order\norder = exchange.create_order(\n market_id=market.market_id,\n outcome_id=outcome.outcome_id,\n side='buy',\n type='limit',\n amount=10,\n price=0.50\n)\n\nprint(f'Order placed: {order.id}')\n\n# 4. Check order status\nupdated_order = exchange.fetch_order(order.id)\nprint(f'Status: {updated_order.status}')\nprint(f'Filled: {updated_order.filled}/{updated_order.amount}')\n\n# 5. Cancel if needed\nif updated_order.status == 'open':\n exchange.cancel_order(order.id)\n print('Order cancelled')\n\n# 6. Check positions\npositions = exchange.fetch_positions()\nfor pos in positions:\n pnl_sign = '+' if pos.unrealized_pnl > 0 else ''\n print(f'{pos.outcome_label}: {pnl_sign}${pos.unrealized_pnl:.2f}')",
"typescript": "import pmxt from 'pmxtjs';\n\nconst exchange = new pmxt.Polymarket({\n privateKey: process.env.POLYMARKET_PRIVATE_KEY\n});\n\n// 1. Check balance\nconst [balance] = await exchange.fetchBalance();\nconsole.log(`Available: $${balance.available}`);\n\n// 2. Search for a market\nconst markets = await exchange.fetchMarkets({ query: 'Trump' });\nconst market = markets[0];\nconst outcome = market.yes;\n\nconsole.log(market.title);\nconsole.log(`Price: ${(outcome.price * 100).toFixed(1)}%`);\n\n// 3. Place a limit order\nconst order = await exchange.createOrder({\n marketId: market.marketId,\n outcomeId: outcome.outcomeId,\n side: 'buy',\n type: 'limit',\n amount: 10,\n price: 0.50\n});\n\nconsole.log(`Order placed: ${order.id}`);\n\n// 4. Check order status\nconst updatedOrder = await exchange.fetchOrder(order.id);\nconsole.log(`Status: ${updatedOrder.status}`);\nconsole.log(`Filled: ${updatedOrder.filled}/${updatedOrder.amount}`);\n\n// 5. Cancel if needed\nif (updatedOrder.status === 'open') {\n await exchange.cancelOrder(order.id);\n console.log('Order cancelled');\n}\n\n// 6. Check positions\nconst positions = await exchange.fetchPositions();\npositions.forEach(pos => {\n console.log(`${pos.outcomeLabel}: ${pos.unrealizedPnL > 0 ? '+' : ''}$${pos.unrealizedPnL.toFixed(2)}`);\n});"
}
}
}
2 changes: 1 addition & 1 deletion core/specs/kalshi/Kalshi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ info:
description: Manually defined OpenAPI spec for endpoints being migrated to spec-first approach

servers:
- url: https://{env}.elections.kalshi.com/trade-api/v2
- url: https://{env}.external-api.kalshi.com/trade-api/v2
description: Kalshi Trade API
variables:
env:
Expand Down
9 changes: 5 additions & 4 deletions core/specs/metaculus/Metaculus.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -431,11 +431,12 @@ components:
must be 1.0, otherwise no more than 0.999 - meaning at least
0.1% of the probability mass must be assigned above the upper bound.<br><br>

At least 1% of the probability mass must be assigned uniformly within
bounds, which means that the CDF must be strictly increasing by at
least 0.01/200 = 0.0005 per step. No two adjacent values of the CDF
can differ by more than 0.59, which is the largest number obtainable
At least 1% of the probability mass must be assigned uniformly within
bounds, which means that the CDF must be strictly increasing by at
least 0.01/200 = 0.0005 per step. No two adjacent values of the CDF
can differ by more than 0.20, which is the largest number obtainable
via the sliders.

type: array
items:
type: number
Expand Down
12 changes: 11 additions & 1 deletion core/specs/myriad/myriad.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -437,7 +437,12 @@ paths:
in: query
schema:
type: string
enum: [open, closed, resolved]
enum: [open, closed, resolved, voided]
- name: trading_model
in: query
description: Filter markets by trading model (e.g. CLOB, AMM)
schema:
type: string
- name: token_address
in: query
schema:
Expand Down Expand Up @@ -1046,6 +1051,11 @@ paths:
in: query
schema:
type: string
- name: trading_model
in: query
description: Filter portfolio results by trading model (e.g. CLOB, AMM)
schema:
type: string
- name: token_address
in: query
schema:
Expand Down
28 changes: 28 additions & 0 deletions core/specs/opinion/opinion-openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -822,6 +822,34 @@ paths:
"400":
$ref: "#/components/responses/BadRequestError"

/market/slug/{slug}:
get:
tags: [Market]
summary: Get market detail by slug
description: Get detailed information about a specific market using its slug
operationId: getMarketDetailBySlug
parameters:
- name: slug
in: path
required: true
description: Market slug
schema:
type: string
responses:
"200":
description: Successful response
content:
application/json:
schema:
allOf:
- $ref: "#/components/schemas/APIBaseResponse"
- type: object
properties:
result:
$ref: "#/components/schemas/MarketDetailResponse"
"400":
$ref: "#/components/responses/BadRequestError"

/market/categorical/{marketId}:
get:
tags: [Market]
Expand Down
55 changes: 49 additions & 6 deletions core/specs/polymarket/PolymarketClobAPI.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,8 @@ components:
type: string
tick_size:
type: string
last_trade_price:
type: string
neg_risk:
type: boolean

Expand Down Expand Up @@ -331,14 +333,24 @@ components:
properties:
success:
type: boolean
errorMsg:
orderID:
type: string
status:
type: string
orderId:
makingAmount:
type: string
orderHashes:
takingAmount:
type: string
transactionsHashes:
type: array
items:
type: string
tradeIDs:
type: array
items:
type: string
errorMsg:
type: string

CancelResponse:
type: object
Expand Down Expand Up @@ -838,6 +850,23 @@ paths:
schema:
$ref: '#/components/schemas/CancelResponse'

/v1/heartbeats:
post:
summary: Refresh authenticated session heartbeat
tags: [Orders]
description: Keep an authenticated Polymarket session or websocket subscription alive.
security:
- L2Auth: []
parameters:
- $ref: '#/components/parameters/L2Headers'
responses:
'200':
description: Heartbeat acknowledged
content:
application/json:
schema:
type: object

/data/order/{id}:
get:
summary: Get Order
Expand Down Expand Up @@ -881,15 +910,29 @@ paths:
in: query
schema:
type: string
- name: next_cursor
in: query
description: Cursor for keyset pagination
schema:
type: string
responses:
'200':
description: List of active orders
content:
application/json:
schema:
type: array
items:
$ref: '#/components/schemas/OpenOrder'
type: object
properties:
limit:
type: integer
next_cursor:
type: string
count:
type: integer
data:
type: array
items:
$ref: '#/components/schemas/OpenOrder'

/data/trades:
get:
Expand Down
26 changes: 16 additions & 10 deletions core/specs/probable/probable.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ components:
type: object
properties:
id:
type: integer
type: string
slug:
type: string
title:
Expand All @@ -223,7 +223,7 @@ components:
type: object
properties:
id:
type: integer
type: string
question:
type: string
market_slug:
Expand Down Expand Up @@ -428,14 +428,9 @@ paths:
content:
application/json:
schema:
type: object
properties:
events:
type: array
items:
$ref: '#/components/schemas/Event'
pagination:
type: object
type: array
items:
$ref: '#/components/schemas/Event'

/public/api/v1/events/{id}:
get:
Expand Down Expand Up @@ -510,6 +505,17 @@ paths:
responses:
'200':
description: List of markets
content:
application/json:
schema:
type: object
properties:
markets:
type: array
items:
$ref: '#/components/schemas/Market'
pagination:
type: object

/public/api/v1/markets/{id}:
get:
Expand Down
6 changes: 3 additions & 3 deletions core/src/exchanges/kalshi/api.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/**
* Auto-generated from /Users/samueltinnerholm/Documents/GitHub/pmxt/.claude/worktrees/agent-a6e1b73d/core/specs/kalshi/Kalshi.yaml
* Generated at: 2026-05-24T14:48:08.117Z
* Auto-generated from /opt/data/repos/pmxt/.worktrees/hermes-42dac47d/core/specs/kalshi/Kalshi.yaml
* Generated at: 2026-06-05T12:40:10.068Z
* Do not edit manually -- run "npm run fetch:openapi" to regenerate.
*/
export const kalshiApiSpec = {
Expand All @@ -11,7 +11,7 @@ export const kalshiApiSpec = {
},
"servers": [
{
"url": "https://{env}.elections.kalshi.com/trade-api/v2",
"url": "https://{env}.external-api.kalshi.com/trade-api/v2",
"variables": {
"env": {
"default": "api",
Expand Down
16 changes: 8 additions & 8 deletions core/src/exchanges/kalshi/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,19 +11,19 @@
* Do NOT put runtime config into api.ts — it will be overwritten.
*
* Environment mapping (aligns with the `{env}` server variable in Kalshi.yaml):
* env = "api" → production: https://api.elections.kalshi.com
* env = "demo-api" → demo/paper: https://demo-api.elections.kalshi.com
* env = "api" → production: https://api.external-api.kalshi.com
* env = "demo-api" → demo/paper: https://demo-api.external-api.kalshi.com
*/

// ── Base URL constants ────────────────────────────────────────────────────────

export const KALSHI_PROD_API_URL = process.env.KALSHI_BASE_URL || "https://api.elections.kalshi.com";
export const KALSHI_DEMO_API_URL = process.env.KALSHI_DEMO_BASE_URL || "https://demo-api.kalshi.co";
export const KALSHI_PROD_API_URL = process.env.KALSHI_BASE_URL || "https://api.external-api.kalshi.com";
export const KALSHI_DEMO_API_URL = process.env.KALSHI_DEMO_BASE_URL || "https://demo-api.external-api.kalshi.com";

export const KALSHI_PROD_WS_URL =
"wss://api.elections.kalshi.com/trade-api/ws/v2";
"wss://api.external-api.kalshi.com/trade-api/ws/v2";
export const KALSHI_DEMO_WS_URL =
"wss://demo-api.kalshi.co/trade-api/ws/v2";
"wss://demo-api.external-api.kalshi.com/trade-api/ws/v2";

// ── Path constants ────────────────────────────────────────────────────────────

Expand Down Expand Up @@ -52,12 +52,12 @@ export interface KalshiApiConfig {
/**
* Return a typed config object for the requested environment.
*
* @param demoMode - Pass `true` to target demo-api.elections.kalshi.com.
* @param demoMode - Pass `true` to target demo-api.external-api.kalshi.com.
*
* @example
* ```typescript
* const config = getKalshiConfig(true);
* // config.apiUrl === "https://demo-api.elections.kalshi.com"
* // config.apiUrl === "https://demo-api.external-api.kalshi.com"
* ```
*/
export function getKalshiConfig(demoMode = false, baseUrlOverride?: string): KalshiApiConfig {
Expand Down
1 change: 0 additions & 1 deletion core/src/exchanges/metaculus/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,6 @@ function buildOutcomes(question: any, postId: string, medianProb: number): Marke
aggregations: latest,
resolution: question?.resolution ?? null,
scaling: question?.scaling ?? null,
possibilities: question?.possibilities ?? null,
};

// Multiple choice: one outcome per option, each independently forecastable
Expand Down
21 changes: 18 additions & 3 deletions core/src/exchanges/myriad/api.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/**
* Auto-generated from /Users/ndmeiri/Developer/pmxt/core/specs/myriad/myriad.yaml
* Generated at: 2026-04-21T22:01:26.565Z
* Auto-generated from /opt/data/repos/pmxt/.worktrees/hermes-42dac47d/core/specs/myriad/myriad.yaml
* Generated at: 2026-06-05T12:40:10.188Z
* Do not edit manually -- run "npm run fetch:openapi" to regenerate.
*/
export const myriadApiSpec = {
Expand Down Expand Up @@ -163,10 +163,18 @@ export const myriadApiSpec = {
"enum": [
"open",
"closed",
"resolved"
"resolved",
"voided"
]
}
},
{
"name": "trading_model",
"in": "query",
"schema": {
"type": "string"
}
},
{
"name": "token_address",
"in": "query",
Expand Down Expand Up @@ -652,6 +660,13 @@ export const myriadApiSpec = {
"type": "string"
}
},
{
"name": "trading_model",
"in": "query",
"schema": {
"type": "string"
}
},
{
"name": "token_address",
"in": "query",
Expand Down
2 changes: 2 additions & 0 deletions core/src/exchanges/myriad/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ export function mapMarketState(state: string): 'active' | 'inactive' | 'closed'
return 'inactive';
case 'resolved':
return 'closed';
case 'voided':
return 'closed';
default:
return 'active';
}
Expand Down
23 changes: 21 additions & 2 deletions core/src/exchanges/opinion/api.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/**
* Auto-generated from /Users/ndmeiri/Developer/pmxt/core/specs/opinion/opinion-openapi.yaml
* Generated at: 2026-04-21T22:01:26.567Z
* Auto-generated from /opt/data/repos/pmxt/.worktrees/hermes-42dac47d/core/specs/opinion/opinion-openapi.yaml
* Generated at: 2026-06-05T12:40:10.198Z
* Do not edit manually -- run "npm run fetch:openapi" to regenerate.
*/
export const opinionApiSpec = {
Expand Down Expand Up @@ -147,6 +147,25 @@ export const opinionApiSpec = {
]
}
},
"/market/slug/{slug}": {
"get": {
"tags": [
"Market"
],
"summary": "Get market detail by slug",
"operationId": "getMarketDetailBySlug",
"parameters": [
{
"name": "slug",
"in": "path",
"required": true,
"schema": {
"type": "string"
}
}
]
}
},
"/market/categorical/{marketId}": {
"get": {
"tags": [
Expand Down
Loading
Loading