예제 #1
0
        /// <summary>
        /// Function: Convert a value from the Sell currency denomination to the Buy currency denomination on a given date.
        /// </summary>
        /// <param name="value">Value to be converted.
        /// </param>
        /// <param name="date">Reference date.
        /// </param>
        /// <param name="type">Time series type of time series point.
        /// </param>
        /// <param name="provider">Provider of reference time series object (Standard is AQI).
        /// </param>
        /// <param name="timeSeriesRoll">Roll type of reference time series object.
        /// </param>
        /// <param name="buy">Target currency in the conversion.
        /// </param>
        /// <param name="sell">Initial currency in the conversion.
        /// </param>
        public static double Convert(double value, DateTime date, TimeSeriesType type, DataProvider provider, TimeSeriesRollType timeSeriesRoll, Currency buy, Currency sell)
        {
            if (buy == sell)
            {
                return(value);
            }

            CurrencyPair pair = CurrencyPair.FindCurrencyPair(buy, sell);


            if (pair != null)
            {
                return(pair.Convert(value, date, type, provider, timeSeriesRoll));
            }

            CurrencyPair pair_inv = CurrencyPair.FindCurrencyPair(sell, buy);

            if (pair_inv != null)
            {
                return(pair_inv.ConvertInverse(value, date, type, provider, timeSeriesRoll));
            }

            Console.WriteLine("WARNING: NO CURRENCY PAIR FOUND - " + buy.Name + "/" + sell.Name);
            return(value);
        }
예제 #2
0
        /// <summary>
        /// Function: Convert a value from the Sell currency denomination to the Buy currency denomination on a given date.
        /// </summary>
        /// <param name="value">Value to be converted.
        /// </param>
        /// <param name="date">Reference date.
        /// </param>
        /// <param name="type">Time series type of time series point.
        /// </param>
        /// <param name="provider">Provider of reference time series object (Standard is AQI).
        /// </param>
        /// <param name="timeSeriesRoll">Roll type of reference time series object.
        /// </param>
        /// <param name="buy">Target currency in the conversion.
        /// </param>
        /// <param name="sell">Initial currency in the conversion.
        /// </param>
        public static double Convert(double value, DateTime date, TimeSeriesType type, DataProvider provider, TimeSeriesRollType timeSeriesRoll, Currency buy, Currency sell)
        {
            if (buy == sell)
            {
                return(value);
            }

            CurrencyPair pair = CurrencyPair.FindCurrencyPair(buy, sell);

            if (pair != null)
            {
                return(pair.Convert(value, date, type, provider, timeSeriesRoll));
            }

            CurrencyPair pair_inv = CurrencyPair.FindCurrencyPair(sell, buy);

            if (pair_inv != null)
            {
                return(pair_inv.ConvertInverse(value, date, type, provider, timeSeriesRoll));
            }

            return(0.0);
        }