Intraday Rolling Straddles
Overview
This sample strategy implements an intraday rolling short straddle for NIFTY index options using OpenAlgo Python APIs. The bot sells an at-the-money (ATM) NIFTY straddle at a configurable time, then automatically rolls (closes and reopens a new straddle) whenever the NIFTY spot moves ±0.4% from the last entry reference, up to a user-defined daily limit. All open positions are force-closed (squared off) at a specified time before market close.
Key Features
Instrument: NIFTY Index Options (customizable)
Fixed Expiry: All option orders use the expiry you set (e.g.,
19JUN25
)Entry: Places the first ATM straddle at a configurable time (e.g., 10:00 a.m.)
Rolling Trigger: Monitors the NIFTY spot price; rolls to a new ATM straddle on every 0.4% move from the last reference point
Order Limit: Limits the number of rolling straddles per day (default: 3, can be changed)
Exit: Squares off all open legs at a configurable EOD time (e.g., 3:15 p.m.)
All times in IST (Asia/Kolkata timezone)
No database or persistent logs — actions are printed to the console for full transparency
Parameter-based configuration: Change any key value by simply editing the variable at the top of the script
Python Strategy
Parameters (Edit at Top of Script)
STRADDLE_ENTRY_HOUR
Hour to enter first straddle (24h format)
10
STRADDLE_ENTRY_MINUTE
Minute to enter first straddle
0
SQUAREOFF_HOUR
Hour to force square-off all legs
15
SQUAREOFF_MINUTE
Minute to force square-off all legs
15
MAX_STRADDLES_PER_DAY
Max straddles allowed per day
3
EXPIRY
Expiry date for all option legs (OpenAlgo format)
"19JUN25"
LOT_SIZE
Number of options per leg (NIFTY = 75 as of 2025)
75
Order Format
All orders use the OpenAlgo symbol format:
Call Example:
NIFTY19JUN2522350CE
Put Example:
NIFTY19JUN2522350PE
Orders are placed as:
Type:
MARKET
Action:
SELL
(entry),BUY
(exit)Product:
MIS
Exchange:
NFO
How the Strategy Works
Start & First Entry: At your configured entry time (e.g., 10:00 a.m.), the bot sells 1 lot of ATM NIFTY CE and PE for the expiry you set.
Rolling Logic: Every 5 seconds, the bot checks the latest NIFTY spot. If the spot moves up or down by at least 0.4% from the last entry reference, the bot:
Closes both legs of the current straddle
Sells a new ATM CE and PE (same expiry, current ATM)
Daily Straddle Limit: The bot never enters more straddles than the daily limit you set. (Default: 3 per day)
End-of-Day Squareoff: At your configured squareoff time (e.g., 3:15 p.m.), any open straddle is closed, and no further trades are placed for the day.
Console Logging: All quotes, trades, entries, exits, and reference changes are clearly printed in real time.
Usage
Edit the parameters at the top of the script as needed (no need for .env or environment variables).
Run the script. Ensure your OpenAlgo API is running and accessible.
All actions and errors will be displayed in your terminal or console.
Limitations and Notes
This sample does not use persistent order logging or database.
No explicit risk management or stop loss (can be added if desired).
Only supports one instrument/expiry at a time.
Ensure your OpenAlgo symbol format and expiry match your broker’s contract details.
Last updated