Application Level | Table of Content | Query |
Subscription |
For real-time data retrieval without filtering use the Subscribe() or Subscribe(DateTime) method.
For real-time data retrieval with filtering use the Subscribe(TradeCaptureReportRequest) method.
To continue reports retrieval Handler automatically sends requests for all active subscriptions every 3 seconds. This interval can be changed using the Session(Uri, String, String, String, Int32) constructor parameter.
using OnixS.CmeStpHandler; void Main() { // Create session. Session session = new Session(new Uri("UrlValue"), "SenderCompIdValue", "SenderSubIdValue", "Password"); session.TradeCaptureReportReceived += new EventHandler<TradeCaptureReportEventArgs>(session_TradeCaptureReportReceived); session.TradeCaptureReportRequestAcknowledgementReceived += new EventHandler<TradeCaptureReportRequestAcknowledgementEventArgs>(session_TradeCaptureReportRequestAcknowledgementReceived); // Subscribe for all data. string subscriptionId = session.Subscribe(); // Process received reports (if any) .. // Unsubscribe. session.Unsubscribe(subscriptionId); // Subscribe with filters. TradeCaptureReportRequest request = new TradeCaptureReportRequest(); request.Instruments.Add(new RequestInstrument() { SecurityExchange = SecurityExchange.Nymex }); request.TradeCaptureDate.LastUpdateTime = DateTime.Now.AddHours(-1); // Subscribe for all NYMEX trades for last hour. subscriptionId = session.Subscribe(request); // Process received reports (if any) .. // Unsubscribe. session.Unsubscribe(subscriptionId); } void session_TradeCaptureReportReceived(object sender, TradeCaptureReportEventArgs e) { Console.WriteLine("Trade Capture Report Received."); } void session_TradeCaptureReportRequestAcknowledgementReceived(object sender, TradeCaptureReportRequestAcknowledgementEventArgs e) { switch (e.TradeCaptureReportRequestAcknowledgement.TradeRequestStatus) { case TradeRequestStatus.Accepted: Console.WriteLine("Trade Capture Report Request accepted: " + report.TradeRequestResult.ToString()); break; case TradeRequestStatus.Completed: Console.WriteLine("Trade Capture Report Request completed: " + report.TradeRequestResult.ToString()); break; case TradeRequestStatus.Rejected: Console.WriteLine("Trade Capture Report Request rejected: " + report.TradeRequestResult.ToString() + ", " + report.Text); break; } }