Skip to content

Place Order

The Place Order endpoint allows you to execute a single buy or sell order by specifying essential parameters such as the instrument, quantity, price, order type, and execution type.

Usage

from nubra_python_sdk.start_sdk import InitNubraSdk, NubraEnv
from nubra_python_sdk.trading.trading_data import NubraTrader
from nubra_python_sdk.trading.trading_enum import (
    DeliveryTypeEnum, 
    OrderSideEnum, 
    OrderStatusEnum, 
    OrderTypeEnum, 
    ExecutionTypeEnum
)

# Initialize the Nubra SDK client
# Use NubraEnv.UAT for testing or NubraEnv.PROD for production
nubra = InitNubraSdk(NubraEnv.UAT)  # or NubraEnv.PROD

##using totp login and .env file 
#nubra = InitNubraSdk(NubraEnv.UAT, totp_login= True ,env_creds = True)

trade = NubraTrader(nubra,version= "V1")

result = trade.create_order({
    "ref_id": 70075,
    "request_type": "ORDER_REQUEST_NEW",
    "order_type": OrderTypeEnum.ORDER_TYPE_LIMIT,
    "order_qty": 1,
    "order_price": 72000, #in paise
    "order_side": OrderSideEnum.ORDER_SIDE_BUY,
    "order_delivery_type": DeliveryTypeEnum.ORDER_DELIVERY_TYPE_CNC,
    "execution_type": ExecutionTypeEnum.STRATEGY_TYPE_LIMIT
})

Accessing Data

#Get order details
print(f"Order ID: {result.root[0].order_id}")
print(f"Exchange Order ID: {result.root[0].exchange_order_id}")
print(f"Reference ID: {result.root[0].ref_id}")
print(f"Display Name: {result.root[0].display_name}")

Request Parameters

Parameter Type Required Description
ref_id int Yes The instrument reference id received from Instrument API (e.g., "69353")
request_type str Yes Always use ORDER_REQUEST_NEW
order_type enum Yes ORDER_TYPE_LIMIT / ORDER_TYPE_MARKET
order_qty int Yes Quantity of contracts or shares
order_price int Yes The limit price for the order. The order will only execute at this price or better (in paise)
order_side enum Yes ORDER_SIDE_BUY or ORDER_SIDE_SELL
order_delivery_type enum Yes ORDER_DELIVERY_TYPE_IDAY, ORDER_DELIVERY_TYPE_CNC
execution_type enum Yes Strategy type – MARKET, LIMIT, IOC, etc.
leg_size int No Required for ICEBERG strategy. The size of each visible portion (leg) of the order. This is the quantity that will be exposed to the market at one time.
Note: The total order quantity must be greater than the leg_size (and usually an integer multiple of leg_size).
trigger_price int No Required only for STOPLOSS orders. The price at which the stop order is triggered/activated. For a BUY stop-loss order, the trigger price must be less than or equal to the order price. For a SELL stop-loss order, the trigger price must be greater than or equal to the order price (in paise)

Execution Strategy Types

In our trading API, the execution type determines how an order is executed. Below is a detailed explanation of each supported strategy type, including its behavior and required parameters.

Strategy Type Description
STRATEGY_TYPE_LIMIT A Limit Order strategy executes a buy or sell at a specific price (the limit) or better. This means a buy order will execute at the limit price or lower, and a sell order will execute at the limit price or higher. Limit orders guarantee the price but not the execution – the order will only fill if the market reaches the specified price.
STRATEGY_TYPE_MARKET A Market Order strategy executes immediately against the best available prices in the market.
STRATEGY_TYPE_IOC An Immediate-Or-Cancel (IOC) strategy is a time-in-force instruction that attempts to execute all or part of the order immediately and cancels any portion that remains unfilled. In practice, an IOC order will match against available orders in the market instantaneously. If it can only be partially filled, it will do so and cancel the rest; if it cannot be filled at all in that moment, it is canceled entirely.
STRATEGY_TYPE_ICEBERG An Iceberg Order strategy allows you to place a large order while only revealing a small portion of it at any given time. The order is divided into smaller chunks (called legs), which are placed sequentially. Only the leg currently being executed is visible in the order book, while the rest of the order remains hidden – much like the bulk of an iceberg is hidden. When one leg is fully executed, the next leg (another portion of the order) is automatically placed, until the entire order quantity is traded.
STRATEGY_TYPE_STOPLOSS A Stop-Loss strategy is a conditional order designed to trigger once the market reaches a certain price, in order to limit losses or to initiate a trade when a level is breached. In our API, this is implemented as a Stop-Limit order: you specify a trigger price and a limit price. The order remains inactive until the trigger price is reached in the market; once that happens, the system will place a limit order at the given order_price.

Execution Type Requirements

Execution Type Additional Required Fields Order Type
STRATEGY_TYPE_LIMIT order_price ORDER_TYPE_LIMIT
STRATEGY_TYPE_MARKET ORDER_TYPE_MARKET
STRATEGY_TYPE_IOC order_price ORDER_TYPE_LIMIT
STRATEGY_TYPE_ICEBERG order_price, leg_size ORDER_TYPE_LIMIT
STRATEGY_TYPE_STOPLOSS order_price, trigger_price ORDER_TYPE_LIMIT

Misconfiguring required fields will result in validation errors or rejections.

Response Structure

class CreateOrderResponse:
    order_id: int
    exchange_order_id: Optional[int]
    ref_id: Optional[int]
    display_name: Optional[str]
    order_type: Optional[str]
    order_side: Optional[OrderSideEnum]
    order_price: Optional[int]
    order_qty: Optional[int]
    leg_size: Optional[int]
    filled_qty: Optional[int]
    avg_filled_price: Optional[int]
    order_status: Optional[OrderStatusEnum]
    last_modified: Optional[int] 
    last_traded_price: Optional[int] 
    order_delivery_type: Optional[DeliverySideEnum]
    trigger_price: Optional[int]
    execution_type: Optional[ExecutionTypeEnum]
    max_prate: Optional[int]

Response Attributes

Attribute Description
order_id Unique ID of the order
exchange_order_id order ID assigned by the exchange
ref_id The instrument reference id received from Instrument API (e.g., "69353")
display_name Represents the internal name of the traded instrument
order_type Type of order (Limit, Market)
order_side Buy or Sell
order_price Price at which order is placed
order_qty Total quantity ordered
leg_size Size of each leg in the order
filled_qty Quantity already filled
avg_filled_price Average price of filled quantity
order_status Current status of the order
last_modified Last modification time
last_traded_price Last traded price of the instrument
order_delivery_type CNC, Intraday
trigger_price Trigger price for stop-loss orders
execution_type Execution mode

Enum Reference

In the context of the Orders API, enums specify permissible values for various order parameters.

class OrderSideEnum(str, Enum):
    ORDER_SIDE_BUY= "ORDER_SIDE_BUY"
    ORDER_SIDE_SELL= "ORDER_SIDE_SELL"

class ExecutionTypeEnum(str, Enum):
    """Enumerates execution types for orders."""
    STRATEGY_TYPE_LIMIT= "STRATEGY_TYPE_LIMIT"
    STRATEGY_TYPE_MARKET= "STRATEGY_TYPE_MARKET"
    STRATEGY_TYPE_IOC= "STRATEGY_TYPE_IOC"
    STRATEGY_TYPE_ICEBERG= "STRATEGY_TYPE_ICEBERG"
    STRATEGY_TYPE_STOPLOSS= "STRATEGY_TYPE_STOPLOSS"

class DeliveryTypeEnum(str, Enum):
    """Enumerates delivery types for orders."""
    ORDER_DELIVERY_TYPE_IDAY= "ORDER_DELIVERY_TYPE_IDAY"
    ORDER_DELIVERY_TYPE_CNC= "ORDER_DELIVERY_TYPE_CNC"

class OrderTypeEnum(str, Enum):
    """Enumerates types of orders."""
    ORDER_TYPE_LIMIT= "ORDER_TYPE_LIMIT"
    ORDER_TYPE_MARKET= "ORDER_TYPE_MARKET"

class OrderStatusEnum(str, Enum):
    ORDER_STATUS_PENDING = "ORDER_STATUS_PENDING"
    ORDER_STATUS_SENT = "ORDER_STATUS_SENT"
    ORDER_STATUS_OPEN = "ORDER_STATUS_OPEN"
    ORDER_STATUS_REJECTED = "ORDER_STATUS_REJECTED"
    ORDER_STATUS_CANCELLED = "ORDER_STATUS_CANCELLED"
    ORDER_STATUS_FILLED = "ORDER_STATUS_FILLED"
    ORDER_STATUS_EXPIRED = "ORDER_STATUS_EXPIRED"
    ORDER_STATUS_TRIGGERED = "ORDER_STATUS_TRIGGERED"
    ORDER_STATUS_PARTIAL_FILLED = "ORDER_STATUS_PARTIAL_FILLED" 

Note:

All order types are supported for NSE orders.

However, for BSE orders, currently STRATEGY_TYPE_LIMIT and STRATEGY_TYPE_MARKET is supported.