Groww LogoGroww API

Smart Orders

Automate entry and exit strategies with Smart Orders using GTT and OCO orders. This guide demonstrates creating, modifying, canceling, and managing smart orders for CASH and F&O segments.

Smart Orders help you automate entries/exits with minimal code. Two types are supported:

  • GTT (Good Till Triggered): Triggers a single order when price crosses your trigger
  • OCO (One Cancels the Other): Places target and stop-loss together; execution of one cancels the other

Create GTT

Create a GTT that arms a single order when your trigger condition is met.

Python SDK Usage

from growwapi import GrowwAPI
 
# Groww API Credentials (Replace with your actual credentials)
API_AUTH_TOKEN = "your_token"
 
# Initialize Groww API
groww = GrowwAPI(API_AUTH_TOKEN)
 
gtt_response = groww.create_smart_order(
    smart_order_type=groww.SMART_ORDER_TYPE_GTT,
    reference_id="gtt-ref-unique123",
    segment=groww.SEGMENT_CASH,
    trading_symbol="TCS",
    quantity=10,
    product_type=groww.PRODUCT_CNC,
    exchange=groww.EXCHANGE_NSE,
    duration=groww.VALIDITY_DAY,
    # GTT-specific parameters
    trigger_price="3985.00",
    trigger_direction=groww.TRIGGER_DIRECTION_DOWN,
    order={
        "order_type": groww.ORDER_TYPE_LIMIT,
        "price": "3990.00",
        "transaction_type": groww.TRANSACTION_TYPE_BUY
    }
)
print(gtt_response)

Parameters

NameTypeDescription
smart_order_type *strSet to GTT to create a Good-Till-Triggered smart order. Example: GTT.
reference_id *strUser-provided alphanumeric string (8-20 characters) that serves as an idempotency key, with at most two hyphens (-) allowed.
segment *strSegment for which the order will be placed. See Segment. Examples: CASH, FNO.
trading_symbol *strTrading Symbol of the instrument as defined by the exchange
quantity *intQuantity for the post-trigger order. For FNO, must respect lot size. Examples: 10, 50.
trigger_price *strTrigger price as a decimal string. Example: "3985.00".
trigger_direction *strDirection to monitor relative to the trigger price. Examples: UP, DOWN.
order *dictPost-trigger order details
order["order_type"] *strPost-trigger execution order type. See Order type. Examples: LIMIT, SL.
order["price"]strPost-trigger limit price (required if order_type is LIMIT or SL). Example: "3990.00".
order["transaction_type"] *strPost-trigger transaction type. See Transaction type. Examples: BUY, SELL.
child_legsdictOptional child legs for bracket orders (target/stop-loss).
product_type *strProduct for the post-trigger order. See Product type. Examples: CNC, MIS.
exchange *strExchange where the instrument is traded. See Exchange. Examples: NSE.
duration *strValidity of the post-trigger order. See Validity. Example: DAY.

*required parameters

Response

{
  "smart_order_id": "gtt_91a7f4",
  "smart_order_type": "GTT",
  "status": "ACTIVE",
  "trading_symbol": "TCS",
  "exchange": "NSE",
  "quantity": 10,
  "product_type": "CNC",
  "duration": "DAY",
  "order": {
    "order_type": "LIMIT",
    "price": "3990.00",
    "transaction_type": "BUY"
  },
  "trigger_direction": "DOWN",
  "trigger_price": "3985.00",
  "segment": "CASH",
  "ltp": 4000.50,
  "remark": null,
  "display_name": "TCS Ltd",
  "child_legs": null,
  "is_cancellation_allowed": true,
  "is_modification_allowed": true,
  "created_at": "2025-09-30T07:00:00",
  "expire_at": "2026-09-30T07:00:00",
  "triggered_at": null,
  "updated_at": "2025-09-30T07:00:00"
}

Schema reference: Smart Order Response (GTT).

Create OCO

Create an OCO to protect or exit positions with target and stop-loss.

Python SDK Usage

from growwapi import GrowwAPI
 
# Groww API Credentials (Replace with your actual credentials)
API_AUTH_TOKEN = "your_token"
 
# Initialize Groww API
groww = GrowwAPI(API_AUTH_TOKEN)
 
oco_response = groww.create_smart_order(
    smart_order_type=groww.SMART_ORDER_TYPE_OCO,
    reference_id="oco-ref-unique456",
    segment=groww.SEGMENT_FNO,
    trading_symbol="NIFTY25OCT24000CE",
    quantity=50,
    product_type=groww.PRODUCT_MIS,
    exchange=groww.EXCHANGE_NSE,
    duration=groww.VALIDITY_DAY,
    # OCO-specific parameters
    net_position_quantity=50,
    transaction_type=groww.TRANSACTION_TYPE_SELL,
    target={
        "trigger_price": "120.50",
        "order_type": groww.ORDER_TYPE_LIMIT,
        "price": "121.00"
    },
    stop_loss={
        "trigger_price": "95.00",
        "order_type": groww.ORDER_TYPE_STOP_LOSS_MARKET,
        "price": None
    }
)
print(oco_response)

Parameters

NameTypeDescription
smart_order_type *strSet to OCO to create a One-Cancels-Other smart order (target + stop-loss). Example: OCO.
reference_id *strUser-provided alphanumeric string (8-20 characters) that serves as an idempotency key, with at most two hyphens (-) allowed.
segment *strSegment for which the order will be placed. See Segment. Examples: FNO, CASH.
trading_symbol *strTrading Symbol of the instrument as defined by the exchange
quantity *intTotal quantity for both legs. Must be ≤ abs(net_position_quantity). Example: 50.
net_position_quantity *intYour current net position in this symbol. Used to derive leg directions and validate quantity. Example: 50.
transaction_type *strDirection of protection/exit for your position. See Transaction type. Examples: BUY, SELL.
target *dictTake-profit leg details
target["trigger_price"] *strTake-profit trigger price (decimal string). Example: "120.50".
target["order_type"] *strOrder type for the target leg. See Order type. Examples: LIMIT, MARKET.
target["price"]strTarget leg limit price (required if order_type = LIMIT). Example: "121.00".
stop_loss *dictStop-loss leg details
stop_loss["trigger_price"] *strStop-loss trigger price (decimal string). Example: "95.00".
stop_loss["order_type"] *strOrder type for the stop-loss leg. See Order type. Examples: SL, SL_M.
stop_loss["price"]strStop-loss leg limit price (required if order_type = SL). Example: "94.50".
product_type *strProduct for the OCO. See Product type. Note: For OCO in cash segment, only MIS is supported currently.
exchange *strExchange for this instrument. See Exchange. Example: NSE.
duration *strValidity for both legs. See Validity. Example: DAY.

*required parameters

Important OCO orders are meant to exit an existing position.

  • In the F&O segment you must already hold the contract.
  • In the CASH segment, OCO is restricted to intraday (MIS) positions.

Response

{
  "smart_order_id": "oco_a12bc3",
  "smart_order_type": "OCO",
  "status": "ACTIVE",
  "trading_symbol": "NIFTY25OCT24000CE",
  "exchange": "NSE",
  "quantity": 50,
  "product_type": "MIS",
  "duration": "DAY",
  "target": {
    "trigger_price": "120.50",
    "order_type": "LIMIT",
    "price": "121.00"
  },
  "stop_loss": {
    "trigger_price": "95.00",
    "order_type": "SL_M",
    "price": null
  },
  "is_cancellation_allowed": true,
  "is_modification_allowed": true,
  "created_at": "2025-09-30T07:00:00",
  "expire_at": null,
  "triggered_at": null,
  "updated_at": "2025-09-30T07:00:00"
}

Schema reference: Smart Order Response (OCO).

Notes

  • quantity must be ≤ abs(net_position_quantity).
  • If a leg executes, the other cancels automatically.

Modify Smart Order

Modify contracts differ by flow. Only the fields listed below are honoured; everything else is ignored or rejected. Use cancel + create when you need changes outside of these lists.

Modifiable Fields - GTT

  • quantity - Updated order quantity
  • trigger_price - Updated trigger price threshold
  • trigger_direction - Updated direction
  • order.order_type - Updated order type
  • order.price - Updated limit price (required for LIMIT/SL types; set to None for MARKET/SL_M)
  • child_legs - Updated bracket order legs (optional; all child leg fields are modifiable if provided)

Modifiable Fields - OCO

  • quantity - Updated order quantity
  • duration - Updated validity
  • product_type - Updated product (e.g., MIS ↔ NRML for FNO; CASH OCO only supports MIS)
  • target.trigger_price - Updated profit target trigger price
  • stop_loss.trigger_price - Updated stop-loss trigger price

Modify GTT

from growwapi import GrowwAPI
 
# Groww API Credentials (Replace with your actual credentials)
API_AUTH_TOKEN = "your_token"
 
# Initialize Groww API
groww = GrowwAPI(API_AUTH_TOKEN)
 
modify_response = groww.modify_smart_order(
    smart_order_id="gtt_91a7f4",
    smart_order_type=groww.SMART_ORDER_TYPE_GTT,
    segment=groww.SEGMENT_CASH,
    quantity=12,
    trigger_price="3980.00",
    trigger_direction=groww.TRIGGER_DIRECTION_DOWN,
    order={
        "order_type": groww.ORDER_TYPE_LIMIT,
        "price": "3985.00",
        "transaction_type": groww.TRANSACTION_TYPE_BUY
    }
)
print(modify_response)

Parameters (GTT)

NameTypeDescription
smart_order_id *strSmart order identifier. Example: gtt_91a7f4.
smart_order_type *strSet to GTT (required for routing)
segment *strSegment of the order (required for routing). See Segment. Examples: CASH, FNO.
quantityintUpdated quantity.
trigger_pricestrUpdated trigger price (decimal string).
trigger_directionstrUpdated trigger direction. Examples: UP, DOWN.
order["order_type"]strUpdated order type. See Order type.
order["price"]strUpdated limit price (required if order_type is LIMIT or SL; set to None for MARKET/SL_M).
order["transaction_type"]strTransaction type (required but not modifiable). See Transaction type.
child_legsdictUpdated child legs for bracket orders (all child leg fields modifiable if provided).

*required parameters

Modify OCO

from growwapi import GrowwAPI
 
# Groww API Credentials (Replace with your actual credentials)
API_AUTH_TOKEN = "your_token"
 
# Initialize Groww API
groww = GrowwAPI(API_AUTH_TOKEN)
 
modify_oco_response = groww.modify_smart_order(
    smart_order_id="oco_a12bc3",
    smart_order_type=groww.SMART_ORDER_TYPE_OCO,
    segment=groww.SEGMENT_FNO,
    quantity=40,
    duration=groww.VALIDITY_DAY,
    product_type=groww.PRODUCT_MIS,
    target={
        "trigger_price": "122.00"
    },
    stop_loss={
        "trigger_price": "97.50"
    }
)
print(modify_oco_response)

Parameters (OCO)

NameTypeDescription
smart_order_id *strSmart order identifier. Example: oco_a12bc3.
smart_order_type *strSet to OCO (required for routing)
segment *strSegment of the order (required for routing). See Segment. Examples: FNO, CASH.
durationstrUpdated validity. See Validity.
quantityintUpdated total quantity.
product_typestrUpdated product. See Product type.
target["trigger_price"]strUpdated target trigger price (decimal string).
target["order_type"]strTarget order type (not modifiable). See Order type.
target["price"]strTarget limit price (not modifiable).
stop_loss["trigger_price"]strUpdated stop-loss trigger price (decimal string).
stop_loss["order_type"]strStop-loss order type (not modifiable). See Order type.
stop_loss["price"]strStop-loss limit price (not modifiable).

*required parameters

Response

{
  "smart_order_id": "oco_a12bc3",
  "smart_order_type": "OCO",
  "status": "ACTIVE",
  "quantity": 40
}

Schema reference: Smart Order Response (GTT) or Smart Order Response (OCO).

Modify vs Cancel-Create

What you need to changeGTTOCOAction
Quantity✅ Modify✅ ModifyUse modify
Trigger price✅ Modify✅ Modify (both legs)Use modify
Trigger direction✅ ModifyN/AUse modify
Order type✅ Modify❌ Not modifiableGTT: modify; OCO: cancel+create
Limit price✅ Modify❌ Not modifiableGTT: modify; OCO: cancel+create
Duration/validity❌ Not modifiable✅ ModifyOCO: modify; GTT: cancel+create
Product type❌ Not modifiable✅ ModifyOCO: modify; GTT: cancel+create
Symbol/contract❌ Not modifiable❌ Not modifiableCancel + create
Exchange❌ Not modifiable❌ Not modifiableCancel + create
Segment❌ Not modifiable❌ Not modifiableCancel + create
Smart order type (GTT ↔ OCO)❌ Not modifiable❌ Not modifiableCancel + create

Note: When a field is marked as "Not modifiable" (❌), you must cancel the existing smart order and create a new one with the desired changes. The "N/A" designation indicates that the feature does not apply to that smart order type.

Cancel Smart Order

Cancel any active smart order.

Python SDK Usage

from growwapi import GrowwAPI
 
# Groww API Credentials (Replace with your actual credentials)
API_AUTH_TOKEN = "your_token"
 
# Initialize Groww API
groww = GrowwAPI(API_AUTH_TOKEN)
 
cancel_response = groww.cancel_smart_order(
    segment=groww.SEGMENT_CASH,
    smart_order_type=groww.SMART_ORDER_TYPE_GTT,
    smart_order_id="gtt_91a7f4"
)
print(cancel_response)

Parameters

NameTypeDescription
segment *strSegment of the smart order to cancel. See Segment. Examples: CASH, FNO.
smart_order_type *strSmart order type. Examples: GTT, OCO.
smart_order_id *strSmart order identifier. Example: gtt_91a7f4.

*required parameters

Response

{
  "smart_order_id": "gtt_91a7f4",
  "smart_order_type": "GTT",
  "status": "CANCELLED"
}

Schema reference: Smart Order Response (GTT) or Smart Order Response (OCO).

Get Smart Order

Retrieve details of a specific smart order by its internal ID.

Python SDK Usage

from growwapi import GrowwAPI
 
# Groww API Credentials (Replace with your actual credentials)
API_AUTH_TOKEN = "your_token"
 
# Initialize Groww API
groww = GrowwAPI(API_AUTH_TOKEN)
 
order_details = groww.get_smart_order(
    segment=groww.SEGMENT_CASH,
    smart_order_type=groww.SMART_ORDER_TYPE_GTT,
    smart_order_id="gtt_91a7f4"
)
print(order_details)

Parameters

NameTypeDescription
segment *strSegment of the smart order to fetch. See Segment. Examples: CASH, FNO.
smart_order_type *strSmart order type. Examples: GTT, OCO.
smart_order_id *strSmart order identifier. Example: gtt_91a7f4.

*required parameters

Response

{
  "smart_order_id": "gtt_91a7f4",
  "smart_order_type": "GTT",
  "status": "ACTIVE",
  "trading_symbol": "TCS",
  "exchange": "NSE",
  "quantity": 10,
  "product_type": "CNC",
  "duration": "DAY",
  "order": {
    "order_type": "LIMIT",
    "price": "3990.00",
    "transaction_type": "BUY"
  },
  "trigger_direction": "DOWN",
  "trigger_price": "3985.00",
  "segment": "CASH",
  "ltp": 4000.50,
  "remark": null,
  "display_name": "TCS Ltd",
  "child_legs": null,
  "is_cancellation_allowed": true,
  "is_modification_allowed": true,
  "created_at": "2025-09-30T07:00:00",
  "expire_at": "2026-09-30T07:00:00",
  "triggered_at": null,
  "updated_at": "2025-09-30T07:00:00"
}

Schema reference: Smart Order Response (GTT) or Smart Order Response (OCO).

List Smart Orders

Filter and list smart orders by type, segment, status and a time window. Pagination is supported.

Python SDK Usage

from growwapi import GrowwAPI
 
# Groww API Credentials (Replace with your actual credentials)
API_AUTH_TOKEN = "your_token"
 
# Initialize Groww API
groww = GrowwAPI(API_AUTH_TOKEN)
 
orders_list = groww.get_smart_order_list(
    segment=groww.SEGMENT_FNO,
    smart_order_type=groww.SMART_ORDER_TYPE_OCO,
    status=groww.SMART_ORDER_STATUS_ACTIVE,
    page=0,
    page_size=10,
    start_date_time="2025-01-16T09:15:00",
    end_date_time="2025-01-16T15:30:00"
)
print(orders_list)

Parameters

NameTypeDescription
segmentstrSegment to list smart orders for. See Segment. Examples: FNO, CASH. Optional; server defaults may apply if omitted.
smart_order_typestrSmart order type to list. Examples: OCO, GTT. Optional; server defaults may apply if omitted.
statusstrCurrent state filter. Examples: ACTIVE, TRIGGERED, CANCELLED, COMPLETED. Optional; server defaults may apply if omitted.
pageintPage number starting from 0. Use with page_size to paginate long lists. Min: 0, Max: 500.
page_sizeintNumber of records per page. Tune this for your UI/export. Min: 1, Max: 50.
start_date_timestrInclusive start of the time window in ISO 8601. Examples: 2025-01-16T09:15:00, 2025-01-16T00:00:00.
end_date_timestrInclusive end of the time window in ISO 8601. Must not be before start_date_time. Examples: 2025-01-16T09:15:00, 2025-01-16T00:00:00.

Validations:

  • end_date_time must not be before start_date_time.
  • Date range between start_date_time and end_date_time must not exceed one month.

Tip If you expect an order that has already been triggered or cancelled, switch the status filter accordingly—ACTIVE only returns live, untriggered smart orders.

Response

{
  "orders": [
    {
      "smart_order_id": "gtt_91a7f4",
      "smart_order_type": "GTT",
      "status": "ACTIVE",
      "trading_symbol": "TCS",
      "exchange": "NSE",
      "quantity": 10
    }
  ]
}
NameTypeDescription
orderslistList of smart orders
orders[]dictSmart order item (GTT or OCO). See Smart Order Response (GTT) or Smart Order Response (OCO)

Smart Order Constants

The Python SDK provides constants for smart order types, trigger directions, and statuses:

Smart Order Types

groww.SMART_ORDER_TYPE_GTT  # "GTT"
groww.SMART_ORDER_TYPE_OCO  # "OCO"

Trigger Directions

groww.TRIGGER_DIRECTION_UP    # "UP"
groww.TRIGGER_DIRECTION_DOWN  # "DOWN"

Smart Order Status

groww.SMART_ORDER_STATUS_ACTIVE      # "ACTIVE" - Order is monitoring trigger conditions
groww.SMART_ORDER_STATUS_TRIGGERED   # "TRIGGERED" - Trigger condition met, order placed
groww.SMART_ORDER_STATUS_CANCELLED   # "CANCELLED" - User cancelled the order
groww.SMART_ORDER_STATUS_EXPIRED     # "EXPIRED" - Order expired due to time/date expiry
groww.SMART_ORDER_STATUS_FAILED      # "FAILED" - Order placement or trigger failed
groww.SMART_ORDER_STATUS_COMPLETED   # "COMPLETED" - Order successfully completed

Quick Tips

  • Use a unique reference_id per new smart order to avoid accidental duplicates.
  • For OCO, ensure quantityabs(net_position_quantity). The leg directions are derived from your net position.
  • All prices should be passed as decimal strings (e.g., "3985.00").
  • Use the SDK constants (like SMART_ORDER_TYPE_GTT) for better type safety and code clarity.

Schemas

Smart Order Response (GTT)

NameTypeDescription
smart_order_idstrSmart order identifier
smart_order_typestrSmart order type. Example: GTT.
statusstrSmart order status (e.g., ACTIVE)
trading_symbolstrTrading Symbol of the instrument as defined by the exchange
exchangestrStock exchange
quantityintQuantity
product_typestrProduct type
durationstrValidity
order.order_typestrOrder type. See Order type. Examples: LIMIT, SL.
order.pricestrPrice for LIMIT/SL
order.transaction_typestrSee Transaction type. Examples: BUY, SELL.
ltpfloatLast traded price of the instrument
trigger_directionstrTrigger direction. Examples: UP, DOWN.
trigger_pricestrTrigger price (decimal string)
segmentstrMarket segment
remarkstrRemark or status message
display_namestrDisplay name for the instrument
child_legsdictChild legs for bracket orders (target/stop-loss)
is_cancellation_allowedboolWhether cancellation is allowed
is_modification_allowedboolWhether modification is allowed
created_atstrCreation time (ISO 8601). Examples: 2025-01-16T09:15:00, 2025-01-16T00:00:00.
expire_atstrExpiry time (ISO 8601). Examples: 2025-01-16T09:15:00, 2025-01-16T00:00:00.
triggered_atstrTrigger time (ISO 8601). Examples: 2025-01-16T09:15:00, 2025-01-16T00:00:00.
updated_atstrLast updated time (ISO 8601). Examples: 2025-01-16T09:15:00, 2025-01-16T00:00:00.

Smart Order Response (OCO)

NameTypeDescription
smart_order_idstrSmart order identifier
smart_order_typestrSmart order type. Example: OCO.
statusstrSmart order status (e.g., ACTIVE)
trading_symbolstrTrading Symbol of the instrument as defined by the exchange
exchangestrStock exchange
quantityintQuantity of the order to be placed
product_typestrProduct type
durationstrValidity
target.trigger_pricestrTarget trigger price (decimal string)
target.order_typestrOrder type. See Order type. Examples: LIMIT, MARKET.
target.pricestrTarget limit price
stop_loss.trigger_pricestrStop-loss trigger price (decimal string)
stop_loss.order_typestrOrder type. See Order type. Examples: SL, SL_M.
stop_loss.pricestrStop-loss limit price
is_cancellation_allowedboolWhether cancellation is allowed
is_modification_allowedboolWhether modification is allowed
created_atstrCreation time (ISO 8601). Examples: 2025-01-16T09:15:00, 2025-01-16T00:00:00.
expire_atstrExpiry time (ISO 8601). Examples: 2025-01-16T09:15:00, 2025-01-16T00:00:00.
triggered_atstrTrigger time (ISO 8601). Examples: 2025-01-16T09:15:00, 2025-01-16T00:00:00.
updated_atstrLast updated time (ISO 8601). Examples: 2025-01-16T09:15:00, 2025-01-16T00:00:00.

On this page