예제 #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)));
        }