No results for ""
Live Events
Register event listeners using TD.on(eventName, callback) at the top level of your script — never inside onStart, onStop, or any other function (Rule 7). Listeners are active only while the script is running.
data[0] is the symbolId (a string), not the symbol name you subscribed with. Build a { symbolId: symbolName } map during onStart if you need to match by name. All numeric fields also arrive as strings — use parseFloat().Available Events
| Event | Fires | Status |
|---|---|---|
tick |
On every price tick | Working |
bar1min |
Every minute, 1-min OHLCV candle | Working |
bar5min |
Every 5 minutes, 5-min OHLCV candle | Working |
bidAsk |
On every bid/ask update | Working |
heartbeat |
Every ~5 seconds (connection status) | Working |
greeks |
On Greeks update for option symbols | Working — needs full option symbol |
1. 'tick' Event
Fires on every price tick for subscribed symbols. High-frequency during market hours — avoid heavy computation inside the handler (Best Practices).
TD.on("tick", (data) => {
TD.log("Tick data:", data);
});
// Response example:
// ["100001262","2026-06-19T10:29:53","1329.5","88","1332.66","2910587",
// "1328","1338.2","1324.9","1328.1","0","0","3878822871.42","",
// "2445","1329.5","996","1329.6","1735"]
| Index | Field |
|---|---|
0 |
Symbol ID (string) — NOT symbol name |
1 |
Last Update Time |
2 |
LTP — Last Trade Price |
3 |
LTQ — Last Traded Quantity |
4 |
ATP — Average Trade Price |
5 |
TTQ — Total Trade Quantity |
6 |
Open |
7 |
High |
8 |
Low |
9 |
Previous Close |
10 |
OI — Open Interest |
11 |
Previous OI Close |
12 |
Day's Turnover |
13 |
Special Tag ("O" / "H" / "L" or "") |
14 |
Tick Sequence No |
15 |
Bid |
16 |
Bid Quantity |
17 |
Ask |
18 |
Ask Quantity |
2. 'bar1min' Event
Fires every minute with 1-minute OHLCV candle data for subscribed symbols.
TD.on("bar1min", (data) => {
TD.log("1 Min Bar:", data);
});
// Response example:
// ["200000001","2026-06-19T10:41:00","23968.35","23969.95","23959.95","23961.35","0","0"]
| Index | Field |
|---|---|
0 |
Symbol ID (string) |
1 |
Timestamp |
2 |
Open |
3 |
High |
4 |
Low |
5 |
Close |
6 |
Volume |
7 |
OI — Open Interest |
const SYMBOLS = ["NIFTY"];
let currentRow = 2;
TD.on("bar1min", async (data) => {
try {
await TD.Sheet.setCellRange("A" + currentRow, data);
currentRow++;
} catch (err) {
TD.log("Write error: " + err.message);
}
});
TD.onStart = async () => {
currentRow = 2; // reset on every start
try {
await TD.Sheet.setCellRange("A1", [
"SymbolId", "Timestamp", "Open", "High", "Low", "Close", "Volume", "OI",
]);
const response = await TD.Feed.addSymbols(SYMBOLS);
if (!response.success) throw new Error(response.message);
TD.log("Ready — waiting for bars.");
} catch (err) {
TD.log("Start error: " + err.message);
}
};
TD.onStop = async () => {
await TD.Feed.removeSymbols(SYMBOLS);
};
TD.onError = (err) => {
TD.log("Error: " + err.message);
};
3. 'bar5min' Event
Fires every 5 minutes with a 5-minute OHLCV candle. Same data shape as bar1min.
const SYMBOLS = ["NIFTY"];
let symbolMap = {};
let currentRow = 2;
TD.on("bar5min", async (data) => {
try {
const symbolId = data[0];
const symbolName = symbolMap[symbolId] || symbolId;
await TD.Sheet.setCellRange("A" + currentRow, [
symbolName,
data[1],
parseFloat(data[2]),
parseFloat(data[3]),
parseFloat(data[4]),
parseFloat(data[5]),
parseFloat(data[6]),
parseFloat(data[7]),
]);
currentRow++;
} catch (err) {
TD.log("Bar write error: " + err.message);
}
});
TD.onStart = async () => {
try {
currentRow = 2;
symbolMap = {};
await TD.Sheet.setCellRange("A1", [
"Symbol", "Timestamp", "Open", "High", "Low", "Close", "Volume", "OI",
]);
const response = await TD.Feed.addSymbols(SYMBOLS);
if (!response.success) throw new Error(response.message);
for (const sym of response.symbollist) {
symbolMap[sym[1]] = sym[0];
}
TD.log("Ready — waiting for 5-min bars.");
await TD.UI.showAlert("5-min bar streaming started", "success");
} catch (err) {
TD.log("Start error: " + err.message);
}
};
TD.onStop = async () => {
await TD.Feed.removeSymbols(SYMBOLS);
};
TD.onError = (err) => {
TD.log("Error: " + err.message);
};
4. 'bidAsk' Event
Fires on every bid/ask update for subscribed symbols.
TD.on("bidAsk", (data) => {
TD.log("Bid Ask data:", data);
});
// Response example:
// ["100001262","2026-06-19T11:13:48","1325.1","128","1325.2","197"]
| Index | Field |
|---|---|
0 |
Symbol ID (string) |
1 |
Last Update Time |
2 |
Bid |
3 |
Bid Quantity |
4 |
Ask |
5 |
Ask Quantity |
5. 'heartbeat' Event
Fires every ~5 seconds. Indicates WebSocket connection status — not a per-symbol clock tick.
TD.on("heartbeat", (data) => {
TD.log("Heartbeat:", data);
});
// Response example:
// {
// "success": true,
// "message": "HeartBeat",
// "timestamp": "2026-06-19T11:18:50.522"
// }
6. 'greeks' Event
Fires on Greeks updates for subscribed option symbols. Subscribe using the full TD option symbol string — not the base index name (Rule 11). Format: "<INDEX><YYMMDD><STRIKE><CE|PE>", e.g. "NIFTY26062323500CE".
TD.on("greeks", (data) => {
TD.log("Greeks:", data);
});
// Response example:
// ["302851361","2026-06-23T10:41:35","26.51","0.9947","-3.5266","0.0001","0.14","0.3417"]
| Index | Field |
|---|---|
0 |
Symbol ID |
1 |
Timestamp |
2 |
Delta |
3 |
Gamma |
4 |
Theta |
5 |
Vega |
6 |
Rho |
7 |
IV |
const SYMBOLS = ["NIFTY26062323500CE"];
TD.on("greeks", async (data) => {
try {
await TD.Sheet.setCellRange("A2", [
data[0], data[1],
parseFloat(data[2]), parseFloat(data[3]), parseFloat(data[4]),
parseFloat(data[5]), parseFloat(data[6]), parseFloat(data[7]),
]);
} catch (err) {
TD.log("Greeks write error: " + err.message);
}
});
TD.onStart = async () => {
try {
await TD.Sheet.setCellRange("A1", [
"Symbol ID", "Timestamp", "Delta", "Gamma", "Theta", "Vega", "Rho", "IV",
]);
const response = await TD.Feed.addSymbols(SYMBOLS);
if (!response.success) {
TD.log("Subscribe failed: " + response.message);
await TD.UI.showAlert("Subscribe failed: " + response.message, "error");
return;
}
TD.log("Subscribed. Waiting for Greeks updates...");
await TD.UI.showAlert("Greeks streaming started", "success");
} catch (err) {
TD.log("Start error: " + err.message);
}
};
TD.onStop = async () => {
try {
await TD.Feed.removeSymbols(SYMBOLS);
TD.log("Greeks stream stopped.");
} catch (err) {
TD.log("Stop error: " + err.message);
}
};
TD.onError = (err) => {
TD.log("Error: " + err.message);
};
'tick' and 'bidAsk' can fire many times per second during market hours. Keep handler logic minimal, and never call a REST method (TD.Historical.*, TD.Analytics.*, TD.OptionChain.*) from inside any event handler — see Rule 17.Empowering traders and analysts with high-performance real-time market data directly within their spreadsheets.
Resources
Support
© 2026 TrueData Market Data Services LLP. All rights reserved.