public List<double[]> CalculateCurve(int pMonth, int pYear)
        {
            List<double[]> curve = new List<double[]>();
            List<Currency> currencies = new CurrencyServices(_user).FindAllCurrencies();
            DateTime date = new DateTime(pYear, pMonth, 1);
            DateTime endDate = date.AddMonths(1);

            foreach (Currency currency in currencies)
            {
                double[] realAmount = new double[(endDate - date).Days];
                int i = 0;
                while (date < endDate)
                {
                    ExchangeRate rate = _rateManager.Select(date, currency);
                    realAmount[i] = (rate == null) ? 0 : rate.Rate;
                    date = date.AddDays(1);
                    i++;
                }
                date = new DateTime(pYear, pMonth, 1);
                curve.Add(realAmount);
            }
            return curve;
        }
        public List <double[]> CalculateCurve(int pMonth, int pYear)
        {
            List <double[]> curve      = new List <double[]>();
            List <Currency> currencies = new CurrencyServices(_user).FindAllCurrencies();
            DateTime        date       = new DateTime(pYear, pMonth, 1);
            DateTime        endDate    = date.AddMonths(1);

            foreach (Currency currency in currencies)
            {
                double[] realAmount = new double[(endDate - date).Days];
                int      i          = 0;
                while (date < endDate)
                {
                    ExchangeRate rate = _rateManager.Select(date, currency);
                    realAmount[i] = (rate == null) ? 0 : rate.Rate;
                    date          = date.AddDays(1);
                    i++;
                }
                date = new DateTime(pYear, pMonth, 1);
                curve.Add(realAmount);
            }
            return(curve);
        }
Beispiel #3
0
        public ExchangeRate FindLatestExchangeRate(DateTime pDate,Currency pCurrency)
        {
            ExchangeRate exchangeRate = null;
             Currency pivot = new CurrencyServices(_user).GetPivot();
            if (!pivot.Equals(pCurrency))
            {
                if (new CurrencyServices(_user).FindAllCurrencies().Count > 1)
                {
                    double rate = _exchangeRateServices.GetMostRecentlyRate(pDate,pCurrency);

                    exchangeRate = new ExchangeRate
                                       {
                                           Currency = pCurrency,
                                           Date = pDate,
                                           Rate = rate
                                       };
                }
            }
            else
            {
                exchangeRate = new ExchangeRate
                {
                    Currency = pCurrency,
                    Date = pDate,
                    Rate = 1
                };
            }
            return exchangeRate;
        }
Beispiel #4
0
        public ExchangeRate FindExchangeRate(DateTime pDate, Currency pCurrency)
        {
            ExchangeRate exchangeRate = null;
            Currency pivot = new CurrencyServices(_user).GetPivot();

            if (!pivot.Equals(pCurrency))
            {
                if (new CurrencyServices(_user).FindAllCurrencies().Count > 1)
                {
                    exchangeRate = _exchangeRateServices.SelectExchangeRate(pDate.Date, pCurrency);
                    if (exchangeRate == null)
                        throw new OpenCbsExchangeRateException(OpenCbsExchangeRateExceptionEnum.ExchangeRateIsNull);
                }
            }
            else
            {
                exchangeRate = new ExchangeRate
                                   {
                                       Currency = pCurrency,
                                       Date = pDate,
                                       Rate = 1
                                   };
            }
            return exchangeRate;
        }