CreateStructure Example CS

C# Example - CreateStructure![]() ![]() ![]() ![]() ![]() // ################################################################################## // The first function here CreateStructure(), contains a series of // function calls leading upto the main function call, the second function // within this file ( CreateStructurePart() ). // which contains the answer that we are looking for.![]() // The first function here is simply an example of how to construct the parameters // in order acquire either a string Key (that is to be passed to other functions) // or a computed result.![]() // If you are viewing this source code from the chm or web help file you can use the // outlining features to collapse certain sections of the code for better readability. // ################################################################################## ![]() using System;![]() // Optional using instruction. We will use a mix of utilising fully qualified names (in the case of the financial objects) // and using the reduced version (in the case of declaring enumerations). // This is just to demostrate both types of coding.![]() using CTQL; // You need to add a reference to the QuantToolsNET.v2.dll also![]() // Some global parameter in order to append to user defined keys. // We use it here to ensure that we have unique Keys (in the case several of our examples // use the same key-name) // In normal use, a user defined string will be used and so this variable will be pointless. static int nCTQryLegsGlobal; // Used by function parameters that take an optional range value. // In Excel we simply omit the value, within the API functions, // we pass an empty range object static CTQL.CTRangeData oEmptyRange = new CTQL.CTRangeData(); public string CS_EX_CreateStructure() { nCTQryLegsGlobal += 1; string szErrorMsg = "";![]() try {![]() ![]() // EURO calendar used for holiday adjustments. ![]() string MyEuroCal; MyEuroCal = CALEUROPart(); ![]() ![]() // UK date calendar used within the UK stock exchange. ![]() string MyCALUKExchange; MyCALUKExchange = CALUKExchangePart(); ![]() ![]() // Creates a centralized valuation date object. ![]() string MyValuationDate; MyValuationDate = ValueDateObjPart(); ![]() ![]() // Generates a schedule of start and end dates, given the initial // start date and unadjusted final end dates. string MySchedule; MySchedule = MakeSchedulePart( MyEuroCal); ![]() ![]() // Creates a Deposit template which is almost identical to a Libor // Index, but without the YieldCurve information. string MyDepoTPL; MyDepoTPL = CreateDepoTemplatePart( MyCALUKExchange, MyEuroCal); ![]() ![]() // Creates a Swap template which is almost identical to the definition // of the parameters of a swap contract, but without the swap duration, // buysell, and YieldCurve information. string MySwapTPL; MySwapTPL = CreateSwapTemplatePart( MyEuroCal, MyDepoTPL); ![]() ![]() // Creates a SABR curve to model the dynamics of the volatility // curve (smile). string MySABRVolCurve; MySABRVolCurve = SABRVolCurvePart( MyValuationDate, MyDepoTPL, MySwapTPL); ![]() ![]() // Creates an amortisation object to be used within the amortisation // fixed and floating rate leg objects. string MyCreateAmortObj; MyCreateAmortObj = CreateAmortObjPart( MySchedule); ![]() ![]() // Creates a yield curve using market rates (No cross-currency // Swaps). string MyMiniYC; MyMiniYC = MKTYC_D__3Part( MyValuationDate, MyDepoTPL, MySwapTPL); ![]() ![]() // Creates a new Index code. string MyNewIndex2; MyNewIndex2 = CreateIndex__2Part( MyCALUKExchange, MyEuroCal, MyMiniYC); ![]() ![]() // Creates a market object which is an aggregate of interest rate // market objects (Discounting curve and Interest rate volatility // curve (volcurve)). string MyMarket4; MyMarket4 = CreateMKT__4Part( MyMiniYC, MySABRVolCurve); ![]() ![]() // Creates a floating rate leg. string MyCreateFloatLeg3; MyCreateFloatLeg3 = CreateFloatLeg__3Part( MySchedule, MyNewIndex2, MyMarket4); ![]() ![]() // Creates an amortised floating rate leg. string MyCreateAmortFloatLeg2; MyCreateAmortFloatLeg2 = CreateAmortFloatLeg__2Part( MyCreateAmortObj, MyNewIndex2, MyMarket4); ![]() ![]() // Creates a Fixed rate leg. string MyCreateFixedRateLeg3; MyCreateFixedRateLeg3 = CreateFixedRateLeg__3Part( MySchedule, MyMarket4); ![]() ![]() // This floating leg (or FRN) only provide one payoff. string MyCreateZCFloatLeg2; MyCreateZCFloatLeg2 = CreateZCFloatLeg__2Part( MySchedule, MyNewIndex2, MyMarket4); ![]() ![]() // Creates an amortised fixed rate leg. string MyCreateAmortFixLeg2; MyCreateAmortFixLeg2 = CreateAmortFixLeg__2Part( MyCreateAmortObj, MyMarket4); ![]() ![]() // Creates a porfolio of caplet or floorlet options from this floating // Rate Leg. string MyCreateCapFLTLeg2; MyCreateCapFLTLeg2 = CreateCapFLTLeg__2Part( MyCreateFloatLeg3, MySABRVolCurve); ![]() ![]() // Creates a Structure object (which is really a portfolio of leg // objects). string MyStructure; MyStructure = CreateStructurePart( MyCreateAmortFloatLeg2, MyCreateFixedRateLeg3, MyCreateZCFloatLeg2, MyCreateAmortFixLeg2, MyCreateCapFLTLeg2); // This is the result we are looking for. return MyStructure; ![]() } catch(Exception e) { szErrorMsg = e.Message; throw e; } } ![]() ![]() // ///////////////////////////////////////////////////////////////////![]() private string CreateStructurePart( string MyCreateAmortFloatLeg2, string MyCreateFixedRateLeg3, string MyCreateZCFloatLeg2, string MyCreateAmortFixLeg2, string MyCreateCapFLTLeg2) {![]() // Create example range for parameter CreateStructure_Legs CTQL.CTRangeData CreateStructure_Legs; ![]() string[] arrBCreateStructure_Legs = { MyCreateAmortFloatLeg2, MyCreateFixedRateLeg3, MyCreateZCFloatLeg2, MyCreateAmortFixLeg2, MyCreateCapFLTLeg2 // Array Data }; CTQL.StringVector arrCreateStructure_Legs = new CTQL.StringVector(arrBCreateStructure_Legs); // Second parameter determines whether the array is a column array (false) or a row array (true) CreateStructure_Legs = new CTQL.CTRangeData(arrCreateStructure_Legs, false); ![]() ![]() // Key value to use as a handle for the created object string MyStructure = "MyStructure" + "_" + System.Convert.ToString(nCTQryLegsGlobal);![]() // When creating this object for the first time, set this parameter // to a positive value. int Reload = 1;![]() // Excel function call would be this - "CT.LEG.CreateStructure()"![]() // Creates a Structure object (which is really a portfolio of leg // objects). string rCreateStructure; rCreateStructure = CTQL.CTQryLegsSA.CreateStructure( MyStructure, Reload, CreateStructure_Legs);![]() ![]() return rCreateStructure; } ![]() ![]() ![]() // ///////////////////////////////////////////////////////////////////![]() private string CreateAmortFloatLeg__2Part( string MyCreateAmortObj, string MyNewIndex2, string MyMarket4) {![]() // Create example range for parameter CreateAmortFloatLeg__2_Margin CTQL.CTRangeData CreateAmortFloatLeg__2_Margin; ![]() double[] arrBCreateAmortFloatLeg__2_Margin = { 0.0002, 0.0002, 0.0002, 0.0002, 0.0002, 0.0002, 0.0002, 0.0002, 0.0002, 0.0002, 0.0002, 0.0002, 0.0002, 0.0002, 0.0002, 0.0002, 0.0002, 0.0002, 0.0002, 0.0002 // Array Data }; CTQL.DoubleVector arrCreateAmortFloatLeg__2_Margin = new CTQL.DoubleVector(arrBCreateAmortFloatLeg__2_Margin); // Second parameter determines whether the array is a column array (false) or a row array (true) CreateAmortFloatLeg__2_Margin = new CTQL.CTRangeData(arrCreateAmortFloatLeg__2_Margin, false); ![]() ![]() // Key value to use as a handle for the created object string MyCreateAmortFloatLeg2 = "MyCreateAmortFloatLeg2" + "_" + System.Convert.ToString(nCTQryLegsGlobal);![]() // When creating this object for the first time, set this parameter // to a positive value. int Reload = 1;![]() // Whether you would like to PAY or REC this leg. CTIEnums.PAYRECEnum PayRec = CTIEnums.PAYRECEnum.PAYREC_REC;![]() // A positive factor value you wish to multiply the Floating-Reset // Rate/Fixed-Coupon Rate by (Usually 1). int Gearing = 1;![]() // Currency of the Notional amount. CTIEnums.CCYEnum Ccy = CTIEnums.CCYEnum.CCY_EUR;![]() // Payment Business Day Convention. CTIEnums.BDCEnum BusDayConv = CTIEnums.BDCEnum.BDC_modifiedfollowing;![]() // Payment DayCounter. CTIEnums.DayCountEnum DayCount = CTIEnums.DayCountEnum.DayCount_actual365_fixed;![]() // Whether you wish to exchange the principal amount(s) at the // start and termination of the leg contract. bool ExchangePrincipal = false;![]() // If a CMS index is specified (within the parameter 'IndexKey') // and the 'CMSAlgo' parameter within this CMS Index has been set // to 'Hull' then the correlation between swap rates and fwd rates // is required. double SMPFWDRho = 0.8;![]() // Excel function call would be this - "CT.LEG.CreateAmortFloatLeg()"![]() // Creates an amortised floating rate leg. string rCreateAmortFloatLeg__2; rCreateAmortFloatLeg__2 = CTQL.CTLegsSA.CreateAmortFloatLeg( MyCreateAmortFloatLeg2, Reload, PayRec, Gearing, MyCreateAmortObj, Ccy, BusDayConv, DayCount, MyNewIndex2, CreateAmortFloatLeg__2_Margin, ExchangePrincipal, MyMarket4, SMPFWDRho);![]() ![]() return rCreateAmortFloatLeg__2; } ![]() ![]() ![]() // ///////////////////////////////////////////////////////////////////![]() private string CreateFixedRateLeg__3Part( string MySchedule, string MyMarket4) {![]() // Create example range for parameter CreateFixedRateLeg__3_Notional CTQL.CTRangeData CreateFixedRateLeg__3_Notional; ![]() int[] arrBCreateFixedRateLeg__3_Notional = { 5000000, 5000000, 5000000, 5000000, 5000000, 5000000, 5000000, 5000000, 5000000, 5000000, 5000000, 5000000, 5000000, 5000000, 5000000, 5000000, 5000000, 5000000, 5000000, 5000000 // Array Data }; CTQL.IntVector arrCreateFixedRateLeg__3_Notional = new CTQL.IntVector(arrBCreateFixedRateLeg__3_Notional); // Second parameter determines whether the array is a column array (false) or a row array (true) CreateFixedRateLeg__3_Notional = new CTQL.CTRangeData(arrCreateFixedRateLeg__3_Notional, false); // Create example range for parameter CreateFixedRateLeg__3_PrincipalPayments CTQL.CTRangeData CreateFixedRateLeg__3_PrincipalPayments; ![]() int[] arrBCreateFixedRateLeg__3_PrincipalPayments = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 // Array Data }; CTQL.IntVector arrCreateFixedRateLeg__3_PrincipalPayments = new CTQL.IntVector(arrBCreateFixedRateLeg__3_PrincipalPayments); // Second parameter determines whether the array is a column array (false) or a row array (true) CreateFixedRateLeg__3_PrincipalPayments = new CTQL.CTRangeData(arrCreateFixedRateLeg__3_PrincipalPayments, false); // Create example range for parameter CreateFixedRateLeg__3_Coupon CTQL.CTRangeData CreateFixedRateLeg__3_Coupon; ![]() double[] arrBCreateFixedRateLeg__3_Coupon = { 0.05, 0.05, 0.05, 0.05, 0.05, 0.05, 0.05, 0.05, 0.05, 0.05, 0.05, 0.05, 0.05, 0.05, 0.05, 0.05, 0.05, 0.05, 0.05, 0.05 // Array Data }; CTQL.DoubleVector arrCreateFixedRateLeg__3_Coupon = new CTQL.DoubleVector(arrBCreateFixedRateLeg__3_Coupon); // Second parameter determines whether the array is a column array (false) or a row array (true) CreateFixedRateLeg__3_Coupon = new CTQL.CTRangeData(arrCreateFixedRateLeg__3_Coupon, false); ![]() ![]() // Key value to use as a handle for the created object string MyCreateFixedRateLeg3 = "MyCreateFixedRateLeg3" + "_" + System.Convert.ToString(nCTQryLegsGlobal);![]() // When creating this object for the first time, set this parameter // to a positive value. int Reload = 1;![]() // Whether you would like to PAY or REC this leg. CTIEnums.PAYRECEnum PayRec = CTIEnums.PAYRECEnum.PAYREC_PAY;![]() // A positive factor value you wish to multiply the Floating-Reset // Rate/Fixed-Coupon Rate by (Usually 1). int Gearing = 1;![]() // Currency of the Notional amount. CTIEnums.CCYEnum Ccy = CTIEnums.CCYEnum.CCY_EUR;![]() // Payment Business Day Convention. CTIEnums.BDCEnum BusDayConv = CTIEnums.BDCEnum.BDC_modifiedfollowing;![]() // Payment DayCounter. CTIEnums.DayCountEnum DayCount = CTIEnums.DayCountEnum.DayCount_actual365_fixed;![]() // Whether you wish to exchange the principal amount(s) at the // start and termination of the leg contract. bool ExchangePrincipal = false;![]() // Excel function call would be this - "CT.LEG.CreateFixedRateLeg()"![]() // Creates a Fixed rate leg. string rCreateFixedRateLeg__3; rCreateFixedRateLeg__3 = CTQL.CTFIXLegsSA.CreateFixedRateLeg( MyCreateFixedRateLeg3, Reload, PayRec, Gearing, CreateFixedRateLeg__3_Notional, CreateFixedRateLeg__3_PrincipalPayments, Ccy, MySchedule, BusDayConv, DayCount, CreateFixedRateLeg__3_Coupon, ExchangePrincipal, MyMarket4);![]() ![]() return rCreateFixedRateLeg__3; } ![]() ![]() ![]() // ///////////////////////////////////////////////////////////////////![]() private string CreateZCFloatLeg__2Part( string MySchedule, string MyNewIndex2, string MyMarket4) {![]() // Create example range for parameter CreateZCFloatLeg__2_Notional CTQL.CTRangeData CreateZCFloatLeg__2_Notional; ![]() int[] arrBCreateZCFloatLeg__2_Notional = { 5000000, 5000000, 5000000, 5000000, 5000000, 5000000, 5000000, 5000000, 5000000, 5000000, 5000000, 5000000, 5000000, 5000000, 5000000, 5000000, 5000000, 5000000, 5000000, 5000000 // Array Data }; CTQL.IntVector arrCreateZCFloatLeg__2_Notional = new CTQL.IntVector(arrBCreateZCFloatLeg__2_Notional); // Second parameter determines whether the array is a column array (false) or a row array (true) CreateZCFloatLeg__2_Notional = new CTQL.CTRangeData(arrCreateZCFloatLeg__2_Notional, false); // Create example range for parameter CreateZCFloatLeg__2_PrincipalPayments CTQL.CTRangeData CreateZCFloatLeg__2_PrincipalPayments; ![]() int[] arrBCreateZCFloatLeg__2_PrincipalPayments = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 // Array Data }; CTQL.IntVector arrCreateZCFloatLeg__2_PrincipalPayments = new CTQL.IntVector(arrBCreateZCFloatLeg__2_PrincipalPayments); // Second parameter determines whether the array is a column array (false) or a row array (true) CreateZCFloatLeg__2_PrincipalPayments = new CTQL.CTRangeData(arrCreateZCFloatLeg__2_PrincipalPayments, false); // Create example range for parameter CreateZCFloatLeg__2_Margin CTQL.CTRangeData CreateZCFloatLeg__2_Margin; ![]() double[] arrBCreateZCFloatLeg__2_Margin = { 0.0002, 0.0002, 0.0002, 0.0002, 0.0002, 0.0002, 0.0002, 0.0002, 0.0002, 0.0002, 0.0002, 0.0002, 0.0002, 0.0002, 0.0002, 0.0002, 0.0002, 0.0002, 0.0002, 0.0002 // Array Data }; CTQL.DoubleVector arrCreateZCFloatLeg__2_Margin = new CTQL.DoubleVector(arrBCreateZCFloatLeg__2_Margin); // Second parameter determines whether the array is a column array (false) or a row array (true) CreateZCFloatLeg__2_Margin = new CTQL.CTRangeData(arrCreateZCFloatLeg__2_Margin, false); ![]() ![]() // Key value to use as a handle for the created object string MyCreateZCFloatLeg2 = "MyCreateZCFloatLeg2" + "_" + System.Convert.ToString(nCTQryLegsGlobal);![]() // When creating this object for the first time, set this parameter // to a positive value. int Reload = 1;![]() // Whether you would like to PAY or REC this leg. CTIEnums.PAYRECEnum PayRec = CTIEnums.PAYRECEnum.PAYREC_REC;![]() // A positive factor value you wish to multiply the Floating-Reset // Rate/Fixed-Coupon Rate by (Usually 1). int Gearing = 1;![]() // Currency of the Notional amount. CTIEnums.CCYEnum Ccy = CTIEnums.CCYEnum.CCY_EUR;![]() // Payment Business Day Convention. CTIEnums.BDCEnum BusDayConv = CTIEnums.BDCEnum.BDC_modifiedfollowing;![]() // Payment DayCounter. CTIEnums.DayCountEnum DayCount = CTIEnums.DayCountEnum.DayCount_actual365_fixed;![]() // Whether you wish to exchange the principal amount(s) at the // start and termination of the leg contract. bool ExchangePrincipal = false;![]() // If a CMS index is specified (within the parameter 'IndexKey') // and the 'CMSAlgo' parameter within this CMS Index has been set // to 'Hull' then the correlation between swap rates and fwd rates // is required. double SMPFWDRho = 0.8;![]() // Excel function call would be this - "CT.LEG.CreateZCFloatLeg()"![]() // This floating leg (or FRN) only provide one payoff. string rCreateZCFloatLeg__2; rCreateZCFloatLeg__2 = CTQL.CTZCFLTLegsSA.CreateZCFloatLeg( MyCreateZCFloatLeg2, Reload, PayRec, Gearing, CreateZCFloatLeg__2_Notional, CreateZCFloatLeg__2_PrincipalPayments, Ccy, MySchedule, BusDayConv, DayCount, MyNewIndex2, CreateZCFloatLeg__2_Margin, ExchangePrincipal, MyMarket4, SMPFWDRho);![]() ![]() return rCreateZCFloatLeg__2; } ![]() ![]() ![]() // ///////////////////////////////////////////////////////////////////![]() private string CreateAmortFixLeg__2Part( string MyCreateAmortObj, string MyMarket4) {![]() // Create example range for parameter CreateAmortFixLeg__2_Coupon CTQL.CTRangeData CreateAmortFixLeg__2_Coupon; ![]() double[] arrBCreateAmortFixLeg__2_Coupon = { 0.05, 0.05, 0.05, 0.05, 0.05, 0.05, 0.05, 0.05, 0.05, 0.05, 0.05, 0.05, 0.05, 0.05, 0.05, 0.05, 0.05, 0.05, 0.05, 0.05 // Array Data }; CTQL.DoubleVector arrCreateAmortFixLeg__2_Coupon = new CTQL.DoubleVector(arrBCreateAmortFixLeg__2_Coupon); // Second parameter determines whether the array is a column array (false) or a row array (true) CreateAmortFixLeg__2_Coupon = new CTQL.CTRangeData(arrCreateAmortFixLeg__2_Coupon, false); ![]() ![]() // Key value to use as a handle for the created object string MyCreateAmortFixLeg2 = "MyCreateAmortFixLeg2" + "_" + System.Convert.ToString(nCTQryLegsGlobal);![]() // When creating this object for the first time, set this parameter // to a positive value. int Reload = 1;![]() // Whether you would like to PAY or REC this leg. CTIEnums.PAYRECEnum PayRec = CTIEnums.PAYRECEnum.PAYREC_PAY;![]() // A positive factor value you wish to multiply the Floating-Reset // Rate/Fixed-Coupon Rate by (Usually 1). int Gearing = 1;![]() // Currency of the Notional amount. CTIEnums.CCYEnum Ccy = CTIEnums.CCYEnum.CCY_EUR;![]() // Payment Business Day Convention. CTIEnums.BDCEnum BusDayConv = CTIEnums.BDCEnum.BDC_modifiedfollowing;![]() // Payment DayCounter. CTIEnums.DayCountEnum DayCount = CTIEnums.DayCountEnum.DayCount_actual365_fixed;![]() // Whether you wish to exchange the principal amount(s) at the // start and termination of the leg contract. bool ExchangePrincipal = false;![]() // Excel function call would be this - "CT.LEG.CreateAmortFixLeg()"![]() // Creates an amortised fixed rate leg. string rCreateAmortFixLeg__2; rCreateAmortFixLeg__2 = CTQL.CTFIXLegsSA.CreateAmortFixLeg( MyCreateAmortFixLeg2, Reload, PayRec, Gearing, MyCreateAmortObj, Ccy, BusDayConv, DayCount, CreateAmortFixLeg__2_Coupon, ExchangePrincipal, MyMarket4);![]() ![]() return rCreateAmortFixLeg__2; } ![]() ![]() ![]() // ///////////////////////////////////////////////////////////////////![]() private string CreateCapFLTLeg__2Part( string MyCreateFloatLeg3, string MySABRVolCurve) {![]() // Create example range for parameter CreateCapFLTLeg__2_EnablePeriods CTQL.CTRangeData CreateCapFLTLeg__2_EnablePeriods; ![]() int[] arrBCreateCapFLTLeg__2_EnablePeriods = { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 // Array Data }; CTQL.IntVector arrCreateCapFLTLeg__2_EnablePeriods = new CTQL.IntVector(arrBCreateCapFLTLeg__2_EnablePeriods); // Second parameter determines whether the array is a column array (false) or a row array (true) CreateCapFLTLeg__2_EnablePeriods = new CTQL.CTRangeData(arrCreateCapFLTLeg__2_EnablePeriods, false); // Create example range for parameter CreateCapFLTLeg__2_Strike CTQL.CTRangeData CreateCapFLTLeg__2_Strike; ![]() double[] arrBCreateCapFLTLeg__2_Strike = { 0.03, 0.03, 0.03, 0.03, 0.03, 0.03, 0.03, 0.03, 0.03, 0.03, 0.03, 0.03, 0.03, 0.03, 0.03, 0.03, 0.03, 0.03, 0.03, 0.03 // Array Data }; CTQL.DoubleVector arrCreateCapFLTLeg__2_Strike = new CTQL.DoubleVector(arrBCreateCapFLTLeg__2_Strike); // Second parameter determines whether the array is a column array (false) or a row array (true) CreateCapFLTLeg__2_Strike = new CTQL.CTRangeData(arrCreateCapFLTLeg__2_Strike, false); ![]() ![]() // Key value to use as a handle for the created object string MyCreateCapFLTLeg2 = "MyCreateCapFLTLeg2" + "_" + System.Convert.ToString(nCTQryLegsGlobal);![]() // When creating this object for the first time, set this parameter // to a positive value. int Reload = 1;![]() // Excel function call would be this - "CT.LEG.CreateCapFLTLeg()"![]() // Creates a porfolio of caplet or floorlet options from this floating // Rate Leg. string rCreateCapFLTLeg__2; rCreateCapFLTLeg__2 = CTQL.CTExoticLegsSA.CreateCapFLTLeg( MyCreateCapFLTLeg2, Reload, MyCreateFloatLeg3, CreateCapFLTLeg__2_EnablePeriods, CreateCapFLTLeg__2_Strike, MySABRVolCurve);![]() ![]() return rCreateCapFLTLeg__2; } ![]() ![]() ![]() // ///////////////////////////////////////////////////////////////////![]() private string CreateAmortObjPart( string MySchedule) {![]() ![]() ![]() // Key value to use as a handle for the created object string MyCreateAmortObj = "MyCreateAmortObj" + "_" + System.Convert.ToString(nCTQryLegsGlobal);![]() // When creating this object for the first time, set this parameter // to a positive value. int Reload = 1;![]() // Initial positive notional amount. double Notional = 5000000;![]() // Final positive notional amount. double FinalNot = 1000000;![]() // Whether you wish to include principal payments that are paid // to the holder of this contract during the life of the leg contract. bool PrincipalPayments = true;![]() // Amortisation method to use. CTIEnums.AmortEnum AmortMethod = CTIEnums.AmortEnum.Amort_Linear;![]() // Amortisation rate to use. double AmortRate = 0.06;![]() // The number of times you would like to repeat the Notional amounts // computed (normally 1). int AmortRepeatNot = 1;![]() // Excel function call would be this - "CT.UTIL.CreateAmortObj()"![]() // Creates an amortisation object to be used within the amortisation // fixed and floating rate leg objects. string rCreateAmortObj; rCreateAmortObj = CTQL.CTUtilsSA.CreateAmortObj( MyCreateAmortObj, Reload, Notional, FinalNot, PrincipalPayments, AmortMethod, AmortRate, AmortRepeatNot, MySchedule);![]() ![]() return rCreateAmortObj; } ![]() ![]() ![]() // ///////////////////////////////////////////////////////////////////![]() private string CreateIndex__2Part( string MyCALUKExchange, string MyEuroCal, string MyMiniYC) {![]() // Create example range for parameter CreateIndex__2_BasisSwaps CTQL.CTRangeData CreateIndex__2_BasisSwaps = new CTQL.CTRangeData(); System.Text.StringBuilder CreateIndex__2_BasisSwaps_builder = new System.Text.StringBuilder(100); // We could set the value for each cell individually, but for display // purposes, this is quicker and more informative. CreateIndex__2_BasisSwaps_builder.Append("{"); CreateIndex__2_BasisSwaps_builder.Append("'1Y' | 3.5 | True ;"); CreateIndex__2_BasisSwaps_builder.Append("'2Y' | 3 | True ;"); CreateIndex__2_BasisSwaps_builder.Append("'3Y' | 3.25 | True ;"); CreateIndex__2_BasisSwaps_builder.Append("'4Y' | 3.25 | True ;"); CreateIndex__2_BasisSwaps_builder.Append("'5Y' | 3.25 | True ;"); CreateIndex__2_BasisSwaps_builder.Append("'7Y' | 3.25 | True ;"); CreateIndex__2_BasisSwaps_builder.Append("'10Y' | 3.25 | True ;"); CreateIndex__2_BasisSwaps_builder.Append("'15Y' | 3 | True ;"); CreateIndex__2_BasisSwaps_builder.Append("'20Y' | 2.75 | True ;"); CreateIndex__2_BasisSwaps_builder.Append("'30Y' | 2.75 | True"); CreateIndex__2_BasisSwaps_builder.Append("}"); CreateIndex__2_BasisSwaps.RangeFromStr ( CreateIndex__2_BasisSwaps_builder.ToString() ); // Create example range for parameter CreateIndex__2_PastFixings CTQL.CTRangeData CreateIndex__2_PastFixings = new CTQL.CTRangeData(); System.Text.StringBuilder CreateIndex__2_PastFixings_builder = new System.Text.StringBuilder(100); // We could set the value for each cell individually, but for display // purposes, this is quicker and more informative. CreateIndex__2_PastFixings_builder.Append("{"); CreateIndex__2_PastFixings_builder.Append("#21/Mar/2005# | 0.0353 ;"); CreateIndex__2_PastFixings_builder.Append("#22/Mar/2005# | 0.0356 ;"); CreateIndex__2_PastFixings_builder.Append("#23/Mar/2005# | 0.0356 ;"); CreateIndex__2_PastFixings_builder.Append("#24/Mar/2005# | 0.0354 ;"); CreateIndex__2_PastFixings_builder.Append("#25/Mar/2005# | 0.0357 ;"); CreateIndex__2_PastFixings_builder.Append("#28/Mar/2005# | 0.0356 ;"); CreateIndex__2_PastFixings_builder.Append("#29/Mar/2005# | 0.0355 ;"); CreateIndex__2_PastFixings_builder.Append("#30/Mar/2005# | 0.0356 ;"); CreateIndex__2_PastFixings_builder.Append("#31/Mar/2005# | 0.0354 ;"); CreateIndex__2_PastFixings_builder.Append("#1/Apr/2005# | 0.0353 ;"); CreateIndex__2_PastFixings_builder.Append("#4/Apr/2005# | 0.0357 ;"); CreateIndex__2_PastFixings_builder.Append("#5/Apr/2005# | 0.0356 ;"); CreateIndex__2_PastFixings_builder.Append("#6/Apr/2005# | 0.0353 ;"); CreateIndex__2_PastFixings_builder.Append("#7/Apr/2005# | 0.0356 ;"); CreateIndex__2_PastFixings_builder.Append("#8/Apr/2005# | 0.0356 ;"); CreateIndex__2_PastFixings_builder.Append("#11/Apr/2005# | 0.0356 ;"); CreateIndex__2_PastFixings_builder.Append("#12/Apr/2005# | 0.0353 ;"); CreateIndex__2_PastFixings_builder.Append("#13/Apr/2005# | 0.0354 ;"); CreateIndex__2_PastFixings_builder.Append("#14/Apr/2005# | 0.0356 ;"); CreateIndex__2_PastFixings_builder.Append("#15/Apr/2005# | 0.0354 ;"); CreateIndex__2_PastFixings_builder.Append("#18/Apr/2005# | 0.0355 ;"); CreateIndex__2_PastFixings_builder.Append("#19/Apr/2005# | 0.0354 ;"); CreateIndex__2_PastFixings_builder.Append("#20/Apr/2005# | 0.0356 ;"); CreateIndex__2_PastFixings_builder.Append("#21/Apr/2005# | 0.0356 ;"); CreateIndex__2_PastFixings_builder.Append("#22/Apr/2005# | 0.0356 ;"); CreateIndex__2_PastFixings_builder.Append("#25/Apr/2005# | 0.0353 ;"); CreateIndex__2_PastFixings_builder.Append("#26/Apr/2005# | 0.0356 ;"); CreateIndex__2_PastFixings_builder.Append("#27/Apr/2005# | 0.0356 ;"); CreateIndex__2_PastFixings_builder.Append("#28/Apr/2005# | 0.0354 ;"); CreateIndex__2_PastFixings_builder.Append("#29/Apr/2005# | 0.0355 ;"); CreateIndex__2_PastFixings_builder.Append("#2/May/2005# | 0.0356 ;"); CreateIndex__2_PastFixings_builder.Append("#3/May/2005# | 0.0355 ;"); CreateIndex__2_PastFixings_builder.Append("#4/May/2005# | 0.0356 ;"); CreateIndex__2_PastFixings_builder.Append("#5/May/2005# | 0.0357 ;"); CreateIndex__2_PastFixings_builder.Append("#6/May/2005# | 0.0356 ;"); CreateIndex__2_PastFixings_builder.Append("#9/May/2005# | 0.0357 ;"); CreateIndex__2_PastFixings_builder.Append("#10/May/2005# | 0.0356 ;"); CreateIndex__2_PastFixings_builder.Append("#11/May/2005# | 0.0357 ;"); CreateIndex__2_PastFixings_builder.Append("#12/May/2005# | 0.0354 ;"); CreateIndex__2_PastFixings_builder.Append("#13/May/2005# | 0.0356 ;"); CreateIndex__2_PastFixings_builder.Append("#16/May/2005# | 0.0357 ;"); CreateIndex__2_PastFixings_builder.Append("#17/May/2005# | 0.0354 ;"); CreateIndex__2_PastFixings_builder.Append("#18/May/2005# | 0.0354 ;"); CreateIndex__2_PastFixings_builder.Append("#19/May/2005# | 0.0354 ;"); CreateIndex__2_PastFixings_builder.Append("#20/May/2005# | 0.0357 ;"); CreateIndex__2_PastFixings_builder.Append("#23/May/2005# | 0.0354 ;"); CreateIndex__2_PastFixings_builder.Append("#24/May/2005# | 0.0357 ;"); CreateIndex__2_PastFixings_builder.Append("#25/May/2005# | 0.0354 ;"); CreateIndex__2_PastFixings_builder.Append("#26/May/2005# | 0.0356 ;"); CreateIndex__2_PastFixings_builder.Append("#27/May/2005# | 0.0353 ;"); CreateIndex__2_PastFixings_builder.Append("#30/May/2005# | 0.0357 ;"); CreateIndex__2_PastFixings_builder.Append("#31/May/2005# | 0.0354 ;"); CreateIndex__2_PastFixings_builder.Append("#1/Jun/2005# | 0.0355 ;"); CreateIndex__2_PastFixings_builder.Append("#2/Jun/2005# | 0.0356 ;"); CreateIndex__2_PastFixings_builder.Append("#3/Jun/2005# | 0.0357 ;"); CreateIndex__2_PastFixings_builder.Append("#6/Jun/2005# | 0.0357 ;"); CreateIndex__2_PastFixings_builder.Append("#7/Jun/2005# | 0.0355 ;"); CreateIndex__2_PastFixings_builder.Append("#8/Jun/2005# | 0.0355 ;"); CreateIndex__2_PastFixings_builder.Append("#9/Jun/2005# | 0.0356 ;"); CreateIndex__2_PastFixings_builder.Append("#10/Jun/2005# | 0.0354 ;"); CreateIndex__2_PastFixings_builder.Append("#13/Jun/2005# | 0.0353 ;"); CreateIndex__2_PastFixings_builder.Append("#14/Jun/2005# | 0.0357 ;"); CreateIndex__2_PastFixings_builder.Append("#15/Jun/2005# | 0.0354 ;"); CreateIndex__2_PastFixings_builder.Append("#16/Jun/2005# | 0.0356 ;"); CreateIndex__2_PastFixings_builder.Append("#17/Jun/2005# | 0.0355 ;"); CreateIndex__2_PastFixings_builder.Append("#20/Jun/2005# | 0.0355 ;"); CreateIndex__2_PastFixings_builder.Append("#21/Jun/2005# | 0.0353 ;"); CreateIndex__2_PastFixings_builder.Append("#22/Jun/2005# | 0.0355 ;"); CreateIndex__2_PastFixings_builder.Append("#23/Jun/2005# | 0.0354 ;"); CreateIndex__2_PastFixings_builder.Append("#24/Jun/2005# | 0.0354 ;"); CreateIndex__2_PastFixings_builder.Append("#27/Jun/2005# | 0.0353 ;"); CreateIndex__2_PastFixings_builder.Append("#28/Jun/2005# | 0.0355 ;"); CreateIndex__2_PastFixings_builder.Append("#29/Jun/2005# | 0.0353 ;"); CreateIndex__2_PastFixings_builder.Append("#30/Jun/2005# | 0.0355 ;"); CreateIndex__2_PastFixings_builder.Append("#1/Jul/2005# | 0.0353 ;"); CreateIndex__2_PastFixings_builder.Append("#4/Jul/2005# | 0.0353 ;"); CreateIndex__2_PastFixings_builder.Append("#5/Jul/2005# | 0.0356 ;"); CreateIndex__2_PastFixings_builder.Append("#6/Jul/2005# | 0.0356 ;"); CreateIndex__2_PastFixings_builder.Append("#7/Jul/2005# | 0.0354 ;"); CreateIndex__2_PastFixings_builder.Append("#8/Jul/2005# | 0.0353 ;"); CreateIndex__2_PastFixings_builder.Append("#11/Jul/2005# | 0.0354 ;"); CreateIndex__2_PastFixings_builder.Append("#12/Jul/2005# | 0.0354 ;"); CreateIndex__2_PastFixings_builder.Append("#13/Jul/2005# | 0.0353 ;"); CreateIndex__2_PastFixings_builder.Append("#14/Jul/2005# | 0.0356 ;"); CreateIndex__2_PastFixings_builder.Append("#15/Jul/2005# | 0.0353"); CreateIndex__2_PastFixings_builder.Append("}"); CreateIndex__2_PastFixings.RangeFromStr ( CreateIndex__2_PastFixings_builder.ToString() ); ![]() ![]() // Key value to use as a handle for the created object string MyNewIndex2 = "MyNewIndex2" + "_" + System.Convert.ToString(nCTQryLegsGlobal);![]() // When creating this object for the first time, set this parameter // to a positive value. int Reload = 1;![]() // New Index code to create string IndexCode = "3MEuroIndex2";![]() // Tenor of the index. string Tenor = "3M";![]() // Within a Floating leg object, where there are many fixing periods, // when fixing a rate there are two ways the end date of a fixing // period can be computed. bool LIBORMethod = true;![]() // Number of days for fixing a rate. int FixingDays = 2;![]() // Currency code in which default values will be copied CTIEnums.CCYEnum Ccy = CTIEnums.CCYEnum.CCY_EUR;![]() // Business day convention needed for day adjustments when an adjustment // moves the date into the preceding, following month. CTIEnums.BDCEnum BusDayConv = CTIEnums.BDCEnum.BDC_monthendreference;![]() // Daycounter required for year length calculations. CTIEnums.DayCountEnum DayCounter = CTIEnums.DayCountEnum.DayCount_actual365_fixed;![]() // Interpolation methodology to utilise when interpolating the // forward spread curve (generated from the interes
|