Place Basket Order¶
The Place Basket Order endpoint enables the simultaneous execution of multiple buy or sell orders across various instruments by grouping them into a single request.
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.basket_order([
    {
        "ref_id": 70075,
        "request_type": "ORDER_REQUEST_NEW",
        "order_type": OrderTypeEnum.ORDER_TYPE_LIMIT,
        "order_qty": 1,
        "order_price": 720,
        "order_side": OrderSideEnum.ORDER_SIDE_BUY,
        "order_delivery_type": DeliveryTypeEnum.ORDER_DELIVERY_TYPE_CNC,
        "execution_type": ExecutionTypeEnum.STRATEGY_TYPE_LIMIT
    },
    {
        "ref_id": 70076,
        "request_type": "ORDER_REQUEST_NEW",
        "order_type": OrderTypeEnum.ORDER_TYPE_LIMIT,
        "order_qty": 1,
        "order_price": 715,
        "order_side": OrderSideEnum.ORDER_SIDE_BUY,
        "order_delivery_type": DeliveryTypeEnum.ORDER_DELIVERY_TYPE_CNC,
        "execution_type": ExecutionTypeEnum.STRATEGY_TYPE_LIMIT
    }
])
Accessing Data¶
#Get Basket Information
print(f"Basket ID: {result.basket_id}")
print(f"User ID: {result.user_id}")
print(f"Basket Name: {result.basket_name}")
#Order 1 details
print(f"Order 1 ID: {result.orders[0].order_id}")
print(f"Exchange Order ID: {result.orders[0].exchange_order_id}")
print(f"Ref ID: {result.orders[0].ref_id}")
print(f"Display Name: {result.orders[0].display_name}")
#Order 2 details
print(f"Order 2 ID: {result.orders[1].order_id}")
print(f"Exchange Order ID: {result.orders[1].exchange_order_id}")
print(f"Ref ID: {result.orders[1].ref_id}")
print(f"Display Name: {result.orders[1].display_name}")
Request Parameters¶
| Parameter | Type | Required | Description | 
|---|---|---|---|
| orders | array | Yes | Array of order objects | 
Each order object in the array should contain:
| 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 | Price at which order is placed (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 | 
| trigger_price | int | No | Mandatory for STOPLOSS orders (in paise) | 
Response Structure¶
#BasketOrder
class BasketOrderResponse:
  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]
  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[DeliveryTypeEnum]
  trigger_price: Optional[int]
  execution_type: Optional[ExecutionTypeEnum]
class BasketOrderWrapper:
  basket_id: int
  basket_name: Optional[str]
  orders: List[BasketOrderResponse]
Response Attributes¶
| Attribute | Description | 
|---|---|
| basket_id | Unique identifier assigned to the basket | 
| basket_name | (Optional) Name assigned to the basket | 
| orders | List of order responses (see CreateOrderResponse) | 
Note: The basket order response includes a few additional fields like basket_id, basket_name, and user_id. Apart from these, each order inside the orders list follows the same structure as the CreateOrderResponse.