options-trading
Options trading with OpenAlgo - single leg orders, multi-leg strategies (Iron Condor, Straddle, Strangle, Spreads), options chain analysis, and Greeks calculation
What this skill does
# OpenAlgo Options Trading
Execute options trading strategies using OpenAlgo's unified Python SDK. Supports index options (NIFTY, BANKNIFTY, FINNIFTY), stock options, and complex multi-leg strategies.
## Environment Setup
```python
from openalgo import api
client = api(
api_key='your_api_key_here',
host='http://127.0.0.1:5000'
)
```
## Quick Start Scripts
### Single Leg Options Order
```bash
python scripts/options_order.py --underlying NIFTY --expiry 30JAN25 --offset ATM --option-type CE --action BUY --quantity 75
```
### Iron Condor Strategy
```bash
python scripts/iron_condor.py --underlying NIFTY --expiry 30JAN25 --quantity 75
```
### Straddle Strategy
```bash
python scripts/straddle.py --underlying BANKNIFTY --expiry 30JAN25 --action BUY --quantity 30
```
---
## Options Symbol Format
OpenAlgo uses standardized symbol formats:
| Type | Format | Example |
|------|--------|---------|
| Index Options | `[INDEX][DDMMMYY][STRIKE][CE/PE]` | `NIFTY30JAN2526000CE` |
| Stock Options | `[SYMBOL][DDMMMYY][STRIKE][CE/PE]` | `RELIANCE30JAN251400CE` |
| Index Futures | `[INDEX][DDMMMYY]FUT` | `NIFTY30JAN25FUT` |
## Offset System
OpenAlgo uses an intuitive offset system to select strikes relative to ATM:
| Offset | Meaning | Example (NIFTY ATM=26000) |
|--------|---------|---------------------------|
| `ATM` | At The Money | 26000 |
| `ITM1` | 1 strike In The Money | CE: 25950, PE: 26050 |
| `ITM2` | 2 strikes In The Money | CE: 25900, PE: 26100 |
| `OTM1` | 1 strike Out of The Money | CE: 26050, PE: 25950 |
| `OTM2` | 2 strikes Out of The Money | CE: 26100, PE: 25900 |
| `OTM5` | 5 strikes Out of The Money | CE: 26250, PE: 25750 |
---
## Core API Methods
### 1. Single Leg Options Order
Place ATM, ITM, or OTM options orders:
```python
# ATM Call Option
response = client.optionsorder(
strategy="OptionsBot",
underlying="NIFTY",
exchange="NSE_INDEX",
expiry_date="30JAN25",
offset="ATM",
option_type="CE",
action="BUY",
quantity=75,
pricetype="MARKET",
product="NRML",
splitsize=0 # 0 = no splitting
)
```
**Response:**
```json
{
"exchange": "NFO",
"offset": "ATM",
"option_type": "CE",
"orderid": "25013000000001",
"status": "success",
"symbol": "NIFTY30JAN2526000CE",
"underlying": "NIFTY30JAN25FUT",
"underlying_ltp": 26015.50
}
```
**ITM Put Option:**
```python
response = client.optionsorder(
strategy="OptionsBot",
underlying="NIFTY",
exchange="NSE_INDEX",
expiry_date="30JAN25",
offset="ITM3", # 3 strikes ITM
option_type="PE",
action="BUY",
quantity=75,
pricetype="MARKET",
product="NRML"
)
```
**OTM Call Option:**
```python
response = client.optionsorder(
strategy="OptionsBot",
underlying="NIFTY",
exchange="NSE_INDEX",
expiry_date="30JAN25",
offset="OTM5", # 5 strikes OTM
option_type="CE",
action="SELL",
quantity=75,
pricetype="MARKET",
product="NRML"
)
```
### 2. Multi-Leg Options Order
Execute complex strategies with multiple legs in a single call:
#### Iron Condor (4 legs)
```python
response = client.optionsmultiorder(
strategy="Iron Condor",
underlying="NIFTY",
exchange="NSE_INDEX",
expiry_date="30JAN25",
legs=[
{"offset": "OTM6", "option_type": "CE", "action": "BUY", "quantity": 75},
{"offset": "OTM6", "option_type": "PE", "action": "BUY", "quantity": 75},
{"offset": "OTM4", "option_type": "CE", "action": "SELL", "quantity": 75},
{"offset": "OTM4", "option_type": "PE", "action": "SELL", "quantity": 75}
]
)
```
**Response:**
```json
{
"status": "success",
"underlying": "NIFTY",
"underlying_ltp": 26050.45,
"results": [
{"leg": 1, "action": "BUY", "offset": "OTM6", "option_type": "CE", "symbol": "NIFTY30JAN2526350CE", "orderid": "123", "status": "success"},
{"leg": 2, "action": "BUY", "offset": "OTM6", "option_type": "PE", "symbol": "NIFTY30JAN2525750PE", "orderid": "124", "status": "success"},
{"leg": 3, "action": "SELL", "offset": "OTM4", "option_type": "CE", "symbol": "NIFTY30JAN2526250CE", "orderid": "125", "status": "success"},
{"leg": 4, "action": "SELL", "offset": "OTM4", "option_type": "PE", "symbol": "NIFTY30JAN2525850PE", "orderid": "126", "status": "success"}
]
}
```
#### Bull Call Spread (2 legs)
```python
response = client.optionsmultiorder(
strategy="Bull Call Spread",
underlying="NIFTY",
exchange="NSE_INDEX",
expiry_date="30JAN25",
legs=[
{"offset": "ATM", "option_type": "CE", "action": "BUY", "quantity": 75},
{"offset": "OTM2", "option_type": "CE", "action": "SELL", "quantity": 75}
]
)
```
#### Bear Put Spread (2 legs)
```python
response = client.optionsmultiorder(
strategy="Bear Put Spread",
underlying="NIFTY",
exchange="NSE_INDEX",
expiry_date="30JAN25",
legs=[
{"offset": "ATM", "option_type": "PE", "action": "BUY", "quantity": 75},
{"offset": "OTM2", "option_type": "PE", "action": "SELL", "quantity": 75}
]
)
```
#### Straddle (2 legs)
```python
response = client.optionsmultiorder(
strategy="Long Straddle",
underlying="BANKNIFTY",
exchange="NSE_INDEX",
expiry_date="30JAN25",
legs=[
{"offset": "ATM", "option_type": "CE", "action": "BUY", "quantity": 30},
{"offset": "ATM", "option_type": "PE", "action": "BUY", "quantity": 30}
]
)
```
#### Strangle (2 legs)
```python
response = client.optionsmultiorder(
strategy="Short Strangle",
underlying="NIFTY",
exchange="NSE_INDEX",
expiry_date="30JAN25",
legs=[
{"offset": "OTM3", "option_type": "CE", "action": "SELL", "quantity": 75},
{"offset": "OTM3", "option_type": "PE", "action": "SELL", "quantity": 75}
]
)
```
#### Diagonal Spread (Different Expiries)
```python
response = client.optionsmultiorder(
strategy="Diagonal Spread",
underlying="NIFTY",
exchange="NSE_INDEX",
legs=[
{"offset": "ITM2", "option_type": "CE", "action": "BUY", "quantity": 75, "expiry_date": "27FEB25"},
{"offset": "OTM2", "option_type": "CE", "action": "SELL", "quantity": 75, "expiry_date": "30JAN25"}
]
)
```
#### Calendar Spread (Same Strike, Different Expiries)
```python
response = client.optionsmultiorder(
strategy="Calendar Spread",
underlying="NIFTY",
exchange="NSE_INDEX",
legs=[
{"offset": "ATM", "option_type": "CE", "action": "BUY", "quantity": 75, "expiry_date": "27FEB25"},
{"offset": "ATM", "option_type": "CE", "action": "SELL", "quantity": 75, "expiry_date": "30JAN25"}
]
)
```
---
## Options Analysis
### Get Option Symbol
Find the exact symbol for a given strike:
```python
response = client.optionsymbol(
underlying="NIFTY",
exchange="NSE_INDEX",
expiry_date="30JAN25",
offset="ATM",
option_type="CE"
)
# Response: {'symbol': 'NIFTY30JAN2526000CE', 'exchange': 'NFO', 'lotsize': 75, ...}
```
### Get Option Chain
Retrieve the full option chain for analysis:
```python
chain = client.optionchain(
underlying="NIFTY",
exchange="NSE_INDEX",
expiry_date="30JAN25",
strike_count=10 # ±10 strikes from ATM
)
```
**Response includes for each strike:**
```json
{
"strike": 26000.0,
"ce": {
"symbol": "NIFTY30JAN2526000CE",
"label": "ATM",
"ltp": 250.50,
"bid": 250.00,
"ask": 251.00,
"volume": 1500000,
"oi": 5000000,
"lotsize": 75
},
"pe": {
"symbol": "NIFTY30JAN2526000PE",
"label": "ATM",
"ltp": 245.00,
"bid": 244.50,
"ask": 245.50,
"volume": 1200000,
"oi": 4500000,
"lotsize": 75
}
}
```
### Calculate Option Greeks
Get Delta, Gamma, Theta, Vega, Rho for any option:
```python
greeks = client.optiongreeks(
symbol="NIFTY30JAN2526000CE",
exchange="NFO",
interest_rate=0.00,
underlying_symbol="NIFTY",
underlying_exchange="NSE_INDEX"
)
```
**Response:**
```json
{
"status": "success",
"symbol": "NIFTY30JAN2526000CE",
"optiRelated in General
modeling-omnistudio-epc-catalog
IncludedSalesforce Industries CME EPC product-modeling skill for Product2-based catalog creation. Use when creating EPC products, configuring product attributes, building offer bundles with Product Child Items, or reviewing EPC DataPack JSON metadata for product catalog changes. TRIGGER when: user creates or updates Product2 EPC records, AttributeAssignment payloads, AttributeMetadata/AttributeDefaultValues, Offer bundles, or ProductChildItem relationships. DO NOT TRIGGER when: designing OmniScripts/FlexCards/Integration Procedures (use building-omnistudio-omniscript, building-omnistudio-flexcard, or building-omnistudio-integration-procedure), implementing Apex business logic (use generating-apex), or troubleshooting deployment pipelines (use deploying-metadata).
relationship-science-coach
IncludedUse this skill for direct, practical adult relationship coaching: couples conflict, repair, trust, marriage, dating, flirting, attachment patterns, emotional connection, sex, desire differences, eroticism, kink negotiation, affection, love languages, breakups, and long-term passion. Draw on Gottman, EFT and Hold Me Tight, attachment science, modern sex research, Perel, Nagoski, Kerner, Schnarch, Love and Stosny, and flexible love-language tools. Be concrete and low-hedge. Redirect only for imminent danger, abuse, coercive control, minors, non-consent, self-harm, stalking, or medical/legal/psychiatric decisions.
building-sf-integrations
IncludedSalesforce integration architecture and runtime plumbing with 120-point scoring. Use this skill to set up Named Credentials, External Credentials, External Services, REST/SOAP callout patterns, Platform Events, and Change Data Capture. TRIGGER when: user sets up Named Credentials, External Services, REST/SOAP callouts, Platform Events, CDC, or touches .namedCredential-meta.xml files. DO NOT TRIGGER when: Connected App/OAuth config (use configuring-connected-apps), Apex-only logic (use generating-apex), or data import/export (use handling-sf-data).
venue-templates
IncludedAccess comprehensive LaTeX templates, formatting requirements, and submission guidelines for major scientific publication venues (Nature, Science, PLOS, IEEE, ACM), academic conferences (NeurIPS, ICML, CVPR, CHI), research posters, and grant proposals (NSF, NIH, DOE, DARPA). This skill should be used when preparing manuscripts for journal submission, conference papers, research posters, or grant proposals and need venue-specific formatting requirements and templates.
let-fate-decide
IncludedDraws the 12 Houses of the Zodiac Tarot spread to inject entropy into planning when prompts are vague, ambiguous, or casually delegated. Interprets the spread to guide next steps. Use when the user says 'let fate decide', 'YOLO', 'whatever', 'idk', or other nonchalant phrases, makes Yu-Gi-Oh references, or when you are about to arbitrarily pick between multiple reasonable approaches. Prefer over ask-questions-if-underspecified when the user's tone is casual or playful rather than precision-seeking.
net-ops
IncludedCross-platform network troubleshooting (Windows, macOS, Linux) via local or remote shell. Use for: DNS broken, can't resolve hostnames, nslookup/dig works but apps fail, NRPT, WFP, scutil, /etc/resolver, systemd-resolved, /etc/resolv.conf, NetworkManager, VPN DNS leak residue (ProtonVPN/Mullvad/WireGuard/AnyConnect), AV/firewall blocking DNS or DoH, Tailscale DNS interaction, intermittent connectivity, remote diagnostics over SSH.