Example #1
0
        public double IrParSwapRate(IrSwap swap)
        {
            double floatPV      = ValueFloatLeg(swap.FloatLeg) / swap.FloatLeg.Notional;
            double fixedAnnuity = Annuity(swap.FixedLeg.Schedule, Interpolation);

            return(floatPV / fixedAnnuity);
        }
Example #2
0
        public ADouble IrParSwapRateAD(IrSwap swap)
        {
            ADouble floatPv      = ValueFloatLegAD(swap.FloatLeg) / swap.FloatLeg.Notional;
            ADouble fixedAnnuity = AnnuityAD(swap.FixedLeg.Schedule, Interpolation);

            return(floatPv / fixedAnnuity);
        }
        /* Functions below are the actual functions used to
         * parse instrument strings into actual objects. We've created
         * a method for each of the instrument classes we consider.
         * Note that the string has to have a very specific format.
         */

        private void InterpretTenorBasisSwapString(string instrumentString)
        {
            string identifier, type, currency, swapNoSpreadIdent, swapSpreadIdent;

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

            identifier = infoArray[0];
            type       = infoArray[1];
            currency   = infoArray[2];

            // In accordance with market practice, we put the spread on the short leg
            swapSpreadIdent   = infoArray[3];
            swapNoSpreadIdent = infoArray[4];

            try
            {
                IrSwap         swapNoSpread = IrSwaps[swapNoSpreadIdent];
                IrSwap         swapSpread   = IrSwaps[swapSpreadIdent];
                TenorBasisSwap swap         = new TenorBasisSwap(swapSpread, swapNoSpread, _defaultTradeSign);
                BasisSwaps[identifier] = swap;
                DateTime curvePoint = swap.GetCurvePoint();
                CurvePointMap[identifier]           = swap.GetCurvePoint();
                InstrumentTypeMap[identifier]       = QuoteType.ParBasisSpread;
                InstrumentFormatTypeMap[identifier] = InstrumentFormatType.BasisSpreads;
                IdentifierStringMap[identifier]     = instrumentString;
            }
            catch
            {
                // Ignore instrument
            }
        }
        public static void PlainVanillaSwap_Make(string baseName, string fixedLegName, string floatLegName, int tradeSign)
        {
            FixedLeg fixedLeg = ObjectMap.FixedLegs[fixedLegName];
            FloatLeg floatLeg = ObjectMap.FloatLegs[floatLegName];
            IrSwap   swap     = new MasterThesis.IrSwap(floatLeg, fixedLeg, tradeSign);

            ObjectMap.LinearRateInstruments[baseName] = swap;
            ObjectMap.IrSwaps[baseName] = swap;
        }
Example #5
0
        public TenorBasisSwap(IrSwap swapSpread, IrSwap swapNoSpread, int tradeSign)
        {
            this.FloatLegNoSpread = swapNoSpread.FloatLeg.Copy();
            this.FloatLegSpread   = swapSpread.FloatLeg.Copy();
            this.SwapSpread       = swapSpread.Copy();
            this.SwapNoSpread     = swapNoSpread.Copy();

            TradeSign = tradeSign;
            CheckTradeSign();

            ConstructedFromFloatingLegs = false;
        }
Example #6
0
        public TenorBasisSwap(FloatLeg floatLegSpread, FloatLeg floatLegNoSpread, int tradeSign)
        {
            this.FloatLegNoSpread = floatLegNoSpread.Copy();
            this.FloatLegSpread   = floatLegSpread.Copy();

            // Construct default FixedLeg - quick and dirty
            FixedLeg tempFixedLeg = new FixedLeg(floatLegNoSpread.AsOf, floatLegSpread.StartDate, floatLegSpread.EndDate, 0.01, CurveTenor.Fwd1Y, DayCount.THIRTY360, DayRule.MF, floatLegSpread.Notional);

            SwapSpread   = new IrSwap(floatLegSpread, tempFixedLeg, tradeSign);
            SwapNoSpread = new IrSwap(floatLegNoSpread, tempFixedLeg, -1 * tradeSign);

            TradeSign = tradeSign;
            CheckTradeSign();

            ConstructedFromFloatingLegs = true;
        }
Example #7
0
 // Fixed-for-floating Interest rate swaps
 public ADouble IrSwapNpvAD(IrSwap swap)
 {
     return((double)swap.TradeSign * (ValueFloatLegAD(swap.FloatLeg) - ValueFixedLegAD(swap.FixedLeg)));
 }
Example #8
0
 // Interest rate swap
 public double IrSwapNpv(IrSwap swap)
 {
     return(swap.TradeSign * (ValueFloatLeg(swap.FloatLeg) - ValueFixedLeg(swap.FixedLeg)));
 }
        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.
            }
        }