These scripts implement options strategies that don’t fit neatly into a single bullish, bearish, or neutral category. They combine directional and volatility views, or are primarily volatility plays regardless of market direction.
Before running: Replace ACCESS_TOKEN in each file with your Upstox access token.
Works on any index: Change
"Nifty 50"insearch_instrument()to trade a different index — e.g."Nifty Bank"for Bank Nifty or"SENSEX"for BSE Sensex.
When to use: You expect a moderate upward move in Nifty but not a big rally. You want to enter at very low cost or even collect a small credit.
What it does: Buys one ATM call and sells two OTM calls (ATM+1). The two sold calls bring in more premium than the one bought call costs, so this trade is often entered at zero cost or a small net credit. Maximum profit is at the short strike (ATM+1). If Nifty rises sharply beyond ATM+1, the uncovered short call starts losing — this is the key risk.
Example:
You profit when : Nifty closes below 23,290 (approx upper breakeven)
Max profit : ₹120 per unit — if Nifty closes exactly at 23,150
Max loss : Increases as Nifty rises sharply above the short strike — no hard cap
Warning: The uncovered portion of the short call creates unlimited upside risk. Always have a stop-loss in place if Nifty rallies strongly.
Run:
python3 code/call_ratio_spread.py
When to use: You expect a moderate fall in Nifty but not a sharp crash. You want to enter at very low cost or collect a small credit.
What it does: Buys one ATM put and sells two OTM puts (ATM-1). The two sold puts generate more premium than the one bought put costs, so this trade is often entered at zero cost or a small net credit. Maximum profit is at the short strike (ATM-1). If Nifty falls sharply below ATM-1, the uncovered short put starts losing — this is the key risk.
Example:
You profit when : Nifty closes above 22,810 (approx lower breakeven)
Max profit : ₹110 per unit — if Nifty closes exactly at 23,050
Max loss : Increases as Nifty falls sharply below the short strike — no hard cap
Warning: The uncovered portion of the short put creates large downside risk. Always have a stop-loss in place if Nifty falls sharply.
Run:
python3 code/put_ratio_spread.py
When to use: You expect a big move in Nifty but are unsure of the direction — for example, before a major event like RBI policy, budget, or election results.
What it does: Buys both an ATM call and an ATM put at the same strike. You profit if Nifty moves significantly in either direction — up or down. The total premium paid is your maximum loss, which occurs only if Nifty closes exactly at the strike at expiry. This is the opposite of the short straddle.
Think of it as paying for volatility. You don’t care which way the market goes — you just need it to move enough to cover both premiums.
Example:
Upper breakeven : 23,100 + 280 = 23,380
Lower breakeven : 23,100 − 280 = 22,820
Max profit : Unlimited — grows as Nifty moves far in either direction
Max loss : ₹280 per unit — if Nifty closes exactly at ATM strike
Long vs Short Straddle: Long straddle profits from big moves; short straddle profits from calm markets. Choose based on your volatility expectation, not just direction.
Run:
python3 code/long_straddle.py
When to use: Same as the long straddle — you expect a big move but don’t know the direction. You want a cheaper entry than the straddle and are okay with a wider breakeven range.
What it does: Buys an OTM call (ATM+1) and an OTM put (ATM-1). Since both options are already out of the money, they cost less than ATM options. Total premium paid is lower, but Nifty needs to move further before the trade starts making money.
Example:
Upper breakeven : 23,150 + 205 = 23,355
Lower breakeven : 23,050 − 205 = 22,845
Max profit : Grows as Nifty moves far in either direction
Max loss : ₹205 per unit — if Nifty closes between the two bought strikes
Straddle vs Strangle: Strangle is cheaper but needs a larger move to profit. Straddle costs more but starts profiting sooner. Pick strangle when you expect a large move; straddle when you expect a moderate but decisive move.
Run:
python3 code/long_strangle.py
When to use: You expect Nifty to move significantly away from its current level but want your risk and cost to be fully capped. The opposite of the iron butterfly.
What it does: Buys both an ATM call and ATM put (like a straddle), and sells an OTM call (ATM+2) and OTM put (ATM-2) as wings to reduce the net cost. The sold wings cap your maximum profit but significantly lower what you pay to enter. You profit if Nifty moves beyond the ATM strike by more than the net debit paid.
Example:
Upper breakeven : ATM strike + Net debit = 23,100 + 165 = 23,265
Lower breakeven : ATM strike − Net debit = 23,100 − 165 = 22,935
Max profit : Wing width − Net debit — capped at the outer wings
Max loss : ₹165 per unit — if Nifty closes exactly at ATM strike
Long Iron Butterfly vs Long Straddle: The iron butterfly is cheaper to enter because the sold wings offset cost, but your profit is capped. Use it when you want defined risk on both cost and reward.
Run:
python3 code/long_iron_butterfly.py
When to use: You expect Nifty to break out of its current range but want fully capped risk. The opposite of the short iron condor.
What it does: Buys an OTM call (ATM+1) and an OTM put (ATM-1), and sells further OTM call (ATM+2) and put (ATM-2) wings to cap the cost. You pay a net debit. The trade profits if Nifty moves beyond either of the inner bought strikes by enough to cover the net debit paid. Both max profit and max loss are fully defined.
Example:
Upper breakeven : Short call strike + Net debit = 23,150 + 90 = 23,240
Lower breakeven : Short put strike − Net debit = 23,050 − 90 = 22,960
Max profit : Wing width − Net debit — earned when Nifty moves beyond outer wings
Max loss : ₹90 per unit — the net premium paid
Long Iron Condor vs Long Strangle: Both profit from big moves, but the condor is cheaper because the wings cap your cost. The trade-off is capped profit. Use the condor when you want a cheaper, defined-risk volatility play.
Run:
python3 code/long_iron_condor.py
When to use: You expect a big move in Nifty but lean towards a fall being more likely. You want to profit in either direction but earn more if the market drops.
What it does: Buys one ATM call and two ATM puts at the same strike. It’s like a long straddle but with an extra put — so the downside pays out twice as much as the upside. You pay more premium than a straddle, but the additional put doubles your profit for every point Nifty falls below the breakeven. If Nifty rallies instead, you still profit, just at a slower rate.
Think of it as a straddle with a bearish tilt — you’re not sure which way it goes, but you’re guessing down is more likely.
Example:
Upper breakeven : Strike + Total premium = 23,100 + 410 = 23,510
Lower breakeven : Strike − (Total premium ÷ 2) = 23,100 − 205 = 22,895
Max profit : Unlimited on both sides — larger on the downside (2× puts)
Max loss : ₹410 per unit — if Nifty closes exactly at the ATM strike
Strip vs Long Straddle: Strip profits more on a big fall, less on a big rise. Use it when you expect volatility but have a slight bearish bias.
Run:
python3 code/strip.py
When to use: You expect a big move in Nifty but lean towards a rise being more likely. You want to profit in either direction but earn more if the market rallies.
What it does: Buys two ATM calls and one ATM put at the same strike. It’s like a long straddle but with an extra call — so the upside pays out twice as much as the downside. You pay more premium than a straddle, but the additional call doubles your profit for every point Nifty rises above the breakeven. If Nifty falls instead, you still profit, just at a slower rate.
Think of it as a straddle with a bullish tilt — you’re not sure which way it goes, but you’re guessing up is more likely.
Example:
Upper breakeven : Strike + (Total premium ÷ 2) = 23,100 + 215 = 23,315
Lower breakeven : Strike − Total premium = 23,100 − 430 = 22,670
Max profit : Unlimited on both sides — larger on the upside (2× calls)
Max loss : ₹430 per unit — if Nifty closes exactly at the ATM strike
Strap vs Long Straddle: Strap profits more on a big rally, less on a big fall. Use it when you expect volatility but have a slight bullish bias.
Run:
python3 code/strap.py