OptionDesk

How Per-Leg Expiry Works on OptionDesk

Calendar spread backtest India: give each leg its own expiry to build calendars and diagonals. How expiry slots resolve, and what if the near leg expires first.

Updated 2026-11-27 · 6 min read

On this page
  1. Why time is a position, not just a deadline
  2. Expiry slots, not dates
  3. Do weekly slots exist on every index?
  4. What happens at the near leg's expiry
  5. Reading the controls
  6. What mistakes do traders make?
  7. Next step

Most structures put every leg in one expiry. Calendars and diagonals do not, and the engine supports them by letting each leg name its own. This page explains how that resolves and what it does not do.

The per-leg expiry selector. Two legs on different expiries is a calendar; different expiries and different strikes is a diagonal. The per-leg expiry selector. Two legs on different expiries is a calendar; different expiries and different strikes is a diagonal.

Why time is a position, not just a deadline

Every option is a bet on two things at once: where the underlying goes, and how much time is left. Buy and sell the same strike in two different expiries and you cancel most of the first bet and keep the second — you are trading time itself.

The near leg decays faster than the far leg. That difference is the whole position.

An analogy: two ice blocks, one small, one large, in the same room. Both melt. The small one melts faster. A calendar is selling the small one and buying the large one, and being paid for the difference in melting speed.

Expiry slots, not dates

Each leg row carries its own expiry selector: Wk 0, Wk 1, Wk 2, Mth 0, Mth 1.

These are slots, resolved against the entry day rather than fixed dates. Wk 0 is the nearest weekly expiry on or after that day; Wk 1 the one after; Mth 0 the nearest monthly.

That is what lets one rule run across years. A backtest across several years does not name a single contract anywhere — each cycle resolves its own legs from its own day. Fixed dates would give you one trade.

Same expiry, both legs → a vertical, a strangle, a condor. Different expiries, same strike → a calendar. Different expiries, different strikes → a diagonal.

The duplicate-leg guard understands this. The same strike and side is rejected inside one expiry — where it is just a doubled position, not a structure — but allowed across two, because that is the structure.

Do weekly slots exist on every index?

No, and the answer depends on the window. The archive labels each contract weekly or monthly and carries its expiry date, so the slots resolve out of the data rather than off a calendar we keep in step with the exchange.

Underlying and window What Wk 0 resolves to
NIFTY, or SENSEX on BSE, any window The nearest weekly expiry on or after the entry day
BankNifty, FinNifty, MidcpNifty, before November 2024 The nearest weekly expiry, as for NIFTY
The same three, after November 2024 The nearest monthly expiry: weekly contracts were discontinued, so Wk 0 equals Mth 0 and Wk 1 equals Mth 1
An F&O stock, any window The nearest monthly expiry

When a weekly slot falls back to a monthly, the result header carries a line saying the underlying has no weekly contracts in that window. A calendar built from Wk 0 and Wk 1 on BankNifty in 2025 is therefore a monthly-to-next-monthly calendar, not a weekly one. On the form, an underlying with monthly contracts only shows a note and its legs use Mth 0 and Mth 1.

What happens at the near leg's expiry

This is the part that decides whether a calendar backtest means what you think it means.

The position is not carried past the nearest leg's expiry. In a hold-to-expiry run the session window is truncated to the earliest expiry across all legs. On that day, both legs are squared off at your configured exit time and the trade reports TIME.

So the far leg is closed at market, at whatever it is worth that afternoon. It is never expired, never assigned, and never left running.

Three consequences worth stating plainly:

  • There is no roll. The engine will not close the near leg and open the next one. Rolling is a decision, and the engine does not make decisions for you. What this measures is holding the structure to the near expiry — a narrower question than a rolled calendar programme, but one with an unambiguous answer.
  • Margin is estimated once, at entry. It is not re-estimated as the structure changes. Read it as a pre-trade figure.
  • Incomplete cycles are skipped, not half-run. If the window cannot reach the required expiry — usually the far leg running past the end of the archive — the cycle is skipped with a reason. A partially simulated calendar would be reporting a result for a trade that never finished.

The common misconception. "A calendar backtest tells me whether selling weeklies against a monthly works." It tells you whether one such structure, held to the near expiry, worked. The rolled programme — sell the next weekly, and the next — is a different strategy, and this measures a single leg of it.

Reading the controls

On each leg row, the expiry selector sits alongside side, lots, strike criterion, SL% and TP%. Its tooltip states the purpose directly: "Which expiry this leg trades. Put two legs on different expiries to build a calendar or a diagonal."

The panel footer repeats the division of responsibility, which is worth internalising: SL%, TP% and Trail act on that leg alone; the position stop and target act on the whole structure. On a calendar that distinction matters more than usual — a leg stop on the near leg leaves you holding a naked long in a further expiry.

Every other per-leg rule works normally across expiries. A leg's stop is a percentage of its own entry premium, so the far leg's stop is calculated on the far leg's price, not on the structure's net debit.

What mistakes do traders make?

Expecting the far leg to be held past the near expiry. It is closed with everything else on the near leg's expiry day.

Reading a calendar result as a rolled-calendar result. They are different strategies. This one has a defined end.

Putting a leg stop on one leg of a calendar without thinking about what remains. Cutting the short near leg leaves a long far leg — a completely different position from the one you tested. Consider Exit all legs when one fires if that is not what you want.

Assuming the margin figure updates. It is an entry-time estimate for the full structure.

Using Wk 2 or Mth 1 near the end of the archive. The far cycle may not fit inside the data, and those cycles are skipped — which can quietly shrink the sample. Check the trade count against the number of cycles you expected.

Next step

Open /backtest, build two legs at the same strike with Wk 0 and Wk 1, and run it. Then compare against the same structure with both legs in Wk 0 — the difference is what the time spread was actually worth. Read stops and targets before adding per-leg rules to a calendar.

Common questions

Can each leg of a strategy have a different expiry?
Yes. Every leg row carries its own expiry selector — Wk 0, Wk 1, Wk 2, Mth 0 or Mth 1. Two legs on different expiries at the same strike is a calendar; at different strikes it is a diagonal. Each leg is filled and marked from its own expiry cycle's data, minute by minute.
What do Wk 0, Wk 1, Mth 0 mean?
They are slots, not dates. Wk 0 is the nearest weekly expiry on or after the entry day, Wk 1 the one after that, Wk 2 the one after that; Mth 0 is the nearest monthly and Mth 1 the next. Resolving a slot rather than a fixed date is what lets one rule run across years of history — every cycle picks its own contracts.
Can I put two legs on the same strike and side if they have different expiries?
Yes, and that is exactly what a calendar is. The duplicate-leg guard is expiry-aware: the same strike and side is rejected only within one expiry, where it would just be a doubled position rather than a structure.
What happens when the near leg expires before the far leg?
The position is not carried past the nearest leg's expiry. In a hold-to-expiry run the session window is truncated to the earliest expiry across all legs, and on that day both legs are squared off at the configured exit time with the reason TIME. The far leg is closed at market — never expired, never assigned, and never rolled.
Does the engine roll the near leg of a calendar?
No. Rolling is a decision, not a mechanic, and the engine does not make decisions on your behalf. A calendar backtest here measures holding the structure to the near leg's expiry, which is a narrower question than a rolled calendar programme but an honest one.
Is margin recalculated when one leg of a calendar closes?
No. Margin is estimated once at entry and not re-estimated as the structure changes, so a calendar's margin figure reflects the full two-leg structure throughout. Treat it as a pre-trade estimate rather than a running requirement.
Does Wk 0 mean a weekly expiry on every index?
No. Weekly contracts on NSE's BankNifty, FinNifty and MidcpNifty were discontinued in November 2024, and F&O stocks have only ever had monthlies. On an underlying with no weekly contract in the window, a weekly slot resolves to the nearest monthly (Wk 0 becomes Mth 0, Wk 1 becomes Mth 1), and the result header says so.
Why does my calendar backtest skip some cycles?
If the truncated window cannot reach the required expiry — usually because the far leg's cycle runs past the end of the archive — the cycle is skipped with a reason rather than half-run. A partially simulated calendar would report a result for a trade that never finished.

Disclosures

  • Not investment advice. OptionDesk provides tools, analytics, backtesting and education for NSE F&O only. It is not a SEBI-registered Investment Adviser or Research Analyst, and does not provide investment advice, buy/sell calls, tips or trade execution. You place every order yourself, through your own broker.
  • Projected, not promised. Every projected figure — payoffs, max profit/loss, probability of profit, target-date P&L and similar estimates — is “projected, not advice.” Backtested and simulated results are hypothetical, do not represent actual trading, and are not indicative of future results.
  • Delayed market data. Market data shown on OptionDesk is delayed by approximately one minute — it is not a live feed. It is provided for analysis and education only, and must not be relied on for time-sensitive execution.
  • F&O risk. Trading in futures & options carries a high risk of loss and is not suitable for every investor. Consider your objectives and risk tolerance, and seek independent advice where appropriate.

More in How the engine works