示例#1
0
        private ExchangeRateResponse ToResponse(YahooManaged.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(YahooManaged.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)));
        }