Skip to content

feat(rain): add fetchOrderBooks batch order-book fetch#1693

Merged
realfishsam merged 1 commit into
pmxt-dev:mainfrom
JSap0914:fix/1666-rain-fetch-order-books
Jul 18, 2026
Merged

feat(rain): add fetchOrderBooks batch order-book fetch#1693
realfishsam merged 1 commit into
pmxt-dev:mainfrom
JSap0914:fix/1666-rain-fetch-order-books

Conversation

@JSap0914

Copy link
Copy Markdown
Contributor

What

RainExchange had a working single-outcome fetchOrderBook, but the batch
fetchOrderBooks fell through to the base class stub and threw
Method fetchOrderBooks not implemented.. exchange.has.fetchOrderBooks also
reported false.

This adds a fetchOrderBooks(outcomeIds) override that loops the already-working
fetchOrderBook and returns a Record<string, OrderBook> keyed by outcome id.

Why

Rain has no native batch order-book endpoint, so the batch variant is emulated
by fanning out to the single-outcome fetch — the same way fetchOrderBook
itself is already declared 'emulated'. To keep the capability map honest,
fetchOrderBooks is declared 'emulated' in capabilityOverrides (rather than
letting it auto-derive to true), so it stays consistent with the single fetch.

Tests

Added core/test/unit/rain-fetch-order-books.core.test.ts:

  • fetchOrderBooks([...]) calls the single-outcome fetchOrderBook once per id
    (verified via a stub) and returns a record matching those N individual calls.
  • exchange.has.fetchOrderBooks now reports 'emulated' instead of false.
# focused
npx jest -c jest.config.js test/unit/rain-fetch-order-books.core.test.ts
  Tests: 2 passed, 2 total

# full core suite
npx jest -c jest.config.js
  Test Suites: 48 passed, 1 skipped, 49 total
  Tests: 812 passed, 3 skipped, 815 total

# type check
npx tsc --noEmit   # exit 0

# generators (no drift)
node core/scripts/check-exchange-drift.js   # No drift. All layers in sync.
node core/scripts/generate-compliance.js    # COMPLIANCE.md unchanged

Fixes #1666

RainExchange exposed a working single-outcome fetchOrderBook but never
overrode the batch fetchOrderBooks, so calling it threw "Method
fetchOrderBooks not implemented." and has.fetchOrderBooks reported false.

Add a fetchOrderBooks(outcomeIds) override that loops the already-working
single-outcome fetchOrderBook and returns a Record keyed by outcome id.
Declare it as an emulated capability in capabilityOverrides to stay
consistent with fetchOrderBook: 'emulated' (there is no native batch
endpoint), so has.fetchOrderBooks now reports 'emulated'.

Fixes pmxt-dev#1666
@realfishsam
realfishsam merged commit 59abfbe into pmxt-dev:main Jul 18, 2026
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.

Rain missing fetchOrderBooks (batch order-book fetch) despite working single fetchOrderBook

2 participants