Subscribe Touchline
Websocket TouchLine subscription API will provide multiple instruments available actions and possible values at once.
Request Details
| Parameter | Description |
|---|---|
| t | t ‘t’ represents touchline task |
| k | One or more scriplist for subscription. Example NSE |
Code
from typing import Any
from thefirstock import thefirstock
from thefirstock.pyClient.websocket import WsClient
from thefirstock.pyClient.websocket.enums import MessageTopic
client = thefirstock.webSocketLogin()
ws = client.ws
@ws.on_connect
def connected(client, message):
if message.get('s') == 'OK':
client.subscribe_touchline('NSE', '22')
@ws.on_message(MessageTopic.TOUCHLINE_FEED)
def msg_handler(client: WsClient, message: Any):
print(message)
ws.connect(uid='uid' #Replace with the uid, actid='actid' #Replace with the actid)
ws.run_forever()
const Firstock = require('thefirstock');
const firstock = new Firstock();
const ws = firstock.initializeWebSocket();
ws.on('open', function open() {
firstock.getWebSocketDetails((err, result) => {
if (!err) {
ws.send(result)
}
})
});
ws.on("error", function error(error) {
console.log(`WebSocket error: ${error}`)
})
ws.on('message', function message(data) {
const result = firstock.receiveWebSocketDetails(data)
console.log('Result: ', result)
ws.send(firstock.subscribeTouchline("NSE|26000#NSE|26009#NSE|26017"))
});
Subscription Acknowledgement
| Parameter | Description |
|---|---|
| t | tk ‘tk’ represents touchline acknowledgement |
| e | NSE, BSE, NFO Exchange name |
| tk | 22 Scrip Token |
| pp | 2 for NSE, BSE price precision |
| ts | Trading Symbol |
| ti | Tick size |
| ls | Lot size |
| lp | LTP |
| pc | Percentage change |
| v | volume |
| o | Open Price |
| h | High Price |
| l | Low Price |
| c | Close Price |
| ap | Average trade Price |
TouchLine subscription Updates
| Parameter | Description |
|---|---|
| tf | tf ‘tf’ represents touchline feed |
| e | NSE, BSE, NFO .. Exchane name |
| tk | 22 Script token |
| lp | LTP |
| tk | 22 Script token |
| pc | Percentage change |
| v | volume |
| o | Open Price |
| h | High Price |
| l | Low Price |
| c | Close Price |
| ap | Average trade Price |