Rajandran R Creator of OpenAlgo Sketchmaker, RagZ. Building GenAI Applications. Telecom Engineer turned Full-time Derivative Trader. Mostly Trading Nifty, Banknifty, High Liquid Stock Derivatives. Trading the Markets Since 2006 onwards. Using Market Profile and Orderflow for more than a decade. Designed and published 100+ open source trading systems on various trading tools. Now the recent curiosity on building Trading AI Agents.

How to Generate Synthetic Future Charts in Python Using Weekly Options

5 min read

A synthetic future chart rebuilds the price of an index future from options alone: take the ATM call price, subtract the ATM put price and add the strike. In this tutorial you will generate synthetic future charts in Python with OpenAlgo using NIFTY weekly options, plotted as 5-minute candles with Plotly.

Synthetic futures are a smart way to replicate index futures prices using only options data. This technique is particularly helpful when you’re dealing with weekly options and want to track market sentiment or momentum without directly using futures contracts.

Key takeaways

  • Synthetic future price = ATM call price minus ATM put price plus strike price (put-call parity).
  • It tracks the futures price closely and reacts to option repricing, which makes it useful for weekly option traders.
  • The Python script pulls 5-minute CE and PE history through the OpenAlgo API and plots synthetic candles with Plotly.
  • Update the hard-coded expiry before you run the code: NIFTY weekly options now expire on Tuesday.
  • ATM strikes give the cleanest result; deep ITM or OTM strikes add noise.

In this guide, we’ll cover:

Python for traders, the quick way in

BEGINNER FRIENDLY · RATED 5.0

Python for traders, the quick way in

A crash course that gets you from zero to writing your own market data scripts.

  • Python basics with market examples
  • Fetch, clean and chart price data
  • Lifetime access
Start learning →by Marketcalls

What Is a Synthetic Future?

A synthetic future approximates the price of a futures contract using the following formula:

Synthetic Future Price = Call Price - Put Price + Strike Price

This is based on options pricing theory and reflects the fair value of a future using the at-the-money (ATM) options.

Where the formula comes from

Put-call parity for options on the same underlying, strike and expiry says that a long call plus a short put behaves exactly like a long future at the strike price. Rearranging gives F = K + (C minus P). Strictly, the call-put difference should be adjusted for interest until expiry, but for a weekly option with a few days left that adjustment is a few paise on NIFTY, so the simple formula is good enough for charting. This is the same idea behind the synthetic long and short future to reduce transaction cost, where a long call and short put replace a futures position.

InputExample valueResult
ATM strike (K)24,000
Call premium (C)₹152
Put premium (P)₹118
Synthetic future = C minus P plus K152 minus 118 plus 24,00024,034
Illustrative numbers to show the arithmetic, not live market prices.

Why Use Synthetic Futures with Weekly Options?

  1. Improved Liquidity in Options: Weekly options often have better liquidity than their corresponding futures, especially for retail traders.
  2. Early Market Readings: Synthetic futures reflect real-time changes in sentiment as options prices adjust quickly to underlying movements.
  3. Volatility Insight: Since options price includes implied volatility, the synthetic future also indirectly reflects changing volatility conditions.
  4. Better Precision for Option Strategies: Traders executing strategies like intraday straddles or strangles can monitor the synthetic future for trend confirmation.

What changed for weekly options since this was written

  • From 20 November 2024, SEBI allowed each exchange to offer weekly expiries on only one benchmark index, so on NSE only NIFTY 50 kept weekly options (Zerodha summary of the SEBI rules). Bank Nifty, Fin Nifty and Midcap Select weekly contracts were discontinued.
  • From September 2025 NSE moved its derivatives expiry day from Thursday to Tuesday, so NIFTY weekly options now expire on Tuesdays (Angel One report).

Both changes matter for the script below: the symbol format stays the same, but the expiry date you type in must be a valid Tuesday expiry.


Requirements

Before running the code, ensure the following:

  • OpenAlgo application is installed, running, and connected to your broker.
  • Generate your OpenAlgo API Key from the OpenAlgo dashboard.
  • Configure the API key in the Python script.

To install necessary packages:

pip install openalgo pandas plotly

If you’re using a Jupyter notebook:

pip install nbformat ipykernel

Python Code: Generate a Synthetic Future Chart

import pandas as pd
from openalgo import api
from datetime import datetime, timedelta
import plotly.graph_objects as go

client = api(api_key='your_openalgo_api_key', host='http://127.0.0.1:5000')

# Date Range
end_date = datetime.now()
start_date = end_date - timedelta(days=5)

# ATM Strike Calculation
spot = client.quotes(symbol="NIFTY", exchange="NSE_INDEX")['data']['ltp']
atm_strike = round(spot / 50) * 50
expiry = '05JUN25'
ce_symbol = f"NIFTY{expiry}{atm_strike}CE"
pe_symbol = f"NIFTY{expiry}{atm_strike}PE"

# Historical Data
df_ce = client.history(symbol=ce_symbol, exchange="NFO", interval="5m",
                       start_date=start_date.strftime("%Y-%m-%d"),
                       end_date=end_date.strftime("%Y-%m-%d"))
df_pe = client.history(symbol=pe_symbol, exchange="NFO", interval="5m",
                       start_date=start_date.strftime("%Y-%m-%d"),
                       end_date=end_date.strftime("%Y-%m-%d"))

# Combine and Calculate Synthetic Future
df = df_ce[['open', 'high', 'low', 'close']].copy()
df['open'] = df_ce['open'] - df_pe['open'] + atm_strike
df['high'] = df_ce['high'] - df_pe['low'] + atm_strike
df['low'] = df_ce['low'] - df_pe['high'] + atm_strike
df['close'] = df_ce['close'] - df_pe['close'] + atm_strike
df.index = pd.to_datetime(df.index)
formatted_index = df.index.strftime('%d-%b\n%H:%M')

# Plot
fig = go.Figure(data=[
    go.Candlestick(x=formatted_index,
                   open=df['open'], high=df['high'],
                   low=df['low'], close=df['close'],
                   name="Synthetic Future")
])
fig.update_layout(
    title=f'NIFTY Synthetic Future ({atm_strike})',
    xaxis=dict(type="category", tickmode="array",
               tickvals=formatted_index[::len(formatted_index)//10]),
    xaxis_title='Time', yaxis_title='Price',
    template="plotly_dark", xaxis_rangeslider_visible=False,
    height=500, width=800
)

fig.write_html("synthetic_future_chart.html", auto_open=True)
# fig.show()  # Use this only inside a Jupyter Notebook

How the code works

  1. Connect: api() creates an OpenAlgo client pointing at your local OpenAlgo server.
  2. Find the ATM strike: it reads the NIFTY spot LTP and rounds it to the nearest 50 points, which is the NIFTY strike interval.
  3. Build symbols: it creates the CE and PE symbols in OpenAlgo format, for example NIFTY05JUN2524800CE.
  4. Fetch history: it downloads five days of 5-minute candles for both options from NFO.
  5. Calculate: synthetic open and close use CE minus PE plus strike. For the high it uses CE high minus PE low, and for the low CE low minus PE high, which gives the widest possible synthetic range.
  6. Plot: a Plotly candlestick chart is written to synthetic_future_chart.html and opened in the browser.

Tips before you run it

  • Change the expiry string. 05JUN25 was the weekly expiry when this was published. Replace it with the current Tuesday expiry in the same DDMMMYY format.
  • Keep the strike fixed. The script calculates ATM once. If NIFTY moves several hundred points during the five days, the chosen strike drifts away from ATM. That is fine for a chart, but for live monitoring recompute ATM each session.
  • Align the timestamps. If one leg has a missing candle, the subtraction misaligns. Aligning both DataFrames first avoids that:
df_ce, df_pe = df_ce.align(df_pe, join='inner', axis=0)
  • High and low are approximations. The CE high and the PE low may not have happened at the same moment, so treat the wicks as an outer bound and rely on open and close for signals.

Can Synthetic Futures Be Calculated Only from ATM Options?

No, synthetic futures can technically be calculated using any option strike pair (Call and Put with the same strike and expiry). However, ATM (At-The-Money) options are the most commonly used and practically preferred for this purpose.

  1. Put-Call Parity is Most Accurate at ATM.
    This parity relationship holds best for ATM options where extrinsic (time) value dominates, and intrinsic value is minimal.
  2. Better Liquidity and Tighter Spreads
    ATM options typically have the highest trading volumes, leading to more accurate pricing and minimal slippage.
  3. Balanced Implied Volatility
    ATM options are less influenced by volatility skew, making the synthetic value more stable and reflective of actual market sentiment.

Using Non-ATM Strikes: What to Expect

  • In-the-Money (ITM) or Out-of-the-Money (OTM) options can also be used to compute synthetic prices.
  • However, the calculated price may deviate more from the actual future price due to:
    • Lower liquidity
    • Higher bid-ask spreads
    • Uneven implied volatility across strikes

This could introduce noise or pricing bias into your synthetic chart.

How traders use synthetic future charts

  • Straddle and strangle management: the synthetic future shows which way the market is leaning without switching to the futures chart.
  • Spot vs synthetic gap: the difference between synthetic future and spot reflects cost of carry and dividends; an unusual gap near events can signal positioning.
  • Cross-check with the futures contract: when the synthetic future and the actual future diverge noticeably, one of the legs is mispriced or illiquid.
  • Combine with sentiment indicators: pair the chart with a put call ratio chart for a fuller view of option positioning.

Wrapping up

Synthetic future charts provide a unique, real-time view of market direction and option sentiment. They are especially useful in strategies involving intraday options like straddles, giving a more precise edge over traditional spot or futures tracking.

This method not only saves cost (by avoiding direct futures trades) but also provides deeper insights for short-term decision-making using just the options market.

If you have not set up OpenAlgo yet, start with the OpenAlgo introduction, then connect your broker and generate an API key before running the script.

Frequently Asked Questions

What is a synthetic future?

A synthetic future is a position or price built from options that behaves like a futures contract. Buying a call and selling a put at the same strike and expiry creates a synthetic long future; the price equals call premium minus put premium plus strike.

How do you calculate synthetic future price?

Synthetic future price = call price minus put price plus strike price, using a call and put with the same strike and expiry, ideally at the money.

Is synthetic future the same as Nifty futures price?

They are close but not identical. The synthetic future is derived from the weekly options of the chosen expiry, while the listed future is a separate contract with its own expiry, so small differences from carry, liquidity and bid-ask spreads are normal.

Which expiry should I use for NIFTY synthetic futures?

Use the nearest weekly expiry for intraday work because it is the most liquid. NIFTY weekly options currently expire on Tuesdays.

Python Elite membership

MEMBERSHIP

Python Elite membership

15 Python, AI and algo trading programs in one plan, including QuantFlow and AI Bootcamp live mentorship.

  • Python from fundamentals to trading apps
  • Backtesting, broker APIs and OpenAlgo
  • Live QuantFlow and AI Bootcamp sessions
View Python Elite →by Marketcalls

Learn by watching: free videos every week

Market Profile, order flow, Python, AI and OpenAlgo tutorials on YouTube.

Rajandran R Creator of OpenAlgo Sketchmaker, RagZ. Building GenAI Applications. Telecom Engineer turned Full-time Derivative Trader. Mostly Trading Nifty, Banknifty, High Liquid Stock Derivatives. Trading the Markets Since 2006 onwards. Using Market Profile and Orderflow for more than a decade. Designed and published 100+ open source trading systems on various trading tools. Now the recent curiosity on building Trading AI Agents.

One Reply to “How to Generate Synthetic Future Charts in Python Using…”

  1. Hello Sir, is it possible to use automated trading rules for fundamental analysis also?

Leave a Reply

Get Notifications, Alerts on Market Updates, Trading Tools, Automation & More