### PUT /TBTWebsocketUsageGuide Source: https://myapi.fyers.in/static/media/v3.0ce77080e168cb8039ed.yaml With the Tick-by-Tick (TBT) WebSocket, we are introducing the concept of channels. A channel acts as a logical grouping for different subscribed symbols, making it easier to manage data streams efficiently.
To receive completed candle data, it is important to send a timestamp that comes before the current minute. If you send a timestamp for the current minute, you will receive partial data because the minute is not yet finished. Therefore, it is recommended to always use a "range_to" timestamp of the previous minute to ensure that you receive the completed candle data.
Example:Current Time(seconds can be 1-59): 12:10:20 PM
Input for history will be:
So you will get 2 candles - 12:08 PM and 12:09 PM candles. This example is for 1-minute candles; for other resolutions, you have to subtract the resolution time from "range_to" to get completed candles only.
| Proto Version | Proto URL | Compiled files URL | Updated on |
|---|---|---|---|
| 1.0.0 | https://public.fyers.in/tbtproto/1.0.0/msg.proto | https://public.fyers.in/tbtproto/1.0.0/protogencode.zip | 20-02-2025 |
| Type | Data Format | Field Explanation |
|---|---|---|
| SocketMessage |
|
message SocketMessage {
MessageType type = 1;
map<string, MarketFeed> feeds = 2;
bool snapshot = 3;
string msg = 4;
bool error = 5;
}
|
| MarketFeed |
|
message MarketFeed {
Quote quote = 1;
ExtendedQuote eq = 2;
DailyQuote dq = 3;
OHLCV ohlcv = 4;
Depth depth = 5;
google.protobuf.UInt64Value feed_time = 6;
google.protobuf.UInt64Value send_time = 7;
string token = 8;
uint64 sequence_no = 9;
bool snapshot = 10;
string ticker = 11;
SymDetail symdetail = 12;
}
|
| Depth |
|
message Depth {
google.protobuf.UInt64Value tbq = 1;
google.protobuf.UInt64Value tsq = 2;
repeated MarketLevel asks = 3;
repeated MarketLevel bids = 4;
}
|
| MarketLevel |
|
message MarketLevel {
google.protobuf.Int64Value price = 1;
google.protobuf.UInt32Value qty = 2;
google.protobuf.UInt32Value nord = 3;
google.protobuf.UInt32Value num = 4;
}
|
"position_mapper" :
{
"symbol": "symbol",
"id": "id",
"buy_avg": "buyAvg",
"buy_qty": "buyQty",
"buy_val": "buyVal",
"sell_avg": "sellAvg",
"sell_qty": "sellQty",
"sell_val": "sellVal",
"net_avg": "netAvg",
"net_qty": "netQty",
"tran_side": "side",
"qty": "qty",
"product_type": "productType",
"pl_realized": "realized_profit",
"rbirefrate": "rbiRefRate",
"fy_token": "fyToken",
"exchange": "exchange",
"segment": "segment",
"day_buy_qty": "dayBuyQty",
"day_sell_qty": "daySellQty",
"cf_buy_qty": "cfBuyQty",
"cf_sell_qty": "cfSellQty",
"qty_multiplier": "qtyMulti_com",
"pl_total": "pl",
"cross_curr_flag": "crossCurrency",
"pl_unrealized": "unrealized_profit"
},
"order_mapper" :
{
"client_id":"clientId",
"id":"id",
"id_parent":"parentId",
"id_exchange":"exchOrdId",
"qty":"qty",
"qty_remaining":"remainingQuantity",
"qty_filled":"filledQty",
"price_limit":"limitPrice",
"price_stop":"stopPrice",
"tradedPrice":"price_traded",
"ord_type":"type",
"fy_token":"fyToken",
"exchange":"exchange",
"segment":"segment",
"symbol":"symbol",
"instrument":"instrument",
"oms_msg":"message",
"offline_flag":"offlineOrder",
"time_oms":"orderDateTime",
"validity":"orderValidity",
"product_type":"productType",
"tran_side":"side",
"org_ord_status":"status",
"ord_source":"source",
"symbol_exch":"ex_sym",
"symbol_desc":"description"
},
"trade_mapper" :
{
"id_fill": "tradeNumber",
"id": "orderNumber",
"qty_traded": "tradedQty",
"price_traded": "tradePrice",
"traded_val": "tradeValue",
"product_type": "productType",
"client_id": "clientId",
"id_exchange": "exchangeOrderNo",
"ord_type": "orderType",
"tran_side": "side",
"symbol": "symbol",
"fill_time": "orderDateTime",
"fy_token": "fyToken",
"exchange": "exchange",
"segment": "segment"
}
| Type | Purpose | Encoding Format | Data Format |
|---|---|---|---|
| Ping | Ping message to keep connection alive | String |
"ping"
|
| Subscribe | Subscribe to the symbols for which data is required | Json string |
{
"type": 1,
"data": {
"subs": 1,
"symbols": ["NSE:IOC25FEBFUT", "NSE:NIFTY25FEBFUT",
"NSE:BANKNIFTY25FEBFUT", "NSE:FINNIFTY25FEBFUT", "NSE:TCS25FEBFUT"],
"mode": "depth",
"channel": "1"
}
}
|
| Unsubscribe | Unsubscribe to the symbols for which data is NOT required | Json string |
{
"type": 1,
"data": {
"subs": -1,
"symbols": ["NSE:IOC25FEBFUT", "NSE:NIFTY25FEBFUT",
"NSE:BANKNIFTY25FEBFUT", "NSE:FINNIFTY25FEBFUT", "NSE:TCS25FEBFUT"],
"mode": "depth",
"channel": "1"
}
}
|
| Switch Channel | Switch between active and paused channels | Json string |
{
"type": 2,
"data": {
"resumeChannels": ["1"],
"pauseChannels": []
}
}
|