示例#1
0
        public async Task <decimal> GetPrice(string baseCcy, string termsCurrency)
        {
            var sym = await _binanceWebsocketService.GetPriceAsync($"{termsCurrency}{baseCcy}");

            if (sym != null)
            {
                return(sym.Value);
            }

            return(decimal.Zero);
        }
        public async Task <decimal> GetPrice(string baseCcy, string termsCurrency)
        {
            if (Helpers.Helpers.CurrenciesAreEquivalent(baseCcy, termsCurrency))
            {
                return(1);
            }

            try
            {
                var sym = await _binanceWebsocketService.GetPriceAsync($"{termsCurrency}{baseCcy}");

                if (sym != null)
                {
                    return(sym.Value);
                }
            }
            catch (Exception e)
            {
                _log.LogError($"Error in getting {baseCcy}-{termsCurrency} price from Binance: {e.Message}");
                return(decimal.Zero);
            }

            return(decimal.Zero);
        }