Listing Product Pairs

Tradable product pairs are returned by List Products. This endpoint’s response includes all enabled products for a given portfolio, along with crucial details such as minimum/maximum order increments and order book precision. This can be used to validate order parameters, ensure compliance with product constraints, and power trading interfaces or workflows.
ProductsService productsService = PrimeServiceFactory.createProductsService(client);

ListPortfolioProductsRequest request = new ListPortfolioProductsRequest.Builder()
    .portfolioId("PORTFOLIO_ID_HERE")
    .build();

ListPortfolioProductsResponse response = productsService.listPortfolioProducts(request);
To learn more about this SDK, please visit the Prime Java SDK.

Creating a Trade

Trading via the Prime REST API is conducted through the Create Order endpoint. When an order is created, the product (for example, BTC-USD) and the portfolio ID must be specified. The portfolio ID determines which trading balance will be used for debits and credits, and can be obtained from List Portfolios or from the URL of the Prime web UI. Any order algorithm supported in the Prime UI is also available through the Create Order API. Prime supports specifying orders in both base units (e.g., “10 ETH”) and quote units (e.g., “100,000 USD of ETH”).
OrdersService ordersService = PrimeServiceFactory.createOrdersService(client);

CreateOrderRequest request = new CreateOrderRequest.Builder()
    .portfolioId("PORTFOLIO_ID_HERE")
    .productId("ADA-USD")
    .side(OrderSide.BUY)
    .type(OrderType.MARKET)
    .baseQuantity("10.0")
    .clientOrderId(UUID.randomUUID().toString())
    .build());
CreateOrderResponse orderResponse = ordersService.createOrder(request);
To learn more about this SDK, please visit the Prime Java SDK.
An Order Preview can also be submitted, which is useful in scenarios where a preview screen is needed, or to obtain a general idea of trading conditions. This is not a hold.

Tracking an order

When an order is successfully created, the API returns an order ID. This ID can be used to check the current status or attempt to cancel the order. There are multiple ways to track order status:
  • Orders WebSocket: Subscribe to real-time updates for order status and fills via the Orders Websocket
  • Get Order by ID: Poll the Get Order by ID endpoint to retrieve detailed information about the order, including price and quantity details.

Order State

Orders progress through different statuses during their lifecycle. Here are the possible order states:
  1. PENDING - The order has been accepted by Prime but has not yet been placed on the order book
  2. OPEN - The order is active on the order book and available for execution. All order types, including market orders, start in this state before any fills occur. The order remains open until it reaches a terminal state (filled, cancelled, failed, or expired)
  3. FILLED - The order has been completely executed for the full requested quantity
  4. CANCELLED - The order has been cancelled either by client request or by the system. System cancellations may occur when market orders with Immediate or Cancel (IMMEDIATE_OR_CANCEL) instructions cannot be fully executed
  5. FAILED - The order could not be executed and was rejected by the system. This typically occurs with Fill or Kill (FILL_OR_KILL) orders that cannot be immediately filled in their entirety
  6. EXPIRED - The order was not fully executed before reaching its specified expiration time. This applies to time-limited orders, including Good Until Datetime (GOOD_UNTIL_DATE_TIME) limit orders and algorithmic orders such as TWAP/VWAP.
Examples of using Get Order by ID are shown below.
OrdersService ordersService = PrimeServiceFactory.createOrdersService(client);

GetOrderByOrderIdRequest request = new GetOrderByOrderIdRequest.Builder()
    .portfolioId("PORTFOLIO_ID_HERE")
    .orderId("ORDER_ID_HERE")
    .build();

GetOrderByOrderIdResponse response = ordersService.getOrderByOrderId(request);
To learn more about this SDK, please visit the Prime Java SDK.

Orders WebSocket

Highly recommended for both REST and FIX integrations - The Orders WebSocket provides real-time order status updates and fills without the need for polling status from REST. This is the most efficient way to monitor order lifecycle events as they occur. The WebSocket follows the same order state flow detailed above. To subscribe to order updates, you’ll need your Service Account ID, which can be obtained from the Prime UI. For comprehensive information about WebSocket implementation, authentication, and message formats, refer to the WebSocket Feed Overview.

Order Fills

An order can be split into multiple fills. Each fill contains specific details, such as venue that executed the fill. These fills are all tied to the same order ID. Examples of using list Order Fills are shown below.
OrdersService ordersService = PrimeServiceFactory.createOrdersService(client);

ListOrderFillsRequest request = new ListOrderFillsRequest.Builder()
    .portfolioId("PORTFOLIO_ID_HERE")
    .orderId("ORDER_ID_HERE")
.build();

ListOrderFillsResponse response = ordersService.listOrderFills(request);
To learn more about this SDK, please visit the Prime Java SDK.

Cancelling an order

If an order is still open, a cancellation may be attempted via Cancel Order. Note that a cancellation request does not guarantee a successful cancellation because the order status could change at any time (e.g., it may fill before the cancel request is processed).
OrdersService ordersService = PrimeServiceFactory.cancelOrdersService(client);

CancelOrderRequest request = new CancelOrderRequest.Builder()
    .portfolioId("PORTFOLIO_ID_HERE")
    .orderId("ORDER_ID_HERE")
.build());

CancelOrderResponse orderResponse = ordersService.cancelOrder(request);
To learn more about this SDK, please visit the Prime Java SDK.