Exemple #1
0
        private IEnumerable <Symbol> GetStoredSymbols()
        {
            var domain      = _config["localApiEndpoint"];
            var companyList = SharedHelper.GetResponsePayload($"{domain}api/Symbols");
            var listPayload = JsonConvert.DeserializeObject <IEnumerable <Symbol> >(companyList);

            return(listPayload);
        }
        private double GetLastestPrice(string ticker)
        {
            var domain   = _config["finnhubEndpoint"];
            var apiToken = _config["apiToken"];

            var quoteResult = SharedHelper.GetResponsePayload($"{domain}quote?symbol={ticker}&token={apiToken}");
            var jsonObject  = JsonConvert.DeserializeObject <dynamic>(quoteResult);

            return(jsonObject.c);
        }
Exemple #3
0
        private bool PostSymbols(IEnumerable <Symbol> symbolsList)
        {
            var domain = _config["localApiEndpoint"];
            var url    = $"{domain}api/Symbols/PostSymbols";

            var jsonPayload = JsonConvert.SerializeObject(symbolsList);

            var success = SharedHelper.PostJsonPayload(url, jsonPayload);

            return(success);
        }
        private bool PostSymbols(Stock stock)
        {
            var domain = _config["localApiEndpoint"];
            var url    = $"{domain}api/Stocks/{stock.StockId}";

            var jsonPayload = JsonConvert.SerializeObject(stock);

            var success = SharedHelper.PutJsonPayload(url, jsonPayload);

            return(success);
        }
        public string GetCompanyDetails(string ticker)
        {
            var domain   = _config["stockEndpoint"];
            var apiToken = _config["apiToken"];

            var profilePayload        = SharedHelper.GetResponsePayload($"{domain}stock/profile2?symbol={ticker}&token={apiToken}");
            var quotePayload          = SharedHelper.GetResponsePayload($"{domain}quote?symbol={ticker}&token={apiToken}");
            var targetPricePayload    = SharedHelper.GetResponsePayload($"{domain}stock/price-target?symbol={ticker}&token={apiToken}");
            var reccomendationPayload = SharedHelper.GetResponsePayload($"{domain}stock/recommendation?symbol={ticker}&token={apiToken}");

            var formattedPayload = ConfigureCompanyDetails(profilePayload, quotePayload, targetPricePayload, reccomendationPayload);

            return(formattedPayload);
        }