Пример #1
0
        private ExchangeRateResponse ToResponse(Base.Response <HistQuotesResult> resp, YCurrencyID[] currencies)
        {
            List <ExchangeRateData> lst = new List <ExchangeRateData>();

            if (resp.Result != null)
            {
                foreach (HistQuotesDataChain hqc in resp.Result.Chains)
                {
                    if (hqc.Count > 0)
                    {
                        YCurrencyID cur = FinanceHelper.YCurrencyIDFromString(hqc.ID);
                        if (cur != null)
                        {
                            QuotesData q = new QuotesData();
                            q.SetID(hqc.ID);
                            HistQuotesData hqd = (HistQuotesData)hqc[0];
                            q.Change             = hqd.Close - hqd.PreviousClose;
                            q.LastTradePriceOnly = hqd.Close;
                            q.LastTradeDate      = hqd.TradingDate;
                            q.Volume             = hqd.Volume;
                            lst.Add(new ExchangeRateData(cur.BaseCurrency, cur.DepCurrency, q));
                        }
                    }
                }
            }
            return(new ExchangeRateResponse(resp.Connection, new ExchangeRateResult(lst.ToArray(), currencies)));
        }
Пример #2
0
        /// <summary>
        /// Overloaded constructor
        /// </summary>
        /// <param name="id"></param>
        /// <remarks></remarks>
        public YCurrencyID(string id)
        {
            YCurrencyID newRel = FinanceHelper.YCurrencyIDFromString(id);

            if (newRel != null)
            {
                this.BaseCurrency = newRel.BaseCurrency;
                this.DepCurrency  = newRel.DepCurrency;
            }
            else
            {
                throw new ArgumentException("The id is not valid", "id");
            }
        }
Пример #3
0
        private ExchangeRateResponse ToResponse(Base.Response <QuotesResult> resp, YCurrencyID[] currencies)
        {
            List <ExchangeRateData> lst = new List <ExchangeRateData>();

            if (resp.Result != null)
            {
                foreach (QuotesData q in resp.Result.Items)
                {
                    YCurrencyID cur = FinanceHelper.YCurrencyIDFromString(q.ID);
                    if (cur != null)
                    {
                        lst.Add(new ExchangeRateData(cur.BaseCurrency, cur.DepCurrency, q));
                    }
                }
            }
            return(new ExchangeRateResponse(resp.Connection, new ExchangeRateResult(lst.ToArray(), currencies)));
        }
 /// <summary>
 /// Downloads a list of historical currency exchange rates
 /// </summary>
 /// <param name="currencies"></param>
 /// <param name="tradeDate"></param>
 /// <returns></returns>
 /// <remarks></remarks>
 public ExchangeRateResponse Download(YCurrencyID[] currencies, DateTime tradeDate)
 {
     if (currencies == null)
         throw new ArgumentNullException("currencies", "The passed currencies have no values.");
     return this.ToResponse(mHistQuotesDownload.Download(FinanceHelper.IIDsToStrings(currencies), tradeDate, tradeDate, HistQuotesInterval.Daily), currencies);
 }
 /// <summary>
 /// Downloads a list of actual currency exchange rates
 /// </summary>
 /// <param name="currencies">List of all currency-pairs</param>
 /// <returns></returns>
 /// <remarks></remarks>
 public ExchangeRateResponse Download(YCurrencyID[] currencies)
 {
     if (currencies == null)
         throw new ArgumentNullException("currencies", "The passed currencies have no values.");
     return this.ToResponse(mQuotesBaseDownload.Download(FinanceHelper.IIDsToStrings(currencies)), currencies);
 }