コード例 #1
0
ファイル: ADCurve.cs プロジェクト: finukan/MasterThesis
        public ADouble OisSwapNpvAD(OisSwap swap, InterpMethod interpolation)
        {
            ADouble oisAnnuity = OisAnnuityAD(swap.FloatSchedule, interpolation);
            double  notional   = swap.TradeSign * swap.Notional;
            ADouble oisRate    = OisRateSimpleAD(swap, interpolation);

            return(notional * (oisRate - swap.FixedRate) * oisAnnuity);
        }
コード例 #2
0
ファイル: ADCurve.cs プロジェクト: finukan/MasterThesis
        public ADouble OisRateSimpleAD(OisSwap swap, InterpMethod interpolation)
        {
            // Simple calculation of par OIS rate. Holds only under the assumption
            // that FRA's can be perfectly hedged by OIS zero coupon bonds.

            ADouble annuity = OisAnnuityAD(swap.FixedSchedule, interpolation);

            return((DiscFactor(swap.AsOf, swap.StartDate, swap.FixedSchedule.DayCount, interpolation) - DiscFactor(swap.AsOf, swap.EndDate, swap.FixedSchedule.DayCount, interpolation)) / annuity);
        }
コード例 #3
0
ファイル: Curves.cs プロジェクト: finukan/MasterThesis
        public double OisRateSimple(OisSwap swap, InterpMethod interpolation)
        {
            // Simple calculation of par OIS rate. Holds only under the assumption
            // that FRA's can perfecetly hedge something.

            double   annuity = OisAnnuity(swap.FixedSchedule, interpolation);
            DateTime asOf    = swap.AsOf;

            return((DiscFactor(asOf, swap.StartDate, swap.FixedSchedule.DayCount, interpolation) - DiscFactor(asOf, swap.EndDate, swap.FixedSchedule.DayCount, interpolation)) / annuity);
        }
コード例 #4
0
ファイル: ADCurve.cs プロジェクト: finukan/MasterThesis
        public ADouble OisRateAD(OisSwap swap, InterpMethod interpolation)
        {
            ADouble floatContribution = 0.0;
            ADouble annuity           = OisAnnuityAD(swap.FixedSchedule, interpolation);

            DateTime asOf = swap.FloatSchedule.AsOf;

            for (int i = 0; i < swap.FloatSchedule.AdjEndDates.Count; i++)
            {
                DateTime startDate      = swap.FloatSchedule.AdjStartDates[i];
                DateTime endDate        = swap.FloatSchedule.AdjEndDates[i];
                ADouble  compoundedRate = OisCompoundedRateAD(asOf, startDate, endDate, swap.FloatSchedule.DayRule, swap.FloatSchedule.DayCount, interpolation);
                ADouble  discFactor     = DiscFactor(asOf, endDate, swap.FixedSchedule.DayCount, interpolation);
                ADouble  coverage       = DateHandling.Cvg(startDate, endDate, swap.FloatSchedule.DayCount);
                floatContribution = floatContribution + discFactor * compoundedRate * coverage;
            }
            return(floatContribution / annuity);
        }
コード例 #5
0
ファイル: LinearRateADD.cs プロジェクト: finukan/MasterThesis
 // Overnight indexed swaps (More functionality is contained in the AD Curve class
 public ADouble OisRateSimpleAD(OisSwap swap)
 {
     return(ADDiscCurve.OisRateSimpleAD(swap, Interpolation));
 }
コード例 #6
0
 // Ois swaps (more functions are located under the Curve-classes)
 public double OisRateSimple(OisSwap swap)
 {
     return(DiscCurve.OisRateSimple(swap, Interpolation));
 }
コード例 #7
0
        private void InterpretSwapString(string instrumentString)
        {
            string     identifier, type, currency, startTenor, endTenor, settlementLag, fixedFreq, floatFreq, referenceIndex;
            DayRule    dayRule;
            DayCount   floatDayCount, fixedDayCount;
            CurveTenor floatTenor, fixedTenor;

            string[] infoArray = instrumentString.Split(',').ToArray();

            identifier     = infoArray[0];
            type           = infoArray[1];
            currency       = infoArray[2];
            startTenor     = infoArray[3];
            endTenor       = infoArray[4];
            settlementLag  = infoArray[5];
            dayRule        = StrToEnum.DayRuleConvert(infoArray[6]);
            fixedFreq      = infoArray[9];
            floatFreq      = infoArray[10];
            referenceIndex = infoArray[12];
            floatDayCount  = StrToEnum.DayCountConvert(infoArray[14]);
            fixedDayCount  = StrToEnum.DayCountConvert(infoArray[13]);
            floatTenor     = StrToEnum.CurveTenorFromSimpleTenor(floatFreq);
            fixedTenor     = StrToEnum.CurveTenorFromSimpleTenor(fixedFreq);


            DateTime startDate, endDate;

            // Make sure to get fwd starting stuff right here...
            if (DateHandling.StrIsConvertableToDate(startTenor))
            {
                startDate = Convert.ToDateTime(startTenor);
            }
            else
            {
                startDate = DateHandling.AddTenorAdjust(AsOf, settlementLag, dayRule);
            }

            if (DateHandling.StrIsConvertableToDate(endTenor))
            {
                endDate = Convert.ToDateTime(endTenor);
            }
            else
            {
                endDate = DateHandling.AddTenorAdjust(startDate, endTenor, dayRule);
            }

            try
            {
                if (referenceIndex == "EONIA")
                {
                    // Handle OIS case
                    // Error with endTenor here and string parsing

                    // TEMPORARY
                    //settlementLag = "0D";
                    //dayRule = DayRule.F;

                    // This is a dirty hack to value deposits
                    if (identifier == "EUREONON" || identifier == "EUREONTN")
                    {
                        Deposit deposit = new Deposit(AsOf, startTenor, endTenor, settlementLag, _defaultFixedRate, floatDayCount, dayRule, _defaultNotional, _defaultTradeSign);
                        Deposits[identifier]                = deposit;
                        CurvePointMap[identifier]           = deposit.GetCurvePoint();
                        InstrumentTypeMap[identifier]       = QuoteType.Deposit;
                        InstrumentFormatTypeMap[identifier] = InstrumentFormatType.Swaps;
                        IdentifierStringMap[identifier]     = instrumentString;
                    }
                    else
                    {
                        OisSwap oisSwap = new OisSwap(AsOf, startTenor, endTenor, settlementLag, fixedDayCount, floatDayCount, dayRule, _defaultNotional, _defaultFixedRate, _defaultTradeSign);
                        OisSwaps[identifier]                = oisSwap;
                        CurvePointMap[identifier]           = oisSwap.GetCurvePoint();
                        InstrumentTypeMap[identifier]       = QuoteType.OisRate;
                        InstrumentFormatTypeMap[identifier] = InstrumentFormatType.Swaps;
                        IdentifierStringMap[identifier]     = instrumentString;
                    }
                }
                else
                {
                    // Handle non-OIS case
                    IrSwap swap = new IrSwap(AsOf, startDate, endDate, _defaultFixedRate, fixedTenor, floatTenor, fixedDayCount, floatDayCount, dayRule, dayRule, _defaultNotional, _defaultTradeSign, 0.0);
                    IrSwaps[identifier]                 = swap;
                    CurvePointMap[identifier]           = swap.GetCurvePoint();
                    InstrumentTypeMap[identifier]       = QuoteType.ParSwapRate;
                    InstrumentFormatTypeMap[identifier] = InstrumentFormatType.Swaps;
                    IdentifierStringMap[identifier]     = instrumentString;
                }
            }
            catch
            {
                // Ignore instrument.
            }
        }