Beispiel #1
0
 public Symbol(SymbolCodeEnum code, CurrencyCodeEnum baseCurrencyCode, CurrencyCodeEnum quoteCurrencyCode, bool tradable)
 {
     Code              = code;
     BaseCurrencyCode  = baseCurrencyCode;
     QuoteCurrencyCode = quoteCurrencyCode;
     Tradable          = tradable;
 }
Beispiel #2
0
        private CurrencyHandler GetHandler(CurrencyCodeEnum currencyCode)
        {
            switch (currencyCode)
            {
            case CurrencyCodeEnum.Ars:
                return(new BnaHandler(_httpClientFactoryMock.Object,
                                      Mock.Of <HttpClientPoliciesSettings>(),
                                      _mockUsdCurrencySettings.Object,
                                      Mock.Of <ISlackHooksService>(),
                                      Mock.Of <ILogger <CurrencyHandler> >()));

            case CurrencyCodeEnum.Cop:
                return(new TrmHandler(_httpClientFactoryMock.Object,
                                      Mock.Of <HttpClientPoliciesSettings>(),
                                      _mockUsdCurrencySettings.Object,
                                      Mock.Of <ISlackHooksService>(),
                                      Mock.Of <ILogger <CurrencyHandler> >()));

            case CurrencyCodeEnum.Mxn:
                return(new DofHandler(_httpClientFactoryMock.Object,
                                      Mock.Of <HttpClientPoliciesSettings>(),
                                      _mockUsdCurrencySettings.Object,
                                      Mock.Of <ISlackHooksService>(),
                                      Mock.Of <ILogger <CurrencyHandler> >()));

            default:
                throw new ArgumentException();
            }
        }
Beispiel #3
0
        /// <summary>
        /// Obtiene el tipo de cambio devuelto de la api
        /// </summary>
        /// <returns></returns>
        public async Task <QuoteModel> GetCotizacionActual(CurrencyCodeEnum code)
        {
            try
            {
                this.httpClient = new HttpClient();
                QuoteModel cambioToday = new QuoteModel();

                // TODO: obtenerlo con IOptions desde appSettings
                CredentialConectionApi _conf = new CredentialConectionApi()
                {
                    Url    = "http://api.cambio.today/v1/quotes/{0}/{1}/json?quantity=1&key={2}",
                    Target = "ARS",
                    Key    = "2388|XNqKbbax_KuK93xR^4dQk8mKjc^Bf*VC"
                };

                string cambiosTodayURL = string.Format(_conf.Url, code.ToString("g"), _conf.Target, _conf.Key);

                var response = await this.httpClient.GetAsync(cambiosTodayURL);

                if (response.IsSuccessStatusCode)
                {
                    var result = await response.Content.ReadAsStringAsync();

                    cambioToday = JsonConvert.DeserializeObject <QuoteModel>(result);
                    return(cambioToday);
                }
            }
            catch (Exception)
            {
                throw new Exception("Ha ocurrido un problema al intentar obtener la cotización");
            }

            return(null);
        }
Beispiel #4
0
 protected async Task SendSlackNotification(
     string htmlPage,
     DateTime dateTime,
     CurrencyCodeEnum currencyCode,
     Exception e = null)
 {
     Logger.LogError(e ?? new Exception("Error getting HTML"), "Error getting HTML, title is not valid, please check HTML: {Page}", htmlPage);
     await SlackHooksService.SendNotification($"Can't get currency from {currencyCode} currency code, please check Html in the log or if the date is holiday {dateTime.ToUniversalTime():yyyy-MM-dd}");
 }
Beispiel #5
0
        public ICurrency Get(CurrencyCodeEnum code)
        {
            var matched = Currency.Where(c => c.Code == code).FirstOrDefault();

            if (matched == null)
            {
                throw new ArgumentException($"No currency could be found for code '{code}'");
            }

            return(matched);
        }
Beispiel #6
0
        public ISymbol Get(CurrencyCodeEnum baseCurrencyCode, CurrencyCodeEnum quoteCurrencyCode)
        {
            var matched = Symbols.Where(s => s.BaseCurrencyCode == baseCurrencyCode && s.QuoteCurrencyCode == quoteCurrencyCode).FirstOrDefault();

            if (matched == null)
            {
                throw new ArgumentException($"No symbol could be found for base '{baseCurrencyCode}' & quote '{quoteCurrencyCode}'");
            }

            return(matched);
        }
Beispiel #7
0
        /// <summary>
        /// Create a handler depending of currency code.
        /// </summary>
        /// <param name="currencyCode">The currency code</param>
        /// <returns>A handler</returns>
        public CurrencyHandler CreateHandler(CurrencyCodeEnum currencyCode)
        {
            switch (currencyCode)
            {
            case CurrencyCodeEnum.Ars:
                return((BnaHandler)_serviceProvider.GetService(typeof(BnaHandler)));

            case CurrencyCodeEnum.Mxn:
                return((DofHandler)_serviceProvider.GetService(typeof(DofHandler)));

            case CurrencyCodeEnum.Cop:
                return((TrmHandler)_serviceProvider.GetService(typeof(TrmHandler)));

            default:
                throw new ArgumentException(nameof(currencyCode), $"The currencyCode '{currencyCode}' is not supported.");
            }
        }
Beispiel #8
0
 public Task <WrappedResponse <ICollection <Deposit> > > GetDeposits(CurrencyCodeEnum currencyCode, int limit)
 {
     throw new NotImplementedException();
 }
Beispiel #9
0
 public Task <WrappedResponse <Deposit> > GetDeposit(CurrencyCodeEnum currencyCode, string transactionId)
 {
     throw new NotImplementedException();
 }
Beispiel #10
0
 public Task <WrappedResponse <WithdrawCrypto> > WithdrawCrypto(CurrencyCodeEnum cryptoCurrencyCode, decimal withdrawalFee, decimal volume, string address)
 {
     throw new NotImplementedException();
 }
Beispiel #11
0
        public static string GetCurrencyCode(this IExchange ex, CurrencyCodeEnum currencyCode)
        {
            var currency = ex.CurrencyConverter.Where(c => c.CurrencyCode == currencyCode).FirstOrDefault();

            return(currency != null && currency.AltCurrencyCode != null ? currency.AltCurrencyCode : currencyCode.ToString());
        }
Beispiel #12
0
        /// <summary>
        /// Converts a CurrencyCodeEnum value to a corresponding string value
        /// </summary>
        /// <param name="enumValue">The CurrencyCodeEnum value to convert</param>
        /// <returns>The representative string value</returns>
        public static string ToValue(CurrencyCodeEnum enumValue)
        {
            switch (enumValue)
            {
            //only valid enum elements can be used
            //this is necessary to avoid errors
            case CurrencyCodeEnum.UNDEFINED:
            case CurrencyCodeEnum.AED:
            case CurrencyCodeEnum.AFN:
            case CurrencyCodeEnum.ALL:
            case CurrencyCodeEnum.AMD:
            case CurrencyCodeEnum.ANG:
            case CurrencyCodeEnum.AOA:
            case CurrencyCodeEnum.ARS:
            case CurrencyCodeEnum.AUD:
            case CurrencyCodeEnum.AWG:
            case CurrencyCodeEnum.AZN:
            case CurrencyCodeEnum.BAM:
            case CurrencyCodeEnum.BBD:
            case CurrencyCodeEnum.BDT:
            case CurrencyCodeEnum.BGN:
            case CurrencyCodeEnum.BHD:
            case CurrencyCodeEnum.BIF:
            case CurrencyCodeEnum.BMD:
            case CurrencyCodeEnum.BND:
            case CurrencyCodeEnum.BOB:
            case CurrencyCodeEnum.BOV:
            case CurrencyCodeEnum.BRL:
            case CurrencyCodeEnum.BSD:
            case CurrencyCodeEnum.BTN:
            case CurrencyCodeEnum.BWP:
            case CurrencyCodeEnum.BYN:
            case CurrencyCodeEnum.BYR:
            case CurrencyCodeEnum.BZD:
            case CurrencyCodeEnum.CAD:
            case CurrencyCodeEnum.CDF:
            case CurrencyCodeEnum.CHE:
            case CurrencyCodeEnum.CHF:
            case CurrencyCodeEnum.CHW:
            case CurrencyCodeEnum.CLF:
            case CurrencyCodeEnum.CLP:
            case CurrencyCodeEnum.CNY:
            case CurrencyCodeEnum.COP:
            case CurrencyCodeEnum.COU:
            case CurrencyCodeEnum.CRC:
            case CurrencyCodeEnum.CUC:
            case CurrencyCodeEnum.CUP:
            case CurrencyCodeEnum.CVE:
            case CurrencyCodeEnum.CZK:
            case CurrencyCodeEnum.DJF:
            case CurrencyCodeEnum.DKK:
            case CurrencyCodeEnum.DOP:
            case CurrencyCodeEnum.DZD:
            case CurrencyCodeEnum.EGP:
            case CurrencyCodeEnum.ERN:
            case CurrencyCodeEnum.ETB:
            case CurrencyCodeEnum.EUR:
            case CurrencyCodeEnum.FJD:
            case CurrencyCodeEnum.FKP:
            case CurrencyCodeEnum.GBP:
            case CurrencyCodeEnum.GEL:
            case CurrencyCodeEnum.GHS:
            case CurrencyCodeEnum.GIP:
            case CurrencyCodeEnum.GMD:
            case CurrencyCodeEnum.GNF:
            case CurrencyCodeEnum.GTQ:
            case CurrencyCodeEnum.GYD:
            case CurrencyCodeEnum.HKD:
            case CurrencyCodeEnum.HNL:
            case CurrencyCodeEnum.HRK:
            case CurrencyCodeEnum.HTG:
            case CurrencyCodeEnum.HUF:
            case CurrencyCodeEnum.IDR:
            case CurrencyCodeEnum.ILS:
            case CurrencyCodeEnum.INR:
            case CurrencyCodeEnum.IQD:
            case CurrencyCodeEnum.IRR:
            case CurrencyCodeEnum.ISK:
            case CurrencyCodeEnum.JMD:
            case CurrencyCodeEnum.JOD:
            case CurrencyCodeEnum.JPY:
            case CurrencyCodeEnum.KES:
            case CurrencyCodeEnum.KGS:
            case CurrencyCodeEnum.KHR:
            case CurrencyCodeEnum.KMF:
            case CurrencyCodeEnum.KPW:
            case CurrencyCodeEnum.KRW:
            case CurrencyCodeEnum.KWD:
            case CurrencyCodeEnum.KYD:
            case CurrencyCodeEnum.KZT:
            case CurrencyCodeEnum.LAK:
            case CurrencyCodeEnum.LBP:
            case CurrencyCodeEnum.LKR:
            case CurrencyCodeEnum.LRD:
            case CurrencyCodeEnum.LSL:
            case CurrencyCodeEnum.LTL:
            case CurrencyCodeEnum.LYD:
            case CurrencyCodeEnum.MAD:
            case CurrencyCodeEnum.MDL:
            case CurrencyCodeEnum.MGA:
            case CurrencyCodeEnum.MKD:
            case CurrencyCodeEnum.MMK:
            case CurrencyCodeEnum.MNT:
            case CurrencyCodeEnum.MOP:
            case CurrencyCodeEnum.MRO:
            case CurrencyCodeEnum.MRU:
            case CurrencyCodeEnum.MUR:
            case CurrencyCodeEnum.MVR:
            case CurrencyCodeEnum.MWK:
            case CurrencyCodeEnum.MXN:
            case CurrencyCodeEnum.MXV:
            case CurrencyCodeEnum.MYR:
            case CurrencyCodeEnum.MZN:
            case CurrencyCodeEnum.NAD:
            case CurrencyCodeEnum.NGN:
            case CurrencyCodeEnum.NIO:
            case CurrencyCodeEnum.NOK:
            case CurrencyCodeEnum.NPR:
            case CurrencyCodeEnum.NZD:
            case CurrencyCodeEnum.OMR:
            case CurrencyCodeEnum.PAB:
            case CurrencyCodeEnum.PEN:
            case CurrencyCodeEnum.PGK:
            case CurrencyCodeEnum.PHP:
            case CurrencyCodeEnum.PKR:
            case CurrencyCodeEnum.PLN:
            case CurrencyCodeEnum.PYG:
            case CurrencyCodeEnum.QAR:
            case CurrencyCodeEnum.RON:
            case CurrencyCodeEnum.RSD:
            case CurrencyCodeEnum.RUB:
            case CurrencyCodeEnum.RUR:
            case CurrencyCodeEnum.RWF:
            case CurrencyCodeEnum.SAR:
            case CurrencyCodeEnum.SBD:
            case CurrencyCodeEnum.SCR:
            case CurrencyCodeEnum.SDG:
            case CurrencyCodeEnum.SEK:
            case CurrencyCodeEnum.SGD:
            case CurrencyCodeEnum.SHP:
            case CurrencyCodeEnum.SLL:
            case CurrencyCodeEnum.SOS:
            case CurrencyCodeEnum.SRD:
            case CurrencyCodeEnum.SSP:
            case CurrencyCodeEnum.STD:
            case CurrencyCodeEnum.STN:
            case CurrencyCodeEnum.SVC:
            case CurrencyCodeEnum.SYP:
            case CurrencyCodeEnum.SZL:
            case CurrencyCodeEnum.THB:
            case CurrencyCodeEnum.TJS:
            case CurrencyCodeEnum.TMT:
            case CurrencyCodeEnum.TND:
            case CurrencyCodeEnum.TOP:
            case CurrencyCodeEnum.TRY:
            case CurrencyCodeEnum.TTD:
            case CurrencyCodeEnum.TWD:
            case CurrencyCodeEnum.TZS:
            case CurrencyCodeEnum.UAH:
            case CurrencyCodeEnum.UGX:
            case CurrencyCodeEnum.USD:
            case CurrencyCodeEnum.USN:
            case CurrencyCodeEnum.USS:
            case CurrencyCodeEnum.UYI:
            case CurrencyCodeEnum.UYU:
            case CurrencyCodeEnum.UZS:
            case CurrencyCodeEnum.VEF:
            case CurrencyCodeEnum.VES:
            case CurrencyCodeEnum.VND:
            case CurrencyCodeEnum.VUV:
            case CurrencyCodeEnum.WST:
            case CurrencyCodeEnum.XAF:
            case CurrencyCodeEnum.XAG:
            case CurrencyCodeEnum.XAU:
            case CurrencyCodeEnum.XBA:
            case CurrencyCodeEnum.XBB:
            case CurrencyCodeEnum.XBC:
            case CurrencyCodeEnum.XBD:
            case CurrencyCodeEnum.XCD:
            case CurrencyCodeEnum.XDR:
            case CurrencyCodeEnum.XOF:
            case CurrencyCodeEnum.XPD:
            case CurrencyCodeEnum.XPF:
            case CurrencyCodeEnum.XPT:
            case CurrencyCodeEnum.XSU:
            case CurrencyCodeEnum.XTS:
            case CurrencyCodeEnum.XUA:
            case CurrencyCodeEnum.XXX:
            case CurrencyCodeEnum.YER:
            case CurrencyCodeEnum.ZAR:
            case CurrencyCodeEnum.ZMW:
            case CurrencyCodeEnum.ZWL:
                return(StringValues[(int)enumValue]);

            //an invalid enum value was requested
            default:
                return(null);
            }
        }