Skip to content

feat(Metaculus): wire Metaculus exchange into package, server, docs, and compliance#71

Merged
realfishsam merged 9 commits intopmxt-dev:mainfrom
0xharryriddle:harry/metaculus-exchange-integration
Apr 4, 2026
Merged

feat(Metaculus): wire Metaculus exchange into package, server, docs, and compliance#71
realfishsam merged 9 commits intopmxt-dev:mainfrom
0xharryriddle:harry/metaculus-exchange-integration

Conversation

@0xharryriddle
Copy link
Copy Markdown
Contributor

Summary

The Metaculus implementation already lived under core/src/exchanges/metaculus/. This PR finishes the integration by exporting it from the public API, registering it on the HTTP sidecar, aligning types and credentials, refreshing compliance and Python wrappers, documenting it in the README, and fixing a Probable/viem typing issue that blocked tsc.


What changed

Metaculus exposure and auth

  • Export MetaculusExchange / Metaculus from core/src/index.ts and add Metaculus to the default pmxt object.
  • ExchangeCredentials: optional apiToken for Metaculus (Authorization: Token …).
  • MetaculusExchange: complete has map for ExchangeHas; short note that the API expects a token (403 when unauthenticated).

HTTP sidecar

  • core/src/server/app.ts: metaculus in singletons and createExchange; per-request instances when credentials.apiToken is present (alongside existing privateKey/apiKey logic).

Compliance

  • core/test/compliance/shared.ts: initExchange passes METACULUS_API_TOKEN for MetaculusExchange.
  • core/scripts/generate-compliance.js: Metaculus column + METACULUS_API_TOKEN in the documented env block; core/COMPLIANCE.md regenerated.

Data / SDK

  • fetchEvents: category supports string or { name } entries.
  • Python Exchange: optional api_tokenapiToken in request credentials; generator updated; _exchanges.py / __init__.py regenerated.

Docs

  • readme.md: Metaculus in Supported Exchanges.

Build fix (non-Metaculus)

  • probable/auth.ts: duplicate viem installs make WalletClient types incompatible; pass wallet into createClobClient with as any plus a comment (runtime unchanged).

Manual verification

With METACULUS_API_TOKEN set (e.g. in repo-root .env) and dotenv loading that file, fetchMarkets succeeds against the live API. Example run from core after npm run build:

◇ injecting env (13) from ../.env
fetchMarkets: 5 Who will be elected US President in 2024? 2

Interpretation: five markets returned; first market title as shown; 2 outcomes on that market (binary-style).

Note: Plain node -e does not load .env. Use DOTENV_CONFIG_PATH=../.env node -r dotenv/config -e "..." from core, export the variable in the shell, or rely on compliance tests / sidecar with env configured.


How to test (for reviewers)

  1. Set METACULUS_API_TOKEN (root .env or environment).
  2. cd core && npm run build
  3. Run a small script or REPL that constructs new Metaculus({ apiToken: process.env.METACULUS_API_TOKEN }) and calls fetchMarkets({ limit: 5 }), with env loaded as above.
  4. Optional: npx jest … --testNamePattern=MetaculusExchange on fetchMarkets / fetchEvents with the same token.

Notes

  • Text search uses fetchMarkets({ query: "…" }), consistent with the unified market API (no separate searchMarkets on the base class).
  • Metaculus remains read-only in has (no trading / OHLCV / order book, etc.).

github-actions bot and others added 8 commits February 25, 2026 00:22
…n auth

- Export MetaculusExchange from core index and pmxt default map; add apiToken
  to ExchangeCredentials for Authorization: Token header.
- Register metaculus on HTTP sidecar; honor apiToken for per-request instances.
- Complete Metaculus has map; document token requirement; fix event category
  when Metaculus returns string or object categories.
- Regenerate COMPLIANCE.md and Python _exchanges (Metaculus + api_token on
  Exchange client); compliance initExchange reads METACULUS_API_TOKEN.
- README: add Metaculus to supported exchanges.
- Probable: cast wallet for createClobClient when duplicate viem installs
  break WalletClient assignability (tsc).

Made-with: Cursor
@realfishsam
Copy link
Copy Markdown
Contributor

Huge! Will review ASAP.

…t data

Add forecast submission (createOrder) and withdrawal (cancelOrder) for
binary and multiple-choice questions. Improve error handling with 403
auth disambiguation, add community prediction extraction with fallbacks,
and support group-of-questions expansion into individual markets.
@realfishsam realfishsam merged commit b4540b5 into pmxt-dev:main Apr 4, 2026
1 of 6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants