/* 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 ADouble ParBasisSpreadTwoLegsAD(TenorBasisSwap swap)
        {
            ADouble pvNoSpread    = ValueFloatLegNoSpreadAD(swap.FloatLegNoSpread) / swap.FloatLegNoSpread.Notional;
            ADouble pvSpread      = ValueFloatLegNoSpreadAD(swap.FloatLegSpread) / swap.FloatLegSpread.Notional;
            ADouble annuitySpread = AnnuityAD(swap.FloatLegSpread.Schedule, Interpolation);

            return((pvNoSpread - pvSpread) / annuitySpread);
        }
        public static void BasisSwap_Make(string baseName, string floatLegNoSpreadName, string floatLegSpreadName, int tradeSign)
        {
            FloatLeg       floatLegNoSpread = ObjectMap.FloatLegs[floatLegNoSpreadName];
            FloatLeg       floatLegSpread   = ObjectMap.FloatLegs[floatLegSpreadName];
            TenorBasisSwap swap             = new MasterThesis.TenorBasisSwap(floatLegSpread, floatLegNoSpread, tradeSign);

            ObjectMap.LinearRateInstruments[baseName] = swap;
            ObjectMap.BasisSwaps[baseName]            = swap;
        }
        public ADouble ParBasisSpreadTwoIrsAD(TenorBasisSwap swap)
        {
            // Tedious way
            //ADouble pvNoSpread = ValueFloatLegNoSpreadAD(swap.FloatLegNoSpread) / swap.FloatLegNoSpread.Notional;
            //ADouble pvSpread = ValueFloatLegNoSpreadAD(swap.FloatLegSpread) / swap.FloatLegSpread.Notional;
            //ADouble annuityOfSpreadFixedLeg = AnnuityAD(swap.FloatLegSpread.Schedule, Interpolation);
            //ADouble annuityOfNoSpreadFixedLeg = AnnuityAD(swap.FloatLegNoSpread.Schedule, Interpolation);
            //return pvNoSpread / annuityOfNoSpreadFixedLeg - pvSpread / annuityOfSpreadFixedLeg;

            return(IrParSwapRateAD(swap.SwapNoSpread) - IrParSwapRateAD(swap.SwapSpread));
        }
 public ADouble ParBasisSpreadAD(TenorBasisSwap swap)
 {
     if (swap.ConstructedFromFloatingLegs)
     {
         return(ParBasisSpreadTwoLegsAD(swap));
     }
     else
     {
         return(ParBasisSpreadTwoIrsAD(swap));
     }
 }
 // Tenor basis swaps
 public ADouble BasisSwapNpvAD(TenorBasisSwap swap)
 {
     if (swap.ConstructedFromFloatingLegs)
     {
         return(BasisSwapNpvTwoLegsAD(swap));
     }
     else
     {
         return(BasisSwapNpvTwoIrsAD(swap));
     }
 }
 public ADouble BasisSwapNpvTwoIrsAD(TenorBasisSwap swap)
 {
     return(ValueLinearRateProductAD(swap.SwapNoSpread) - ValueLinearRateProductAD(swap.SwapSpread));
 }
 public ADouble BasisSwapNpvTwoLegsAD(TenorBasisSwap swap)
 {
     return((double)swap.TradeSign * (ValueFloatLegAD(swap.FloatLegNoSpread) - ValueFloatLegAD(swap.FloatLegSpread)));
 }
Exemple #9
0
 public double BasisSwapNpvTwoLegs(TenorBasisSwap swap)
 {
     return(swap.TradeSign * (ValueFloatLeg(swap.FloatLegNoSpread) - ValueFloatLeg(swap.FloatLegSpread)));
 }