/// <summary> /// Called by UpdatePortfolioPrices and LimitOrderChecks /// </summary> /// <param name="securities"></param> /// <returns></returns> public void GetUpdatedPricing(List <Security> securities) { var resultList = new List <Security>(); if (securities != null && securities.Count > 0) { using (var yahooAPI = new YahooAPIService()) { yahooAPI.GetUpdatedPricing(securities); } } }
public List <Security> GetSecurityInfo(List <string> tickers) { var resultList = new List <Security>(); if (tickers != null && tickers.Count > 0) { using (var yahooAPI = new YahooAPIService()) { resultList = yahooAPI.GetMultipleSecurities(tickers); } } return(resultList); }
/// <summary> /// Get pricing and security info for a single ticker. /// </summary> /// <param name="ticker"></param> /// <returns></returns> public Security GetSecurityInfo(string ticker) { if (!string.IsNullOrEmpty(ticker)) { using (var yahooAPI = new YahooAPIService()) { var result = yahooAPI.GetSingleSecurity(ticker, _securityDatabaseList); TryDatabaseInsert(result); return(result); } } return(new Stock("", "", "", 0, 0.00)); //If you hit this, the ticker was null or empty }
public async Task GetUpdatedPricing(List <Position> positions) { var secList = new List <Security>(); foreach (var pos in positions) { secList.Add(pos.Security); } if (positions != null && positions.Count > 0) { using (var yahooAPI = new YahooAPIService()) { await yahooAPI.GetUpdatedPricing(positions); } } }
/// <summary> /// Get pricing and security info for a single ticker. /// </summary> /// <param name="ticker"></param> /// <returns></returns> public async Task GetSecurityInfo(string ticker, bool isScreener, bool isPreview) { if (!string.IsNullOrEmpty(ticker)) { using (var yahooAPI = new YahooAPIService()) { var result = await yahooAPI.GetSingleSecurity(ticker, _securityDatabaseList); if (!_localMode) { TryDatabaseInsert(result); } var responseMessage = new StockDataResponseMessage(result, isPreview, isScreener); Messenger.Default.Send <StockDataResponseMessage>(responseMessage); } } }
/// <summary> /// Method takes a request for multiple tickers or multiple positions /// and sends a listed of updated data /// </summary> /// <param name="message"></param> /// <returns></returns> public async Task GetSecurityInfo(StockDataRequestMessage message) { var tickersToQuery = new List <string>(); var positionsQuery = false; var tickersQuery = false; if (message.Tickers != null && message.Tickers.Count > 0) { tickersToQuery = message.Tickers; tickersQuery = true; } else if (message.Positions != null && message.Positions.Count > 0) { tickersToQuery = message.Positions.Select(s => s.Ticker).Distinct().ToList(); positionsQuery = true; } using (var yahooAPI = new YahooAPIService()) { var resultList = await yahooAPI.GetMultipleSecurities(tickersToQuery); //Return response. Message's boolean is True if this is a startup call of this method. if (message.IsStartupRequest && positionsQuery) { Messenger.Default.Send <PositionPricingMessage>(new PositionPricingMessage(resultList, true)); } else if (message.IsStartupRequest && tickersQuery) { Messenger.Default.Send <StockDataResponseMessage>(new StockDataResponseMessage(resultList, true)); } else { Messenger.Default.Send <StockDataResponseMessage>(new StockDataResponseMessage(resultList, false)); } } }