roozrob / yahoo-finance-managed

Automatically exported from code.google.com/p/yahoo-finance-managed
0 stars 0 forks source link

CrossDataTable #39

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
Hi Maas,
is possible for you to re-add the CrossDataTable function in?:
MassOne.Finance.YahooFinance.Support.ExchangeRAteCalculator

function:

        /// <summary>
        /// Returns a data table where every available currency is value converted to each other
        /// </summary>
        /// <param name="firstColumnName">The text in the left edge of the column header</param>
        /// <param name="items">The exchange items. Every exchange item must have the same base currency.</param>
        /// <returns></returns>
        /// <remarks></remarks>
        public static System.Data.DataTable CrossDataTable(IEnumerable<Support.ExchangeRateData> items, string firstColumnName = "")
        {
            System.Data.DataTable dt = new System.Data.DataTable();
            if (items != null)
            {
                dt.Columns.Add(firstColumnName, typeof(string));
                foreach (Support.ExchangeRateData curX in items)
                {
                    if (curX != null)
                        dt.Columns.Add(curX.CurrencyRelation.DepCurrency.ID, typeof(double));
                }
                foreach (Support.ExchangeRateData curY in items)
                {
                    if (curY != null)
                    {
                        System.Data.DataRow row = dt.NewRow();
                        row[0] = curY.CurrencyRelation.DepCurrency.ID;
                        foreach (Support.ExchangeRateData curX in items)
                        {
                            if (curX != null)
                                row[curX.CurrencyRelation.DepCurrency.ID] = Math.Round(Support.ExchangeRateCalculator.ConvertCurrency(1, curY, curX), 4);
                        }
                        dt.Rows.Add(row);
                    }
                }
            }
            return dt;
        }

Regards, Angel

Original issue reported on code.google.com by i...@advancedcomputing.ch on 21 Mar 2012 at 5:15

GoogleCodeExporter commented 8 years ago
Is it such a problem for you to implement these few lines of code in your 
library?
I want to remove the DataTable support in whole lib.

greetz

Maas

Original comment by Maas...@gmail.com on 22 Mar 2012 at 2:44

GoogleCodeExporter commented 8 years ago
No problem, ... done.

Angel

Original comment by i...@advancedcomputing.ch on 22 Mar 2012 at 5:04

GoogleCodeExporter commented 8 years ago
Did you often used the other DataTable converter functions?

Maas

Original comment by Maas...@gmail.com on 22 Mar 2012 at 5:44

GoogleCodeExporter commented 8 years ago
Hi maas, no I've used only this funct.
Thanks

Angel

Original comment by i...@advancedcomputing.ch on 22 Mar 2012 at 10:07

GoogleCodeExporter commented 8 years ago

Original comment by Maas...@gmail.com on 30 Apr 2012 at 12:48