POST
/
v1
/
portfolios
/
{portfolio_id}
/
order_preview
Get Order Preview
curl --request POST \
  --url https://api.prime.coinbase.com/v1/portfolios/{portfolio_id}/order_preview \
  --header 'Content-Type: application/json' \
  --data '{
  "product_id": "<string>",
  "side": "BUY",
  "type": "MARKET",
  "base_quantity": "<string>",
  "quote_value": "<string>",
  "limit_price": "<string>",
  "start_time": "2023-11-07T05:31:56Z",
  "expiry_time": "2023-11-07T05:31:56Z",
  "time_in_force": "GOOD_UNTIL_DATE_TIME",
  "is_raise_exact": true,
  "historical_pov": "<string>",
  "stop_price": "<string>",
  "settl_currency": "<string>",
  "postOnly": true,
  "display_quote_size": "100.50",
  "display_base_size": "10.5"
}'
{
  "portfolio_id": "3e1fe27e-26fe-46d8-b118-c752a2ae6b47",
  "product_id": "BTC-USD",
  "side": "BUY",
  "type": "MARKET",
  "base_quantity": "50",
  "quote_value": "100",
  "limit_price": "50.12",
  "start_time": "2021-05-31T09:59:59.000Z",
  "expiry_time": "2021-05-31T10:59:59.000Z",
  "time_in_force": "GOOD_UNTIL_DATE_TIME",
  "commission": "4.99",
  "slippage": "0.05",
  "best_bid": "10",
  "best_ask": "10",
  "average_filled_price": "50.19",
  "order_total": "123",
  "historical_pov": "0.5",
  "is_raise_exact": false,
  "stop_price": "50000.00",
  "display_size": "10.5",
  "display_quote_size": "100.50",
  "display_base_size": "10.5"
}
Use the Prime SDK or CLI to test this endpoint by following the quickstart guide and running with the following examples
OrdersService ordersService = PrimeServiceFactory.createOrdersService(client);

GetOrderPreviewRequest request = new GetOrderPreviewRequest.Builder()
    .portfolioId("PORTFOLIO_ID_HERE")
    .productId("ADA-USD")
    .side(OrderSide.BUY)
    .type(OrderType.MARKET)
    .baseQuantity("10.0")
    .build();

GetOrderPreviewResponse orderResponse = ordersService.getOrderPreview(request);
For more information, please visit the Prime Java SDK.

Path Parameters

portfolio_id
string
required

The ID of the portfolio that owns the order

Body

application/json
product_id
string
required
side
enum<string>
required
  • UNKNOWN_ORDER_SIDE: nil value
  • BUY: Buy order
  • SELL: Sell order
Available options:
BUY,
SELL
type
enum<string>
required
Available options:
MARKET,
LIMIT,
TWAP,
BLOCK,
VWAP,
STOP_LIMIT,
RFQ
base_quantity
string
quote_value
string
limit_price
string
start_time
string<date-time>
expiry_time
string<date-time>
time_in_force
enum<string>
  • UNKNOWN_TIME_IN_FORCE: nil value
  • GOOD_UNTIL_DATE_TIME: Expires at a certain date/time
  • GOOD_UNTIL_CANCELLED: Order stays on the books until cancelled
  • IMMEDIATE_OR_CANCEL: Order is executed immediately at submission or is cancelled
  • FILL_OR_KILL: Order is executed immediately and fully at submission or is cancelled
Available options:
GOOD_UNTIL_DATE_TIME,
GOOD_UNTIL_CANCELLED,
IMMEDIATE_OR_CANCEL,
FILL_OR_KILL
is_raise_exact
boolean
historical_pov
string
stop_price
string
settl_currency
string
postOnly
boolean

Specifies whether the order is treated as a post only order.

display_quote_size
string

The maximum order size that will show up on venue order books (in quote currency).

Example:

"100.50"

display_base_size
string

The maximum order size that will show up on venue order books (in base currency).

Example:

"10.5"

Response

200 - application/json

A successful response.

portfolio_id
string

The ID of the portfolio that owns the order

Example:

"3e1fe27e-26fe-46d8-b118-c752a2ae6b47"

product_id
string

The ID of the product being traded by the order

Example:

"BTC-USD"

side
enum<string>
  • UNKNOWN_ORDER_SIDE: nil value
  • BUY: Buy order
  • SELL: Sell order
Available options:
BUY,
SELL
type
enum<string>
Available options:
MARKET,
LIMIT,
TWAP,
BLOCK,
VWAP,
STOP_LIMIT,
RFQ
base_quantity
string

Order size in base asset units (either base_quantity or quote_value is required)

Example:

"50"

quote_value
string

Order size in quote asset units, i.e. the amount the user wants to spend (when buying) or receive (when selling); the quantity in base units will be determined based on the market liquidity and indicated quote_value. Either base_quantity or quote_value is required

Example:

"100"

limit_price
string

The limit price (required for TWAP, VWAP, LIMIT, and STOP_LIMIT orders)

Example:

"50.12"

start_time
string<date-time>

The start time of the order in UTC (only applies to TWAP orders.)

Example:

"2021-05-31T09:59:59.000Z"

expiry_time
string<date-time>

The expiry time of the order in UTC (TWAP, VWAP, LIMIT and STOP_LIMIT GTD only). Required for TWAP and VWAP orders if historical_pov is unspecified

Example:

"2021-05-31T10:59:59.000Z"

time_in_force
enum<string>
  • UNKNOWN_TIME_IN_FORCE: nil value
  • GOOD_UNTIL_DATE_TIME: Expires at a certain date/time
  • GOOD_UNTIL_CANCELLED: Order stays on the books until cancelled
  • IMMEDIATE_OR_CANCEL: Order is executed immediately at submission or is cancelled
  • FILL_OR_KILL: Order is executed immediately and fully at submission or is cancelled
Available options:
GOOD_UNTIL_DATE_TIME,
GOOD_UNTIL_CANCELLED,
IMMEDIATE_OR_CANCEL,
FILL_OR_KILL
commission
string

Indicate the total commission paid on this order in quote currency - only applicable if the order has any fills

Example:

"4.99"

slippage
string

How much slippage is expected

Example:

"0.05"

best_bid
string

Current best bid for order book

Example:

"10"

best_ask
string

Current best ask for order book

Example:

"10"

average_filled_price
string

Indicate expected average filled price based on the current order book

Example:

"50.19"

order_total
string

Order quantity + fees

Example:

"123"

historical_pov
string

The estimated participation rate for a TWAP/VWAP order. This field can be specified instead of expiry time, and will be used to compute the expiry time of the order based on historical participation rate.

Example:

"0.5"

is_raise_exact
boolean

Raise Exact order flag

Example:

false

stop_price
string

Stop price for the order

Example:

"50000.00"

display_size
string

The maximum order size that will show up on venue order books.

Example:

"10.5"

display_quote_size
string

The maximum order size that will show up on venue order books (in quote currency).

Example:

"100.50"

display_base_size
string

The maximum order size that will show up on venue order books (in base currency).

Example:

"10.5"