private void ClearWatchlistMarkets() { if (WatchlistMarkets != null) { UnsubscribeFromWatchlistInstruments(); WatchlistMarkets.Clear(); } }
// <Summary> // GetRestWatchlistMarkets // </Summary> public async void GetRestWatchlistMarkets() { try { if ((Watchlists != null) && (WatchlistIndex < Watchlists.Count)) { AddStatusMessage(String.Format("Retrieving watchlist markets for watchlist called {0}", Watchlists[WatchlistIndex].WatchlistName)); var response = await igRestApiClient.instrumentsForWatchlist(Watchlists[WatchlistIndex].WatchlistId); if (response != null) { if (response && (response.Response.markets != null) && (response.Response.markets.Count > 0)) { WatchlistMarkets.Clear(); foreach (var wim in response.Response.markets.Select(LoadMarket)) { WatchlistMarkets.Add(wim); } // Get unique epics for these orders ( we don't want to subscribe to the same epic twice ) var uniqueEpics = (from dbo in WatchlistMarkets where dbo.Model.StreamingPricesAvailable == true select dbo.Model.Epic).Distinct().ToArray(); if (uniqueEpics.Length != 0) { SubscribeL1WatchlistPrices(uniqueEpics); SubscribeToCharts(uniqueEpics); } else { AddStatusMessage("There are no watchlist instruments with streaming prices enabled"); } } else { AddStatusMessage("HttpStatusCode error: " + response.StatusCode); } } else { AddStatusMessage("GetRestWatchlistMarkets : null response from server"); } } } catch (Exception ex) { AddStatusMessage(ex.Message); } }
// <Summary> // GetRestWatchlistMarkets // </Summary> public async void GetRestWatchlistMarkets() { try { if ((Watchlists != null) && (WatchlistIndex < Watchlists.Count)) { UpdateWatchlistsMessage(String.Format("Retrieving watchlist markets for watchlist called {0}", Watchlists[WatchlistIndex].WatchlistName)); var response = await igRestApiClient.instrumentsForWatchlist(Watchlists[WatchlistIndex].WatchlistId); if (response != null) { if (response && (response.Response.markets != null) && (response.Response.markets.Count > 0)) { WatchlistMarkets.Clear(); foreach (var wl in response.Response.markets) { var wim = new IgPublicApiData.WatchlistMarketModel(); wim.Model = new IgPublicApiData.InstrumentModel(); wim.Model.High = wl.high; wim.Model.Low = wl.low; wim.Model.Epic = wl.epic; wim.Model.Bid = wl.bid; wim.Model.Offer = wl.offer; wim.Model.PctChange = wl.percentageChange; wim.Model.NetChange = wl.netChange; wim.Model.InstrumentName = wl.instrumentName; wim.Model.StreamingPricesAvailable = wl.streamingPricesAvailable; wim.Model.MarketStatus = wl.marketStatus; WatchlistMarkets.Add(wim); } // Get unique epics for these orders ( we don't want to subscribe to the same epic twice ) var uniqueEpics = (from dbo in WatchlistMarkets where dbo.Model.StreamingPricesAvailable == true select dbo.Model.Epic).Distinct().ToArray(); if (uniqueEpics.Length != 0) { SubscribeL1WatchlistPrices(uniqueEpics); } else { UpdateWatchlistsMessage("There are no watchlist instruments with streaming prices enabled"); } } else { UpdateWatchlistsMessage("HttpStatusCode error: " + response.StatusCode); } } else { UpdateWatchlistsMessage("GetRestWatchlistMarkets : null response from server"); } } } catch (Exception ex) { UpdateWatchlistsMessage(ex.Message); } }