TrueData
India Equities
Introduction
The India Equities dataset by TrueData tracks the Equities listed on the NSE exchange in India. The data covers 2,053 Indian Equities, starts in January 2010, and is delivered on any frequency from minute to daily.
This dataset depends on the India Equity Security Master dataset because the India Equity Security Master dataset contains information on splits, dividends, and symbol changes.
For more information about the India Equities dataset, including CLI commands and pricing, see the dataset listing.
About the Provider
TrueData was founded by Kapil Marwaha in 2007 with goal to provide a multitude of solutions for the financial services sector, including making market data feeds available. TrueData is an authorized NSE and MCX data vendor that supports many applications, including a wide range of technical analysis applications and trading platforms.
Getting Started
The following snippet demonstrates how to request data from the India Equities dataset:
from QuantConnect.DataSource import * # Indian Rupee must be in the Cashbook to trade Indian Equities. self.SetAccountCurrency("INR") # or self.SetCash("INR", 100000) self.equity = self.AddEquity("YESBANK", Resolution.Daily, Market.India).Symbol
using QuantConnect.DataSource; // Indian Rupee must be in the Cashbook to trade Indian Equities. SetAccountCurrency("INR"); // or SetCash("INR", 100000); _equity = AddEquity("YESBANK", Resolution.Daily, Market.India).Symbol;
Supported Assets
To view the supported assets in the India Equities dataset, see the Data Explorer.
Requesting Data
To add India Equities data to your algorithm, call the AddEquity method with Market.India. Save a reference to the Equity Symbol so you can access the data later in your algorithm.
class TrueDataIndiaEquitiesAlgorithm(QCAlgorithm): def Initialize(self) -> None: # Set the Brokerage Model to Samco or Zerodha self.SetBrokerageModel(BrokerageName.Samco) # Indian Rupee must be in the Cashbook to trade Indian Equities. self.SetAccountCurrency("INR") self.SetStartDate(2021, 12, 1) self.SetEndDate(2021, 12, 31) self.SetCash(1000000) # Requesting Data self.symbol = self.AddEquity("YESBANK", Resolution.Daily, Market.India).Symbol
public class TrueDataIndiaEquitiesAlgorithm : QCAlgorithm { private Symbol _symbol; public override void Initialize() { // Set the Brokerage Model to Samco or Zerodha SetBrokerageModel(BrokerageName.Samco); // Indian Rupee must be in the Cashbook to trade Indian Equities. SetAccountCurrency("INR"); SetStartDate(2021, 12, 1); SetEndDate(2021, 12, 31); SetCash(1000000); // Requesting Data _symbol = AddEquity("YESBANK", Resolution.Daily, Market.India).Symbol; } }
For more information about creating India Equity subscriptions, see Requesting Data.
Accessing Data
To get the current India Equities data, index the Bars property of the current Slice with the Equity Symbol. Slice objects deliver unique events to your algorithm as they happen, but the Slice may not contain data for your security at every time step. To avoid issues, check if the Slice contains the data you want before you index it.
def OnData(self, slice: Slice) -> None: if self.symbol in slice.Bars: trade_bar = slice.Bars[self.symbol] self.Log(f"{self.symbol} close at {slice.Time}: {trade_bar.Close}")
public override void OnData(Slice slice) { if (slice.Bars.ContainsKey(_symbol)) { var tradeBar = slice.Bars[_symbol]; Log($"{_symbol} price at {slice.Time}: {tradeBar.Close}"); } }
You can also iterate through all of the data objects in the current Slice.
def OnData(self, slice: Slice) -> None: for symbol, trade_bar in slice.Bars.items(): self.Log(f"{symbol} close at {slice.Time}: {trade_bar.Close}")
public override void OnData(Slice slice) { foreach (var kvp in slice.Bars) { var symbol = kvp.Key; var tradeBar = kvp.Value; Log($"{symbol} price at {slice.Time}: {tradeBar.Close}"); } }
For more information about accessing India Equities data, see Handling Data.
Current Trading Day Data
To get current trading day data, call the History method with the Equity Symbol. If there is no data in the period you request, the history result is empty.
# DataFrame history_df = self.History(self.symbol, 100, Resolution.Daily) # TradeBar objects history_trade_bars = self.History[TradeBar](self.symbol, 100, Resolution.Daily)
var history = History(_symbol, 100, Resolution.Daily);
For more information about historical data, see History Requests.