It looks like you're new here. If you want to get involved, click one of these buttons!
/*
To get live price use KiteTicker websocket connection.
It is recommended to use only one websocket connection at any point of time and make sure you stop connection,
once user goes out of app.
*/
// Create a new Ticker instance
Ticker ticker = new Ticker(MyAPIKey, MyAccessToken);
// Add handlers to events
ticker.OnTick += onTick;
ticker.OnOrderUpdate += OnOrderUpdate;
ticker.OnReconnect += onReconnect;
ticker.OnNoReconnect += oNoReconnect;
ticker.OnError += onError;
ticker.OnClose += onClose;
ticker.OnConnect += onConnect;
// Engage reconnection mechanism and connect to ticker
ticker.EnableReconnect(Interval: 5,Retries: 50);
ticker.Connect();
// Subscribing to NIFTY50 and setting mode to LTP
ticker.Subscribe(Tokens: new UInt32[] { 256265 });
ticker.SetMode(Tokens: new UInt32[] { 256265 }, Mode: Constants.MODE_LTP);
// Example onTick handler
private static void onTick(Tick TickData)
{
Console.WriteLine("LTP: " + TickData.LastPrice);
}
private static void OnOrderUpdate(Order OrderData)
{
Console.WriteLine("OrderUpdate " + Utils.JsonSerialize(OrderData));
}
// Disconnect ticker before closing the application
ticker.Close();
You need to check out the Kite Connect sample project inside the root directory.
I would suggest going through the API documentation before getting started.