private void AlgoLookupSubscription_OnData(object sender, AlgoLookupEventArgs e) { if (e.Event == ProductDataEvent.Found) { Console.WriteLine("Algo Instrument Found: {0}", e.AlgoLookup.Algo.Alias); m_algo = e.AlgoLookup.Algo; // Create an Algo TradeSubscription to listen for order / fill events only for orders submitted through it m_algoTradeSubscription = new AlgoTradeSubscription(tt_net_sdk.Dispatcher.Current, m_algo); m_algoTradeSubscription.OrderUpdated += new EventHandler <OrderUpdatedEventArgs>(m_algoTradeSubscription_OrderUpdated); m_algoTradeSubscription.OrderAdded += new EventHandler <OrderAddedEventArgs>(m_algoTradeSubscription_OrderAdded); m_algoTradeSubscription.OrderDeleted += new EventHandler <OrderDeletedEventArgs>(m_algoTradeSubscription_OrderDeleted); m_algoTradeSubscription.OrderFilled += new EventHandler <OrderFilledEventArgs>(m_algoTradeSubscription_OrderFilled); m_algoTradeSubscription.OrderRejected += new EventHandler <OrderRejectedEventArgs>(m_algoTradeSubscription_OrderRejected); m_algoTradeSubscription.OrderBookDownload += new EventHandler <OrderBookDownloadEventArgs>(m_algoTradeSubscription_OrderBookDownload); m_algoTradeSubscription.Start(); } else if (e.Event == ProductDataEvent.NotAllowed) { Console.WriteLine("Not Allowed : Please check your Token access"); } else { // Algo Instrument was not found and TT API has given up looking for it Console.WriteLine("Cannot find Algo instrument: {0}", e.Message); Dispose(); } }
public void Dispose() { lock (m_Lock) { if (!m_isDisposed) { // Unattached callbacks and dispose of all subscriptions if (m_instrLookupRequest != null) { m_instrLookupRequest.OnData -= m_instrLookupRequest_OnData; m_instrLookupRequest.Dispose(); m_instrLookupRequest = null; } if (m_algoLookupSubscription != null) { m_algoLookupSubscription.OnData -= AlgoLookupSubscription_OnData; m_algoLookupSubscription.Dispose(); m_algoLookupSubscription = null; } if (m_priceSubscription != null) { m_priceSubscription.FieldsUpdated -= m_priceSubscription_FieldsUpdated; m_priceSubscription.Dispose(); m_priceSubscription = null; } if (m_algoTradeSubscription != null) { m_algoTradeSubscription.OrderUpdated -= m_algoTradeSubscription_OrderUpdated; m_algoTradeSubscription.OrderAdded -= m_algoTradeSubscription_OrderAdded; m_algoTradeSubscription.OrderDeleted -= m_algoTradeSubscription_OrderDeleted; m_algoTradeSubscription.OrderFilled -= m_algoTradeSubscription_OrderFilled; m_algoTradeSubscription.OrderRejected -= m_algoTradeSubscription_OrderRejected; m_algoTradeSubscription.ExportValuesUpdated -= m_algoTradeSubscription_ExportValuesUpdated; m_algoTradeSubscription.AlertsFired -= m_algoTradeSubscription_AlertsUpdated; m_algoTradeSubscription.Dispose(); m_algoTradeSubscription = null; } m_isDisposed = true; } TTAPI.Shutdown(); } }