Пример #1
0
        public static double[,] CreateCashExtendedTable(MaturityValuePairs input, aaSwap_crv3Parameters parameters)
        {
            var result = new double[input.Rows, 6];
            var spotDate = aaDateAdjustWrapper.RollDate(parameters.ValuationDate, parameters.SpotDelay, 1, 4, parameters.HolidayCentre);
            for(int i = 0; i < input.Rows; ++i)
            {
                var tenorString = input.ObjectTable[i, 0].ToString();
                DateTime effectiveDate = Tenor.IsON(tenorString) ? parameters.ValuationDate : spotDate;
                DateTime terminatingDate = DateTime.MinValue;
                Tenor tenor = Tenor.FromString(tenorString);
                switch(tenor.TenorType)
                {
                    case TenorType.Month:
                        terminatingDate = aaDateAdjustWrapper.RollDate(effectiveDate, tenor.Duration, 4, parameters.AdjustMethod, parameters.HolidayCentre);
                        break;
                    case TenorType.Week:
                        terminatingDate = aaDateAdjustWrapper.RollDate(effectiveDate, tenor.Duration, 3, parameters.AdjustMethod, parameters.HolidayCentre);
                        break;
                    case TenorType.CalendarDay:
                        terminatingDate = aaDateAdjustWrapper.RollDate(effectiveDate, tenor.Duration, 2, parameters.AdjustMethod, parameters.HolidayCentre);
                        break;
                    case TenorType.BusinessDay:
                        terminatingDate = aaDateAdjustWrapper.RollDate(effectiveDate, tenor.Duration, 1, parameters.AdjustMethod, parameters.HolidayCentre);
                        break;
                    default:
                        throw new System.Exception("Unsupported tenor type in money market rates: " + tenorString);
                }

                result[i, 0] = effectiveDate.ToOADate();
                result[i, 1] = terminatingDate.ToOADate();
                result[i, 2] = (double)((decimal)input.ObjectTable[i, 1]);
                result[i, 3] = parameters.CashQuoteRateQuotationBasis;
                result[i, 4] = parameters.CashQuoteAccrualMethod;
                result[i, 5] = (double)1;
            }
            return result;
        }
Пример #2
0
        public static double[,] CreateSwapsExtendedTable(MaturityValuePairs input, aaSwap_crv3Parameters parameters)
        {
            var result = new double[input.Rows, 10];
            var spotDate = aaDateAdjustWrapper.RollDate(parameters.ValuationDate, parameters.SpotDelay, 1, parameters.AdjustMethod, parameters.HolidayCentre);
            for (int i = 0; i < input.Rows; ++i)
            {
                var tenorString = input.ObjectTable[i, 0].ToString();
                DateTime effectiveDate = spotDate;
                DateTime terminatingDate = DateTime.MinValue;
                Tenor tenor = Tenor.FromString(tenorString);
                switch (tenor.TenorType)
                {
                    case TenorType.Month:
                        terminatingDate = aaDateAdjustWrapper.RollDate(effectiveDate, tenor.Duration, 4, parameters.AdjustMethod, parameters.HolidayCentre);
                        break;
                    case TenorType.Week:
                        terminatingDate = aaDateAdjustWrapper.RollDate(effectiveDate, tenor.Duration, 3, parameters.AdjustMethod, parameters.HolidayCentre);
                        break;
                    case TenorType.CalendarDay:
                        terminatingDate = aaDateAdjustWrapper.RollDate(effectiveDate, tenor.Duration, 2, parameters.AdjustMethod, parameters.HolidayCentre);
                        break;
                    case TenorType.BusinessDay:
                        terminatingDate = aaDateAdjustWrapper.RollDate(effectiveDate, tenor.Duration, 1, parameters.AdjustMethod, parameters.HolidayCentre);
                        break;
                    case TenorType.Year:
                        terminatingDate = aaDateAdjustWrapper.RollDate(effectiveDate, tenor.Duration, 5, parameters.AdjustMethod, parameters.HolidayCentre);
                        break;
                    default:
                        throw new System.Exception("Unsupported tenor type in swap rates: " + tenorString);
                }

                result[i, 0] = effectiveDate.ToOADate();
                result[i, 1] = terminatingDate.ToOADate();
                result[i, 2] = (double)((decimal)input.ObjectTable[i, 1]);
                result[i, 3] = parameters.SwapQuoteFixedPayFrequency;
                result[i, 4] = parameters.SwapQuoteFixedAccrualMethod;
                result[i, 5] = parameters.SwapQuoteBusinessDayConvention;
                result[i, 6] = (double)1;
                result[i, 7] = double.NaN;
                result[i, 8] = parameters.SwapQuoteFloatingPayFrequency;
                result[i, 9] = parameters.SwapQuoteFloatingAccrualMethod;
            }
            return result;
        }
Пример #3
0
        public static object Build(aaSwap_crv3Parameters p, int curveType)
        {
            var singleton = FinCADWrapper.Instance();
            lock (singleton.GetLock())
            {
                double[,] discCurve = null;

                var cashTable = CreateCashExtendedTable(p.CashQuotes, p);
                var swapsTable = CreateSwapsExtendedTable(p.SwapQuotes, p);
                var holidays = aaHolidaysWrapper.Holidays(p.HolidayCentre);
                using (SLog.NDC("aaSwap_crv3"))
                {
                    FinCADHelpers.LogFinCADError(FincadFunctions.aaSwap_crv3(
                        p.ValuationDate.ToOADate(),
                        cashTable,
                        new double[0, 0],
                        swapsTable,
                        p.SwapBootstrapingMethod,
                        p.Interpolation,
                        p.FuturesGapMethod,
                        p.RateQuotationBasis,
                        p.AccrualMethod,
                        holidays,
                        p.MethodUsed,
                        p.MinimumLength,
                        p.MethodForExtending,
                        p.YieldSpread,
                        p.SpreadType,
                        curveType,
                        ref discCurve));
                }
                return discCurve;
            }
        }