private void StartConnection(String adapter) { try { frmCredentials f = new frmCredentials(); if (f.ShowDialog() != System.Windows.Forms.DialogResult.OK) { this.Close(); return; } //Databind the Grid to the Instruments dgvMarketData.AutoGenerateColumns = false; dgvMarketData.DataSource = _Instruments; CiApi.Instance.Login(_g.UserName, _g.Password, _g.RequestServer); CiApi.Instance.StreamingManager.StreamingUrl = _g.StreamingServer; var accountInformation = CiApi.Instance.ServiceManager.AccountInformationService.GetClientAndTradingAccount(); var cfdMarkets = CiApi.Instance.ServiceManager.CfdMarketService.ListCfdMarkets("", true, true, accountInformation.ClientAccountId, 100); List <int> marketIdList = new List <int>(); foreach (var cfdMarket in cfdMarkets.Markets) { marketIdList.Add(cfdMarket.MarketId); } var marketInfoListResponse = CiApi.Instance.ServiceManager.MarketInformationService.ListMarketInformation(marketIdList); CiApi.Instance.StreamingManager.Streams.PriceStream.SubscribeToMarketPriceList(marketIdList); CiApi.Instance.StreamingManager.Streams.PriceStream.PriceChanged += (o, s) => HandlePriceUpdate(s.Data); Log.Info("Streaming.."); this.Show(); } catch (ApiCallException apiCallException) { Log.Error(apiCallException.Message); } catch (Exception ex) { Log.Error(ex); CiApi.Instance.Logout(); } }
private void StartConnection(String adapter) { try { frmCredentials f = new frmCredentials(); if (f.ShowDialog() != System.Windows.Forms.DialogResult.OK) { this.Close(); return; } //Databind the Grid to the Instruments dgvMarketData.AutoGenerateColumns = false; dgvMarketData.DataSource = _Instruments; CiApi.Instance.Login(_g.UserName, _g.Password, _g.RequestServer); CiApi.Instance.StreamingManager.StreamingUrl = _g.StreamingServer; var accountInformation = CiApi.Instance.ServiceManager.AccountInformationService.GetClientAndTradingAccount(); var cfdMarkets = CiApi.Instance.ServiceManager.CfdMarketService.ListCfdMarkets("", true, true, accountInformation.ClientAccountId, 100); List<int> marketIdList = new List<int>(); foreach (var cfdMarket in cfdMarkets.Markets) { marketIdList.Add(cfdMarket.MarketId); } var marketInfoListResponse = CiApi.Instance.ServiceManager.MarketInformationService.ListMarketInformation(marketIdList); CiApi.Instance.StreamingManager.Streams.PriceStream.SubscribeToMarketPriceList(marketIdList); CiApi.Instance.StreamingManager.Streams.PriceStream.PriceChanged += (o, s) => HandlePriceUpdate(s.Data); Log.Info("Streaming.."); this.Show(); } catch (ApiCallException apiCallException) { Log.Error(apiCallException.Message); } catch (Exception ex) { Log.Error(ex); CiApi.Instance.Logout(); } }