Assembla home | Assembla project page
 

Changeset 225

Show
Ignore:
Timestamp:
07/15/08 05:45:12 (1 year ago)
Author:
snovik
Message:

Changes: A bunch of changes as I am getting ready for the next level of abstraction in Monte Carlo and would like to make a point here
New: Some matrix utilities. Test of these is still to come

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/QLNet/QLNet.sln

    r187 r225  
    5151                {96693C81-8F03-4FCF-AC22-470820236A8A}.Release|Any CPU.ActiveCfg = Release|Any CPU 
    5252                {96693C81-8F03-4FCF-AC22-470820236A8A}.Release|Any CPU.Build.0 = Release|Any CPU 
    53                 {6F0131DC-A031-4422-85AD-C8C497AE244F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 
    54                 {6F0131DC-A031-4422-85AD-C8C497AE244F}.Debug|Any CPU.Build.0 = Debug|Any CPU 
     53                {6F0131DC-A031-4422-85AD-C8C497AE244F}.Debug|Any CPU.ActiveCfg = Release|Any CPU 
     54                {6F0131DC-A031-4422-85AD-C8C497AE244F}.Debug|Any CPU.Build.0 = Release|Any CPU 
    5555                {6F0131DC-A031-4422-85AD-C8C497AE244F}.Release|Any CPU.ActiveCfg = Release|Any CPU 
    5656                {6F0131DC-A031-4422-85AD-C8C497AE244F}.Release|Any CPU.Build.0 = Release|Any CPU 
  • trunk/QLNet/QLNet.vsmdi

    r204 r225  
    1010  <TestList name="Swap" id="1fb9da58-c37b-40da-9772-c8899ed4f8c6" parentListId="8c43106b-9dc1-4907-a29f-aa66a61bf5b6"> 
    1111    <TestLinks> 
    12       <TestLink id="019427b9-dea4-5598-dd43-a00afdcf7984" name="testCachedValue" storage="test2008\bin\debug\test2008.dll" type="Microsoft.VisualStudio.TestTools.TestTypes.Unit.UnitTestElement, Microsoft.VisualStudio.QualityTools.Tips.UnitTest.ObjectModel,   PublicKeyToken=b03f5f7f11d50a3a" /> 
     12      <TestLink id="bfdd9348-cf70-0cc9-aefe-30e8f235d572" name="testSpreadDependency" storage="test2008\bin\debug\test2008.dll" type="Microsoft.VisualStudio.TestTools.TestTypes.Unit.UnitTestElement, Microsoft.VisualStudio.QualityTools.Tips.UnitTest.ObjectModel,   PublicKeyToken=b03f5f7f11d50a3a" /> 
    1313      <TestLink id="cd832602-6407-a10e-5585-88a96542e91e" name="testInArrears" storage="test2008\bin\debug\test2008.dll" type="Microsoft.VisualStudio.TestTools.TestTypes.Unit.UnitTestElement, Microsoft.VisualStudio.QualityTools.Tips.UnitTest.ObjectModel,   PublicKeyToken=b03f5f7f11d50a3a" /> 
    1414      <TestLink id="4a7f54ba-aa40-17eb-4f2c-4e956babf8b3" name="testRateDependency" storage="test2008\bin\debug\test2008.dll" type="Microsoft.VisualStudio.TestTools.TestTypes.Unit.UnitTestElement, Microsoft.VisualStudio.QualityTools.Tips.UnitTest.ObjectModel,   PublicKeyToken=b03f5f7f11d50a3a" /> 
    1515      <TestLink id="6d8e3375-fefb-38b0-2f10-3bb7dcdc7cc6" name="testFairRate" storage="test2008\bin\debug\test2008.dll" type="Microsoft.VisualStudio.TestTools.TestTypes.Unit.UnitTestElement, Microsoft.VisualStudio.QualityTools.Tips.UnitTest.ObjectModel,   PublicKeyToken=b03f5f7f11d50a3a" /> 
    16       <TestLink id="bfdd9348-cf70-0cc9-aefe-30e8f235d572" name="testSpreadDependency" storage="test2008\bin\debug\test2008.dll" type="Microsoft.VisualStudio.TestTools.TestTypes.Unit.UnitTestElement, Microsoft.VisualStudio.QualityTools.Tips.UnitTest.ObjectModel,   PublicKeyToken=b03f5f7f11d50a3a" /> 
     16      <TestLink id="019427b9-dea4-5598-dd43-a00afdcf7984" name="testCachedValue" storage="test2008\bin\debug\test2008.dll" type="Microsoft.VisualStudio.TestTools.TestTypes.Unit.UnitTestElement, Microsoft.VisualStudio.QualityTools.Tips.UnitTest.ObjectModel,   PublicKeyToken=b03f5f7f11d50a3a" /> 
    1717      <TestLink id="f909c484-4167-4782-e0bc-cd5f18e918ba" name="testFairSpread" storage="test2008\bin\debug\test2008.dll" type="Microsoft.VisualStudio.TestTools.TestTypes.Unit.UnitTestElement, Microsoft.VisualStudio.QualityTools.Tips.UnitTest.ObjectModel,   PublicKeyToken=b03f5f7f11d50a3a" /> 
     18    </TestLinks> 
     19  </TestList> 
     20  <TestList name="Matrices" id="25633d76-5f09-440e-8201-24fb89c87f80" parentListId="8c43106b-9dc1-4907-a29f-aa66a61bf5b6"> 
     21    <TestLinks> 
     22      <TestLink id="b4704ed2-b5d7-2ec0-af5e-d8f52bdc6660" name="testEigenvectors" storage="test2008\bin\debug\test2008.dll" type="Microsoft.VisualStudio.TestTools.TestTypes.Unit.UnitTestElement, Microsoft.VisualStudio.QualityTools.Tips.UnitTest.ObjectModel,   PublicKeyToken=b03f5f7f11d50a3a" /> 
    1823    </TestLinks> 
    1924  </TestList> 
     
    8489  <TestList name="American Option" id="da9a808d-acf7-4baf-9dfb-e4b091d30fef" parentListId="8c43106b-9dc1-4907-a29f-aa66a61bf5b6"> 
    8590    <TestLinks> 
    86       <TestLink id="33c4d801-48ac-44c4-329e-d6fe84f5e034" name="testJuValues" storage="test2008\bin\debug\test2008.dll" type="Microsoft.VisualStudio.TestTools.TestTypes.Unit.UnitTestElement, Microsoft.VisualStudio.QualityTools.Tips.UnitTest.ObjectModel,   PublicKeyToken=b03f5f7f11d50a3a" /> 
     91      <TestLink id="2bbf531b-68cb-84c0-a06f-6bedfb89f20f" name="testBaroneAdesiWhaleyValues" storage="test2008\bin\debug\test2008.dll" type="Microsoft.VisualStudio.TestTools.TestTypes.Unit.UnitTestElement, Microsoft.VisualStudio.QualityTools.Tips.UnitTest.ObjectModel,   PublicKeyToken=b03f5f7f11d50a3a" /> 
    8792      <TestLink id="3be50179-04ee-902d-73d8-3c94e9305a67" name="testFdShoutGreeks" storage="test2008\bin\debug\test2008.dll" type="Microsoft.VisualStudio.TestTools.TestTypes.Unit.UnitTestElement, Microsoft.VisualStudio.QualityTools.Tips.UnitTest.ObjectModel,   PublicKeyToken=b03f5f7f11d50a3a" /> 
    8893      <TestLink id="783f96db-cce8-bf61-b280-f5010f7d7eb3" name="testFdValues" storage="test2008\bin\debug\test2008.dll" type="Microsoft.VisualStudio.TestTools.TestTypes.Unit.UnitTestElement, Microsoft.VisualStudio.QualityTools.Tips.UnitTest.ObjectModel,   PublicKeyToken=b03f5f7f11d50a3a" /> 
    8994      <TestLink id="1e42c90a-8e82-1369-9ed9-52b036b1c07e" name="testBjerksundStenslandValues" storage="test2008\bin\debug\test2008.dll" type="Microsoft.VisualStudio.TestTools.TestTypes.Unit.UnitTestElement, Microsoft.VisualStudio.QualityTools.Tips.UnitTest.ObjectModel,   PublicKeyToken=b03f5f7f11d50a3a" /> 
    9095      <TestLink id="9f4ff6f8-9938-8ecb-5608-7dbc928cbda3" name="testFdAmericanGreeks" storage="test2008\bin\debug\test2008.dll" type="Microsoft.VisualStudio.TestTools.TestTypes.Unit.UnitTestElement, Microsoft.VisualStudio.QualityTools.Tips.UnitTest.ObjectModel,   PublicKeyToken=b03f5f7f11d50a3a" /> 
    91       <TestLink id="2bbf531b-68cb-84c0-a06f-6bedfb89f20f" name="testBaroneAdesiWhaleyValues" storage="test2008\bin\debug\test2008.dll" type="Microsoft.VisualStudio.TestTools.TestTypes.Unit.UnitTestElement, Microsoft.VisualStudio.QualityTools.Tips.UnitTest.ObjectModel,   PublicKeyToken=b03f5f7f11d50a3a" /> 
     96      <TestLink id="33c4d801-48ac-44c4-329e-d6fe84f5e034" name="testJuValues" storage="test2008\bin\debug\test2008.dll" type="Microsoft.VisualStudio.TestTools.TestTypes.Unit.UnitTestElement, Microsoft.VisualStudio.QualityTools.Tips.UnitTest.ObjectModel,   PublicKeyToken=b03f5f7f11d50a3a" /> 
    9297    </TestLinks> 
    9398  </TestList> 
  • trunk/QLNet/QLNet/Error.cs

    r217 r225  
    2323namespace QLNet { 
    2424    public class Error { 
    25                 public static ArgumentException UnknownTimeUnit(TimeUnit u) { 
    26                         return new ArgumentException("Unknown TimeUnit: " + u); } 
    2725                public static ArgumentException UnknownFrequency(Frequency f) { 
    2826                        return new ArgumentException("Unknown frequency: " + f); } 
  • trunk/QLNet/QLNet/Indexes/Ibor/DailyTenorLibor.cs

    r111 r225  
    2323 
    2424namespace QLNet { 
     25    //! base class for O/N-S/N BBA LIBOR indexes but the EUR ones 
     26    //    ! One day deposit LIBOR fixed by BBA. 
     27    // 
     28    //        See <http://www.bba.org.uk/bba/jsp/polopoly.jsp?d=225&a=1414>. 
     29    //     
     30    public class DailyTenorLibor : IborIndex { 
     31        // http://www.bba.org.uk/bba/jsp/polopoly.jsp?d=225&a=1412 : 
     32        // no o/n or s/n fixings (as the case may be) will take place 
     33        // when the principal centre of the currency concerned is 
     34        // closed but London is open on the fixing day. 
     35        public DailyTenorLibor(string familyName, int settlementDays, Currency currency, Calendar financialCenterCalendar,  
     36                               DayCounter dayCounter) 
     37            : this(familyName, settlementDays, currency, financialCenterCalendar, dayCounter, new Handle<YieldTermStructure>()) { 
     38        } 
    2539 
    26         //! base class for O/N-S/N BBA LIBOR indexes but the EUR ones 
    27 //    ! One day deposit LIBOR fixed by BBA. 
    28 // 
    29 //        See <http://www.bba.org.uk/bba/jsp/polopoly.jsp?d=225&a=1414>. 
    30 //     
    31         public class DailyTenorLibor : IborIndex 
    32         { 
    33  
    34                 // http://www.bba.org.uk/bba/jsp/polopoly.jsp?d=225&a=1412 : 
    35                 // no o/n or s/n fixings (as the case may be) will take place 
    36                 // when the principal centre of the currency concerned is 
    37                 // closed but London is open on the fixing day. 
    38  
    39                 public DailyTenorLibor(string familyName, int settlementDays, Currency currency, Calendar financialCenterCalendar, DayCounter dayCounter) : this(familyName, settlementDays, currency, financialCenterCalendar, dayCounter, new Handle<YieldTermStructure>()) 
    40                 { 
    41                 } 
    42  
    43         public DailyTenorLibor(string familyName, int settlementDays, Currency currency, Calendar financialCenterCalendar, DayCounter dayCounter, Handle<YieldTermStructure> h) 
    44             : base(familyName, new Period(1, TimeUnit.Days), settlementDays, currency, new JointCalendar(new UnitedKingdom(UnitedKingdom.Market.Exchange), financialCenterCalendar, JointCalendar.JointCalendarRule.JoinHolidays), 
    45                 Utils.liborConvention(new Period(1, TimeUnit.Days)),  
    46                 Utils.liborEOM(new Period(1, TimeUnit.Days)), dayCounter, h) 
    47                 { 
    48                         if (!(currency!= new EURCurrency())) 
     40        public DailyTenorLibor(string familyName, int settlementDays, Currency currency, Calendar financialCenterCalendar,  
     41                               DayCounter dayCounter, Handle<YieldTermStructure> h) 
     42            : base(familyName, new Period(1, TimeUnit.Days), settlementDays, currency,  
     43                   new JointCalendar(new UnitedKingdom(UnitedKingdom.Market.Exchange), financialCenterCalendar, JointCalendar.JointCalendarRule.JoinHolidays), 
     44                   Utils.liborConvention(new Period(1, TimeUnit.Days)), Utils.liborEOM(new Period(1, TimeUnit.Days)), dayCounter, h) { 
     45            if (!(currency != new EURCurrency())) 
    4946                throw new ApplicationException("for EUR Libor dedicated EurLibor constructor must be used"); 
    50                
    51        
     47       
     48   
    5249} 
  • trunk/QLNet/QLNet/Indexes/Ibor/Euribor.cs

    r61 r225  
    2323 
    2424namespace QLNet { 
    25  
    26     // %Euribor index 
    27     // Euribor rate fixed by the ECB. 
    28     // This is the rate fixed by the ECB. Use EurLibor if you're interested in the London fixing by BBA. 
    29     public class Euribor : IborIndex { 
    30         public Euribor(Period tenor) : this(tenor, new Handle<YieldTermStructure>()) { } 
    31         public Euribor(Period tenor, Handle<YieldTermStructure> h) : 
    32             base("Euribor", tenor, 2, // settlementDays 
    33                  new EURCurrency(), new TARGET(), 
    34                  euriborConvention(tenor), euriborEOM(tenor), 
    35                  new Actual360(), h) { } 
    36  
    37         private static BusinessDayConvention euriborConvention(Period p) { 
     25    public static partial class Utils { 
     26        public static BusinessDayConvention euriborConvention(Period p) { 
    3827            switch (p.units()) { 
    3928                case TimeUnit.Days: 
     
    4433                    return BusinessDayConvention.ModifiedFollowing; 
    4534                default: 
    46                     throw Error.UnknownTimeUnit(p.units()); 
     35                    throw new ArgumentException("Unknown TimeUnit: " + p.units()); 
    4736            } 
    4837        } 
    4938 
    50         private static bool euriborEOM(Period p) { 
     39        public static bool euriborEOM(Period p) { 
    5140            switch (p.units()) { 
    5241                case TimeUnit.Days: 
     
    5746                    return true; 
    5847                default: 
    59                     throw Error.UnknownTimeUnit(p.units()); 
     48                    throw new ArgumentException("Unknown TimeUnit: " + p.units()); 
    6049            } 
    6150        } 
     51    } 
     52    /// <summary> 
     53    /// %Euribor index 
     54    /// Euribor rate fixed by the ECB. 
     55    /// This is the rate fixed by the ECB. Use EurLibor if you're interested in the London fixing by BBA. 
     56    /// </summary> 
     57    public class Euribor : IborIndex { 
     58        public Euribor(Period tenor) : this(tenor, new Handle<YieldTermStructure>()) { } 
     59        public Euribor(Period tenor, Handle<YieldTermStructure> h) : 
     60            base("Euribor", tenor, 2, // settlementDays 
     61                 new EURCurrency(), new TARGET(), 
     62                 Utils.euriborConvention(tenor), Utils.euriborEOM(tenor), 
     63                 new Actual360(), h) { } 
     64    } 
     65 
     66    //! Actual/365 %Euribor index 
     67    /*! Euribor rate adjusted for the mismatch between the actual/360 
     68        convention used for Euribor and the actual/365 convention 
     69        previously used by a few pre-EUR currencies. 
     70    */ 
     71    public class Euribor365 : IborIndex { 
     72        public Euribor365(Period tenor) : this(tenor, new Handle<YieldTermStructure>()) { } 
     73        public Euribor365(Period tenor, Handle<YieldTermStructure> h) 
     74            : base("Euribor365", tenor, 
     75                   2, // settlement days 
     76                   new EURCurrency(), new TARGET(), Utils.euriborConvention(tenor), Utils.euriborEOM(tenor), 
     77                   new Actual365Fixed(), h) { 
     78            if (tenor.units() == TimeUnit.Days) 
     79                throw new ApplicationException("for daily tenors (" + tenor + ") dedicated DailyTenor constructor must be used"); 
     80        } 
     81    } 
     82 
     83 
     84    //! Daily tenor %Euribor index 
     85    /*! Euribor rate fixed by the ECB. 
     86 
     87        \warning This is the rate fixed by the ECB. Use EurLibor 
     88                 if you're interested in the London fixing by BBA. 
     89    */ 
     90    public class DailyTenorEuribor : IborIndex { 
     91        public DailyTenorEuribor(int settlementDays) : this(settlementDays, new Handle<YieldTermStructure>()) { } 
     92        public DailyTenorEuribor(int settlementDays, Handle<YieldTermStructure> h) 
     93            : base("Euribor", new Period(1, TimeUnit.Days), settlementDays, 
     94                    new EURCurrency(), new TARGET(), 
     95                    Utils.euriborConvention(new Period(1, TimeUnit.Days)), Utils.euriborEOM(new Period(1, TimeUnit.Days)), 
     96                    new Actual360(), h) { } 
     97    } 
     98 
     99    //! Daily tenor Actual/365 %Euribor index 
     100    /*! Euribor rate adjusted for the mismatch between the actual/360 
     101        convention used for Euribor and the actual/365 convention 
     102        previously used by a few pre-EUR currencies. 
     103    */ 
     104    public class DailyTenorEuribor365 : IborIndex { 
     105        public DailyTenorEuribor365(int settlementDays) : this(settlementDays, new Handle<YieldTermStructure>()) { } 
     106        public DailyTenorEuribor365(int settlementDays, Handle<YieldTermStructure> h)  
     107            : base("Euribor365", new Period(1, TimeUnit.Days), 
     108                    settlementDays, 
     109                    new EURCurrency(), new TARGET(), 
     110                    Utils.euriborConvention(new Period(1, TimeUnit.Days)), Utils.euriborEOM(new Period(1, TimeUnit.Days)), 
     111                    new Actual365Fixed(), h) {} 
     112    } 
     113 
     114    //! 1-week %Euribor index 
     115    public class EuriborSW : Euribor { 
     116        public EuriborSW() : this(new Handle<YieldTermStructure>()) { } 
     117        public EuriborSW(Handle<YieldTermStructure> h) : base(new Period(1, TimeUnit.Weeks), h) { } 
     118    } 
     119 
     120    //! 2-weeks %Euribor index 
     121    public class Euribor2W : Euribor { 
     122        public Euribor2W() : this(new Handle<YieldTermStructure>()) { } 
     123        public Euribor2W(Handle<YieldTermStructure> h) : base(new Period(2, TimeUnit.Weeks), h) { } 
     124    } 
     125 
     126    //! 3-weeks %Euribor index 
     127    public class Euribor3W : Euribor { 
     128        public Euribor3W() : this(new Handle<YieldTermStructure>()) { } 
     129        public Euribor3W(Handle<YieldTermStructure> h) : base(new Period(3, TimeUnit.Weeks), h) { } 
     130    } 
     131 
     132    //! 1-month %Euribor index 
     133    public class Euribor1M : Euribor { 
     134        public Euribor1M() : this(new Handle<YieldTermStructure>()) { } 
     135        public Euribor1M(Handle<YieldTermStructure> h) : base(new Period(1, TimeUnit.Months), h) { } 
     136    } 
     137 
     138    //! 2-months %Euribor index 
     139    public class Euribor2M : Euribor { 
     140        public Euribor2M() : this(new Handle<YieldTermStructure>()) { } 
     141        public Euribor2M(Handle<YieldTermStructure> h) : base(new Period(2, TimeUnit.Months), h) { } 
    62142    } 
    63143 
     
    65145    public class Euribor3M : Euribor { 
    66146        public Euribor3M() : this(new Handle<YieldTermStructure>()) { } 
    67         public Euribor3M(Handle<YieldTermStructure> h) 
    68             : base(new Period(3, TimeUnit.Months), h) {} 
     147        public Euribor3M(Handle<YieldTermStructure> h) : base(new Period(3, TimeUnit.Months), h) {} 
    69148    } 
     149 
     150    // 4-months %Euribor index 
     151    public class Euribor4M : Euribor { 
     152        public Euribor4M() : this(new Handle<YieldTermStructure>()) { } 
     153        public Euribor4M(Handle<YieldTermStructure> h) : base(new Period(4, TimeUnit.Months), h) { } 
     154    } 
     155 
     156    // 5-months %Euribor index 
     157    public class Euribor5M : Euribor { 
     158        public Euribor5M() : this(new Handle<YieldTermStructure>()) { } 
     159        public Euribor5M(Handle<YieldTermStructure> h) : base(new Period(5, TimeUnit.Months), h) { } 
     160    } 
     161 
    70162    // 6-months %Euribor index 
    71163    public class Euribor6M : Euribor { 
    72164        public Euribor6M() : this(new Handle<YieldTermStructure>()) { } 
    73         public Euribor6M(Handle<YieldTermStructure> h) 
    74             : base(new Period(6, TimeUnit.Months), h) { } 
     165        public Euribor6M(Handle<YieldTermStructure> h) : base(new Period(6, TimeUnit.Months), h) { } 
    75166    } 
    76167} 
  • trunk/QLNet/QLNet/Indexes/Ibor/Eurlibor.cs

    r111 r225  
    2323 
    2424namespace QLNet { 
    25  
    26     public static partial class Utils 
    27     { 
    28         public static BusinessDayConvention eurliborConvention(Period p) 
    29         { 
    30             switch (p.units()) 
    31             { 
     25    public static partial class Utils { 
     26        public static BusinessDayConvention eurliborConvention(Period p) { 
     27            switch (p.units()) { 
    3228                case TimeUnit.Days: 
    3329                case TimeUnit.Weeks: 
     
    3733                    return BusinessDayConvention.ModifiedFollowing; 
    3834                default: 
    39                     throw Error.UnknownTimeUnit(p.units()); 
     35                    throw new ArgumentException("Unknown TimeUnit: " + p.units()); 
    4036            } 
    4137        } 
    4238 
    43         public static bool eurliborEOM(Period p) 
    44         { 
    45             switch (p.units()) 
    46             { 
     39        public static bool eurliborEOM(Period p) { 
     40            switch (p.units()) { 
    4741                case TimeUnit.Days: 
    4842                case TimeUnit.Weeks: 
     
    5246                    return true; 
    5347                default: 
    54                     throw Error.UnknownTimeUnit(p.units()); 
     48                    throw new ArgumentException("Unknown TimeUnit: " + p.units()); 
    5549            } 
    5650        } 
    5751    } 
    5852 
    59         //! base class for all BBA %EUR %LIBOR indexes but the O/N 
    60 //    ! Euro LIBOR fixed by BBA. 
    61 // 
    62 //        See <http://www.bba.org.uk/bba/jsp/polopoly.jsp?d=225&a=1414>. 
    63 // 
    64 //        \warning This is the rate fixed in London by BBA. Use Euribor if 
    65 //                 you're interested in the fixing by the ECB. 
    66 //     
    67         public class EURLibor : IborIndex 
    68        
     53    /// <summary> 
     54    /// base class for all BBA %EUR %LIBOR indexes but the O/N 
     55    ///    ! Euro LIBOR fixed by BBA. 
     56    /// 
     57    ///        See <http://www.bba.org.uk/bba/jsp/polopoly.jsp?d=225&a=1414>. 
     58    /// 
     59    ///        \warning This is the rate fixed in London by BBA. Use Euribor if 
     60    ///                 you're interested in the fixing by the ECB. 
     61    /// </summary> 
     62    public class EURLibor : IborIndex
    6963        private Calendar target_; 
    7064 
    71                                        // http://www.bba.org.uk/bba/jsp/polopoly.jsp?d=225&a=1412 : 
    72                                        // JoinBusinessDays is the fixing calendar for 
    73                                        // all indexes but o/n 
     65        // http://www.bba.org.uk/bba/jsp/polopoly.jsp?d=225&a=1412 : 
     66        // JoinBusinessDays is the fixing calendar for 
     67        // all indexes but o/n 
    7468 
    7569        public EURLibor(Period tenor) 
    7670            : base("EURLibor", tenor, 2, new EURCurrency(), new JointCalendar(new UnitedKingdom(UnitedKingdom.Market.Exchange), new TARGET(), 
    7771                JointCalendar.JointCalendarRule.JoinHolidays), 
    78                 Utils.eurliborConvention(tenor), Utils.eurliborEOM(tenor), new Actual360(),  
    79                 new Handle<YieldTermStructure>()) 
    80         { 
     72                Utils.eurliborConvention(tenor), Utils.eurliborEOM(tenor), new Actual360(), 
     73                new Handle<YieldTermStructure>()) { 
    8174            target_ = new TARGET(); 
    8275            if (!(tenor.units() != TimeUnit.Days)) 
     
    8477        } 
    8578 
    86                 public EURLibor(Period tenor, Handle<YieldTermStructure> h)  
     79        public EURLibor(Period tenor, Handle<YieldTermStructure> h) 
    8780            : base("EURLibor", tenor, 2, new EURCurrency(), new JointCalendar(new UnitedKingdom(UnitedKingdom.Market.Exchange), new TARGET(), 
    8881                JointCalendar.JointCalendarRule.JoinHolidays), 
    89                 Utils.eurliborConvention(tenor), Utils.eurliborEOM(tenor), new Actual360(), h) 
    90                 { 
    91                         target_ = new TARGET(); 
    92                         if (!(tenor.units()!= TimeUnit.Days)) 
     82                Utils.eurliborConvention(tenor), Utils.eurliborEOM(tenor), new Actual360(), h) { 
     83            target_ = new TARGET(); 
     84            if (!(tenor.units() != TimeUnit.Days)) 
    9385                throw new ApplicationException("for daily tenors (" + tenor + ") dedicated DailyTenor constructor must be used"); 
    94                 } 
    95  
    96 //        ! \name Date calculations 
    97 // 
    98 //            see http://www.bba.org.uk/bba/jsp/polopoly.jsp?d=225&a=1412 
    99 //            @{ 
    100 //         
    101                 public override Date valueDate(Date fixingDate) 
    102                 { 
    103          
    104                         if (!(isValidFixingDate(fixingDate))) 
     86        } 
     87 
     88        //        ! \name Date calculations 
     89        // 
     90        //            see http://www.bba.org.uk/bba/jsp/polopoly.jsp?d=225&a=1412 
     91        //            @{ 
     92        //         
     93        public override Date valueDate(Date fixingDate) { 
     94 
     95            if (!(isValidFixingDate(fixingDate))) 
    10596                throw new ApplicationException("Fixing date " + fixingDate + " is not valid"); 
    106          
    107                         // http://www.bba.org.uk/bba/jsp/polopoly.jsp?d=225&a=1412 : 
    108                         // In the case of EUR the Value Date shall be two TARGET 
    109                         // business days after the Fixing Date. 
    110                         return target_.advance(fixingDate, fixingDays_, TimeUnit.Days); 
    111                 } 
    112                 public override Date maturityDate(Date valueDate) 
    113                 { 
    114                         // http://www.bba.org.uk/bba/jsp/polopoly.jsp?d=225&a=1412 : 
    115                         // In the case of EUR only, maturity dates will be based on days in 
    116                         // which the Target system is open. 
    117                         return target_.advance(valueDate, tenor_, convention_, endOfMonth()); 
    118                 } 
    119         } 
    120  
    121         //! base class for the one day deposit BBA %EUR %LIBOR indexes 
    122 //    ! Euro O/N LIBOR fixed by BBA. It can be also used for T/N and S/N 
    123 //        indexes, even if such indexes do not have BBA fixing. 
    124 // 
    125 //        See <http://www.bba.org.uk/bba/jsp/polopoly.jsp?d=225&a=1414>. 
    126 // 
    127 //        \warning This is the rate fixed in London by BBA. Use Euribor if 
    128 //                 you're interested in the fixing by the ECB. 
    129 //     
    130         public class DailyTenorEURLibor : IborIndex 
    131         { 
    132  
    133                                         // http://www.bba.org.uk/bba/jsp/polopoly.jsp?d=225&a=1412 : 
    134                                         // no o/n or s/n fixings (as the case may be) will take place 
    135                                         // when the principal centre of the currency concerned is 
    136                                         // closed but London is open on the fixing day. 
    137                 public DailyTenorEURLibor(int settlementDays) : this(settlementDays, new Handle<YieldTermStructure>()) 
    138                 { 
    139                 } 
     97 
     98            // http://www.bba.org.uk/bba/jsp/polopoly.jsp?d=225&a=1412 : 
     99            // In the case of EUR the Value Date shall be two TARGET 
     100            // business days after the Fixing Date. 
     101            return target_.advance(fixingDate, fixingDays_, TimeUnit.Days); 
     102        } 
     103        public override Date maturityDate(Date valueDate) { 
     104            // http://www.bba.org.uk/bba/jsp/polopoly.jsp?d=225&a=1412 : 
     105            // In the case of EUR only, maturity dates will be based on days in 
     106            // which the Target system is open. 
     107            return target_.advance(valueDate, tenor_, convention_, endOfMonth()); 
     108        } 
     109    } 
     110 
     111    //! base class for the one day deposit BBA %EUR %LIBOR indexes 
     112    //    ! Euro O/N LIBOR fixed by BBA. It can be also used for T/N and S/N 
     113    //        indexes, even if such indexes do not have BBA fixing. 
     114    // 
     115    //        See <http://www.bba.org.uk/bba/jsp/polopoly.jsp?d=225&a=1414>. 
     116    // 
     117    //        \warning This is the rate fixed in London by BBA. Use Euribor if 
     118    //                 you're interested in the fixing by the ECB. 
     119    //     
     120    public class DailyTenorEURLibor : IborIndex { 
     121 
     122        // http://www.bba.org.uk/bba/jsp/polopoly.jsp?d=225&a=1412 : 
     123        // no o/n or s/n fixings (as the case may be) will take place 
     124        // when the principal centre of the currency concerned is 
     125        // closed but London is open on the fixing day. 
     126        public DailyTenorEURLibor(int settlementDays) 
     127            : this(settlementDays, new Handle<YieldTermStructure>()) { 
     128        } 
    140129        public DailyTenorEURLibor() 
    141130            : base("EURLibor", new Period(1, TimeUnit.Days), 0, new EURCurrency(), new TARGET(), 
    142             Utils.eurliborConvention(new Period(1, TimeUnit.Days)), Utils.eurliborEOM(new Period(1, TimeUnit.Days)), new Actual360(), new Handle<YieldTermStructure>()) 
    143                 { 
    144                 } 
     131            Utils.eurliborConvention(new Period(1, TimeUnit.Days)), Utils.eurliborEOM(new Period(1, TimeUnit.Days)), new Actual360(), new Handle<YieldTermStructure>()) { 
     132        } 
    145133        public DailyTenorEURLibor(int settlementDays, Handle<YieldTermStructure> h) 
    146134            : base("EURLibor", new Period(1, TimeUnit.Days), settlementDays, new EURCurrency(), new TARGET(), 
    147             Utils.eurliborConvention(new Period(1, TimeUnit.Days)), Utils.eurliborEOM(new Period(1, TimeUnit.Days)), new Actual360(), h) 
    148                 { 
    149                 } 
    150         } 
    151  
    152         //! Overnight %EUR %Libor index 
    153         public class EURLiborON : DailyTenorEURLibor 
    154         { 
    155                 public EURLiborON() : base(0, new Handle<YieldTermStructure>()) 
    156                 { 
    157                 } 
    158  
    159                 public EURLiborON(Handle<YieldTermStructure> h) : base(0, h) 
    160                 { 
    161                 } 
    162         } 
    163  
    164         //! 1-week %EUR %Libor index 
    165         public class EURLiborSW : EURLibor 
    166         { 
    167                 public EURLiborSW() : base(new Period(1, TimeUnit.Weeks), new Handle<YieldTermStructure>()) 
    168                 { 
    169                 } 
    170                 public EURLiborSW(Handle<YieldTermStructure> h) : base(new Period(1, TimeUnit.Weeks), h) 
    171                 { 
    172                 } 
    173         } 
    174  
    175         //! 2-weeks %EUR %Libor index 
    176         public class EURLibor2W : EURLibor 
    177         { 
    178                 public EURLibor2W() : base(new Period(2, TimeUnit.Weeks), new Handle<YieldTermStructure>()) 
    179                 { 
    180                 } 
    181                 public EURLibor2W(Handle<YieldTermStructure> h) : base(new Period(2, TimeUnit.Weeks), h) 
    182                 { 
    183                 } 
    184         } 
    185  
    186  
    187         //! 1-month %EUR %Libor index 
    188         public class EURLibor1M : EURLibor 
    189         { 
    190                 public EURLibor1M() : base(new Period(1, TimeUnit.Months), new Handle<YieldTermStructure>()) 
    191                 { 
    192                 } 
    193                 public EURLibor1M(Handle<YieldTermStructure> h) : base(new Period(1, TimeUnit.Months), h) 
    194                 { 
    195                 } 
    196         } 
    197  
    198         //! 2-months %EUR %Libor index 
    199         public class EURLibor2M : EURLibor 
    200         { 
    201                 public EURLibor2M() : base(new Period(2, TimeUnit.Months), new Handle<YieldTermStructure>()) 
    202                 { 
    203                 } 
    204                 public EURLibor2M(Handle<YieldTermStructure> h) : base(new Period(2, TimeUnit.Months), h) 
    205                 { 
    206                 } 
    207         } 
    208  
    209         //! 3-months %EUR %Libor index 
    210         public class EURLibor3M : EURLibor 
    211         { 
    212                 public EURLibor3M() : base(new Period(3, TimeUnit.Months), new Handle<YieldTermStructure>()) 
    213                 { 
    214                 } 
    215                 public EURLibor3M(Handle<YieldTermStructure> h) : base(new Period(3, TimeUnit.Months), h) 
    216                 { 
    217                 } 
    218         } 
    219  
    220         //! 4-months %EUR %Libor index 
    221         public class EURLibor4M : EURLibor 
    222         { 
    223                 public EURLibor4M() : base(new Period(4, TimeUnit.Months), new Handle<YieldTermStructure>()) 
    224                 { 
    225                 } 
    226                 public EURLibor4M(Handle<YieldTermStructure> h) : base(new Period(4, TimeUnit.Months), h) 
    227                 { 
    228                 } 
    229         } 
    230  
    231         //! 5-months %EUR %Libor index 
    232         public class EURLibor5M : EURLibor 
    233         { 
    234                 public EURLibor5M() : base(new Period(5, TimeUnit.Months), new Handle<YieldTermStructure>()) 
    235                 { 
    236                 } 
    237                 public EURLibor5M(Handle<YieldTermStructure> h) : base(new Period(5, TimeUnit.Months), h) 
    238                 { 
    239                 } 
    240         } 
    241  
    242         //! 6-months %EUR %Libor index 
    243         public class EURLibor6M : EURLibor 
    244         { 
    245                 public EURLibor6M() : base(new Period(6, TimeUnit.Months), new Handle<YieldTermStructure>()) 
    246                 { 
    247                 } 
    248                 public EURLibor6M(Handle<YieldTermStructure> h) : base(new Period(6, TimeUnit.Months), h) 
    249                 { 
    250                 } 
    251         } 
    252  
    253         //! 7-months %EUR %Libor index 
    254         public class EURLibor7M : EURLibor 
    255         { 
    256                 public EURLibor7M() : base(new Period(7, TimeUnit.Months), new Handle<YieldTermStructure>()) 
    257                 { 
    258                 } 
    259                 public EURLibor7M(Handle<YieldTermStructure> h) : base(new Period(7, TimeUnit.Months), h) 
    260                 { 
    261                 } 
    262         } 
    263  
    264         //! 8-months %EUR %Libor index 
    265         public class EURLibor8M : EURLibor 
    266         { 
    267                 public EURLibor8M() : base(new Period(8, TimeUnit.Months), new Handle<YieldTermStructure>()) 
    268                 { 
    269                 } 
    270                 public EURLibor8M(Handle<YieldTermStructure> h) : base(new Period(8, TimeUnit.Months), h) 
    271                 { 
    272                 } 
    273         } 
    274  
    275         //! 9-months %EUR %Libor index 
    276         public class EURLibor9M : EURLibor 
    277         { 
    278                 public EURLibor9M() : base(new Period(9, TimeUnit.Months), new Handle<YieldTermStructure>()) 
    279                 { 
    280                 } 
    281                 public EURLibor9M(Handle<YieldTermStructure> h) : base(new Period(9, TimeUnit.Months), h) 
    282                 { 
    283                 } 
    284         } 
    285  
    286         //! 10-months %EUR %Libor index 
    287         public class EURLibor10M : EURLibor 
    288         { 
    289                 public EURLibor10M() : base(new Period(10, TimeUnit.Months), new Handle<YieldTermStructure>()) 
    290                 { 
    291                 } 
    292                 public EURLibor10M(Handle<YieldTermStructure> h) : base(new Period(10, TimeUnit.Months), h) 
    293                 { 
    294                 } 
    295         } 
    296  
    297         //! 11-months %EUR %Libor index 
    298         public class EURLibor11M : EURLibor 
    299         { 
    300                 public EURLibor11M() : base(new Period(11, TimeUnit.Months), new Handle<YieldTermStructure>()) 
    301                 { 
    302                 } 
    303                 public EURLibor11M(Handle<YieldTermStructure> h) : base(new Period(11, TimeUnit.Months), h) 
    304                 { 
    305                 } 
    306         } 
    307  
    308         //! 1-year %EUR %Libor index 
    309         public class EURLibor1Y : EURLibor 
    310         { 
    311                 public EURLibor1Y() : base(new Period(1, TimeUnit.Years), new Handle<YieldTermStructure>()) 
    312                 { 
    313                 } 
    314                 public EURLibor1Y(Handle<YieldTermStructure> h) : base(new Period(1, TimeUnit.Years), h) 
    315                 { 
    316                 } 
    317         } 
     135            Utils.eurliborConvention(new Period(1, TimeUnit.Days)), Utils.eurliborEOM(new Period(1, TimeUnit.Days)), new Actual360(), h) { 
     136        } 
     137    } 
     138 
     139    //! Overnight %EUR %Libor index 
     140    public class EURLiborON : DailyTenorEURLibor { 
     141        public EURLiborON() 
     142            : base(0, new Handle<YieldTermStructure>()) { 
     143        } 
     144 
     145        public EURLiborON(Handle<YieldTermStructure> h) 
     146            : base(0, h) { 
     147        } 
     148    } 
     149 
     150    //! 1-week %EUR %Libor index 
     151    public class EURLiborSW : EURLibor { 
     152        public EURLiborSW() 
     153            : base(new Period(1, TimeUnit.Weeks), new Handle<YieldTermStructure>()) { 
     154        } 
     155        public EURLiborSW(Handle<YieldTermStructure> h) 
     156            : base(new Period(1, TimeUnit.Weeks), h) { 
     157        } 
     158    } 
     159 
     160    //! 2-weeks %EUR %Libor index 
     161    public class EURLibor2W : EURLibor { 
     162        public EURLibor2W() 
     163            : base(new Period(2, TimeUnit.Weeks), new Handle<YieldTermStructure>()) { 
     164        } 
     165        public EURLibor2W(Handle<YieldTermStructure> h) 
     166            : base(new Period(2, TimeUnit.Weeks), h) { 
     167        } 
     168    } 
     169 
     170 
     171    //! 1-month %EUR %Libor index 
     172    public class EURLibor1M : EURLibor { 
     173        public EURLibor1M() 
     174            : base(new Period(1, TimeUnit.Months), new Handle<YieldTermStructure>()) { 
     175        } 
     176        public EURLibor1M(Handle<YieldTermStructure> h) 
     177            : base(new Period(1, TimeUnit.Months), h) { 
     178        } 
     179    } 
     180 
     181    //! 2-months %EUR %Libor index 
     182    public class EURLibor2M : EURLibor { 
     183        public EURLibor2M() 
     184            : base(new Period(2, TimeUnit.Months), new Handle<YieldTermStructure>()) { 
     185        } 
     186        public EURLibor2M(Handle<YieldTermStructure> h) 
     187            : base(new Period(2, TimeUnit.Months), h) { 
     188        } 
     189    } 
     190 
     191    //! 3-months %EUR %Libor index 
     192    public class EURLibor3M : EURLibor { 
     193        public EURLibor3M() 
     194            : base(new Period(3, TimeUnit.Months), new Handle<YieldTermStructure>()) { 
     195        } 
     196        public EURLibor3M(Handle<YieldTermStructure> h) 
     197            : base(new Period(3, TimeUnit.Months), h) { 
     198        } 
     199    } 
     200 
     201    //! 4-months %EUR %Libor index 
     202    public class EURLibor4M : EURLibor { 
     203        public EURLibor4M() 
     204            : base(new Period(4, TimeUnit.Months), new Handle<YieldTermStructure>()) { 
     205        } 
     206        public EURLibor4M(Handle<YieldTermStructure> h) 
     207            : base(new Period(4, TimeUnit.Months), h) { 
     208        } 
     209    } 
     210 
     211    //! 5-months %EUR %Libor index 
     212    public class EURLibor5M : EURLibor { 
     213        public EURLibor5M() 
     214            : base(new Period(5, TimeUnit.Months), new Handle<YieldTermStructure>()) { 
     215        } 
     216        public EURLibor5M(Handle<YieldTermStructure> h) 
     217            : base(new Period(5, TimeUnit.Months), h) { 
     218        } 
     219    } 
     220 
     221    //! 6-months %EUR %Libor index 
     222    public class EURLibor6M : EURLibor { 
     223        public EURLibor6M() 
     224            : base(new Period(6, TimeUnit.Months), new Handle<YieldTermStructure>()) { 
     225        } 
     226        public EURLibor6M(Handle<YieldTermStructure> h) 
     227            : base(new Period(6, TimeUnit.Months), h) { 
     228        } 
     229    } 
     230 
     231    //! 7-months %EUR %Libor index 
     232    public class EURLibor7M : EURLibor { 
     233        public EURLibor7M() 
     234            : base(new Period(7, TimeUnit.Months), new Handle<YieldTermStructure>()) { 
     235        } 
     236        public EURLibor7M(Handle<YieldTermStructure> h) 
     237            : base(new Period(7, TimeUnit.Months), h) { 
     238        } 
     239    } 
     240 
     241    //! 8-months %EUR %Libor index 
     242    public class EURLibor8M : EURLibor { 
     243        public EURLibor8M() 
     244            : base(new Period(8, TimeUnit.Months), new Handle<YieldTermStructure>()) { 
     245        } 
     246        public EURLibor8M(Handle<YieldTermStructure> h) 
     247            : base(new Period(8, TimeUnit.Months), h) { 
     248        } 
     249    } 
     250 
     251    //! 9-months %EUR %Libor index 
     252    public class EURLibor9M : EURLibor { 
     253        public EURLibor9M() 
     254            : base(new Period(9, TimeUnit.Months), new Handle<YieldTermStructure>()) { 
     255        } 
     256        public EURLibor9M(Handle<YieldTermStructure> h) 
     257            : base(new Period(9, TimeUnit.Months), h) { 
     258        } 
     259    } 
     260 
     261    //! 10-months %EUR %Libor index 
     262    public class EURLibor10M : EURLibor { 
     263        public EURLibor10M() 
     264            : base(new Period(10, TimeUnit.Months), new Handle<YieldTermStructure>()) { 
     265        } 
     266        public EURLibor10M(Handle<YieldTermStructure> h) 
     267            : base(new Period(10, TimeUnit.Months), h) { 
     268        } 
     269    } 
     270 
     271    //! 11-months %EUR %Libor index 
     272    public class EURLibor11M : EURLibor { 
     273        public EURLibor11M() 
     274            : base(new Period(11, TimeUnit.Months), new Handle<YieldTermStructure>()) { 
     275        } 
     276        public EURLibor11M(Handle<YieldTermStructure> h) 
     277            : base(new Period(11, TimeUnit.Months), h) { 
     278        } 
     279    } 
     280 
     281    //! 1-year %EUR %Libor index 
     282    public class EURLibor1Y : EURLibor { 
     283        public EURLibor1Y() 
     284            : base(new Period(1, TimeUnit.Years), new Handle<YieldTermStructure>()) { 
     285        } 
     286        public EURLibor1Y(Handle<YieldTermStructure> h) 
     287            : base(new Period(1, TimeUnit.Years), h) { 
     288        } 
     289    } 
    318290 
    319291 
  • trunk/QLNet/QLNet/Indexes/Ibor/Usdlibor.cs

    r144 r225  
    3333            : base("USDLibor", tenor, 2, new USDCurrency(), new UnitedStates(UnitedStates.Market.NYSE), new Actual360(), h) { } 
    3434    } 
     35 
     36    //! Overnight %USD %Libor index 
     37    public class USDLiborON : DailyTenorLibor { 
     38        public USDLiborON() : this(new Handle<YieldTermStructure>()) { } 
     39        public USDLiborON(Handle<YieldTermStructure> h) 
     40            : base("USDLibor", 0, new USDCurrency(), new UnitedStates(UnitedStates.Market.NYSE), new Actual360(), h) {} 
     41    } 
    3542} 
  • trunk/QLNet/QLNet/Instruments/Bonds/Fixedratebond.cs

    r218 r225  
    2727        protected DayCounter dayCounter_; 
    2828 
     29                      //BusinessDayConvention paymentConvention = Following, 
     30                      //Real redemption = 100.0, 
     31                      //const Date& issueDate = Date()); 
     32        public FixedRateBond(int settlementDays, double faceAmount, Schedule schedule, List<double> coupons, 
     33                             DayCounter accrualDayCounter) 
     34            : this(settlementDays, faceAmount, schedule, coupons, accrualDayCounter, BusinessDayConvention.Following, 100, null) { } 
    2935        public FixedRateBond(int settlementDays, double faceAmount, Schedule schedule, List<double> coupons, 
    3036                             DayCounter accrualDayCounter, BusinessDayConvention paymentConvention, 
  • trunk/QLNet/QLNet/Instruments/Bonds/FloatingRateBond.cs

    r218 r225  
    2626    //! \test calculations are tested by checking results against cached values. 
    2727    public class FloatingRateBond : Bond { 
    28         //public FloatingRateBond(int settlementDays, double faceAmount, Schedule schedule, IborIndex index, DayCounter accrualDayCounter, 
    29         //                        BusinessDayConvention paymentConvention = Following, 
    30         //                        int fixingDays = Null<Natural>(), 
    31         //                        List<double> gearings = std::vector<Real>(1, 1.0), 
    32         //                        List<double> spreads = std::vector<Spread>(1, 0.0), 
    33         //                        List<double> caps = std::vector<Rate>(), 
    34         //                        List<double> floors = std::vector<Rate>(), 
    35         //                        bool inArrears = false, 
    36         //                        double redemption = 100.0, 
    37         //                        Date issueDate = Date()) 
     28        public FloatingRateBond(int settlementDays, double faceAmount, Schedule schedule, IborIndex index, DayCounter paymentDayCounter) 
     29            : this(settlementDays, faceAmount, schedule, index, paymentDayCounter, BusinessDayConvention.Following, 
     30                   0, new List<double>() { 1 }, new List<double>() { 1 }, new List<double>(), new List<double>(), 
     31                   false, 100, null) { } 
    3832        public FloatingRateBond(int settlementDays, double faceAmount, Schedule schedule, IborIndex index, DayCounter paymentDayCounter, 
    3933                                BusinessDayConvention paymentConvention, int fixingDays, List<double> gearings, List<double> spreads, 
  • trunk/QLNet/QLNet/Math/Matrix.cs

    r224 r225  
    7979        } 
    8080 
    81         public Matrix(ref Matrix from) { 
    82             data_ = !from.empty() ? new double[from.rows_, from.columns_] : null; 
     81        public Matrix(Matrix from) { 
     82            data_ = !from.empty() ? from.data_ : null; 
    8383            rows_ = from.rows_; 
    8484            columns_ = from.columns_; 
    85  
    86             for (int i = 0; i < rows_; i++) 
    87                 for (int j = 0; j < columns_; j++) 
    88                     data_[i, j] = from.data_[i, j]; 
    8985        } 
    90         // Matrix(const Disposable<Matrix>&);  
    9186            #endregion 
    9287     
     
    175170        } 
    176171 
     172        public void fill(double value) { 
     173            for (int i = 0; i < rows(); i++) 
     174                for (int j = 0; j < columns(); j++) 
     175                    data_[j, i] = value; 
     176        } 
     177 
    177178        public void swap(int i1, int j1, int i2, int j2) { 
    178179            double t = this[i2, j2]; 
  • trunk/QLNet/QLNet/Math/matrixutilities/svd.cs

    r224 r225  
    6767            // we're sure that m_ >= n_ 
    6868            s_ = new Vector(n_); 
    69             U_ = new Matrix(m_, n_, 0.0); 
     69            U_ = new Matrix(m_, n_); 
    7070            V_ = new Matrix(n_, n_); 
    7171            Vector e = new Vector(n_); 
     
    117117                } 
    118118                if (k < nct) { 
    119  
    120119                    // Place the transformation in U for subsequent back multiplication. 
    121120                    for (i = k; i < m_; i++) { 
     
    124123                } 
    125124                if (k < nrt) { 
    126  
    127125                    // Compute the k-th row transformation and place the k-th super-diagonal in e[k]. 
    128126                    // Compute 2-norm without under/overflow. 
     
    142140                    e[k] = -e[k]; 
    143141                    if ((k + 1 < m_) & (e[k] != 0.0)) { 
    144  
    145142                        // Apply the transformation. 
    146143                        for (i = k + 1; i < m_; i++) { 
  • trunk/QLNet/QLNet/Methods/montecarlo/earlyexercisepathpricer.cs

    r223 r225  
    2323 
    2424namespace QLNet { 
     25    public interface IPath : ICloneable { 
     26        int length(); 
     27    } 
     28 
    2529    //! base class for early exercise path pricers 
    2630    /*! Returns the value of an option on a given path and given time. 
    27  
    28         \ingroup mcarlo 
    2931    */ 
    30  
    31     public static class EarlyExerciseTraits<PathType> where PathType : Path { 
     32    public static class EarlyExerciseTraits<PathType> where PathType : IPath { 
    3233        //typedef Real StateType; 
    3334        public static int pathLength(PathType path) { return path.length(); } 
     
    3637 
    3738    // template<class PathType, class TimeType=Size, class ValueType=Real> 
    38     public interface EarlyExercisePathPricer<PathType>
     39    public interface IEarlyExercisePathPricer<PathType, StateType> where PathType : IPath
    3940        // typedef typename EarlyExerciseTraits<PathType>::StateType StateType; 
    4041 
    4142        double value(PathType path, int t); 
    4243 
    43         double state(PathType path, int t); 
    44         List<Func<double, double>> basisSystem(); 
     44        StateType state(PathType path, int t); 
     45        List<Func<StateType, double>> basisSystem(); 
    4546    } 
    4647} 
  • trunk/QLNet/QLNet/Methods/montecarlo/longstaffschwartzpathpricer.cs

    r224 r225  
    3535              reproducing results available in web/literature 
    3636    */ 
    37     public class LongstaffSchwartzPathPricer<PathType> : PathPricer<PathType> where PathType : Path, ICloneable
     37    public class LongstaffSchwartzPathPricer<PathType> : PathPricer<PathType> where PathType : IPath
    3838        protected bool  calibrationPhase_; 
    39         protected EarlyExercisePathPricer<PathType> pathPricer_; 
     39        protected IEarlyExercisePathPricer<PathType, double> pathPricer_; 
    4040 
    4141        protected List<Vector> coeff_; 
     
    4545        protected List<Func<double, double>> v_; 
    4646 
    47         public LongstaffSchwartzPathPricer(TimeGrid times, EarlyExercisePathPricer<PathType> pathPricer, 
     47        public LongstaffSchwartzPathPricer(TimeGrid times, IEarlyExercisePathPricer<PathType, double> pathPricer, 
    4848                                           YieldTermStructure termStructure) { 
    4949            calibrationPhase_ = true; 
     
    6060         
    6161 
    62         public override double value(PathType path) { 
     62        public double value(PathType path) { 
    6363            if (calibrationPhase_) { 
    6464                // store paths for the calibration 
  • trunk/QLNet/QLNet/Methods/montecarlo/montecarlomodel.cs

    r215 r225  
    5252 
    5353        private PathGenerator<IRNG> pathGenerator_; 
    54         private PathPricer<Path> pathPricer_; 
     54        private PathPricer<IPath> pathPricer_; 
    5555        private S sampleAccumulator_; 
    5656        private bool isAntitheticVariate_; 
    57         private PathPricer<Path> cvPathPricer_; 
     57        private PathPricer<IPath> cvPathPricer_; 
    5858        private double cvOptionValue_; 
    5959        private bool isControlVariate_; 
     
    6666        //          result_type cvOptionValue = result_type(), 
    6767        //          PathGenerator<IRNG> cvPathGenerator = path_generator_type()) { 
    68         public MonteCarloModel(PathGenerator<IRNG> pathGenerator, PathPricer<Path> pathPricer, S sampleAccumulator, 
     68        public MonteCarloModel(PathGenerator<IRNG> pathGenerator, PathPricer<IPath> pathPricer, S sampleAccumulator, 
    6969                  bool antitheticVariate) 
    7070            : this(pathGenerator, pathPricer, sampleAccumulator, antitheticVariate, null, 0, null) { } 
    71         public MonteCarloModel(PathGenerator<IRNG> pathGenerator, PathPricer<Path> pathPricer, S sampleAccumulator, 
    72                                bool antitheticVariate, PathPricer<Path> cvPathPricer, double cvOptionValue, 
     71        public MonteCarloModel(PathGenerator<IRNG> pathGenerator, PathPricer<IPath> pathPricer, S sampleAccumulator, 
     72                               bool antitheticVariate, PathPricer<IPath> cvPathPricer, double cvOptionValue, 
    7373                               PathGenerator<IRNG> cvPathGenerator) { 
    7474            pathGenerator_ = pathGenerator; 
  • trunk/QLNet/QLNet/Methods/montecarlo/multipath.cs

    r192 r225  
    2929        \ingroup mcarlo 
    3030    */ 
    31     public class MultiPath
     31    public class MultiPath : IPath
    3232        private List<Path> multiPath_; 
    3333         
     
    4444        //! \name inspectors 
    4545        public int assetNumber() { return multiPath_.Count; } 
     46        public int length() { return pathSize(); } 
    4647        public int pathSize() { return multiPath_[0].length(); } 
    4748 
    4849        //! \name read/write access to components 
    4950        public Path this[int j] { get { return multiPath_[j]; } set { multiPath_[j] = value; } } 
     51 
     52        // ICloneable interface 
     53        public object Clone() { 
     54            MultiPath temp = (MultiPath)this.MemberwiseClone(); 
     55            temp.multiPath_ = new List<Path>(this.multiPath_); 
     56            return temp; 
     57        } 
    5058    } 
    5159} 
  • trunk/QLNet/QLNet/Methods/montecarlo/path.cs

    r224 r225  
    2828        \note the path includes the initial asset value as its first point. 
    2929    */ 
    30     public class Path : ICloneable
     30    public class Path : ICloneable, IPath
    3131        private TimeGrid timeGrid_; 
    3232        private Vector values_; 
  • trunk/QLNet/QLNet/Methods/montecarlo/pathpricer.cs

    r194 r225  
    2828        \ingroup mcarlo 
    2929    */ 
    30     public class PathPricer<PathType> { 
    31         public virtual double value(PathType pt) { throw new NotSupportedException(); } 
     30    public interface PathPricer<PathType> { 
     31        double value(PathType pt); 
    3232    } 
    3333} 
  • trunk/QLNet/QLNet/Methods/montecarlo/sample.cs

    r224 r225  
    2525    //! weighted sample 
    2626    /*! \ingroup mcarlo */ 
     27    // todo check for Sample for value types and Sample for object types to take care of proper object copying 
    2728    public struct Sample<T> { 
    2829        public T value; 
  • trunk/QLNet/QLNet/Pricingengines/mclongstaffschwartzengine.cs

    r198 r225  
    3333              reproducing results available in web/literature 
    3434    */ 
     35    public abstract class MCLongstaffSchwartzEngine<GenericEngine, MC, RNG>  
     36        : MCLongstaffSchwartzEngine<GenericEngine, MC, RNG, Statistics> 
     37        where GenericEngine : IPricingEngine, new() 
     38        where RNG : IRSG, new() { 
     39        protected MCLongstaffSchwartzEngine(StochasticProcess process, int timeSteps, int timeStepsPerYear, 
     40                                            bool brownianBridge, bool antitheticVariate, bool controlVariate, 
     41                                            int requiredSamples, double requiredTolerance, int maxSamples, 
     42                                            ulong seed, int nCalibrationSamples) : 
     43            base(process, timeSteps, timeStepsPerYear, brownianBridge, antitheticVariate, controlVariate, 
     44                 requiredSamples, requiredTolerance, maxSamples, seed, nCalibrationSamples) { } 
     45    } 
    3546    public abstract class MCLongstaffSchwartzEngine<GenericEngine, MC, RNG, S> : McSimulation<MC, RNG, S>, IPricingEngine 
    3647        where GenericEngine : IPricingEngine, new() 
     
    5364        protected int nCalibrationSamples_; 
    5465 
    55         protected LongstaffSchwartzPathPricer<Path> pathPricer_; 
     66        protected LongstaffSchwartzPathPricer<IPath> pathPricer_; 
    5667 
    5768 
     
    106117        } 
    107118 
    108         protected override PathPricer<Path> pathPricer() { 
     119        protected override PathPricer<IPath> pathPricer() { 
    109120            if (pathPricer_ == null)  
    110121                throw new ApplicationException("path pricer unknown"); 
     
    119130        } 
    120131 
    121         protected abstract LongstaffSchwartzPathPricer<Path> lsmPathPricer(); 
     132        protected abstract LongstaffSchwartzPathPricer<IPath> lsmPathPricer(); 
    122133 
    123134        #region PricingEngine 
  • trunk/QLNet/QLNet/Pricingengines/mcsimulation.cs

    r194 r225  
    112112                    throw new ApplicationException("engine does not provide control-variation price"); 
    113113 
    114                 PathPricer<Path> controlPP = this.controlPathPricer(); 
     114                PathPricer<IPath> controlPP = this.controlPathPricer(); 
    115115                if (controlPP == null) 
    116116                    throw new ApplicationException("engine does not provide control-variation path pricer"); 
     
    135135 
    136136 
    137         protected abstract PathPricer<Path> pathPricer(); 
     137        protected abstract PathPricer<IPath> pathPricer(); 
    138138        protected abstract PathGenerator<IRNG> pathGenerator(); 
    139139        protected abstract TimeGrid timeGrid(); 
    140         protected virtual PathPricer<Path> controlPathPricer() { return null; } 
     140        protected virtual PathPricer<IPath> controlPathPricer() { return null; } 
    141141        protected virtual PathGenerator<IRNG> controlPathGenerator() { return null; } 
    142142        protected virtual IPricingEngine controlPricingEngine() { return null; } 
  • trunk/QLNet/QLNet/Pricingengines/vanilla/mcamericanengine.cs

    r224 r225  
    5050 
    5151 
    52         protected override LongstaffSchwartzPathPricer<Path> lsmPathPricer() { 
     52        protected override LongstaffSchwartzPathPricer<IPath> lsmPathPricer() { 
    5353            GeneralizedBlackScholesProcess process = process_ as GeneralizedBlackScholesProcess; 
    5454            if (process == null) 
     
    6363            AmericanPathPricer earlyExercisePathPricer = new AmericanPathPricer(arguments_.payoff, polynomOrder_, polynomType_); 
    6464 
    65             return new LongstaffSchwartzPathPricer<Path>(timeGrid(), earlyExercisePathPricer, process.riskFreeRate()); 
     65            return new LongstaffSchwartzPathPricer<IPath>(timeGrid(), earlyExercisePathPricer, process.riskFreeRate()); 
    6666        } 
    6767 
     
    9191        } 
    9292 
    93         protected override PathPricer<Path> controlPathPricer() { 
     93        protected override PathPricer<IPath> controlPathPricer() { 
    9494            StrikedTypePayoff payoff = arguments_.payoff as StrikedTypePayoff; 
    9595            if(payoff == null) 
     
    106106 
    107107 
    108     public class AmericanPathPricer : EarlyExercisePathPricer<Path>  { 
     108    public class AmericanPathPricer : IEarlyExercisePathPricer<IPath, double>  { 
    109109        protected double scalingValue_; 
    110110        protected Payoff payoff_; 
     
    134134 
    135135        // scale values of the underlying to increase numerical stability 
    136         public double state(Path path, int t) { return path[t]*scalingValue_; } 
    137         public double value(Path path, int t) { return payoff(state(path, t)); } 
     136        public double state(IPath path, int t) { return (path as Path)[t]*scalingValue_; } 
     137        public double value(IPath path, int t) { return payoff(state(path, t)); } 
    138138        public List<Func<double, double>> basisSystem() { return v_; } 
    139139        protected double payoff(double state) { return payoff_.value(state / scalingValue_); } 
  • trunk/QLNet/QLNet/Pricingengines/vanilla/mceuropeanengine.cs

    r197 r225  
    4040                   requiredSamples, requiredTolerance, maxSamples, seed) { } 
    4141 
    42         protected override PathPricer<Path> pathPricer() { 
     42        protected override PathPricer<IPath> pathPricer() { 
    4343            PlainVanillaPayoff payoff = arguments_.payoff as PlainVanillaPayoff; 
    4444            if (payoff == null) 
     
    132132 
    133133 
    134     public class EuropeanPathPricer : PathPricer<Path> { 
     134    public class EuropeanPathPricer : PathPricer<IPath> { 
    135135        private PlainVanillaPayoff payoff_; 
    136136        private double discount_; 
     
    143143        } 
    144144 
    145         public override double value(Path path) { 
     145        public double value(IPath path) { 
    146146            if (!(path.length() > 0)) 
    147147                throw new ApplicationException("the path cannot be empty"); 
    148             return payoff_.value(path.back()) * discount_; 
     148            return payoff_.value((path as Path).back()) * discount_; 
    149149        } 
    150150    } 
  • trunk/QLNet/QLNet/QLNet.csproj

    r223 r225  
    33    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> 
    44    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> 
    5     <ProductVersion>9.0.21022</ProductVersion> 
     5    <ProductVersion>9.0.30428</ProductVersion> 
    66    <SchemaVersion>2.0</SchemaVersion> 
    77    <ProjectGuid>{F6E762BD-DCDF-4CA0-ABAD-CB21C7D03BEC}</ProjectGuid> 
     
    159159    <Compile Include="Math\linearleastsquaresregression.cs" /> 
    160160    <Compile Include="Math\Matrix.cs" /> 
     161    <Compile Include="Math\matrixutilities\choleskydecomposition.cs" /> 
     162    <Compile Include="Math\matrixutilities\pseudosqrt.cs" /> 
    161163    <Compile Include="Math\matrixutilities\svd.cs" /> 
     164    <Compile Include="Math\matrixutilities\symmetricschurdecomposition.cs" /> 
    162165    <Compile Include="Math\Optimization\ArmijoLineSearch.cs" /> 
    163166    <Compile Include="Math\Optimization\ConjugateGradient.cs" /> 
     
    294297    <Compile Include="processes\Ornsteinuhlenbeckprocess.cs" /> 
    295298    <Compile Include="processes\Squarerootprocess.cs" /> 
     299    <Compile Include="processes\stochasticprocessarray.cs" /> 
    296300    <Compile Include="Properties\AssemblyInfo.cs" /> 
    297301    <Compile Include="Quotes\Quote.cs" /> 
  • trunk/QLNet/QLNet/Time/Date.cs

    r217 r225  
    9090                case TimeUnit.Years: { DateTime t = d.date; return new Date(t.AddYears(n)); } 
    9191                default: 
    92                     throw Error.UnknownTimeUnit(u); 
     92                    throw new ArgumentException("Unknown TimeUnit: " + u); 
    9393            } 
    9494        } 
  • trunk/QLNet/QLNet/Time/DayCounters/ActualActual.cs

    r61 r225  
    2424    //! Actual/Actual day count 
    2525    /*! The day count can be calculated according to: 
    26                 - the ISDA convention, also known as "Actual/Actual (Historical)", "Actual/Actual", "Act/Act", and according to ISDA also "Actual/365", "Act/365", and "A/365"; 
     26                - the ISDA convention, also known as "Actual/Actual (Historical)", "Actual/Actual", "Act/Act",  
     27              and according to ISDA also "Actual/365", "Act/365", and "A/365"; 
    2728                - the ISMA and US Treasury convention, also known as "Actual/Actual (Bond)"; 
    2829                - the AFB convention, also known as "Actual/Actual (Euro)". 
  • trunk/QLNet/QLNet/Time/Period.cs

    r61 r225  
    2121using System.Text; 
    2222 
    23 namespace QLNet 
    24 
    25     public class Period 
    26     { 
     23namespace QLNet { 
     24    public class Period { 
    2725        private int length_; 
    2826        private TimeUnit unit_; 
     
    3432        public Period() { length_ = 0; unit_ = TimeUnit.Days; } 
    3533        public Period(int n, TimeUnit u) { length_ = n; unit_ = u; } 
    36         public Period(Frequency f) 
    37         { 
    38             switch (f) 
    39             { 
     34        public Period(Frequency f) { 
     35            switch (f) { 
    4036                case Frequency.Once: 
    4137                case Frequency.NoFrequency: 
     
    6965        } 
    7066 
    71         public Frequency frequency() 
    72         { 
     67        public Frequency frequency() { 
    7368            int length = System.Math.Abs(length_);      // unsigned version 
    7469 
    7570            if (length == 0) return Frequency.NoFrequency; 
    76             switch (unit_) 
    77             { 
     71            switch (unit_) { 
    7872                case TimeUnit.Years: 
    7973                    if (length != 1) throw Error.CannotInitiateFrequency(this); 
     
    9387                    return Frequency.Daily; 
    9488                default: 
    95                     throw Error.UnknownTimeUnit(unit_); 
    96             } 
    97         } 
    98  
    99         public void normalize() 
    100         { 
     89                    throw new ArgumentException("Unknown TimeUnit: " + unit_); 
     90            } 
     91        } 
     92 
     93        public void normalize() { 
    10194            if (length_ != 0) 
    102                 switch (unit_) 
    103                 { 
     95                switch (unit_) { 
    10496                    case TimeUnit.Days: 
    105                         if ((length_ % 7) == 0) 
    106                         { 
     97                        if ((length_ % 7) == 0) { 
    10798                            length_ /= 7; 
    10899                            unit_ = TimeUnit.Weeks; 
     
    110101                        break; 
    111102                    case TimeUnit.Months: 
    112                         if ((length_ % 12) == 0) 
    113                         { 
     103                        if ((length_ % 12) == 0) { 
    114104                            length_ /= 12; 
    115105                            unit_ = TimeUnit.Years; 
     
    120110                        break; 
    121111                    default: 
    122                         throw Error.UnknownTimeUnit(unit_); 
     112                        throw new ArgumentException("Unknown TimeUnit: " + unit_); 
    123113                } 
    124114        } 
     
    133123        public static bool operator >=(Period p1, Period p2) { return !(p1 < p2); } 
    134124        public static bool operator >(Period p1, Period p2) { return p2 < p1; } 
    135         public static bool operator <(Period p1, Period p2) 
    136         { 
     125        public static bool operator <(Period p1, Period p2) { 
    137126            // special cases 
    138127            if (p1.length() == 0) return (p2.length() > 0); 
     
    155144 
    156145        // required by operator < 
    157         struct pair 
    158         { 
     146        struct pair { 
    159147            public int lo, hi; 
    160             public pair(Period p) 
    161             { 
    162                 switch (p.units()) 
    163                 { 
     148            public pair(Period p) { 
     149                switch (p.units()) { 
    164150                    case TimeUnit.Days: 
    165151                        lo = hi = p.length(); break; 
     
    171157                        lo = 365 * p.length(); hi = 366 * p.length(); break; 
    172158                    default: 
    173                         throw Error.UnknownTimeUnit(p.units()); 
     159                        throw new ArgumentException("Unknown TimeUnit: " + p.units()); 
    174160                } 
    175161            } 
     
    178164        public override bool Equals(object o) { return this == (Period)o; } 
    179165        public override int GetHashCode() { return 0; } 
    180         public override string ToString() 
    181         { 
     166        public override string ToString() { 
    182167            return "TimeUnit: " + unit_.ToString() + ", length: " + length_.ToString(); 
    183168        } 
    184         public string ToShortString() 
    185         { 
     169        public string ToShortString() { 
    186170            string result = ""; 
    187171            int n = length(); 
    188172            int m = 0; 
    189             switch (units()) 
    190             { 
     173            switch (units()) { 
    191174                case TimeUnit.Days: 
    192                     if (n >= 7) 
    193                     { 
     175                    if (n >= 7) { 
    194176                        m = n / 7; 
    195177                        result += m + "W"; 
     
    203185                    return result + n + "W"; 
    204186                case TimeUnit.Months: 
    205                     if (n >= 12) 
    206                     { 
     187                    if (n >= 12) { 
    207188                        m = n / 12; 
    208189                        result += n / 12 + "Y"; 
  • trunk/QLNet/Test2008/Test2008.csproj

    r224 r225  
    4242  <ItemGroup> 
    4343    <Compile Include="T_LinearLeastSquaresRegression.cs" /> 
     44    <Compile Include="T_Matrices.cs" /> 
     45    <Compile Include="T_Mclongstaffschwartzengine.cs" /> 
    4446    <Compile Include="T_Optimizers.cs" /> 
    4547    <Compile Include="Properties\AssemblyInfo.cs" />