Esempio n. 1
0
        public List<StockPrice> GetPriceFromAPI(ICollection<StockSymbol> symbols)
        {
            if(symbols != null && symbols.Count > 0)
            {
                StockDataSoapClient client = new StockDataSoapClient();
                var request = new StockPriceRequest();
                request.Body = new StockPriceRequestBody();
                request.Body.pubicKey = ConfigurationManager.AppSettings["PublicKey"];
                request.Body.stockCodes = new ArrayOfString();

                foreach (var symbol in symbols)
                {

                    request.Body.stockCodes.Add(symbol.Ticker);
                }

                request.Body.hash = new HashHelper().ComputeHash(JsonConvert.SerializeObject(request.Body.stockCodes),
                    ConfigurationManager.AppSettings["PrivateKey"]);

                var response = client.StockPrice(request);
                List<StockPrice> prices = JsonConvert.DeserializeObject<List<StockPrice>>(response.Body.StockPriceResult);
                return prices;
            }
            return null;
        }
Esempio n. 2
0
        public List <StockPrice> GetPriceFromAPI(ICollection <StockSymbol> symbols)
        {
            if (symbols != null && symbols.Count > 0)
            {
                StockDataSoapClient client = new StockDataSoapClient();
                var request = new StockPriceRequest();
                request.Body            = new StockPriceRequestBody();
                request.Body.pubicKey   = ConfigurationManager.AppSettings["PublicKey"];
                request.Body.stockCodes = new ArrayOfString();

                foreach (var symbol in symbols)
                {
                    request.Body.stockCodes.Add(symbol.Ticker);
                }

                request.Body.hash = new HashHelper().ComputeHash(JsonConvert.SerializeObject(request.Body.stockCodes),
                                                                 ConfigurationManager.AppSettings["PrivateKey"]);

                var response             = client.StockPrice(request);
                List <StockPrice> prices = JsonConvert.DeserializeObject <List <StockPrice> >(response.Body.StockPriceResult);
                return(prices);
            }
            return(null);
        }