---
title: "Calculate Order"
method: POST
path: "/api/order/calculate"
tags: ["US Stock Trading"]
---

# Calculate Order

`POST /api/order/calculate`

## Request

- Base URL: `https://powered-by-bamboo-sandbox.investbamboo.com`
- URL: `https://powered-by-bamboo-sandbox.investbamboo.com/api/order/calculate`
- Auth: none declared. Required headers: `content-type`, `accept-language`, `x-user-id`, `x-subject-type`, `x-client-token`, `x-request-source`

This endpoint estimates the exact order cost, fees, and trade feasibility for the specified order type before execution.  

It supports **Market**, **Limit**, and **Stop** order types and determines the precise values that should be used when placing an actual order.

The values returned guide what to send in the `/api/order` request.

**Integration Flow:**
- First, call this endpoint to calculate the order.
- Then, use the `order_price` from the calculation response as the `total_price` when placing the order.
- All other response fields (e.g., `price_per_share`, `quantity`, `fee`) must be reused exactly as returned.

**Developer Note:**  
- Multiple example payloads are available below. Please **switch to the relevant example (Market, Limit, or Stop)** before copying and testing your request.
- Market order calculation requires `amount`; Limit and Stop order calculation require `price_per_share`, `price`, and `quantity`.
- Recall that **Limit/Stop orders** are *Good Till Canceled (GTC)* or the set `expiration_date` (default of 90 days applies if no expiration is set).

## Headers

- `content-type` string, required
- `accept-language` string, required
- `x-user-id` string, required
- `x-subject-type` string, required
- `x-client-token` string, required
- `x-request-source` string, required
- `currency` string

## Request body

- union
  - MarketOrderRequest
    - `order_type` 'MARKET', required: Market order calculation.
    - `symbol` string, required: Stock ticker symbol
    - `side` 'buy' | 'sell', required: BUY or SELL
    - `amount` number, required: Investment amount for a market order.
    - `sell_all` boolean: set to true if the user wants to sell_all the shares they have for the specified stock symbol.
  - LimitOrderRequest
    - `order_type` 'LIMIT', required: Limit order calculation.
    - `symbol` string, required: Stock ticker symbol
    - `side` 'buy' | 'sell', required: BUY or SELL
    - `price_per_share` number, required: Current price per share at calculation time.
    - `price` number, required: Limit price at which the user wants the order to execute.
    - `quantity` number, required: Whole-share quantity for the limit order.
    - `sell_all` boolean: set to true if the user wants to sell_all the shares they have for the specified stock symbol.
  - StopOrderRequest
    - `order_type` 'STOP', required: Stop order calculation.
    - `symbol` string, required: Stock ticker symbol
    - `side` 'buy' | 'sell', required: BUY or SELL
    - `price_per_share` number, required: Current price per share at calculation time.
    - `price` number, required: Stop price that triggers the order.
    - `quantity` number, required: Whole-share quantity for the stop order.
    - `sell_all` boolean: set to true if the user wants to sell_all the shares they have for the specified stock symbol.

## Response `200`

Calculated order

- CalculatedOrderResponse
  - `quantity` number, required: Calculated quantity
  - `currency_symbol` string, required: Currency symbol based on currency passed in header
  - `price_per_share` number, float, required: Price Per Share for all order
  - `fee` integer, required: calculated fees
  - `order_price` number, required: calculated order price
  - `number_of_violations` integer, required: Number of violations
  - `blocked_quantity` number, required: Blocked quantity for position
  - `gfv_occurs` boolean, required: GFV occurs
  - `total_price` number, required: calculated total price

## Other responses

- `401`: Token have expired or invalid token
- `422`: Error response

---

[API](https://skmtc.dev/investbamboo/apis/investbamboo-bamboo-api.md) - [All operations](https://skmtc.dev/investbamboo/apis/investbamboo-bamboo-api/llms.txt) - [OpenAPI document](https://skmtc.dev/investbamboo/apis/investbamboo-bamboo-api/revisions/063521e8d924?raw)
