Backtesting
Fetch historical candle data and instrument information for backtesting trading strategies using Groww APIs
Groww Symbol
Groww symbol is a easy to construct unique identifier for an instrument across exchanges and segments. It is formed by concatenating
- Exchange - Where the instrument is traded
- Trading Symbol - The name/ticker of the instrument
- Expiry Date - Only for derivatives (format: DDMmmYY, example: 23Jan25)
- Strike Price - Only for options (the target price level)
- Option Type - Only for derivatives:
- CE = Call Option
- PE = Put Option
- FUT = Futures
For Stocks and Indices: Only exchange and trading symbol are used.
For Futures: Exchange, trading symbol, expiry date, and "FUT" are used.
For Options: All components are used including strike price and option type (CE/PE).
For example:
- Equity:
NSE-WIPRO
,BSE-RELIANCE
- Index:
NSE-NIFTY
,BSE-SENSEX
- Future:
NSE-NIFTY-30Sep25-FUT
,BSE-SENSEX-25Sep25-FUT
- Call Option:
NSE-NIFTY-30Sep25-24650-CE
,BSE-SENSEX-25Sep25-79500-CE
- Put Option:
NSE-NIFTY-30Sep25-24650-PE
,BSE-SENSEX-25Sep25-79500-PE
Groww symbol also exists in the instruments csv file and it can be obtained from the Get Instruments API.
Get Expiries
GET https://api.groww.in/v1/historical/expiries
This API retrieves available expiry dates for derivatives instruments (FNO) for a given exchange and underlying symbol. Useful for backtesting options and futures strategies. Data of FNO instruments are available from 2020.
Request
Request schema
Name | Type | Description |
---|---|---|
exchange * | string | Stock exchange (NSE, BSE) |
underlying_symbol * | string | Underlying symbol for which expiry dates are required (e.g., NIFTY, BANKNIFTY, RELIANCE) |
year | integer | Year for which expiry dates are required (2020 - current year). If year is not specified, current year is considered. |
month | integer | Month for which expiry dates are required (1-12). If month is not specified, expiries of the entire year is returned. |
*
required parameters
Response
Response Schema
Name | Type | Description |
---|---|---|
payload | array[string] | Array of expiry dates in YYYY-MM-DD format |
Get Contracts
GET https://api.groww.in/v1/historical/contracts
This API retrieves available contract symbols for derivatives instruments for a given exchange, underlying symbol, and expiry date. Essential for backtesting specific options or futures contracts. Data of FNO instruments are available from 2020.
Request
Request schema
Name | Type | Description |
---|---|---|
exchange * | string | Stock exchange (NSE, BSE) |
underlying_symbol * | string | Underlying symbol for which contracts are required (1-20 characters) |
expiry_date * | string | Expiry date in YYYY-MM-DD format for which contracts are required |
*
required parameters
Response
Response Schema
Name | Type | Description |
---|---|---|
payload | array[string] | Array of groww symbols of the contracts available for the given expiry date |
Get Historical Candle Data
GET https://api.groww.in/v1/historical/candles
Fetch historical candle data for backtesting trading strategies. This API provides
- Historical OHLC (Open, High, Low, Close) data for all instruments
- Volume for tradable instruments (Equities and FNO)
- Open Interest (OI) for FNO Data of Equities, Indices and FNO instruments are available from 2020.
Request
Request schema
Name | Type | Description |
---|---|---|
exchange * | string | Stock exchange (NSE, BSE) |
segment * | string | Segment of the instrument such as CASH, FNO etc. |
groww_symbol * | string | Groww symbol of the instrument for which historical data is required |
start_time * | string | Start time in yyyy-MM-dd HH:mm:ss or epoch seconds format from which data is required |
end_time * | string | End time in yyyy-MM-dd HH:mm:ss or epoch seconds format until which data is required |
candle_interval * | string | Interval for which data is required. |
*
required parameters
Response
All prices in rupees.
Response Schema
Name | Type | Description |
---|---|---|
candles | array[array] | Array of candle data. Each candle contains: timestamp (yyyy-MM-dd HH:mm:ss), open, high, low, close, volume |
closing_price | float | Closing price of the instrument |
start_time | string | Start time in yyyy-MM-dd HH:mm:ss format |
end_time | string | End time in yyyy-MM-dd HH:mm:ss format |
interval_in_minutes | int | Interval in minutes |
Using Expiries and Contracts APIs for FNO Backtesting
You can combine the expiries and contracts APIs to fetch historical candle data for derivatives instruments. Here's a complete workflow:
Step 1: Get Available Expiries
Step 2: Get Contracts for Specific Expiry
Step 3: Fetch Historical Candles for Specific Contract
Backtesting Data Limits
Candle Intervals | Max Duration per Request |
---|---|
1 min, 2 min, 3 min, 5 min | 30 days |
10 min, 15 min, 30 min | 90 days |
1 hour, 4 hours, 1 day, 1 week, 1 month | 180 days |