public async void GetBrowseMarketsRoot() { try { if (LoggedIn) { // Unsubscribe from any instruments we are currently subscribed to... UnsubscribeFromBrowsePrices(); var response = await igRestApiClient.browseRoot(); if (response && (response.Response != null) && (response.Response.nodes != null)) { BrowseNodes.Clear(); BrowseMarkets.Clear(); foreach (var node in response.Response.nodes) { BrowseNodes.Add(node); } if (response.Response.nodes.Count > 0) { NodeIndex = 0; GetBrowseMarketsCommand.IsEnabled = true; } AddStatusMessage(String.Format("Browse Market data received for {0} nodes", response.Response.nodes.Count)); } else { AddStatusMessage("BrowseMarkets : no browse root nodes"); } } else { AddStatusMessage("Please log in first"); } } catch (Exception ex) { AddStatusMessage(ex.Message); } }
public async void GetBrowseMarkets() { try { if (NodeIndex < 0) { AddStatusMessage("Please select an item"); return; } if ((igRestApiClient == null) || (BrowseNodes == null)) { return; } if (NodeIndex >= BrowseNodes.Count) { AddStatusMessage("Please select a node first"); return; } UnsubscribeFromBrowsePrices(); var response = await igRestApiClient.browse(BrowseNodes[NodeIndex].id); if (!response || (response.Response == null)) { AddStatusMessage("BrowseMarketNodex: no sub-nodes / markets for this node"); return; } if (response.Response.nodes != null) { BrowseNodes.Clear(); AddStatusMessage("Retrieving browse market nodes / markets "); foreach (var node in response.Response.nodes) { if (node != null) { BrowseNodes.Add(node); AddStatusMessage("Browse Node found: " + node.name); } } } else { if (response.Response.markets == null) { return; } BrowseMarkets.Clear(); foreach (var market in response.Response.markets.Where(m => m != null).Select(LoadMarket)) { BrowseMarkets.Add(market); AddStatusMessage(String.Format("Browse Market found: {0} epic:{1}", market.Model.InstrumentName, market.Model.Epic)); } // // Subscribe to Browse Market Instrument Prices ( which are unique and have streaming prices enabled ) // var epics = (from dbo in BrowseMarkets where dbo.Model.StreamingPricesAvailable == true select dbo.Model.Epic).Distinct().ToArray(); if (epics.Length != 0) { SubscribeToBrowsePrices(epics); } } } catch (Exception ex) { AddStatusMessage(ex.Message); } }
public async void GetBrowseMarkets() { try { if (NodeIndex < 0) { UpdateMessage("Please select an item"); return; } if ((igRestApiClient != null) && (BrowseNodes != null)) { if (NodeIndex >= BrowseNodes.Count) { UpdateMessage("Please select a node first"); return; } UnsubscribeFromBrowsePrices(); var response = await igRestApiClient.browse(BrowseNodes[NodeIndex].id); if (response && (response.Response != null)) { if (response.Response.nodes != null) { BrowseNodes.Clear(); UpdateMessage("Retrieving browse market nodes / markets "); foreach (var node in response.Response.nodes) { if (node != null) { BrowseNodes.Add(node); UpdateMessage("Browse Node found: " + node.name); } } } else { if (response.Response.markets != null) { BrowseMarkets.Clear(); foreach (var market in response.Response.markets) { if (market != null) { var bm = new IgPublicApiData.BrowseModel(); bm.Model = new IgPublicApiData.InstrumentModel(); bm.Model.Bid = market.bid; bm.Model.Offer = market.offer; bm.Model.High = market.high; bm.Model.Low = market.low; bm.Model.InstrumentName = market.instrumentName; bm.Model.Epic = market.epic; bm.Model.NetChange = market.netChange; bm.Model.PctChange = market.percentageChange; bm.Model.StreamingPricesAvailable = market.streamingPricesAvailable; BrowseMarkets.Add(bm); UpdateMessage(String.Format("Browse Market found: {0} epic:{1}", market.instrumentName, market.epic)); } } // // Subscribe to Browse Market Instrument Prices ( which are unique and have streaming prices enabled ) // var epics = (from dbo in BrowseMarkets where dbo.Model.StreamingPricesAvailable == true select dbo.Model.Epic).Distinct().ToArray(); if (epics.Length != 0) { SubscribeToBrowsePrices(epics); } } } } else { UpdateMessage("BrowseMarketNodex: no sub-nodes / markets for this node"); } } } catch (Exception ex) { UpdateMessage(ex.Message); } }