Example #1
0
        /// <summary>
        /// Methord To Unsubscribe Security
        /// </summary>
        /// <param name="unsubscribe"></param>
        private void UnsubscribeSecurity(Unsubscribe unsubscribe)
        {
            try
            {
                if (Logger.IsInfoEnabled)
                {
                    Logger.Info(unsubscribe.ToString(), _oType.FullName, "UnsubscribeSecurity");
                }

                // Send Tick unsubscription request
                _marketDataService.Unsubscribe(unsubscribe);
                _responseHandler.OnSymbolUnSubscribed(unsubscribe.Security);
            }
            catch (Exception exception)
            {
                Logger.Error(exception, _oType.FullName, "UnsubscribeSecurity");
            }
        }
Example #2
0
        /// <summary>
        /// Unsubscribe the selected security from gridview.
        /// </summary>
        private void UnsubscribeSecurity()
        {
            try
            {
                Unsubscribe unsubscribe = new Unsubscribe();
                Subscribe   subscribe   = SecutiryList.Single(s => s.Id == SelectedSecurity.Id);
                unsubscribe.Security = subscribe.Security;
                if (Logger.IsInfoEnabled)
                {
                    Logger.Info(unsubscribe.ToString(), _oType.FullName, "UnsubscribeSecurity");
                }
                unsubscribe.Id = subscribe.Id;

                unsubscribe.MarketDataProvider = SelectedProvider.ProviderName;
                var temp = SecurityStatDictionary[SelectedProvider.ProviderName];
                var selectedRowOfGrid = temp.Single(x => x.Id == unsubscribe.Id);

                EventSystem.Publish <Unsubscribe>(unsubscribe);
                EventSystem.Publish <UnsubscribeBars>(new UnsubscribeBars
                {
                    UnSubscribeBarDataRequest = new BarDataRequest
                    {
                        Id = unsubscribe.Id,
                        MarketDataProvider = unsubscribe.MarketDataProvider,
                        Security           = unsubscribe.Security,
                        BarFormat          = selectedRowOfGrid.BarSettingView.BarSettingViewModel.SelectedFormate,
                        BarPriceType       = selectedRowOfGrid.BarSettingView.BarSettingViewModel.SelectedType,
                        BarLength          = selectedRowOfGrid.BarSettingView.BarSettingViewModel.BarLength,
                        PipSize            = selectedRowOfGrid.BarSettingView.BarSettingViewModel.PipSize,
                    }
                });
                SecutiryList.Remove(subscribe);
                SecurityStatDictionary[SelectedProvider.ProviderName].Remove(
                    SecurityStatDictionary[SelectedProvider.ProviderName].Single(x => x.Id == unsubscribe.Id));
                ReloadList(SelectedProvider);
            }
            catch (Exception exception)
            {
                Logger.Error(exception, _oType.FullName, "UnsubscribeSecurity");
            }
        }