Skip to main content

Options order

Resolve an option contract and submit a smart order, optionally split into smaller orders. This is a trading operation.

Offline source contract; this page is not a production deployment announcement. Replace symbols, expiries, quantities and mode snapshots with current account evidence before use.

POST /api/v1/optionsorder​

Authentication: apikey JSON; identity checked in route/service. Send a JSON object with Content-Type: application/json.

Parameters​

FieldTypeRequiredDefault / omissionMeaning
expected_modeStringYesrequiredCurrent server mode: live or analyze.
expected_balance_typeStringYesrequiredCurrent balance type: live or sandbox.
expected_mode_versionIntegerYesrequiredCurrent integer version returned by Funds/Analyzer; refresh after a mode switch.
request_idStringYesrequiredSave before submission. For protected placement retain the same ID and payload for an intentional retry; do not replay an ambiguous submission automatically.
apikeyStringYesrequiredPer-broker IMC key; never use the broker access token.
strategyStringYesrequiredStrategy name.
underlyingStringYesrequiredUnderlying index/equity/future symbol.
exchangeStringYesrequiredExchange identifier supported by the selected instrument and broker.
expiry_dateStringNoomitted; see behavior belowExpiry in DDMMMYY format; use an available master-contract expiry.
strike_intIntegerNoomitted; see behavior belowPositive strike interval override; omit to use actual strikes.
offsetStringYesrequiredATM, ITM1–ITM50 or OTM1–OTM50.
option_typeStringYesrequiredCE or PE (lowercase accepted by schema).
actionStringYesrequiredBUY or SELL.
quantityIntegerYesrequiredPositive quantity; use the current lot size for derivatives.
position_sizeIntegerYesrequiredTarget position size for smart-order execution.
splitsizeIntegerNo00 disables splitting; positive size divides the requested quantity.
pricetypeStringNo"MARKET"Execution price type; supported values depend on the operation.
productStringNo"MIS"Broker-supported product; see constraints below.
priceFloatNo0.0Non-negative price; LIMIT requires a usable positive price.
trigger_priceFloatNo0.0Stop-order trigger price.
disclosed_quantityIntegerNo0Disclosed quantity, subject to broker rules.

Request example​

{
"expected_mode": "analyze",
"expected_balance_type": "sandbox",
"expected_mode_version": 7,
"request_id": "saved-business-request-001",
"apikey": "YOUR_BROKER_IMC_KEY",
"strategy": "Python",
"underlying": "NIFTY",
"exchange": "NSE_INDEX",
"offset": "ATM",
"option_type": "CE",
"action": "BUY",
"quantity": 65,
"position_size": 65,
"expiry_date": "31DEC26",
"product": "MIS"
}

Python SDK​

from layr0_imc import api

client = api(api_key="YOUR_BROKER_IMC_KEY", host="https://YOUR_IMC_HOST")
# Copy the current snapshot from Funds/Analyzer for this same key.
client.set_mode_context(expected_mode="analyze", expected_balance_type="sandbox", expected_mode_version=7)

result = client.optionsorder(request_id='saved-business-request-001', strategy='Python', underlying='NIFTY', exchange='NSE_INDEX', offset='ATM', option_type='CE', action='BUY', quantity=65, position_size=65, expiry_date='31DEC26', product='MIS')
print(result)

Response and errors​

Illustrative 200 success; values are examples, not broker evidence:

{
"status": "success",
"orderid": "EXAMPLE_ORDER_ID",
"symbol": "NIFTY31DEC2625000CE",
"exchange": "NFO",
"underlying": "NIFTY",
"underlying_ltp": 25000,
"offset": "ATM",
"option_type": "CE",
"mode": "analyze",
"balance_type": "sandbox",
"mode_version": 7
}

All incoming JSON objects and arrays follow recursive forbidden-field validation. A prohibited documentation key returns 400 before execution:

{
"status": "error",
"error_code": "FORBIDDEN_JSON_FIELD",
"message": "Documentation fields are not allowed in request JSON."
}

Schema errors use 400. Authentication and broker-session failures retain endpoint-specific errors. Missing mode preconditions use 428 in services (the REST schema can reject missing fields with 400); stale mode snapshots use 409. See HTTP errors and authentication/mode requirements. No error response authorizes an automatic order retry.

Modes, capabilities and usage​

Requires current mode metadata and one service-owned parent lease, which remains active through child execution and splitting. Child requests retain broker identity and mode preconditions. Non-split results contain orderid and resolved symbol details; split results contain results with individual statuses. Semi-auto approval and smart position sizing remain applicable. Preserve partial failures and reconcile unknown outcomes before further orders. Usage is recorded through the established child order execution policy; this route has no additional usage-recording decorator.

Source handler: restx_api.options_order.OptionsOrder.post. Source services: services.place_options_order_service.place_options_order.