OptionsOrder
Options Order
Endpoint URL
This API Function Places Option Orders by Auto-Resolving Symbol based on Underlying and Offset
Local Host : POST http://127.0.0.1:5000/api/v1/optionsorder
Ngrok Domain : POST https://<your-ngrok-domain>.ngrok-free.app/api/v1/optionsorder
Custom Domain: POST https://<your-custom-domain>/api/v1/optionsorderSample API Request (Future as Underlying)
{
"apikey": "<your_app_apikey>",
"strategy": "test_strategy",
"underlying": "NIFTY30DEC25FUT",
"exchange": "NFO",
"expiry_date": "30DEC25",
"offset": "ITM2",
"option_type": "CE",
"action": "BUY",
"quantity": 75,
"pricetype": "MARKET",
"product": "NRML",
"splitsize": 0
}Sample API Response (Analyze Mode)
Sample API Request (Index Underlying with MARKET Order)
Sample API Response (Live Mode)
Sample API Request (LIMIT Order)
Sample API Request (Stop Loss Order)
Parameter Description
apikey
App API key
Mandatory
-
strategy
Strategy name
Mandatory
-
underlying
Underlying symbol (NIFTY, BANKNIFTY, NIFTY30DEC25FUT)
Mandatory
-
exchange
Exchange code (NSE_INDEX, NSE, NFO, BSE_INDEX, BSE, BFO)
Mandatory
-
expiry_date
Expiry date in DDMMMYY format (e.g., 30DEC25)
Mandatory
-
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
-
splitsize
Auto-split order into chunks of this size (0=no split)
Optional
0
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)
Response Parameters
status
API response status (success/error)
string
orderid
Broker order ID (or SB-xxx for analyze mode)
string
symbol
Resolved option symbol
string
exchange
Exchange code where order is placed
string
underlying
Underlying symbol from request
string
underlying_ltp
Last Traded Price of underlying
number
offset
Strike offset from request
string
option_type
Option type (CE/PE)
string
mode
Trading mode (analyze/live)***
string
***Note: mode field is only present in Analyze Mode responses
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.
Product Types for Options
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.
Examples for Different Strategies
1. Buy ATM Straddle
Call Leg:
Put Leg:
2. Covered Call (Equity + Short Call)
Error Response
Common Error Messages
Invalid openalgo apikey
API key is incorrect or expired
Check API key in settings
Option symbol not found
Calculated strike doesn't exist
Check offset and expiry_date
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
Features
Auto Symbol Resolution: Automatically calculates ATM and resolves option symbol
Dual Mode Support: Works in both Live and Analyze (Sandbox) modes
All Order Types: Supports MARKET, LIMIT, SL, and SL-M orders
Real-time LTP: Uses current market price for ATM calculation
Strategy Tracking: Associates orders with strategy names for analytics
Telegram Alerts: Automatic notifications for order placement
Error Handling: Comprehensive error messages for debugging
Rate Limiting
Limit: 10 requests per second
Scope: Per API endpoint
Response: 429 status code if limit exceeded
Best Practices
Test in Analyze Mode First: Enable Analyze Mode to test strategies without real money
Verify Lot Size: Ensure quantity is a multiple of lot size
Verify Offset: Ensure offset value is valid (ATM, ITM1-ITM50, OTM1-OTM50)
Use Appropriate Product: MIS for intraday, NRML for overnight
Handle Errors: Implement error handling for failed orders
Monitor Margin: Check available margin before placing orders
Update Master Contracts: Keep symbol database updated for accurate symbol resolution
Last updated
Was this helpful?