Esempio n. 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)));
        }
Esempio n. 2
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)));
        }