OptionsMultiOrder

Options Multi-Order

Endpoint URL

This API Function Places Multiple Option Legs with Common Underlying by Auto-Resolving Symbols based on Offset. BUY legs are executed first for margin efficiency, then SELL legs.

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

Sample API Request (Iron Condor Strategy)

{
    "apikey": "<your_app_apikey>",
    "strategy": "Iron Condor",
    "underlying": "NIFTY",
    "exchange": "NSE_INDEX",
    "expiry_date": "25NOV25",
    "legs": [
        {
            "offset": "OTM10",
            "option_type": "CE",
            "action": "BUY",
            "quantity": 75
        },
        {
            "offset": "OTM10",
            "option_type": "PE",
            "action": "BUY",
            "quantity": 75
        },
        {
            "offset": "OTM5",
            "option_type": "CE",
            "action": "SELL",
            "quantity": 75
        },
        {
            "offset": "OTM5",
            "option_type": "PE",
            "action": "SELL",
            "quantity": 75
        }
    ]
}

Sample API Response (Live Mode)

{
    "status": "success",
    "underlying": "NIFTY",
    "underlying_ltp": 24150.50,
    "results": [
        {
            "leg": 1,
            "symbol": "NIFTY25NOV2424650CE",
            "exchange": "NFO",
            "offset": "OTM10",
            "option_type": "CE",
            "action": "BUY",
            "status": "success",
            "orderid": "240123000001234"
        },
        {
            "leg": 2,
            "symbol": "NIFTY25NOV2423650PE",
            "exchange": "NFO",
            "offset": "OTM10",
            "option_type": "PE",
            "action": "BUY",
            "status": "success",
            "orderid": "240123000001235"
        },
        {
            "leg": 3,
            "symbol": "NIFTY25NOV2424400CE",
            "exchange": "NFO",
            "offset": "OTM5",
            "option_type": "CE",
            "action": "SELL",
            "status": "success",
            "orderid": "240123000001236"
        },
        {
            "leg": 4,
            "symbol": "NIFTY25NOV2423900PE",
            "exchange": "NFO",
            "offset": "OTM5",
            "option_type": "PE",
            "action": "SELL",
            "status": "success",
            "orderid": "240123000001237"
        }
    ]
}

Sample API Response (Analyze Mode)

{
    "status": "success",
    "mode": "analyze",
    "underlying": "NIFTY",
    "underlying_ltp": 24150.50,
    "results": [
        {
            "leg": 1,
            "symbol": "NIFTY25NOV2424650CE",
            "offset": "OTM10",
            "option_type": "CE",
            "action": "BUY",
            "status": "success",
            "orderid": "SB-1234567890"
        },
        {
            "leg": 2,
            "symbol": "NIFTY25NOV2423650PE",
            "offset": "OTM10",
            "option_type": "PE",
            "action": "BUY",
            "status": "success",
            "orderid": "SB-1234567891"
        },
        {
            "leg": 3,
            "symbol": "NIFTY25NOV2424400CE",
            "offset": "OTM5",
            "option_type": "CE",
            "action": "SELL",
            "status": "success",
            "orderid": "SB-1234567892"
        },
        {
            "leg": 4,
            "symbol": "NIFTY25NOV2423900PE",
            "offset": "OTM5",
            "option_type": "PE",
            "action": "SELL",
            "status": "success",
            "orderid": "SB-1234567893"
        }
    ]
}

Sample API Request

{
    "apikey": "<your_openalgo_apikey>",
    "strategy": "Short Straddle",
    "underlying": "NIFTY",
    "exchange": "NSE_INDEX",
    "legs": [
        {
            "offset": "ATM",
            "option_type": "CE",
            "action": "SELL",
            "expiry_date": "25NOV25",
            "quantity": 75,
            "pricetype": "MARKET",
            "product": "NRML"
        },
        {
            "offset": "ATM",
            "option_type": "PE",
            "action": "SELL",
            "expiry_date": "30DEC25",  
            "quantity": 75,
            "pricetype": "MARKET",
            "product": "NRML"
        }
    ]
}

Sample API Response

{
  "mode": "analyze",
  "results": [
    {
      "action": "SELL",
      "exchange": "NFO",
      "leg": 1,
      "mode": "analyze",
      "offset": "ATM",
      "option_type": "CE",
      "orderid": "25112456537780",
      "status": "success",
      "symbol": "NIFTY25NOV2525950CE"
    },
    {
      "action": "SELL",
      "exchange": "NFO",
      "leg": 2,
      "mode": "analyze",
      "offset": "ATM",
      "option_type": "PE",
      "orderid": "25112458966667",
      "status": "success",
      "symbol": "NIFTY30DEC2525950PE"
    }
  ],
  "status": "success",
  "underlying": "NIFTY",
  "underlying_ltp": 25959.5
}

Sample API Request (Future as Underlying)

{
    "apikey": "<your_app_apikey>",
    "strategy": "Bull Call Spread",
    "underlying": "NIFTY25NOV25FUT",
    "exchange": "NFO",
    "expiry_date": "25NOV25",
    "legs": [
        {
            "offset": "ATM",
            "option_type": "CE",
            "action": "BUY",
            "quantity": 75,
            "product": "NRML"
        },
        {
            "offset": "OTM3",
            "option_type": "CE",
            "action": "SELL",
            "quantity": 75,
            "product": "NRML"
        }
    ]
}

Parameter Description (Request Level)

Parameters
Description
Mandatory/Optional
Default Value

apikey

App API key

Mandatory

-

strategy

Strategy name

Mandatory

-

underlying

Underlying symbol (NIFTY, BANKNIFTY, NIFTY28OCT25FUT)

Mandatory

-

exchange

Exchange code (NSE_INDEX, NSE, NFO, BSE_INDEX, BSE, BFO)

Mandatory

-

expiry_date

Expiry date in DDMMMYY format (e.g., 25NOV25)

Optional*

-

strike_int

Strike interval (50 for NIFTY, 100 for BANKNIFTY)

Optional

Auto-detect

legs

Array of leg objects (1-20 legs)

Mandatory

-

*Note: expiry_date is optional if underlying includes expiry (e.g., NIFTY28OCT25FUT)

Parameter Description (Per Leg)

Parameters
Description
Mandatory/Optional
Default Value

offset

Strike offset (ATM, ITM1-ITM50, OTM1-OTM50)

Mandatory

-

option_type

Option type (CE for Call, PE for Put)

Mandatory

-

action

Action (BUY/SELL)

Mandatory

-

quantity

Quantity (must be multiple of lot size)

Mandatory

-

expiry_date

Per-leg expiry (DDMMMYY) for diagonal/calendar spreads

Optional

Request-level

pricetype

Price type (MARKET/LIMIT/SL/SL-M)

Optional

MARKET

product

Product type (MIS/NRML)**

Optional

MIS

price

Limit price

Optional

0

trigger_price

Trigger price for SL orders

Optional

0

disclosed_quantity

Disclosed quantity

Optional

0

**Note: Options only support MIS and NRML products (CNC not supported)

***Note: Per-leg expiry_date overrides the request-level expiry_date, enabling diagonal and calendar spreads in a single API call

Response Parameters

Parameter
Description
Type

status

API response status (success/error)

string

underlying

Underlying symbol from request

string

underlying_ltp

Last Traded Price of underlying

number

mode

Trading mode (analyze/live)***

string

results

Array of leg results

array

***Note: mode field is only present in Analyze Mode responses

Result Parameters (Per Leg)

Parameter
Description
Type

leg

Leg number (1, 2, 3, ...)

number

symbol

Resolved option symbol

string

exchange

Exchange

string

offset

Strike offset from request

string

option_type

Option type (CE/PE)

string

action

Action (BUY/SELL)

string

status

Leg status (success/error)

string

orderid

Broker order ID (or SB-xxx for analyze mode)

string

message

Error message (only if status is error)

string

Execution Order - BUY First Strategy

The API automatically sorts and executes legs in the following order for margin efficiency:

  1. BUY legs execute first (in parallel) - establishes long positions

  2. Wait for all BUY orders to complete

  3. SELL legs execute next (in parallel) - establishes short positions

This order ensures:

  • Margin benefit from hedged positions

  • Better fill rates on protective legs

  • Reduced margin requirements for spreads

Live Mode vs Analyze Mode

Live Mode

  • When: Analyze Mode toggle is OFF in OpenAlgo settings

  • Behavior: Places real orders with connected broker

  • Order ID Format: Broker's order ID (e.g., "240123000001234")

  • Response: No "mode" field present

Analyze Mode (Sandbox)

  • When: Analyze Mode toggle is ON in OpenAlgo settings

  • Behavior: Places virtual orders in sandbox environment

  • Order ID Format: Sandbox ID with "SB-" prefix (e.g., "SB-1234567890")

  • Response: Includes "mode": "analyze" field

  • Features: Virtual capital, realistic execution, auto square-off

Note: Same API call works in both modes. The system automatically detects which mode is active.

Common Option Strategies with Request/Response Examples

1. Iron Condor (4 Legs)

Request:

{
    "apikey": "<your_app_apikey>",
    "strategy": "Iron Condor",
    "underlying": "NIFTY",
    "exchange": "NSE_INDEX",
    "expiry_date": "25NOV25",
    "legs": [
        {"offset": "OTM10", "option_type": "CE", "action": "BUY", "quantity": 75},
        {"offset": "OTM10", "option_type": "PE", "action": "BUY", "quantity": 75},
        {"offset": "OTM5", "option_type": "CE", "action": "SELL", "quantity": 75},
        {"offset": "OTM5", "option_type": "PE", "action": "SELL", "quantity": 75}
    ]
}

Response:

{
    "status": "success",
    "underlying": "NIFTY",
    "underlying_ltp": 24150.50,
    "results": [
        {"leg": 1, "symbol": "NIFTY25NOV2424650CE", "offset": "OTM10", "option_type": "CE", "action": "BUY", "status": "success", "orderid": "240123000001234"},
        {"leg": 2, "symbol": "NIFTY25NOV2423650PE", "offset": "OTM10", "option_type": "PE", "action": "BUY", "status": "success", "orderid": "240123000001235"},
        {"leg": 3, "symbol": "NIFTY25NOV2424400CE", "offset": "OTM5", "option_type": "CE", "action": "SELL", "status": "success", "orderid": "240123000001236"},
        {"leg": 4, "symbol": "NIFTY25NOV2423900PE", "offset": "OTM5", "option_type": "PE", "action": "SELL", "status": "success", "orderid": "240123000001237"}
    ]
}

2. Long Straddle (2 Legs)

Request:

{
    "apikey": "<your_app_apikey>",
    "strategy": "Long Straddle",
    "underlying": "NIFTY",
    "exchange": "NSE_INDEX",
    "expiry_date": "30DEC25",
    "legs": [
        {"offset": "ATM", "option_type": "CE", "action": "BUY", "quantity": 75},
        {"offset": "ATM", "option_type": "PE", "action": "BUY", "quantity": 75}
    ]
}

Response:

{
    "status": "success",
    "underlying": "NIFTY",
    "underlying_ltp": 24150.50,
    "results": [
        {"leg": 1, "symbol": "NIFTY30DEC2524150CE", "offset": "ATM", "option_type": "CE", "action": "BUY", "status": "success", "orderid": "240123000001238"},
        {"leg": 2, "symbol": "NIFTY30DEC2524150PE", "offset": "ATM", "option_type": "PE", "action": "BUY", "status": "success", "orderid": "240123000001239"}
    ]
}

3. Short Straddle (2 Legs)

Request:

{
    "apikey": "<your_app_apikey>",
    "strategy": "Short Straddle",
    "underlying": "NIFTY",
    "exchange": "NSE_INDEX",
    "expiry_date": "30DEC25",
    "legs": [
        {"offset": "ATM", "option_type": "CE", "action": "SELL", "quantity": 75},
        {"offset": "ATM", "option_type": "PE", "action": "SELL", "quantity": 75}
    ]
}

Response:

{
    "status": "success",
    "underlying": "NIFTY",
    "underlying_ltp": 24150.50,
    "results": [
        {"leg": 1, "symbol": "NIFTY30DEC2524150CE", "offset": "ATM", "option_type": "CE", "action": "SELL", "status": "success", "orderid": "240123000001240"},
        {"leg": 2, "symbol": "NIFTY30DEC2524150PE", "offset": "ATM", "option_type": "PE", "action": "SELL", "status": "success", "orderid": "240123000001241"}
    ]
}

4. Short Strangle (2 Legs)

Request:

{
    "apikey": "<your_app_apikey>",
    "strategy": "Short Strangle",
    "underlying": "NIFTY",
    "exchange": "NSE_INDEX",
    "expiry_date": "25NOV25",
    "legs": [
        {"offset": "OTM3", "option_type": "CE", "action": "SELL", "quantity": 75},
        {"offset": "OTM3", "option_type": "PE", "action": "SELL", "quantity": 75}
    ]
}

Response:

{
    "status": "success",
    "underlying": "NIFTY",
    "underlying_ltp": 24150.50,
    "results": [
        {"leg": 1, "symbol": "NIFTY25NOV2524300CE", "offset": "OTM3", "option_type": "CE", "action": "SELL", "status": "success", "orderid": "240123000001242"},
        {"leg": 2, "symbol": "NIFTY25NOV2524000PE", "offset": "OTM3", "option_type": "PE", "action": "SELL", "status": "success", "orderid": "240123000001243"}
    ]
}

5. Bull Call Spread (2 Legs)

Request:

{
    "apikey": "<your_app_apikey>",
    "strategy": "Bull Call Spread",
    "underlying": "NIFTY",
    "exchange": "NSE_INDEX",
    "expiry_date": "25NOV25",
    "legs": [
        {"offset": "ATM", "option_type": "CE", "action": "BUY", "quantity": 75},
        {"offset": "OTM3", "option_type": "CE", "action": "SELL", "quantity": 75}
    ]
}

Response:

{
    "status": "success",
    "underlying": "NIFTY",
    "underlying_ltp": 24150.50,
    "results": [
        {"leg": 1, "symbol": "NIFTY25NOV2524150CE", "offset": "ATM", "option_type": "CE", "action": "BUY", "status": "success", "orderid": "240123000001244"},
        {"leg": 2, "symbol": "NIFTY25NOV2524300CE", "offset": "OTM3", "option_type": "CE", "action": "SELL", "status": "success", "orderid": "240123000001245"}
    ]
}

6. Bear Put Spread (2 Legs)

Request:

{
    "apikey": "<your_app_apikey>",
    "strategy": "Bear Put Spread",
    "underlying": "NIFTY",
    "exchange": "NSE_INDEX",
    "expiry_date": "25NOV25",
    "legs": [
        {"offset": "ATM", "option_type": "PE", "action": "BUY", "quantity": 75},
        {"offset": "OTM3", "option_type": "PE", "action": "SELL", "quantity": 75}
    ]
}

Response:

{
    "status": "success",
    "underlying": "NIFTY",
    "underlying_ltp": 24150.50,
    "results": [
        {"leg": 1, "symbol": "NIFTY25NOV2524150PE", "offset": "ATM", "option_type": "PE", "action": "BUY", "status": "success", "orderid": "240123000001246"},
        {"leg": 2, "symbol": "NIFTY25NOV2524000PE", "offset": "OTM3", "option_type": "PE", "action": "SELL", "status": "success", "orderid": "240123000001247"}
    ]
}

7. Iron Butterfly (4 Legs)

Request:

{
    "apikey": "<your_app_apikey>",
    "strategy": "Iron Butterfly",
    "underlying": "NIFTY",
    "exchange": "NSE_INDEX",
    "expiry_date": "25NOV25",
    "legs": [
        {"offset": "OTM5", "option_type": "CE", "action": "BUY", "quantity": 75},
        {"offset": "OTM5", "option_type": "PE", "action": "BUY", "quantity": 75},
        {"offset": "ATM", "option_type": "CE", "action": "SELL", "quantity": 75},
        {"offset": "ATM", "option_type": "PE", "action": "SELL", "quantity": 75}
    ]
}

Response:

{
    "status": "success",
    "underlying": "NIFTY",
    "underlying_ltp": 24150.50,
    "results": [
        {"leg": 1, "symbol": "NIFTY25NOV2524400CE", "offset": "OTM5", "option_type": "CE", "action": "BUY", "status": "success", "orderid": "240123000001248"},
        {"leg": 2, "symbol": "NIFTY25NOV2523900PE", "offset": "OTM5", "option_type": "PE", "action": "BUY", "status": "success", "orderid": "240123000001249"},
        {"leg": 3, "symbol": "NIFTY25NOV2524150CE", "offset": "ATM", "option_type": "CE", "action": "SELL", "status": "success", "orderid": "240123000001250"},
        {"leg": 4, "symbol": "NIFTY25NOV2524150PE", "offset": "ATM", "option_type": "PE", "action": "SELL", "status": "success", "orderid": "240123000001251"}
    ]
}

8. Long Call Butterfly (3 Legs)

Request:

{
    "apikey": "<your_app_apikey>",
    "strategy": "Long Call Butterfly",
    "underlying": "NIFTY",
    "exchange": "NSE_INDEX",
    "expiry_date": "30DEC25",
    "legs": [
        {"offset": "ITM2", "option_type": "CE", "action": "BUY", "quantity": 75},
        {"offset": "ATM", "option_type": "CE", "action": "SELL", "quantity": 150},
        {"offset": "OTM2", "option_type": "CE", "action": "BUY", "quantity": 75}
    ]
}

Response:

{
    "status": "success",
    "underlying": "NIFTY",
    "underlying_ltp": 24150.50,
    "results": [
        {"leg": 1, "symbol": "NIFTY30DEC2524050CE", "offset": "ITM2", "option_type": "CE", "action": "BUY", "status": "success", "orderid": "240123000001252"},
        {"leg": 2, "symbol": "NIFTY30DEC2524250CE", "offset": "OTM2", "option_type": "CE", "action": "BUY", "status": "success", "orderid": "240123000001253"},
        {"leg": 3, "symbol": "NIFTY30DEC2524150CE", "offset": "ATM", "option_type": "CE", "action": "SELL", "status": "success", "orderid": "240123000001254"}
    ]
}

9. Call Ratio Spread (1:2 Ratio)

Request:

{
    "apikey": "<your_app_apikey>",
    "strategy": "Call Ratio Spread",
    "underlying": "BANKNIFTY",
    "exchange": "NSE_INDEX",
    "expiry_date": "30DEC25",
    "legs": [
        {"offset": "ATM", "option_type": "CE", "action": "BUY", "quantity": 30},
        {"offset": "OTM3", "option_type": "CE", "action": "SELL", "quantity": 60}
    ]
}

Response:

{
    "status": "success",
    "underlying": "BANKNIFTY",
    "underlying_ltp": 51200.00,
    "results": [
        {"leg": 1, "symbol": "BANKNIFTY30DEC2551200CE", "offset": "ATM", "option_type": "CE", "action": "BUY", "status": "success", "orderid": "240123000001255"},
        {"leg": 2, "symbol": "BANKNIFTY30DEC2551500CE", "offset": "OTM3", "option_type": "CE", "action": "SELL", "status": "success", "orderid": "240123000001256"}
    ]
}

10. Jade Lizard (3 Legs)

Request:

{
    "apikey": "<your_app_apikey>",
    "strategy": "Jade Lizard",
    "underlying": "NIFTY",
    "exchange": "NSE_INDEX",
    "expiry_date": "25NOV25",
    "legs": [
        {"offset": "OTM5", "option_type": "CE", "action": "BUY", "quantity": 75},
        {"offset": "OTM2", "option_type": "CE", "action": "SELL", "quantity": 75},
        {"offset": "OTM3", "option_type": "PE", "action": "SELL", "quantity": 75}
    ]
}

Response:

{
    "status": "success",
    "underlying": "NIFTY",
    "underlying_ltp": 24150.50,
    "results": [
        {"leg": 1, "symbol": "NIFTY25NOV2524400CE", "offset": "OTM5", "option_type": "CE", "action": "BUY", "status": "success", "orderid": "240123000001257"},
        {"leg": 2, "symbol": "NIFTY25NOV2524250CE", "offset": "OTM2", "option_type": "CE", "action": "SELL", "status": "success", "orderid": "240123000001258"},
        {"leg": 3, "symbol": "NIFTY25NOV2524000PE", "offset": "OTM3", "option_type": "PE", "action": "SELL", "status": "success", "orderid": "240123000001259"}
    ]
}

11. Put Ratio Spread (1:2 Ratio)

Request:

{
    "apikey": "<your_app_apikey>",
    "strategy": "Put Ratio Spread",
    "underlying": "NIFTY",
    "exchange": "NSE_INDEX",
    "expiry_date": "30DEC25",
    "legs": [
        {"offset": "ATM", "option_type": "PE", "action": "BUY", "quantity": 75},
        {"offset": "OTM3", "option_type": "PE", "action": "SELL", "quantity": 150}
    ]
}

Response:

{
    "status": "success",
    "underlying": "NIFTY",
    "underlying_ltp": 24150.50,
    "results": [
        {"leg": 1, "symbol": "NIFTY30DEC2524150PE", "offset": "ATM", "option_type": "PE", "action": "BUY", "status": "success", "orderid": "240123000001260"},
        {"leg": 2, "symbol": "NIFTY30DEC2524000PE", "offset": "OTM3", "option_type": "PE", "action": "SELL", "status": "success", "orderid": "240123000001261"}
    ]
}

12. Calendar Spread (Different Expiries - Single API Call)

Note: Calendar spreads use the same strike but different expiry dates. Use per-leg expiry_date to specify different expiries.

Request:

{
    "apikey": "<your_app_apikey>",
    "strategy": "Calendar Spread",
    "underlying": "NIFTY",
    "exchange": "NSE_INDEX",
    "legs": [
        {"offset": "ATM", "option_type": "CE", "action": "BUY", "quantity": 75, "expiry_date": "30DEC25"},
        {"offset": "ATM", "option_type": "CE", "action": "SELL", "quantity": 75, "expiry_date": "25NOV25"}
    ]
}

Response:

{
    "status": "success",
    "underlying": "NIFTY",
    "underlying_ltp": 24150.50,
    "results": [
        {"leg": 1, "symbol": "NIFTY30DEC2524150CE", "offset": "ATM", "option_type": "CE", "action": "BUY", "status": "success", "orderid": "240123000001262"},
        {"leg": 2, "symbol": "NIFTY25NOV2524150CE", "offset": "ATM", "option_type": "CE", "action": "SELL", "status": "success", "orderid": "240123000001263"}
    ]
}

13. Diagonal Spread (Different Strikes & Expiries - Single API Call)

Note: Diagonal spreads combine different strike prices AND different expiry dates. Use per-leg expiry_date to specify different expiries.

Request (Bullish Diagonal Call Spread):

{
    "apikey": "<your_app_apikey>",
    "strategy": "Diagonal Spread",
    "underlying": "NIFTY",
    "exchange": "NSE_INDEX",
    "legs": [
        {"offset": "ITM2", "option_type": "CE", "action": "BUY", "quantity": 75, "expiry_date": "30DEC25"},
        {"offset": "OTM2", "option_type": "CE", "action": "SELL", "quantity": 75, "expiry_date": "25NOV25"}
    ]
}

Response:

{
    "status": "success",
    "underlying": "NIFTY",
    "underlying_ltp": 24150.50,
    "results": [
        {"leg": 1, "symbol": "NIFTY30DEC2524050CE", "offset": "ITM2", "option_type": "CE", "action": "BUY", "status": "success", "orderid": "240123000001264"},
        {"leg": 2, "symbol": "NIFTY25NOV2524250CE", "offset": "OTM2", "option_type": "CE", "action": "SELL", "status": "success", "orderid": "240123000001265"}
    ]
}

Note: BUY legs always execute first for margin efficiency, regardless of order in the request.

Product Types for Options

Product
Description
Margin
Square-off
Use Case

MIS

Margin Intraday

Lower

Auto (3:15 PM)

Intraday trading

NRML

Normal (Carry Forward)

Higher

Manual

Overnight positions

Note: CNC (Cash & Carry) is not supported for options trading.

Lot Size Reference

Underlying
Lot Size
Strike Interval
Exchange

NIFTY

75

50

NSE_INDEX

BANKNIFTY

35

100

NSE_INDEX

FINNIFTY

65

50

NSE_INDEX

MIDCPNIFTY

140

25

NSE_INDEX

NIFTYNXT50

25

50

NSE_INDEX

SENSEX

20

100

BSE_INDEX

BANKEX

30

100

BSE_INDEX

Note: For equity options, lot size varies. Check contract specifications.

Error Response

{
    "status": "error",
    "message": "Validation error",
    "errors": {
        "legs": ["Legs must contain 1 to 20 items."]
    }
}

Partial Success Response

{
    "status": "success",
    "underlying": "NIFTY",
    "underlying_ltp": 24150.50,
    "results": [
        {
            "leg": 1,
            "symbol": "NIFTY25NOV2424650CE",
            "offset": "OTM10",
            "option_type": "CE",
            "action": "BUY",
            "status": "success",
            "orderid": "240123000001234"
        },
        {
            "leg": 2,
            "offset": "OTM10",
            "option_type": "PE",
            "action": "BUY",
            "status": "error",
            "message": "Insufficient funds"
        }
    ]
}

Common Error Messages

Error Message
Cause
Solution

Invalid openalgo apikey

API key is incorrect or expired

Check API key in settings

Option symbol not found

Calculated strike doesn't exist

Check strike_int and offset

Quantity must be a positive integer

Invalid quantity value

Provide valid quantity

Insufficient funds

Not enough margin (Live mode)

Add funds or reduce quantity

Master contract needs update

Symbol database is outdated

Update master contract data

Legs must contain 1 to 20 items

Too many or no legs provided

Provide 1-20 legs

Features

  1. Multi-Leg Execution: Execute up to 20 legs in a single API call

  2. BUY-First Strategy: Automatically executes BUY legs before SELL for margin efficiency

  3. Parallel Execution: Legs within same group (BUY/SELL) execute in parallel

  4. Auto Symbol Resolution: Automatically calculates ATM and resolves option symbols

  5. Dual Mode Support: Works in both Live and Analyze (Sandbox) modes

  6. All Order Types: Supports MARKET, LIMIT, SL, and SL-M orders per leg

  7. Real-time LTP: Uses current market price for ATM calculation

  8. Strategy Tracking: Associates all legs with strategy name for analytics

  9. Telegram Alerts: Automatic notifications for order placement

  10. Partial Success Handling: Returns status for each leg individually

Rate Limiting

  • Limit: 10 requests per second

  • Scope: Per API endpoint

  • Response: 429 status code if limit exceeded

Best Practices

  1. Test in Analyze Mode First: Enable Analyze Mode to test strategies without real money

  2. Verify Lot Sizes: Ensure all leg quantities are multiples of lot size

  3. Check Strike Intervals: Use correct strike_int for each underlying

  4. Use Appropriate Product: MIS for intraday, NRML for overnight

  5. Handle Partial Failures: Check status of each leg in response

  6. Monitor Margin: Check available margin before placing multi-leg orders

  7. Update Master Contracts: Keep symbol database updated for accurate symbol resolution

  8. Consistent Quantities: Use same quantity across legs for proper hedging

  9. Use BUY-First Design: Let the API handle execution order for margin benefits

Comparison with Single Options Order

Feature
optionsorder
optionsmultiorder

Legs per call

1

1-20

API calls needed

Multiple for strategy

Single for entire strategy

Execution control

Manual sequencing

Automatic BUY-first

Margin efficiency

Depends on order

Optimized automatically

Error handling

Per order

Per leg with partial success

Latency

Higher (multiple RTT)

Lower (single RTT)

Use Cases

  1. Spread Strategies: Bull/Bear spreads, ratio spreads

  2. Volatility Strategies: Straddles, strangles, butterflies

  3. Income Strategies: Iron condors, jade lizards

  4. Hedging: Multi-leg protective positions

  5. Complex Combos: Custom multi-leg strategies

Webhook Integration

The optionsmultiorder API works seamlessly with TradingView webhooks for automated strategy execution:

{
    "apikey": "{{strategy.apikey}}",
    "strategy": "{{strategy.order.id}}",
    "underlying": "NIFTY",
    "exchange": "NSE_INDEX",
    "expiry_date": "25NOV25",
    "legs": [
        {"offset": "ATM", "option_type": "CE", "action": "{{strategy.order.action}}", "quantity": 75},
        {"offset": "ATM", "option_type": "PE", "action": "{{strategy.order.action}}", "quantity": 75}
    ]
}

Last updated

Was this helpful?