Skip to content

PlaceSmartOrder

Place Order Smartly by analyzing the current open position. It matches the Position Size with the given position book. Buy/Sell Signal Orders will be traded accordingly to the Position Size.

Endpoint URL

http
Local Host   :  POST http://127.0.0.1:5000/api/v1/placesmartorder
Ngrok Domain :  POST https://<your-ngrok-domain>.ngrok-free.app/api/v1/placesmartorder
Custom Domain:  POST https://<your-custom-domain>/api/v1/placesmartorder

Sample API Request

json
{
  "apikey": "<your_app_apikey>",
  "strategy": "Test Strategy",
  "exchange": "NSE",
  "symbol": "IDEA",
  "action": "BUY",
  "product": "MIS",
  "pricetype": "MARKET",
  "quantity": "1",
  "position_size": "5",
  "price": "0",
  "trigger_price": "0",
  "disclosed_quantity": "0"
}

Sample cURL Request

bash
curl -X POST http://127.0.0.1:5000/api/v1/placesmartorder \
  -H 'Content-Type: application/json' \
  -d '{
  "apikey": "<your_app_apikey>",
  "strategy": "Test Strategy",
  "exchange": "NSE",
  "symbol": "IDEA",
  "action": "BUY",
  "product": "MIS",
  "pricetype": "MARKET",
  "quantity": "1",
  "position_size": "5",
  "price": "0",
  "trigger_price": "0",
  "disclosed_quantity": "0"
}'

Sample API Response

json
{
  "orderid": "240307000616990",
  "status": "success"
}

Parameters Description

ParametersDescriptionMandatory/OptionalDefault Value
apikeyApp API keyMandatory-
strategyStrategy nameMandatory-
exchangeExchange codeMandatory-
symbolTrading symbolMandatory-
actionAction (BUY/SELL)Mandatory-
productProduct typeOptionalMIS
pricetypePrice typeOptionalMARKET
quantitySignal quantity. Unlike PlaceOrder, 0 is accepted here: it means "only reconcile to position_size"Mandatory-
position_sizeTarget net position, signed. Positive is long, negative is short, 0 is flatMandatory-
pricePriceOptional0
trigger_priceTrigger priceOptional0
disclosed_quantityDisclosed quantityOptional0

These twelve fields are the complete SmartOrderSchema. Any other field returns HTTP 400.

How PlaceSmartOrder API Works?

PlaceSmartOrder API function allows traders to build intelligent trading systems that can automatically place orders based on existing trade positions in the position book.

ActionQty (API)Pos Size (API)Current Open PosAction by Tradeboard
BUY10000No Open Pos Found. Buy +100 qty
BUY100100-100BUY 200 to match Open Pos in API Param
BUY100100100No Action. Position matched
BUY100200100BUY 100 to match Open Pos in API Param
SELL10000No Open Pos Found. SELL 100 qty
SELL100-100+100SELL 200 to match Open Pos in API Param
SELL100-100-100No Action. Position matched
SELL100-200-100SELL 100 to match Open Pos in API Param

Response Fields

FieldTypeDescription
statusstring"success" or "error"
orderidstringUnique order ID from broker (on success)
messagestringError message or "No action needed" if position already at target
modestring"analyze" in analyzer mode. The key is absent in live mode; there is no "mode": "live"

Notes

  • Smart orders are ideal for position-based strategies where you want to maintain a specific position size
  • The position_size represents the absolute target position:
    • Positive values = Long position
    • Negative values = Short position
    • Zero = Flat (no position)
  • If current position already matches target, no order is placed
  • Works across all exchanges and product types
  • Fractional quantities are accepted only for CRYPTO; non-crypto quantities must be whole numbers.
  • Rate limit: SMART_ORDER_RATE_LIMIT, default 10 requests per second

Back to: API Documentation