opinion
opinion prediction-market exchange — CCXT unified API: methods, parameters and endpoints.
opinion
Kind: global class
Extends: Exchange
- fetchMarkets
- fetchEvents
- fetchEvent
- fetchTicker
- fetchTickers
- fetchOrderBook
- fetchOHLCV
- parseOHLCV
- createOrder
- cancelOrder
- parsePredictionOrder
- fetchOrders
- fetchOrder
- fetchOpenOrders
- fetchClosedOrders
- fetchMyTrades
- fetchBalance
- fetchPositions
- createApiKey
- fetchApiKey
- deleteApiKey
- watchOrderBook
- watchTicker
- watchTrades
- watchOrders
- watchMyTrades
fetchMarkets
fetches every kind of opinion market categorical parents double as our unified "events" and are cached into this.events as a side effect
Kind: instance method of opinion
Returns: Array<object> - an array of objects representing market data
See: https://docs.opinion.trade/developer-guide/opinion-open-api/market
| Param | Type | Required | Description |
|---|---|---|---|
| params | object | No | extra parameters specific to the exchange API endpoint |
| params.limit | int | No | max number of markets to collect (defaults to options.marketsPageLimit * options.maxMarketsPages, 1000) |
opinion.fetchMarkets (params?)fetchEvents
fetches Opinion's categorical markets - scope required via query/queries/tags/eventId/slug/labelId
Kind: instance method of opinion
Returns: Array<object> - an array of event structures
See: https://docs.opinion.trade/developer-guide/opinion-open-api/market
| Param | Type | Required | Description |
|---|---|---|---|
| params | object | No | extra parameters specific to the exchange API endpoint |
| params.labelId | int | No | filter by opinion category label id |
| params.limit | int | No | max number of events to fetch (paginated server-side; defaults to options.maxFetchEventsResults, 100) |
opinion.fetchEvents (params?)fetchEvent
fetches a single prediction-market event by its market id, or slug
Kind: instance method of opinion
Returns: object - a prediction event structure
See: https://docs.opinion.trade/developer-guide/opinion-open-api/market
| Param | Type | Required | Description |
|---|---|---|---|
| id | string | Yes | the numeric marketId, or the market slug |
| params | object | No | extra parameters specific to the exchange API endpoint |
opinion.fetchEvent (id, params?)fetchTicker
fetches the latest trade price and top of book for a single outcome token
Kind: instance method of opinion
Returns: object - a prediction ticker structure
See: https://docs.opinion.trade/developer-guide/opinion-open-api/token
| Param | Type | Required | Description |
|---|---|---|---|
| outcome | string | Yes | unified outcome or outcome token id |
| params | object | No | extra parameters specific to the exchange API endpoint |
opinion.fetchTicker (outcome, params?)fetchTickers
fetches tickers for multiple outcome tokens - opinion has no all-tickers endpoint, each token needs its own latest-price + orderbook request
Kind: instance method of opinion
Returns: object - a dictionary of prediction ticker structures indexed by outcome
See: https://docs.opinion.trade/developer-guide/opinion-open-api/token
| Param | Type | Required | Description |
|---|---|---|---|
| outcomes | Array<string> | Yes | unified outcomes or outcome token ids - required, opinion has no all-tickers endpoint |
| params | object | No | extra parameters specific to the exchange API endpoint |
opinion.fetchTickers (outcomes, params?)fetchOrderBook
fetches the order book for a single outcome token
Kind: instance method of opinion
Returns: object - a prediction order book structure
See: https://docs.opinion.trade/developer-guide/opinion-open-api/token
| Param | Type | Required | Description |
|---|---|---|---|
| outcome | string | Yes | unified outcome or outcome token id |
| limit | int | No | not used by opinion fetchOrderBook |
| params | object | No | extra parameters specific to the exchange API endpoint |
opinion.fetchOrderBook (outcome, limit?, params?)fetchOHLCV
fetches historical candlestick data for an outcome token
Kind: instance method of opinion
Returns: Array<Array<int>> - a list of candles ordered as timestamp, open, high, low, close, volume
See: https://docs.opinion.trade/developer-guide/opinion-open-api/token
| Param | Type | Required | Description |
|---|---|---|---|
| outcome | string | Yes | unified outcome or outcome token id |
| timeframe | string | Yes | the length of time each candle represents - only '1h' and '1d' are supported live |
| since | int | No | timestamp in ms of the earliest candle to fetch |
| limit | int | No | the maximum number of candles to return |
| params | object | No | extra parameters specific to the exchange API endpoint |
opinion.fetchOHLCV (outcome, timeframe, since?, limit?, params?)parseOHLCV
parses a single opinion price-history point into a unified OHLCV candle
Kind: instance method of opinion
Returns: Array<int> - a candle ordered as timestamp, open, high, low, close, volume
| Param | Type | Required | Description |
|---|---|---|---|
| ohlcv | object | Yes | the raw { p, t } point |
| market | object | No | the outcome object the candle belongs to |
opinion.parseOHLCV (ohlcv, market?)createOrder
places a limit or market order on the CLOB for the given outcome token
Kind: instance method of opinion
Returns: object - a prediction order structure
See: https://docs.opinion.trade/developer-guide/opinion-open-api/order
| Param | Type | Required | Description |
|---|---|---|---|
| outcome | string | Yes | unified outcome or outcome token id |
| type | string | Yes | 'market' or 'limit' |
| side | string | Yes | 'buy' or 'sell' |
| amount | float | Yes | for limit orders, the number of outcome shares to trade; for market orders, the quote (USDT) to spend on a BUY or the shares to sell on a SELL |
| price | float | No | the price per outcome token between 0 and 1; required for limit orders and market SELL orders (where it acts as the reference / worst acceptable price for the taker amount); ignored for market BUY orders (amount is already the quote to spend) |
| params | object | No | extra parameters specific to the exchange API endpoint |
| params.postOnly | bool | No | limit orders only - reject the order if it would cross the spread |
opinion.createOrder (outcome, type, side, amount, price?, params?)cancelOrder
cancels a single open order by id
Kind: instance method of opinion
Returns: object - a prediction order structure
See: https://docs.opinion.trade/developer-guide/opinion-open-api/order
| Param | Type | Required | Description |
|---|---|---|---|
| id | string | Yes | the order id |
| outcome | string | No | not used by opinion cancelOrder |
| params | object | No | extra parameters specific to the exchange API endpoint |
opinion.cancelOrder (id, outcome?, params?)parsePredictionOrder
parses a raw opinion order object into a unified prediction order structure
Kind: instance method of opinion
Returns: object - a prediction order structure
| Param | Type | Required | Description |
|---|---|---|---|
| order | object | Yes | the raw opinion OrderData object |
| market | object | No | the outcome object the order belongs to |
opinion.parsePredictionOrder (order, market?)fetchOrders
fetches all of the authenticated user's orders
Kind: instance method of opinion
Returns: Array<object> - a list of prediction order structures
See: https://docs.opinion.trade/developer-guide/opinion-open-api/order
| Param | Type | Required | Description |
|---|---|---|---|
| outcome | string | No | filter by unified outcome or outcome token id |
| since | int | No | timestamp in ms of the earliest order to fetch |
| limit | int | No | the maximum number of orders to fetch |
| params | object | No | extra parameters specific to the exchange API endpoint |
opinion.fetchOrders (outcome?, since?, limit?, params?)fetchOrder
fetches a single order by id
Kind: instance method of opinion
Returns: object - a prediction order structure
See: https://docs.opinion.trade/developer-guide/opinion-open-api/order
| Param | Type | Required | Description |
|---|---|---|---|
| id | string | Yes | the order id |
| outcome | string | No | unified outcome or outcome token id |
| params | object | No | extra parameters specific to the exchange API endpoint |
opinion.fetchOrder (id, outcome?, params?)fetchOpenOrders
fetches the authenticated user's open orders
Kind: instance method of opinion
Returns: Array<object> - a list of prediction order structures
See: https://docs.opinion.trade/developer-guide/opinion-open-api/order
| Param | Type | Required | Description |
|---|---|---|---|
| outcome | string | No | filter by unified outcome or outcome token id |
| since | int | No | timestamp in ms of the earliest order to fetch |
| limit | int | No | the maximum number of orders to fetch |
| params | object | No | extra parameters specific to the exchange API endpoint |
opinion.fetchOpenOrders (outcome?, since?, limit?, params?)fetchClosedOrders
fetches the authenticated user's closed orders
Kind: instance method of opinion
Returns: Array<object> - a list of prediction order structures
See: https://docs.opinion.trade/developer-guide/opinion-open-api/order
| Param | Type | Required | Description |
|---|---|---|---|
| outcome | string | No | filter by unified outcome or outcome token id |
| since | int | No | timestamp in ms of the earliest order to fetch |
| limit | int | No | the maximum number of orders to fetch |
| params | object | No | extra parameters specific to the exchange API endpoint |
opinion.fetchClosedOrders (outcome?, since?, limit?, params?)fetchMyTrades
fetches the authenticated user's trades
Kind: instance method of opinion
Returns: Array<object> - a list of prediction trade structures
See: https://docs.opinion.trade/developer-guide/opinion-open-api/trade
| Param | Type | Required | Description |
|---|---|---|---|
| outcome | string | No | filter by unified outcome or outcome token id |
| since | int | No | timestamp in ms of the earliest trade to fetch |
| limit | int | No | the maximum number of trades to fetch |
| params | object | No | extra parameters specific to the exchange API endpoint |
opinion.fetchMyTrades (outcome?, since?, limit?, params?)fetchBalance
fetches the authenticated user's quote-token balances
Kind: instance method of opinion
Returns: object - a balance structure
See: https://docs.opinion.trade/developer-guide/opinion-open-api/quote-token
| Param | Type | Required | Description |
|---|---|---|---|
| params | object | No | extra parameters specific to the exchange API endpoint |
opinion.fetchBalance (params?)fetchPositions
fetches the authenticated user's open positions
Kind: instance method of opinion
Returns: Array<object> - a list of prediction position structures
See: https://docs.opinion.trade/developer-guide/opinion-open-api/position
| Param | Type | Required | Description |
|---|---|---|---|
| outcomes | Array<string> | No | filter by unified outcomes or outcome token ids |
| params | object | No | extra parameters specific to the exchange API endpoint |
opinion.fetchPositions (outcomes?, params?)createApiKey
self-service creation of an Open API key linked to this.walletAddress via an EIP-712-signed request - there is no "generate key" button in the Opinion GUI, this is the only documented way to obtain a wallet-linked key
Kind: instance method of opinion
Returns: object - the api credentials { apiKey, walletAddress }
See: https://docs.opinion.trade/developer-guide/opinion-open-api/authentication
| Param | Type | Required | Description |
|---|---|---|---|
| params | object | No | extra parameters |
opinion.createApiKey (params?)fetchApiKey
fetches the currently active Open API key for this.walletAddress
Kind: instance method of opinion
Returns: object - the api credentials { apiKey, walletAddress }
See: https://docs.opinion.trade/developer-guide/opinion-open-api/authentication
| Param | Type | Required | Description |
|---|---|---|---|
| params | object | No | extra parameters |
opinion.fetchApiKey (params?)deleteApiKey
revokes the Open API key for this.walletAddress
Kind: instance method of opinion
Returns: object - raw response, result.deleted confirms revocation
See: https://docs.opinion.trade/developer-guide/opinion-open-api/authentication
| Param | Type | Required | Description |
|---|---|---|---|
| params | object | No | extra parameters |
opinion.deleteApiKey (params?)watchOrderBook
streams the order book of an outcome token; the channel is delta-only so the live book is seeded from the REST snapshot
Kind: instance method of opinion
Returns: object - a prediction order book structure
See: https://docs.opinion.trade/developer-guide/opinion-websocket/market-channels
| Param | Type | Required | Description |
|---|---|---|---|
| outcome | string | Yes | unified outcome or outcome token id |
| limit | int | No | the maximum number of order book entries to return |
| params | object | No | extra parameters specific to the exchange API endpoint |
opinion.watchOrderBook (outcome, limit?, params?)watchTicker
streams last-price updates of an outcome token
Kind: instance method of opinion
Returns: object - a prediction ticker structure
See: https://docs.opinion.trade/developer-guide/opinion-websocket/market-channels
| Param | Type | Required | Description |
|---|---|---|---|
| outcome | string | Yes | unified outcome or outcome token id |
| params | object | No | extra parameters specific to the exchange API endpoint |
opinion.watchTicker (outcome, params?)watchTrades
streams public trades of an outcome token
Kind: instance method of opinion
Returns: Array<object> - a list of prediction trade structures
See: https://docs.opinion.trade/developer-guide/opinion-websocket/market-channels
| Param | Type | Required | Description |
|---|---|---|---|
| outcome | string | Yes | unified outcome or outcome token id |
| since | int | No | timestamp in ms of the earliest trade to return |
| limit | int | No | the maximum number of trades to return |
| params | object | No | extra parameters specific to the exchange API endpoint |
opinion.watchTrades (outcome, since?, limit?, params?)watchOrders
streams the authenticated user's order updates of one market - the venue channel is per-market, so the outcome argument is required
Kind: instance method of opinion
Returns: Array<object> - a list of prediction order structures
See: https://docs.opinion.trade/developer-guide/opinion-websocket/user-channels
| Param | Type | Required | Description |
|---|---|---|---|
| outcome | string | Yes | unified outcome or outcome token id whose market to watch |
| since | int | No | timestamp in ms of the earliest order to return |
| limit | int | No | the maximum number of orders to return |
| params | object | No | extra parameters specific to the exchange API endpoint |
opinion.watchOrders (outcome, since?, limit?, params?)watchMyTrades
streams the authenticated user's executed trades of one market - the venue channel is per-market, so the outcome argument is required
Kind: instance method of opinion
Returns: Array<object> - a list of prediction trade structures
See: https://docs.opinion.trade/developer-guide/opinion-websocket/user-channels
| Param | Type | Required | Description |
|---|---|---|---|
| outcome | string | Yes | unified outcome or outcome token id whose market to watch |
| since | int | No | timestamp in ms of the earliest trade to return |
| limit | int | No | the maximum number of trades to return |
| params | object | No | extra parameters specific to the exchange API endpoint |
opinion.watchMyTrades (outcome, since?, limit?, params?)