diff --git a/ChangeLog.txt b/ChangeLog.txt index 48b20532c..a026ea312 100644 --- a/ChangeLog.txt +++ b/ChangeLog.txt @@ -1,868 +1,717 @@ -commit 0562beea7e1f64a834d2321ed3cecbb9bfd9a791 +commit e2dfdf4864dcf8c84a7cf7827e283c7b181d49d6 Author: Andrea Maggiulli -Date: Thu May 19 18:13:58 2016 +0200 +Date: Fri Sep 2 11:15:43 2016 +0200 - Add missing engine : AnalyticH1HWEngine + Avoid Parallelization in xunit tests . Now you can run : dotnet test to launch whole suite. - QLNet/Pricingengines/vanilla/AnalyticH1HWEngine.cs | 178 +++++++++++++++++++++ - 1 file changed, 178 insertions(+) + Test/Properties/AssemblyInfo.cs | 5 +++++ + 1 file changed, 5 insertions(+) -commit e92c50cdd785fb14b97836c306648a9e45983557 -Merge: 1629ad2 eba0e3b +commit da52b15ba4b736e238429b3d3fb3e37f6f02f88b Author: Andrea Maggiulli -Date: Thu May 19 18:07:42 2016 +0200 +Date: Thu Sep 1 16:31:20 2016 +0200 - Finish Feature HestonHullWhiteProcess + Small trick to fix AppVeyor .NET compilation -commit eba0e3b8b261a9988354d13fb67ac34136c0e7f4 -Merge: 2e72362 1629ad2 -Author: Andrea Maggiulli -Date: Thu May 19 18:02:59 2016 +0200 - - Merged 'develop'. - -commit 1629ad275d41028c53d05293c9a7e57a83ee6a31 -Merge: d8ed7ac 9e8b8bf -Author: Andrea Maggiulli -Date: Thu May 19 18:00:16 2016 +0200 - - Merge pull request #82 from igitur/disposable-savedsettings - - Disposable SavedSettings - -commit 2e72362c49d6c672093a264f628680f0cf252c64 -Author: Andrea Maggiulli -Date: Thu May 19 17:56:56 2016 +0200 - - Added HybridHestonHullWhiteProcess with tests - - QLNet/Math/randomnumbers/SobolBrownianBridgeRsg.cs | 68 +++ - QLNet/Models/MarketModels/BrownianGenerator.cs | 34 ++ - .../BrownianGenerators/SobolBrownianGenerator.cs | 228 +++++++ - .../vanilla/MCHestonHullWhiteEngine.cs | 228 +++++++ - QLNet/QLNet.csproj | 8 + - QLNet/processes/ForwardMeasureProcess.cs | 109 ++++ - QLNet/processes/HullWhiteProcess.cs | 149 +++++ - QLNet/processes/HybridHestonHullWhiteProcess.cs | 224 +++++++ - Test/T_HybridHestonHullWhiteProcess.cs | 653 +++++++++++++++++++++ - 9 files changed, 1701 insertions(+) - -commit 919bf20ddc5aaa982d3044f24b30aa08bfbe0c58 -Author: Andrea Maggiulli -Date: Thu May 19 17:56:07 2016 +0200 - - Small fixes & refactoring - - QLNet/Methods/montecarlo/montecarlomodel.cs | 194 +++++++------- - QLNet/Models/Shortrate/Onefactormodels/vasicek.cs | 254 ++++++++++--------- - QLNet/Pricingengines/mcsimulation.cs | 267 ++++++++++---------- - .../vanilla/AnalyticHestonHullWhiteEngine.cs | 8 +- - QLNet/Pricingengines/vanilla/mcvanillaengine.cs | 281 +++++++++++---------- - 5 files changed, 511 insertions(+), 493 deletions(-) - -commit 9e8b8bfef43358883c00b2ed58957913a81af9cb -Author: Francois Botha -Date: Thu May 19 12:04:47 2016 +0200 - - Make SavedSettings disposable and update tests accordingly - - QLNet/Settings.cs | 47 +- - Test/T_AsianOptions.cs | 627 +++++------ - Test/T_Bonds.cs | 2433 ++++++++++++++++++++++--------------------- - Test/T_CreditDefaultSwap.cs | 795 +++++++------- - Test/T_DigitalOption.cs | 1135 ++++++++++---------- - Test/T_DividendOption.cs | 839 +++++++-------- - Test/T_HestonModel.cs | 1428 ++++++++++++------------- - Test/T_Inflation.cs | 1120 ++++++++++---------- - 8 files changed, 4235 insertions(+), 4189 deletions(-) - -commit 2abde77e2cb8f82d52c914da541f3f28f3c2ec83 -Author: Francois Botha -Date: Wed May 18 12:56:24 2016 +0200 - - reformat and reindent (only whitespace changes and usings reorder) - - Test/T_CashFlows.cs | 525 +++++++------- - Test/T_CreditDefaultSwap.cs | 973 +++++++++++++------------- - Test/T_DividendOption.cs | 1584 +++++++++++++++++++++---------------------- - Test/T_Inflation.cs | 1354 ++++++++++++++++++------------------ - 4 files changed, 2206 insertions(+), 2230 deletions(-) + QLNet/qlnet.project.json | 7 +++++++ + Test/test.project.json | 7 +++++++ + 2 files changed, 14 insertions(+) -commit 60ec7711a9ef87708665db81aa8071070abd0358 +commit 0f8eef4e1b5e55c15131a19069ab8340291538f5 Author: Andrea Maggiulli -Date: Fri May 13 15:13:56 2016 +0200 +Date: Thu Sep 1 15:48:55 2016 +0200 - OrnsteinUhlenbeckProcess class refactoring + Updating code for .NET Core compatibility : Visual Studio 2015 project for .net core compilation. + Now you can compile and test QLNet under .net core from cli or visual studio 2015 ! Enjoy :) - QLNet/processes/Ornsteinuhlenbeckprocess.cs | 166 ++++++++++++++-------------- - 1 file changed, 80 insertions(+), 86 deletions(-) + QLNet/QLNet.xproj | 19 + + QLNet/project.json | 13 + + QLNet/project.lock.json | 2506 ++++++++++++++++ + QLNet_Core.sln | 39 + + Test/Test.xproj | 22 + + Test/project.json | 20 + + Test/project.lock.json | 7496 +++++++++++++++++++++++++++++++++++++++++++++++ + global.json | 6 + + 8 files changed, 10121 insertions(+) -commit 349583aca4d4c1ab4fc581a2ee57e5629bb8459b +commit 7dc5202a86229bda2934cbdb9b04d958398a30b1 Author: Andrea Maggiulli -Date: Fri May 13 15:13:02 2016 +0200 +Date: Thu Sep 1 15:46:09 2016 +0200 - TimeGrid fixes & new ctor + Updating code for .NET Core compatibility : Small ctor fix - .../Pricingengines/Bond/TreeCallableBondEngine.cs | 4 +- - QLNet/Pricingengines/Swap/treeswapengine.cs | 4 +- - .../Pricingengines/swaption/treeswaptionengine.cs | 4 +- - QLNet/timegrid.cs | 93 ++++++++++++++-------- - Test/T_LiborMarketModel.cs | 2 +- - Test/T_LiborMarketModelProcess.cs | 2 +- - 6 files changed, 68 insertions(+), 41 deletions(-) - -commit 6e1274fffeb1682cdea717ba7f6eaff1a27f9c99 -Author: Andrea Maggiulli -Date: Fri May 13 15:07:46 2016 +0200 - - SobolRsg fix bits_ size and reformat code. - - QLNet/Math/randomnumbers/sobolrsg.cs | 951 ++++++++++++++++++----------------- - 1 file changed, 497 insertions(+), 454 deletions(-) - -commit f4322b8c4d6f0b02baa04c4d6db8548968b6e551 -Merge: 7330b60 d8ed7ac -Author: Andrea Maggiulli -Date: Wed May 11 15:23:17 2016 +0200 - - Merged 'develop'. - -commit d8ed7acb3fc183d8eedc5bf6d653235b72a4ed4b -Merge: 2956f64 797ef6e -Author: Andrea Maggiulli -Date: Wed May 11 14:56:14 2016 +0200 - - Merge branch 'igitur-use-weak-event-references' into develop - -commit 797ef6ec252aac442ce061a12e2fe8407787278e -Author: Andrea Maggiulli -Date: Wed May 11 14:54:47 2016 +0200 - - Compatibility fix , substitute a c#6.0 feature. - - QLNet/Patterns/WeakEventSource.cs | 4 ++-- + QLNet/Math/Interpolations/MixedInterpolation.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) -commit 7330b609d2015d5b740bbfba702911af9086f0e8 -Author: Andrea Maggiulli -Date: Wed May 11 14:13:07 2016 +0200 - - HybridHestonHullWhiteProcess Step1 - - .../vanilla/AnalyticBSMHullWhiteEngine.cs | 132 +++++++++++++ - .../vanilla/AnalyticHestonHullWhiteEngine.cs | 115 ++++++++++++ - QLNet/QLNet.csproj | 2 + - Test/T_HybridHestonHullWhiteProcess.cs | 208 +++++++++++++++++++++ - Test/Test.csproj | 1 + - 5 files changed, 458 insertions(+) - -commit 2395b437853ad6f01ae1d855088a6f666fe9c96e -Author: Andrea Maggiulli -Date: Wed May 11 12:27:47 2016 +0200 - - VanillaOption refactoring. - - QLNet/Instruments/VanillaOption.cs | 120 ++++++++++++++++++++----------------- - 1 file changed, 64 insertions(+), 56 deletions(-) - -commit 63370b447ff097ce2ba610c9d24811cb7fcd5acd -Merge: c2f6b6b 2956f64 -Author: Francois Botha -Date: Wed May 11 11:43:04 2016 +0200 - - Merge branch 'develop' of https://github.com/amaggiulli/qlnet into use-weak-event-references - - Conflicts: - QLNet/Models/model.cs - QLNet/Pricingengines/mclongstaffschwartzengine.cs - QLNet/Pricingengines/vanilla/mcvanillaengine.cs - -commit 2956f641465c28b67082a40271f18e6bcdc030e3 -Author: Andrea Maggiulli -Date: Tue May 10 17:16:09 2016 +0200 - - Removed unused code. - - QLNet/Pricingengines/vanilla/HestonExpansionEngine.cs | 2 -- - 1 file changed, 2 deletions(-) - -commit 925cca756b5cc853cd0ea596eddf2e8fa84e8423 -Merge: 623a66e ef50947 -Author: Andrea Maggiulli -Date: Tue May 10 11:39:30 2016 +0200 - - Finish feature Heston - -commit 623a66e58df945ded28c3ae2da03ff6a09510a7d -Author: Andrea Maggiulli -Date: Tue May 10 11:10:01 2016 +0200 - - Finish Heston - - QLNet/Instruments/Bonds/MBSFixedRateBond.cs | 4 +- - QLNet/Math/Optimization/Constraint.cs | 341 +++-- - QLNet/Math/Optimization/ProjectedConstraint.cs | 70 + - QLNet/Math/Optimization/Projection.cs | 80 ++ - QLNet/Math/integrals/GaussLobattoIntegral.cs | 168 +++ - QLNet/Math/integrals/GaussianQuadratures.cs | 10 +- - QLNet/Math/integrals/Integral.cs | 11 +- - QLNet/Math/integrals/Kronrodintegral.cs | 2 +- - .../Math/integrals/gaussianorthogonalpolynomial.cs | 4 +- - .../Math/matrixutilities/TqrEigenDecomposition.cs | 23 +- - .../Methods/montecarlo/earlyexercisepathpricer.cs | 5 +- - QLNet/Methods/montecarlo/montecarlomodel.cs | 12 +- - QLNet/Methods/montecarlo/multipathgenerator.cs | 14 +- - QLNet/Methods/montecarlo/path.cs | 14 +- - QLNet/Methods/montecarlo/pathgenerator.cs | 16 +- - QLNet/Models/Equity/HestonModel.cs | 104 ++ - QLNet/Models/Equity/HestonModelHelper.cs | 109 ++ - .../Equity/PiecewiseTimeDependentHestonModel.cs | 89 ++ - QLNet/Models/Parameter.cs | 364 +++--- - QLNet/Models/model.cs | 223 +++- - .../Pricingengines/Bond/TreeCallableBondEngine.cs | 2 +- - .../CapFloor/analyticcapfloorengine.cs | 10 +- - QLNet/Pricingengines/Swap/treeswapengine.cs | 4 +- - .../Pricingengines/asian/mcdiscreteasianengine.cs | 2 +- - QLNet/Pricingengines/genericmodelengine.cs | 72 +- - .../Pricingengines/latticeshortratemodelengine.cs | 4 +- - QLNet/Pricingengines/mclongstaffschwartzengine.cs | 12 +- - QLNet/Pricingengines/mcsimulation.cs | 2 +- - QLNet/Pricingengines/swaption/g2swaptionengine.cs | 4 +- - .../swaption/jamshidianswaptionengine.cs | 6 +- - .../Pricingengines/swaption/treeswaptionengine.cs | 4 +- - .../Pricingengines/vanilla/AnalyticHestonEngine.cs | 605 +++++++++ - .../vanilla/AnalyticPTDHestonEngine.cs | 210 +++ - .../vanilla/FdHestonVanillaEngine.cs | 92 ++ - .../vanilla/HestonExpansionEngine.cs | 786 ++++++++++++ - .../vanilla/MCEuropeanHestonEngine.cs | 170 +++ - QLNet/Pricingengines/vanilla/mcvanillaengine.cs | 40 +- - QLNet/QLNet.csproj | 12 + - QLNet/Types.cs | 1 + - .../legacy/libormarketmodels/lfmswaptionengine.cs | 2 +- - QLNet/processes/HestonProcess.cs | 604 +++++++++ - Test/T_HestonModel.cs | 1351 ++++++++++++++++++++ - Test/T_LiborMarketModel.cs | 11 +- - Test/T_LiborMarketModelProcess.cs | 12 +- - Test/T_PathGenerator.cs | 24 +- - Test/Test.csproj | 1 + - 46 files changed, 5209 insertions(+), 497 deletions(-) - -commit ef50947e9c51df608bd72dcae6daf1597abf918d -Author: Andrea Maggiulli -Date: Tue May 10 11:08:57 2016 +0200 - - Added Heston model & engine with tests. - - QLNet/Math/Optimization/ProjectedConstraint.cs | 70 + - QLNet/Math/Optimization/Projection.cs | 80 ++ - QLNet/Math/integrals/GaussLobattoIntegral.cs | 168 +++ - QLNet/Math/integrals/Integral.cs | 11 +- - QLNet/Math/integrals/Kronrodintegral.cs | 2 +- - QLNet/Models/Equity/HestonModel.cs | 104 ++ - QLNet/Models/Equity/HestonModelHelper.cs | 109 ++ - QLNet/Models/Parameter.cs | 4 +- - .../Pricingengines/vanilla/AnalyticHestonEngine.cs | 605 +++++++++ - .../vanilla/AnalyticPTDHestonEngine.cs | 210 +++ - .../vanilla/FdHestonVanillaEngine.cs | 92 ++ - .../vanilla/HestonExpansionEngine.cs | 786 ++++++++++++ - .../vanilla/MCEuropeanHestonEngine.cs | 170 +++ - QLNet/QLNet.csproj | 12 + - QLNet/processes/HestonProcess.cs | 604 +++++++++ - Test/T_HestonModel.cs | 1351 ++++++++++++++++++++ - Test/Test.csproj | 1 + - 17 files changed, 4371 insertions(+), 8 deletions(-) - -commit c2f6b6bf03e276c686e91001fa7c00a7be55dc3c -Author: Francois Botha -Date: Mon May 9 18:33:04 2016 +0200 - - notifyObservers has to be public here. - - QLNet/Models/model.cs | 2 +- +commit b9ff67553a423f5bea80b0d775608b52699687f3 +Author: Andrea Maggiulli +Date: Thu Sep 1 15:45:30 2016 +0200 + + Updating code for .NET Core compatibility : Removed unused files. + + .../Interpolations/CubicSplineInterpolation.cs | 341 --------------------- + Test/T_Loan.cs | 69 ----- + 2 files changed, 410 deletions(-) + +commit 1203723cb824ba48faa8873aa50c5034a2cab3f1 +Author: Andrea Maggiulli +Date: Thu Sep 1 14:28:23 2016 +0200 + + Updating code for .NET Core compatibility : Refactored Test project and code to work with Microsoft UnitTesting and Xunit. + Now test project is runnable with .net core. + + Test/T_AmericanOption.cs | 43 ++- + Test/T_AsianOptions.cs | 48 +++- + Test/T_AssetSwap.cs | 367 ++++++++++++++----------- + Test/T_BasketOption.cs | 196 +++++++------- + Test/T_Bermudanswaption.cs | 69 +++-- + Test/T_BlackFormula.cs | 24 +- + Test/T_Bonds.cs | 195 +++++++++----- + Test/T_BusinessDayConvention.cs | 54 ++-- + Test/T_Calendars.cs | 388 ++++++++++++++++----------- + Test/T_CapFloor.cs | 141 ++++++---- + Test/T_CashFlows.cs | 40 ++- + Test/T_CreditDefaultSwap.cs | 64 +++-- + Test/T_Dates.cs | 126 +++++---- + Test/T_DayCounters.cs | 68 +++-- + Test/T_DefaultProbabilityCurves.cs | 50 ++-- + Test/T_DigitalOption.cs | 56 +++- + Test/T_DividendOption.cs | 58 +++- + Test/T_EuropeanOption.cs | 121 ++++++--- + Test/T_ExchangeRate.cs | 94 ++++--- + Test/T_Functions.cs | 88 +++--- + Test/T_HestonModel.cs | 124 ++++++--- + Test/T_HybridHestonHullWhiteProcess.cs | 152 +++++++---- + Test/T_Inflation.cs | 76 ++++-- + Test/T_InflationCapFloorTest.cs | 65 +++-- + Test/T_InflationCapFlooredCouponTest.cs | 65 +++-- + Test/T_Instruments.cs | 32 ++- + Test/T_InterestRate.cs | 48 ++-- + Test/T_Interpolations.cs | 312 +++++++++++++-------- + Test/T_LiborMarketModel.cs | 87 ++++-- + Test/T_LiborMarketModelProcess.cs | 82 ++++-- + Test/T_LinearLeastSquaresRegression.cs | 95 ++++--- + Test/T_LowDiscrepancySequences.cs | 98 ++++--- + Test/T_Matrices.cs | 236 +++++++++------- + Test/T_Money.cs | 50 ++-- + Test/T_Operators.cs | 42 ++- + Test/T_Optimizers.cs | 36 ++- + Test/T_OptionletStripper.cs | 216 ++++++++------- + Test/T_OvernightIndexedSwap.cs | 98 ++++--- + Test/T_PSACurve.cs | 26 +- + Test/T_PathGenerator.cs | 76 ++++-- + Test/T_PiecewiseZeroSpreadedTermStructure.cs | 122 ++++++--- + Test/T_Piecewiseyieldcurve.cs | 153 ++++++++--- + Test/T_Quotes.cs | 68 +++-- + Test/T_RNGTraits.cs | 48 ++-- + Test/T_RiskStats.cs | 116 ++++---- + Test/T_Rounding.cs | 74 +++-- + Test/T_SampledCurve.cs | 36 ++- + Test/T_Schedule.cs | 88 ++++-- + Test/T_ShortRateModels.cs | 50 ++-- + Test/T_Solvers.cs | 68 +++-- + Test/T_Stats.cs | 162 ++++++----- + Test/T_Swaps.cs | 119 +++++--- + Test/T_Swaption.cs | 135 ++++++---- + Test/T_SwaptionVolatilitymatrix.cs | 91 ++++--- + Test/T_TermStructures.cs | 135 ++++++---- + Test/Test.csproj | 4 +- + Test/Utilities.cs | 79 +++++- + 57 files changed, 3823 insertions(+), 2031 deletions(-) + +commit 2977a094c388c58f80100c8c7c76b48a3d008c00 +Author: Andrea Maggiulli +Date: Wed Aug 31 15:04:14 2016 +0200 + + Updating code for .NET Core compatibility : WeakEventSource refactoring, added ICloneable interface if .net core + + QLNet/Patterns/WeakEventSource.cs | 19 +++++++++++++++---- + QLNet/Utils.cs | 9 ++++++++- + 2 files changed, 23 insertions(+), 5 deletions(-) + +commit eb848b6655914cca4baa5bc0127797b5466a898e +Author: Andrea Maggiulli +Date: Wed Aug 31 14:30:13 2016 +0200 + + Updating code for .NET Core compatibility : ForEach Action refactoring + + QLNet/Instruments/YearOnYearInflationSwap.cs | 2 +- + QLNet/Instruments/ZeroCouponInflationSwap.cs | 2 +- + QLNet/Termstructures/Inflation/PiecewiseYoYInflationCurve.cs | 2 +- + QLNet/Termstructures/Inflation/PiecewiseZeroInflationCurve.cs | 2 +- + QLNet/Termstructures/Iterativebootstrap.cs | 2 +- + QLNet/Termstructures/Yield/PiecewiseYieldCurve.cs | 2 +- + QLNet/Termstructures/localbootstrap.cs | 4 ++-- + 7 files changed, 8 insertions(+), 8 deletions(-) + +commit 0ad3e16f01c10f8dc13ad39491cc36a5c363f9b8 +Author: Andrea Maggiulli +Date: Wed Aug 31 12:47:55 2016 +0200 + + Updating code for .NET Core compatibility : Defined QL_DOTNET_FRAMEWORK for debug and release + + QLNet/QLNet.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) -commit 9f03318f74b7c0e097829c4450fae68611e5c2dd -Merge: 3381085 358bc3e -Author: Francois Botha -Date: Mon May 9 18:30:52 2016 +0200 - - Merge remote-tracking branch 'upstream/develop' into use-weak-event-references - -commit aa09ca64f814911226f980eaa0d146c4601bf409 +commit b86f412d0e4303a87baab80ea09f9f12e7855bb6 Author: Andrea Maggiulli -Date: Mon May 9 17:29:59 2016 +0200 +Date: Wed Aug 31 12:39:35 2016 +0200 - Bug fix GaussianOrthogonalPolynomial - wrong check + Updating code for .NET Core compatibility : Defined QL_DOTNET_FRAMEWORK compilation constant to identify between .net framework and .net core. + Encapsulated GetMethodInfo in a static function to handle the environments differences + Small string fix. - .../Math/integrals/gaussianorthogonalpolynomial.cs | 4 +- - .../Equity/PiecewiseTimeDependentHestonModel.cs | 89 ++++++++++++++++++++++ - 2 files changed, 91 insertions(+), 2 deletions(-) + QLNet/Cashflows/CashFlows.cs | 9 +++++---- + QLNet/Cashflows/CouponPricer.cs | 2 +- + QLNet/Math/statistics/sequencestatistics.cs | 8 ++++---- + QLNet/Pricingengines/BlackCalculator.cs | 4 ++-- + QLNet/QLNet.csproj | 2 +- + QLNet/Time/Imm.cs | 4 ++-- + QLNet/Utils.cs | 16 +++++++++++++++- + 7 files changed, 30 insertions(+), 15 deletions(-) -commit 29f41cdb6f31213080f35e20154829948a27d757 +commit 37dab31f62821aa344010a8525df58d587259d5d Author: Andrea Maggiulli -Date: Mon May 9 17:28:28 2016 +0200 +Date: Wed Aug 31 11:37:28 2016 +0200 - Fix MBSFixedRateBond base cashflow - thx @vina0007 + Updating code for .NET Core compatibility : ToLongDateString and ToShortDateString refactoring. - QLNet/Instruments/Bonds/MBSFixedRateBond.cs | 4 ++-- + QLNet/Time/Date.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) -commit 811fe347c788a28485c7e4ca9519858fea2e2c6f -Author: Andrea Maggiulli -Date: Mon May 9 17:25:44 2016 +0200 - - Enabled Handles in GenericModelEngine class. - - .../Pricingengines/Bond/TreeCallableBondEngine.cs | 2 +- - .../CapFloor/analyticcapfloorengine.cs | 10 +-- - QLNet/Pricingengines/Swap/treeswapengine.cs | 4 +- - QLNet/Pricingengines/genericmodelengine.cs | 72 ++++++++++++---------- - .../Pricingengines/latticeshortratemodelengine.cs | 4 +- - QLNet/Pricingengines/swaption/g2swaptionengine.cs | 4 +- - .../swaption/jamshidianswaptionengine.cs | 6 +- - .../Pricingengines/swaption/treeswaptionengine.cs | 4 +- - .../legacy/libormarketmodels/lfmswaptionengine.cs | 2 +- - 9 files changed, 57 insertions(+), 51 deletions(-) - -commit 358bc3ef2e6c6781cecdff4491616ed84a86e685 +commit d741c8e8e332aa84ae0fb7c15a13c02dd88a91bb +Author: Andrea Maggiulli +Date: Wed Aug 31 11:17:23 2016 +0200 + + Updating code for .NET Core compatibility : ApplicationException become Exception. + + QLNet/Cashflows/CPICoupon.cs | 14 +- + QLNet/Cashflows/CappedFlooredCoupon.cs | 10 +- + QLNet/Cashflows/CappedFlooredYoYInflationCoupon.cs | 2 +- + QLNet/Cashflows/Cashflowvectors.cs | 18 +- + QLNet/Cashflows/ConundrumPricer.cs | 12 +- + QLNet/Cashflows/DigitalCoupon.cs | 36 +-- + QLNet/Cashflows/Dividend.cs | 4 +- + QLNet/Cashflows/InflationCoupon.cs | 6 +- + QLNet/Cashflows/InflationCouponPricer.cs | 6 +- + QLNet/Cashflows/OvernightIndexedCoupon.cs | 16 +- + QLNet/Cashflows/SimpleCashFlow.cs | 2 +- + QLNet/Cashflows/averagebmacoupon.cs | 30 +-- + QLNet/Error.cs | 4 +- + QLNet/Exercise.cs | 4 +- + QLNet/Handle.cs | 2 +- + QLNet/Indexes/Ibor/Euribor.cs | 4 +- + QLNet/Indexes/Ibor/Eurlibor.cs | 78 +++--- + QLNet/Indexes/Ibor/Libor.cs | 68 +++--- + QLNet/Indexes/InflationIndex.cs | 140 +++++------ + QLNet/Instruments/AsianOption.cs | 20 +- + QLNet/Instruments/BarrierOption.cs | 18 +- + QLNet/Instruments/Bonds/AmortizingFixedRateBond.cs | 4 +- + QLNet/Instruments/Bonds/CmsRateBond.cs | 4 +- + QLNet/Instruments/Bonds/Fixedratebond.cs | 16 +- + QLNet/Instruments/Bonds/FloatingRateBond.cs | 12 +- + QLNet/Instruments/DividendVanillaOption.cs | 8 +- + QLNet/Instruments/ImpliedVolatility.cs | 2 +- + QLNet/Instruments/MultiAssetOption.cs | 16 +- + QLNet/Instruments/OneAssetOption.cs | 24 +- + QLNet/Instruments/OvernightIndexedSwap.cs | 10 +- + QLNet/Instruments/Stock.cs | 2 +- + QLNet/Instruments/VanillaSwap.cs | 6 +- + QLNet/Instruments/bmaswap.cs | 12 +- + QLNet/Instruments/forward.cs | 6 +- + QLNet/Instruments/forwardrateagreement.cs | 2 +- + QLNet/Instruments/payoffs.cs | 6 +- + QLNet/InterestRate.cs | 6 +- + QLNet/Math/Distributions/GammaDistribution.cs | 6 +- + QLNet/Math/Distributions/NormalDistribution.cs | 12 +- + QLNet/Math/Distributions/binomialdistribution.cs | 12 +- + QLNet/Math/Distributions/chisquaredistribution.cs | 2 +- + QLNet/Math/Distributions/poissondistribution.cs | 4 +- + .../Interpolations/convexmonotoneinterpolation.cs | 10 +- + QLNet/Math/Matrix.cs | 28 +-- + QLNet/Math/Optimization/Constraint.cs | 262 ++++++++++----------- + QLNet/Math/Optimization/EndCriteria.cs | 4 +- + QLNet/Math/Optimization/LineSearch.cs | 2 +- + QLNet/Math/Optimization/ProjectedCostFunction.cs | 10 +- + QLNet/Math/Optimization/Simplex.cs | 188 +++++++-------- + QLNet/Math/Optimization/levenbergmarquardt.cs | 8 +- + QLNet/Math/SampledCurve.cs | 6 +- + QLNet/Math/Solvers1d/Newton.cs | 2 +- + QLNet/Math/Solvers1d/Newtonsafe.cs | 2 +- + QLNet/Math/Vector.cs | 18 +- + QLNet/Math/beta.cs | 8 +- + QLNet/Math/integrals/Integral.cs | 2 +- + QLNet/Math/integrals/Segmentintegral.cs | 2 +- + .../Math/integrals/gaussianorthogonalpolynomial.cs | 18 +- + QLNet/Math/integrals/simpsonintegral.cs | 2 +- + QLNet/Math/integrals/trapezoidintegral.cs | 2 +- + QLNet/Math/linearleastsquaresregression.cs | 4 +- + .../Math/matrixutilities/choleskydecomposition.cs | 4 +- + QLNet/Math/matrixutilities/pseudosqrt.cs | 26 +- + .../matrixutilities/symmetricschurdecomposition.cs | 6 +- + .../Math/randomnumbers/randomsequencegenerator.cs | 2 +- + QLNet/Math/randomnumbers/sobolrsg.cs | 212 ++++++++--------- + QLNet/Math/statistics/gaussianstatistics.cs | 8 +- + QLNet/Math/statistics/generalstatistics.cs | 22 +- + QLNet/Math/statistics/incrementalstatistics.cs | 26 +- + QLNet/Math/statistics/riskstatistics.cs | 16 +- + QLNet/Math/statistics/sequencestatistics.cs | 8 +- + .../Finitedifferences/TridiagonalOperator.cs | 18 +- + .../Finitedifferences/finitedifferencemodel.cs | 2 +- + QLNet/Methods/lattices/binominaltree.cs | 16 +- + QLNet/Methods/lattices/lattice.cs | 4 +- + QLNet/Methods/montecarlo/brownianbridge.cs | 4 +- + QLNet/Methods/montecarlo/lsmbasissystem.cs | 2 +- + QLNet/Methods/montecarlo/multipath.cs | 2 +- + QLNet/Methods/montecarlo/multipathgenerator.cs | 6 +- + QLNet/Methods/montecarlo/path.cs | 24 +- + QLNet/Methods/montecarlo/pathgenerator.cs | 4 +- + QLNet/Models/Parameter.cs | 44 ++-- + .../Shortrate/Onefactormodels/coxingersollross.cs | 4 +- + .../Models/Shortrate/Onefactormodels/hullwhite.cs | 10 +- + QLNet/Models/Shortrate/Twofactorsmodels/g2.cs | 2 +- + QLNet/Models/model.cs | 4 +- + QLNet/Option.cs | 6 +- + QLNet/Pricingengines/Americanpayoffathit.cs | 14 +- + QLNet/Pricingengines/BlackCalculator.cs | 18 +- + QLNet/Pricingengines/Blackscholescalculator.cs | 4 +- + .../asian/mc_discr_arith_av_price.cs | 18 +- + .../asian/mc_discr_arith_av_strike.cs | 8 +- + .../Pricingengines/asian/mc_discr_geom_av_price.cs | 12 +- + .../Pricingengines/asian/mcdiscreteasianengine.cs | 2 +- + .../barrier/AnalyticBarrierEngine.cs | 12 +- + QLNet/Pricingengines/mclongstaffschwartzengine.cs | 2 +- + .../Pricingengines/swaption/blackswaptionengine.cs | 2 +- + QLNet/Pricingengines/swaption/g2swaptionengine.cs | 2 +- + .../vanilla/AnalyticEuropeanEngine.cs | 6 +- + QLNet/Pricingengines/vanilla/FDDividendEngine.cs | 2 +- + .../Pricingengines/vanilla/FDMultiPeriodEngine.cs | 8 +- + .../vanilla/FDStepConditionEngine.cs | 2 +- + QLNet/Pricingengines/vanilla/FDVanillaEngine.cs | 4 +- + QLNet/Pricingengines/vanilla/Integralengine.cs | 4 +- + QLNet/Pricingengines/vanilla/Juquadraticengine.cs | 10 +- + .../vanilla/baroneadesiwhaleyengine.cs | 12 +- + QLNet/Pricingengines/vanilla/binomialengine.cs | 10 +- + .../vanilla/bjerksundstenslandengine.cs | 12 +- + .../vanilla/discretizedvanillaoption.cs | 2 +- + QLNet/Pricingengines/vanilla/mcamericanengine.cs | 16 +- + QLNet/Pricingengines/vanilla/mcvanillaengine.cs | 48 ++-- + QLNet/Termstructures/Inflation/InflationHelpers.cs | 2 +- + QLNet/Termstructures/Inflation/Seasonality.cs | 10 +- + QLNet/Termstructures/InflationTermStructure.cs | 8 +- + .../Volatility/Inflation/CPIVolatilitySurface.cs | 2 +- + .../yoyinflationoptionletvolatilitystructure.cs | 14 +- + QLNet/Termstructures/Volatility/Sabr.cs | 14 +- + QLNet/Termstructures/Volatility/SmileSection.cs | 4 +- + .../Volatility/equityfx/BlackVarianceCurve.cs | 8 +- + .../Volatility/equityfx/LocalVolSurface.cs | 8 +- + QLNet/Termstructures/localbootstrap.cs | 4 +- + QLNet/Time/Calendars/JointCalendar.cs | 6 +- + QLNet/Time/Calendars/Ukraine.cs | 2 +- + QLNet/Time/Calendars/brazil.cs | 10 +- + QLNet/Time/Period.cs | 20 +- + QLNet/Time/Schedule.cs | 6 +- + QLNet/Utils.cs | 4 +- + QLNet/discretizedasset.cs | 4 +- + QLNet/legacy/libormarketmodels/lfmcovarproxy.cs | 2 +- + .../legacy/libormarketmodels/lfmhullwhiteparam.cs | 6 +- + .../legacy/libormarketmodels/lfmswaptionengine.cs | 2 +- + .../legacy/libormarketmodels/liborforwardmodel.cs | 6 +- + QLNet/legacy/libormarketmodels/lmfixedvolmodel.cs | 10 +- + QLNet/payoff.cs | 2 +- + QLNet/processes/Ornsteinuhlenbeckprocess.cs | 52 ++-- + QLNet/processes/stochasticprocessarray.cs | 4 +- + QLNet/timegrid.cs | 12 +- + Test/T_Interpolations.cs | 4 +- + Test/T_Mclongstaffschwartzengine.cs | 6 +- + Test/T_Optimizers.cs | 46 ++-- + 140 files changed, 1117 insertions(+), 1117 deletions(-) + +commit cc4ef00defa92555df38c03facbc29bfb7f577c9 +Author: Andrea Maggiulli +Date: Mon Aug 29 12:32:34 2016 +0200 + + Fix Date.daysBetween and Date operator. Thx @Askolein and @igitur (#106) + + QLNet/Time/Date.cs | 5 ++--- + Test/T_Dates.cs | 7 ++++++- + 2 files changed, 8 insertions(+), 4 deletions(-) + +commit c80eff8f6058a4e85fa51aff7b0eb5397f93d6fa Author: Francois Botha -Date: Mon May 9 16:00:40 2016 +0200 +Date: Wed Jul 27 16:20:38 2016 +0200 - Update .editorconfig files to set line endings to Windows convention. (#80) - - Update .editorconfig files to set line endings to Windows convention. … - Also add files to example projects. - - Examples/BermudanSwaption/.editorconfig | 16 ++++++++++++++++ - Examples/BermudanSwaption/BermudanSwaption.csproj | 3 +++ - Examples/Bonds/.editorconfig | 16 ++++++++++++++++ - Examples/Bonds/Bonds.csproj | 3 +++ - Examples/CallableBonds/.editorconfig | 16 ++++++++++++++++ - Examples/CallableBonds/CallableBonds.csproj | 3 +++ - Examples/EquityOption/.editorconfig | 16 ++++++++++++++++ - Examples/EquityOption/EquityOption.csproj | 3 +++ - Examples/FRA/.editorconfig | 16 ++++++++++++++++ - Examples/FRA/FRA.csproj | 3 +++ - Examples/FittedBondCurve/.editorconfig | 16 ++++++++++++++++ - Examples/FittedBondCurve/FittedBondCurve.csproj | 3 +++ - Examples/Repo/.editorconfig | 16 ++++++++++++++++ - Examples/Repo/Repo.csproj | 3 +++ - Examples/Swap/.editorconfig | 16 ++++++++++++++++ - Examples/Swap/Swap.csproj | 3 +++ - QLNet/.editorconfig | 4 ++-- - Test/.editorconfig | 4 ++-- - 18 files changed, 156 insertions(+), 4 deletions(-) - -commit 33810850d81ce210eb77b28b4d9d30bb0b6e94fe -Author: Francois Botha -Date: Mon May 9 15:38:02 2016 +0200 - - Implement WeakEvent pattern to fix memory leak. - Credit to Thomas Levesque for WeakEventSource code ( http://www.thomaslevesque.com/2015/08/16/weak-events-in-c-take-two ) - - QLNet/Cashflows/CouponPricer.cs | 20 +- - QLNet/Cashflows/InflationCouponPricer.cs | 14 +- - QLNet/Event.cs | 19 +- - QLNet/Handle.cs | 303 ++++++++------- - QLNet/Index.cs | 16 +- - QLNet/Instruments/Bonds/BTP.cs | 14 +- - QLNet/Instruments/Claim.cs | 124 +++--- - QLNet/Models/model.cs | 52 +-- - QLNet/Patterns/LazyObject.cs | 14 +- - QLNet/Patterns/WeakEventSource.cs | 136 +++++++ - QLNet/Patterns/observablevalue.cs | 17 +- - QLNet/PricingEngine.cs | 16 +- - .../Pricingengines/asian/mcdiscreteasianengine.cs | 16 +- - QLNet/Pricingengines/mclongstaffschwartzengine.cs | 16 +- - QLNet/Pricingengines/vanilla/FDBermudanEngine.cs | 16 +- - QLNet/Pricingengines/vanilla/FDEuropeanEngine.cs | 16 +- - QLNet/Pricingengines/vanilla/FDVanillaEngine.cs | 414 +++++++++++---------- - QLNet/Pricingengines/vanilla/mcvanillaengine.cs | 16 +- - QLNet/QLNet.csproj | 1 + - QLNet/Quotes/Quote.cs | 14 +- - QLNet/Settings.cs | 15 +- - QLNet/StochasticProcess.cs | 19 +- - QLNet/Termstructures/Bootstraphelper.cs | 16 +- - 23 files changed, 769 insertions(+), 535 deletions(-) - -commit 45be4c84cb61e6159bd544fadeb27f3054097121 -Author: Francois Botha -Date: Mon May 9 14:18:37 2016 +0200 - - Not sure exactly why, but it seems structs are created on the heap, not stack, so as a struct, this creates a memory leak in the testSobol* cases. Making this a class fixes it. - - QLNet/Methods/montecarlo/sample.cs | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) + Initialise empty convexity adjustment if null (#101) -commit 4224911b6ee0d79430ff555e58f03fc51b33e904 -Author: Andrea Maggiulli -Date: Wed May 4 16:49:59 2016 +0200 - - Constraint & Model refactoring. - - QLNet/Math/Optimization/Constraint.cs | 341 +++++++++++++++++++++++----------- - QLNet/Models/model.cs | 223 +++++++++++++++------- - 2 files changed, 388 insertions(+), 176 deletions(-) - -commit 06bc480c0eaf1c83b8de98c5f9e5c7136d5d5d7a -Author: Andrea Maggiulli -Date: Wed May 4 16:49:01 2016 +0200 - - Added M_2_PI const. - - QLNet/Types.cs | 1 + - 1 file changed, 1 insertion(+) - -commit 7a9f0054f5778df741f41143bb8328e6e0eda5a5 -Author: Andrea Maggiulli -Date: Wed May 4 16:47:53 2016 +0200 - - Added constraint inspector to Parameter class. - - QLNet/Models/Parameter.cs | 364 +++++++++++++++++++++++----------------------- - 1 file changed, 183 insertions(+), 181 deletions(-) - -commit 8fd649e94977fe617bb43efa2c01c353ef2f739a -Author: Andrea Maggiulli -Date: Wed May 4 16:46:38 2016 +0200 - - Fix visibility on gaussianQuadrature - - QLNet/Math/integrals/GaussianQuadratures.cs | 10 +++++----- - 1 file changed, 5 insertions(+), 5 deletions(-) - -commit 7be24fb7a924662d6b0d3740cf4fc57717116079 -Author: Andrea Maggiulli -Date: Wed May 4 16:45:31 2016 +0200 - - Abstracted PathGenerator with interface IPathGenerator to handle MultiPathGenerator in MonteCarlo simulations. - - .../Methods/montecarlo/earlyexercisepathpricer.cs | 5 +-- - QLNet/Methods/montecarlo/montecarlomodel.cs | 12 +++---- - QLNet/Methods/montecarlo/multipathgenerator.cs | 14 ++++---- - QLNet/Methods/montecarlo/path.cs | 14 +++++++- - QLNet/Methods/montecarlo/pathgenerator.cs | 16 ++++----- - .../Pricingengines/asian/mcdiscreteasianengine.cs | 2 +- - QLNet/Pricingengines/mclongstaffschwartzengine.cs | 12 ++++--- - QLNet/Pricingengines/mcsimulation.cs | 2 +- - QLNet/Pricingengines/vanilla/mcvanillaengine.cs | 40 ++++++++++++---------- - Test/T_LiborMarketModel.cs | 11 +++--- - Test/T_LiborMarketModelProcess.cs | 12 ++++--- - Test/T_PathGenerator.cs | 24 ++++++++----- - 12 files changed, 97 insertions(+), 67 deletions(-) - -commit d1bb55f3fb10c01419825b98f830bada9b15cf90 -Author: Andrea Maggiulli -Date: Wed May 4 16:23:57 2016 +0200 + QLNet/Termstructures/Yield/Ratehelpers.cs | 2 ++ + 1 file changed, 2 insertions(+) - Fixed TqrEigenDecomposition bugs. - - .../Math/matrixutilities/TqrEigenDecomposition.cs | 23 +++++++++++++++------- - 1 file changed, 16 insertions(+), 7 deletions(-) - -commit dcac95272e0d64b62bdaae5a67cc2b00d74d6539 -Merge: c38fad2 3e9974b -Author: Andrea Maggiulli -Date: Wed Apr 27 12:59:36 2016 +0200 - - Finish FittedBondCurve feature - -commit 3e9974b6b87b2ee0034e4bb2272ffeb2a8b24c97 -Author: Andrea Maggiulli -Date: Wed Apr 27 12:58:49 2016 +0200 +commit 2e80773a7773ca9caf5387a488966d628e8ef60c +Merge: a98e679 c5773c5 +Author: Andrea Maggiulli +Date: Tue Jul 12 18:04:57 2016 +0200 - Added FittedBondCurve example : Implemented B-spline basis functions, BernsteinPolynomial, FittedBondDiscountCurve, non linear fitting methods. + Merge pull request #95 from screig/develop + + Following the convention of Quant lib, default is to allow negative rates - Examples/FittedBondCurve/FittedBondCurve.cs | 596 +++++++++++++++++++++ - Examples/FittedBondCurve/FittedBondCurve.csproj | 61 +++ - .../FittedBondCurve/Properties/AssemblyInfo.cs | 36 ++ - QLNet/Extensions/ListExtension.cs | 31 ++ - QLNet/Math/BSpline.cs | 96 ++++ - QLNet/Math/BernsteinPolynomial.cs | 33 ++ - QLNet/QLNet.csproj | 5 + - .../Yield/FittedBondDiscountCurve.cs | 468 ++++++++++++++++ - .../Yield/NonLinearFittingMethods.cs | 357 ++++++++++++ - QLNet_with_Examples.sln | 264 ++++----- - 10 files changed, 1821 insertions(+), 126 deletions(-) +commit c5773c511bff4f10991243f0d9e60b9cdafc3c1d +Author: sean creighton +Date: Tue Jul 12 16:51:48 2016 +0200 -commit 21e6fb93fd97536a3ee3271c0cf7097ee87eec4b -Author: Andrea Maggiulli -Date: Wed Apr 27 12:58:22 2016 +0200 + Following the convention of Quant lib, default is to allow negative rates - Update BondHelpers & Bootstraperror. - - QLNet/Termstructures/Bootstraperror.cs | 2 +- + QLNet/QLNet.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) -commit 5fe82236583f02aa390e058a93245f3ca43d4770 -Author: Andrea Maggiulli -Date: Wed Apr 27 12:57:59 2016 +0200 - - Update BondHelpers & Bootstraperror. - - QLNet/Termstructures/Yield/Bondhelpers.cs | 236 ++++++++++++++++-------------- - 1 file changed, 130 insertions(+), 106 deletions(-) - -commit 6da2b52300303840ca23c5e65b06ac03e6c86e67 -Author: Andrea Maggiulli -Date: Wed Apr 27 12:52:21 2016 +0200 - - Fix a bug in IterativeBootstrap that make fail recalculation after interpolate. - - QLNet/Termstructures/Iterativebootstrap.cs | 31 +++++++++++++++++++++--------- - 1 file changed, 22 insertions(+), 9 deletions(-) - -commit 67a3eda25c439372718921a1d742a13c468bf532 -Author: Andrea Maggiulli -Date: Wed Apr 27 12:48:11 2016 +0200 - - Update upper bound for convergence loop in Bootstraptraits - - QLNet/Termstructures/Yield/Bootstraptraits.cs | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -commit c38fad27ad719f390c874646417e67a3c2de497c -Merge: 956e48d fe988a5 -Author: Andrea Maggiulli -Date: Thu Apr 14 12:37:57 2016 +0200 - - Finish RateHelpers Refactoring - -commit fe988a5872d33125b152296e82e9e392be7f7a73 -Author: Andrea Maggiulli -Date: Thu Apr 14 12:36:23 2016 +0200 - - Added rate helper to bootstrap on cross-currency swaps. - Added the possibility for bootstrap helpers to define their pillar date in different ways. - - QLNet/Instruments/Futures.cs | 35 + - QLNet/Instruments/MakeOIS.cs | 166 +-- - QLNet/Instruments/Makevanillaswap.cs | 153 ++- - QLNet/QLNet.csproj | 1 + - QLNet/Termstructures/Bootstraphelper.cs | 49 +- - QLNet/Termstructures/Iterativebootstrap.cs | 43 +- - QLNet/Termstructures/Yield/Ratehelpers.cs | 1704 +++++++++++++++++++--------- - 7 files changed, 1465 insertions(+), 686 deletions(-) - -commit 983da624ddadc63762344a52ea9f4cdd36427a7e -Author: Andrea Maggiulli -Date: Thu Apr 14 12:33:04 2016 +0200 - - Added max-date information to interpolated curve. - - QLNet/Termstructures/Credit/InterpolatedHazardRateCurve.cs | 11 +++++++++-- - .../Inflation/InterpolatedZeroInflationCurve.cs | 11 +++++++++-- - QLNet/Termstructures/Inflation/PiecewiseYoYInflationCurve.cs | 11 +++++++++-- - .../Termstructures/Inflation/PiecewiseZeroInflationCurve.cs | 11 +++++++++-- - QLNet/Termstructures/Volatility/InterpolatedSmileSection.cs | 9 ++++++++- - QLNet/Termstructures/Yield/DiscountCurve.cs | 11 ++++++++++- - QLNet/Termstructures/Yield/ForwardCurve.cs | 9 ++++++++- - QLNet/Termstructures/Yield/PiecewiseYieldCurve.cs | 12 ++++++++++-- - QLNet/Termstructures/Yield/ZeroCurve.cs | 10 +++++++++- - QLNet/Termstructures/interpolatedcurve.cs | 12 ++++++++++++ - 10 files changed, 93 insertions(+), 14 deletions(-) - -commit 956e48dc9252c8711ecedacd9d4443b854d79216 -Author: Andrea Maggiulli -Date: Tue Apr 5 15:08:09 2016 +0200 - - Added IncrementalStatistics test . - I have included the numerical stability test commented because actual implementation fail. - - Test/T_Stats.cs | 59 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ - 1 file changed, 59 insertions(+) - -commit f7ea18d27882bfeefa80d29b0d97b483546137d3 -Author: Andrea Maggiulli -Date: Fri Apr 1 17:04:19 2016 +0200 - - More performant mt19937 implementation. - - QLNet/Math/randomnumbers/mt19937uniformrng.cs | 240 ++++++++++++++------------ - 1 file changed, 128 insertions(+), 112 deletions(-) - -commit e4107aa155726b830cb8e1e2b2933eca03bdd677 -Author: Andrea Maggiulli -Date: Fri Apr 1 15:54:19 2016 +0200 - - Added polynomial functions and Pascal triangle coefficients. - - QLNet/Math/PascalTriangle.cs | 57 ++++++++++++++++ - QLNet/Math/PolynomialFunction.cs | 137 +++++++++++++++++++++++++++++++++++++++ - QLNet/QLNet.csproj | 2 + - 3 files changed, 196 insertions(+) - -commit 29b6a7647086861804f8d20e900589e2b01059f2 -Author: Andrea Maggiulli -Date: Fri Apr 1 15:23:31 2016 +0200 - - Added abcd functions. - - QLNet/Math/AbcdMathFunction.cs | 195 ++++++++++++++ - QLNet/Math/Optimization/CostFunction.cs | 6 + - QLNet/QLNet.csproj | 3 + - QLNet/Termstructures/Volatility/AbcdCalibration.cs | 287 +++++++++++++++++++++ - QLNet/Termstructures/Volatility/AbcdFunction.cs | 153 +++++++++++ - 5 files changed, 644 insertions(+) - -commit 98fa0344b8a9f9c609c2ac56bc45385e0daac9ba -Author: Andrea Maggiulli -Date: Fri Apr 1 12:26:37 2016 +0200 - - Added Intraday component to dates with hours, minutes, seconds and milliseconds. - Updated DayCounters ( and tests ) to include them in results. - - QLNet/Time/Date.cs | 23 +++++++++++++---- - QLNet/Time/DayCounters/Actual360.cs | 4 +-- - QLNet/Time/DayCounters/Actual365Fixed.cs | 4 +-- - QLNet/Time/DayCounters/ActualActual.cs | 16 ++++++------ - Test/T_Dates.cs | 43 ++++++++++++++++++++++++++------ - Test/T_DayCounters.cs | 28 +++++++++++++++++++++ - 6 files changed, 94 insertions(+), 24 deletions(-) - -commit 06e87cb2db78de877772fe0faa85b6aaca729803 -Author: Andrea Maggiulli -Date: Thu Mar 31 16:43:27 2016 +0200 - - Added new DayCounters tests : Business252,Thirty360_BondBasis and Thirty360_EurobondBasis - - QLNet/Time/DayCounters/Business252.cs | 29 ++--- - Test/T_DayCounters.cs | 211 +++++++++++++++++++++++++++++++++- - 2 files changed, 225 insertions(+), 15 deletions(-) - -commit 23564bc78d5ac25a893bd06634117b0ddab53c43 -Author: Andrea Maggiulli -Date: Thu Mar 31 12:05:46 2016 +0200 - - Refactoring AnalyticDiscreteGeometricAveragePriceAsianEngine class +commit a98e679f703bd3a265cac266a8e854524481df3b +Merge: c0a1463 13d4582 +Author: Andrea Maggiulli +Date: Tue Jul 12 16:12:58 2016 +0200 - ...icContinuousGeometricAveragePriceAsianEngine.cs | 1 + - ...yticDiscreteGeometricAveragePriceAsianEngine.cs | 180 +++++++++++++++++++++ - .../asian/analytic_discr_geom_av_price.cs | 180 --------------------- - QLNet/QLNet.csproj | 2 +- - 4 files changed, 182 insertions(+), 181 deletions(-) + Merge pull request #92 from s-moon/patch-1 + + Minor edits -commit 878f1203ec84b1020e110772d7eb7b7cbd7945bf +commit c0a1463a307e9c75d56229da80e71ac78b4eb7a8 +Merge: db5a222 ed6f6f8 Author: Andrea Maggiulli -Date: Thu Mar 31 12:02:12 2016 +0200 - - Refactoring AnalyticContinuousGeometricAveragePriceAsianEngine class +Date: Thu Jun 16 18:48:17 2016 +0200 - ...icContinuousGeometricAveragePriceAsianEngine.cs | 107 ++++++++++++++++++ - .../asian/analytic_cont_geom_av_price.cs | 123 --------------------- - QLNet/QLNet.csproj | 2 +- - 3 files changed, 108 insertions(+), 124 deletions(-) + Finish feature Interpolation -commit 73c40ad81f80391fd23cc74bf85750ae475db66a +commit ed6f6f82637c04fd61123c3c96b8a0821a7bdb69 Author: Andrea Maggiulli -Date: Wed Mar 30 15:00:41 2016 +0200 +Date: Thu Jun 16 18:47:06 2016 +0200 - Asian Option test : testAnalyticDiscreteGeometricAveragePriceGreeks + Added FlatExtrapolator2D - Test/T_AsianOptions.cs | 485 +++++++++++++++++++++++++------------------------ - 1 file changed, 243 insertions(+), 242 deletions(-) + QLNet/Math/Interpolations/FlatExtrapolator2D.cs | 75 +++++++++++++++++++++++++ + QLNet/QLNet.csproj | 1 + + 2 files changed, 76 insertions(+) -commit d86962818ae60c7ecba0154590ac3b9ed87828bd +commit 47b70c0d6f49ef5b0902dd16aae8ebdc79866b3c Author: Andrea Maggiulli -Date: Wed Mar 30 12:05:13 2016 +0200 +Date: Thu Jun 16 18:36:58 2016 +0200 - Added AnalyticDiscreteGeometricAverageStrikeAsianEngine with test. + Added Mixed Interpolation - ...ticDiscreteGeometricAverageStrikeAsianEngine.cs | 144 +++++++++++++++++++++ + QLNet/Math/Interpolation.cs | 4 +- + .../BackwardflatLinearInterpolation.cs | 19 +- + QLNet/Math/Interpolations/MixedInterpolation.cs | 256 +++++++++++++++++++++ QLNet/QLNet.csproj | 1 + - Test/T_AsianOptions.cs | 57 ++++++++ - 3 files changed, 202 insertions(+) + 4 files changed, 275 insertions(+), 5 deletions(-) -commit 05b7f94d5ad5ac8d13108e5357780e4d56ff8b81 +commit 9f7b57ba95ce9751e070d7dbb692a1e5c3ab40fe Author: Andrea Maggiulli -Date: Wed Mar 30 11:37:16 2016 +0200 +Date: Thu Jun 16 17:11:27 2016 +0200 - Asian Option test : testAnalyticDiscreteGeometricAveragePrice + Added BackwardflatLinear Interpolation. - Test/T_AsianOptions.cs | 122 ++++++++++++++++++++++++------------------------- - 1 file changed, 59 insertions(+), 63 deletions(-) + .../BackwardflatLinearInterpolation.cs | 72 ++++++++++++++++++++++ + QLNet/QLNet.csproj | 1 + + 2 files changed, 73 insertions(+) -commit d6143c9da5b87b9f7b96c44b7c003152d82022b4 +commit cbd80ad20df8f5fa2153d83cc6f5c9d59d66cd88 Author: Andrea Maggiulli -Date: Wed Mar 30 11:32:33 2016 +0200 +Date: Thu Jun 16 15:36:36 2016 +0200 - Asian Option test : AnalyticContinuousGeometricAveragePriceGreeks + Added AbcdInterpolation. - Test/T_AsianOptions.cs | 331 ++++++++++++++++++++++++------------------------- - 1 file changed, 159 insertions(+), 172 deletions(-) + QLNet/Math/Interpolations/Abcdinterpolation.cs | 253 +++++++++++++++++++++++++ + QLNet/QLNet.csproj | 1 + + 2 files changed, 254 insertions(+) -commit 15935ec0302702346031d19d73f37ddb8f01ca0d +commit 452d36df228dd9ae0807bb15cb055166be39aefa Author: Andrea Maggiulli -Date: Wed Mar 30 11:21:46 2016 +0200 +Date: Thu Jun 16 15:36:13 2016 +0200 - Asian Option test : AnalyticContinuousGeometricAveragePrice + Interpolation update & refactoring. - QLNet/Instruments/AsianOption.cs | 5 +- - Test/T_AsianOptions.cs | 2244 ++++++++++++++++++++------------------ - 2 files changed, 1170 insertions(+), 1079 deletions(-) + QLNet/Math/Interpolation.cs | 299 +++++++++++++++++++++++--------------------- + 1 file changed, 157 insertions(+), 142 deletions(-) -commit f063eeab71f67c0ebeaa418f2c33d5054565fd18 +commit db5a222e703e7a2cb0f9d19f1c76535fa315130b Author: Andrea Maggiulli -Date: Wed Mar 30 11:20:51 2016 +0200 +Date: Wed Jun 15 10:55:23 2016 +0200 - Fix AnalyticDiscreteGeometricAveragePriceAsianEngine bug on calculate function. + Added Ukrainian hryvnia & updated Ukraine holidays. - .../asian/analytic_discr_geom_av_price.cs | 315 ++++++++++----------- - 1 file changed, 156 insertions(+), 159 deletions(-) + QLNet/Currencies/Europe.cs | 11 +++++++++++ + QLNet/Time/Calendars/Ukraine.cs | 27 +++++++++++++++------------ + 2 files changed, 26 insertions(+), 12 deletions(-) -commit 42578a8a38fd597a9363460dc2f2503b17f068d8 -Author: Andrea Maggiulli -Date: Tue Mar 29 18:08:26 2016 +0200 - - Added BFGS ( Broyden-Fletcher-Goldfarb-Shanno ) algorithm. +commit 312075a9dd06842d4008f7496e840c639c680e9b +Merge: 7ce1ca0 e73e494 +Author: Andrea Maggiulli +Date: Wed Jun 15 10:12:18 2016 +0200 - QLNet/Math/Optimization/BFGS.cs | 105 ++++++++++++++++++++++++++++++++++++++++ - QLNet/QLNet.csproj | 1 + - Test/T_Optimizers.cs | 12 +++-- - 3 files changed, 113 insertions(+), 5 deletions(-) + Merge pull request #91 from igitur/correctly-report-irregular-last-period-in-schedule + + Correctly report irregular last period in schedule. -commit 88751c78c60eb2f029dcf478fbffbc467b72f066 -Author: Andrea Maggiulli -Date: Tue Mar 29 17:44:35 2016 +0200 +commit e73e4943b4fbf80f9de610eb248c427d70a094a9 +Author: Francois Botha +Date: Tue Jun 14 18:43:26 2016 +0200 - Added Goldstein line-search method. + Correctly report irregular last period in schedule. - QLNet/Math/Optimization/GoldsteinLineSearch.cs | 103 +++++++++++++++++++++++++ - QLNet/QLNet.csproj | 1 + - Test/T_Optimizers.cs | 31 +++++++- - 3 files changed, 131 insertions(+), 4 deletions(-) + QLNet/Time/Schedule.cs | 80 ++++++++++++++++++++++++++------------------------ + Test/T_Schedule.cs | 31 ++++++++++++++++++- + 2 files changed, 71 insertions(+), 40 deletions(-) -commit c25a14b2ff74154e8ef4a2f2c790833099ac16c2 +commit 7ce1ca01df1809cd4bbae3885b92aca99eedc49a +Merge: fc4ec15 698ab47 Author: Andrea Maggiulli -Date: Tue Mar 29 17:39:11 2016 +0200 +Date: Tue Jun 14 11:02:34 2016 +0200 - Updated all Optimization Method classes. + Finish Curves Refactoring Feature - QLNet/Math/Optimization/ConjugateGradient.cs | 137 +++++------------------ - QLNet/Math/Optimization/LineSearchBasedMethod.cs | 124 ++++++++++++++++---- - QLNet/Math/Optimization/SteepestDescent.cs | 101 ++++------------- - QLNet/Math/Optimization/method.cs | 19 ++-- - 4 files changed, 165 insertions(+), 216 deletions(-) +commit 13d45829eb24aa07a66171c73a85f933820c27a2 +Author: Stephen Moon +Date: Fri Jun 10 19:11:15 2016 +0100 -commit 7876550c21708a13f7e6ff1d292705d31c4cb27b -Author: Andrea Maggiulli -Date: Tue Mar 29 14:26:49 2016 +0200 - - Improve consistency between caplet stripping and pricing. + Made some minor changes to grammar and text. - QLNet/Termstructures/Volatility/Optionlet/OptionletStripper1.cs | 2 +- - Test/T_OptionletStripper.cs | 2 +- - 2 files changed, 2 insertions(+), 2 deletions(-) + README.md | 31 +++++++++++++++---------------- + 1 file changed, 15 insertions(+), 16 deletions(-) -commit 7e88c65f39ce1646882a821f773d76726d874cf4 +commit 698ab47a981ddffd9e13f8047fb7bfa1fd630f6f Author: Andrea Maggiulli -Date: Thu Mar 24 17:48:48 2016 +0100 +Date: Fri Jun 3 11:59:04 2016 +0200 - Retrieve inflation fixings from the first day of the month. + Fixed TermStructure abstract classes - QLNet/Indexes/InflationIndex.cs | 47 ++++++++++++++++++++++------------------- - 1 file changed, 25 insertions(+), 22 deletions(-) + QLNet/Termstructures/Credit/HazardRateStructure.cs | 7 +++---- + .../DefaultProbabilityTermStructure.cs | 9 ++++----- + QLNet/Termstructures/InflationTermStructure.cs | 23 +++++++++++----------- + QLNet/Termstructures/TermStructure.cs | 10 +++++----- + .../Bond/CallableBondVolatilityStructure.cs | 16 +++++++-------- + .../CapFloor/CapFloorTermVolatilityStructure.cs | 8 ++++---- + .../Volatility/Inflation/CPIVolatilitySurface.cs | 10 +++++----- + .../yoyinflationoptionletvolatilitystructure.cs | 13 +++--------- + .../Optionlet/OptionletVolatilityStructure.cs | 9 +++++---- + .../Volatility/equityfx/BlackVolTermStructure.cs | 15 +++++++------- + .../Volatility/equityfx/LocalVolTermStructure.cs | 7 ++++--- + .../swaption/SwaptionVolatilityStructure.cs | 9 +++++---- + .../Volatility/swaption/swaptionvoldiscrete.cs | 3 ++- + QLNet/Termstructures/Yield/Zeroyieldstructure.cs | 5 +++-- + QLNet/Termstructures/YieldTermStructure.cs | 6 +++--- + QLNet/Termstructures/voltermstructure.cs | 7 ++++--- + Test/T_Inflation.cs | 6 +++--- + Test/T_InflationCapFloorTest.cs | 8 ++++---- + Test/T_InflationCapFlooredCouponTest.cs | 6 +++--- + 19 files changed, 86 insertions(+), 91 deletions(-) -commit d6ad5d4f3da52bbed4e90e7caf9f63be4b57a2c7 -Merge: d5907ef 4b54473 +commit fc4ec15264868203c1004421ad55866c077fabf3 +Merge: 09c52b6 2c49bce Author: Andrea Maggiulli -Date: Thu Mar 24 17:19:19 2016 +0100 +Date: Thu Jun 2 09:43:39 2016 +0200 - Merge branch 'feature/KerkhofSeasonailty' into develop + Finish index feature -commit 4b544735a4208c94642eccb849270f38a1278c8c +commit 2c49bce65d523306b6b542d6fdb84f1ef3399152 Author: Andrea Maggiulli -Date: Thu Mar 24 16:52:10 2016 +0100 - - Added Kerkhof seasonailty model. +Date: Wed Jun 1 13:56:57 2016 +0200 - QLNet/Termstructures/Inflation/Seasonality.cs | 64 +++++++++++++++++++++++++++ - 1 file changed, 64 insertions(+) - -commit d5907efa2dffb858773457914ff1de660789b599 -Merge: ded5d2a 6c75291 -Author: Andrea Maggiulli -Date: Thu Mar 24 16:26:17 2016 +0100 + Fix project configuration. - Finish DateTime feature + QLNet/Cashflows/RangeAccrual.cs | 667 ++++++++++++++++++++++++++++++++++++++++ + QLNet/QLNet.csproj | 1 - + 2 files changed, 667 insertions(+), 1 deletion(-) -commit 6c7529124f72d6d15f663c20a4c5f40f8af7415b +commit ed53c11c20b28875fdf5e8d54bcbf79ea42ccd4a Author: Andrea Maggiulli -Date: Thu Mar 24 16:24:41 2016 +0100 +Date: Wed Jun 1 13:54:15 2016 +0200 - Added Christmas Eve to BOVESPA holidays. + Added CounterpartyAdjSwapEngine engine with example program. - QLNet/Time/Calendars/brazil.cs | 89 ++++++++++++++++++++++-------------------- - 1 file changed, 46 insertions(+), 43 deletions(-) + Examples/CVAIRS/CVAIRS.cs | 189 +++++++++++++++++ + Examples/CVAIRS/CVAIRS.csproj | 61 ++++++ + Examples/CVAIRS/Properties/AssemblyInfo.cs | 36 ++++ + QLNet/Instruments/VanillaSwap.cs | 4 +- + .../Swap/CounterpartyAdjSwapEngine.cs | 232 +++++++++++++++++++++ + QLNet/Pricingengines/Swap/Discountingswapengine.cs | 34 +-- + QLNet/QLNet.csproj | 2 + + QLNet_with_Examples.sln | 12 ++ + 8 files changed, 556 insertions(+), 14 deletions(-) -commit debd31bfd895862730c6e0aa8519d907022e9f5c +commit a16b9cf81e96db6dd7c36c1f0ca0a52ae047f466 Author: Andrea Maggiulli -Date: Thu Mar 24 16:12:59 2016 +0100 +Date: Wed Jun 1 13:53:35 2016 +0200 - Removed MLK day from list of US holidays before 1983. + Updated isExpired() methods with Event interface. - QLNet/Time/Calendars/UnitedStates.cs | 177 ++++++++++++++++++----------------- - 1 file changed, 89 insertions(+), 88 deletions(-) + QLNet/Event.cs | 17 ++++++++++++++++- + QLNet/Instruments/Instrument.cs | 2 +- + QLNet/Instruments/MultiAssetOption.cs | 2 +- + QLNet/Instruments/OneAssetOption.cs | 2 +- + QLNet/Instruments/Swaption.cs | 2 +- + QLNet/Instruments/forward.cs | 6 +----- + QLNet/Instruments/forwardrateagreement.cs | 6 +----- + 7 files changed, 22 insertions(+), 15 deletions(-) -commit 6bd5d5b83006422dc48980e886a795d40056aa9e -Author: Andrea Maggiulli -Date: Thu Mar 24 16:08:07 2016 +0100 +commit 09c52b6534c4c67d93fe2e28a10b9f2b63a6d3b2 +Author: Francois Botha +Date: Mon May 30 17:40:38 2016 +0200 + + Implemented Lagrange boundary condition for cubic interpolation + + QLNet/Math/Interpolations/CubicInterpolation.cs | 81 ++++++++++++++++++------- + 1 file changed, 59 insertions(+), 22 deletions(-) + +commit 437c40be02c4ed4b21619737da89f20258909d90 +Author: Andrea Maggiulli +Date: Mon May 30 11:36:26 2016 +0200 + + CashFlows refactoring & update. - Part 1 + + QLNet/Cashflows/CPICoupon.cs | 5 +- + QLNet/Cashflows/CappedFlooredCoupon.cs | 18 +- + QLNet/Cashflows/CappedFlooredYoYInflationCoupon.cs | 4 +- + QLNet/Cashflows/CashFlows.cs | 20 +- + QLNet/Cashflows/Cashflowvectors.cs | 15 +- + QLNet/Cashflows/CmsCoupon.cs | 5 +- + QLNet/Cashflows/ConundrumPricer.cs | 6 +- + QLNet/Cashflows/Coupon.cs | 112 ++-- + QLNet/Cashflows/CouponPricer.cs | 720 ++++++++++++--------- + QLNet/Cashflows/DigitalCoupon.cs | 2 +- + QLNet/Cashflows/FixedRateCoupon.cs | 26 +- + QLNet/Cashflows/FloatingRateCoupon.cs | 14 +- + QLNet/Cashflows/Iborcoupon.cs | 140 ++-- + QLNet/Cashflows/InflationCoupon.cs | 4 +- + QLNet/Cashflows/OvernightIndexedCoupon.cs | 7 +- + QLNet/Cashflows/averagebmacoupon.cs | 462 ++++++------- + QLNet/Indexes/IBORIndex.cs | 2 +- + QLNet/Instruments/Bonds/AmortizingBond.cs | 22 +- + QLNet/Instruments/Bonds/MBSFixedRateBond.cs | 2 +- + QLNet/Instruments/Loan.cs | 2 +- + QLNet/QLNet.csproj | 3 +- + .../Optionlet/OptionletVolatilityStructure.cs | 4 + + Test/T_CashFlows.cs | 2 +- + 23 files changed, 876 insertions(+), 721 deletions(-) + +commit c6c116ca526b67b8cf56241092a9e1101c7c8079 +Author: Andrea Maggiulli +Date: Thu May 26 18:18:14 2016 +0200 + + Indexes refactoring & update + + QLNet/Index.cs | 206 +++++---- + QLNet/Indexes/IBORIndex.cs | 188 ++++---- + QLNet/Indexes/InflationIndex.cs | 849 ++++++++++++++++++------------------- + QLNet/Indexes/InterestRateIndex.cs | 262 ++++++------ + QLNet/Indexes/Swapindex.cs | 424 +++++++++--------- + QLNet/Indexes/bmaindex.cs | 169 ++++---- + QLNet/QLNet.csproj | 4 +- + 7 files changed, 1085 insertions(+), 1017 deletions(-) + +commit fed563b23f78d6893066cb1a795c670f82929d1e +Author: Francois Botha +Date: Wed May 25 17:52:12 2016 +0200 - Added new Mountain Day holiday for Japan calendar. + Fix tests to Asserts instead of Console.WriteLine statements (#87) - QLNet/Time/Calendars/japan.cs | 65 ++++++++++++++++++++++--------------------- - 1 file changed, 34 insertions(+), 31 deletions(-) + Test/T_Piecewiseyieldcurve.cs | 71 ++++++++++++++++++++----------------------- + 1 file changed, 33 insertions(+), 38 deletions(-) -commit 38429dc0d8d2902fde1054606c01a2b1bcca039d -Author: Andrea Maggiulli -Date: Thu Mar 24 16:02:34 2016 +0100 +commit 9529484b3086c0af95e76926526c2baf997e4212 +Author: Francois Botha +Date: Wed May 25 17:39:08 2016 +0200 - Updated South Korean calendar until the end of 2032. + previousData should be initialized as a NEW List, else it is just a reference to data_ List and will change when data_ changes. (#86) - QLNet/Time/Calendars/southkorea.cs | 102 ++++++++++++++++++++++++++++--------- - 1 file changed, 77 insertions(+), 25 deletions(-) + QLNet/Termstructures/Iterativebootstrap.cs | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) -commit e7e7b7a3177eebf41e268f37727d1c8d9344cd79 +commit c1342e901dbb106aa58dcf75659e3e7e274c764c Author: Andrea Maggiulli -Date: Thu Mar 24 14:58:42 2016 +0100 +Date: Tue May 24 15:24:17 2016 +0200 - Added ECB reserve maintenance periods for 2016. + Fixed links to documentation for LIBOR indexes & reformat code. - QLNet/Time/ECB.cs | 5 +++-- - 1 file changed, 3 insertions(+), 2 deletions(-) + QLNet/Indexes/Ibor/Audlibor.cs | 41 ++- + QLNet/Indexes/Ibor/Cadlibor.cs | 72 +++-- + QLNet/Indexes/Ibor/Chflibor.cs | 54 ++-- + QLNet/Indexes/Ibor/Dkklibor.cs | 40 ++- + QLNet/Indexes/Ibor/Eurlibor.cs | 587 ++++++++++++++++++++++------------------- + QLNet/Indexes/Ibor/Gbplibor.cs | 66 +++-- + QLNet/Indexes/Ibor/Jpylibor.cs | 58 ++-- + QLNet/Indexes/Ibor/Libor.cs | 251 ++++++++++-------- + QLNet/Indexes/Ibor/Nzdlibor.cs | 41 ++- + QLNet/Indexes/Ibor/Seklibor.cs | 40 +-- + QLNet/Indexes/Ibor/Trylibor.cs | 43 +-- + QLNet/Indexes/Ibor/Usdlibor.cs | 65 +++-- + 12 files changed, 728 insertions(+), 630 deletions(-) -commit 4959410835c496f9de498da2798738c50664d4fe +commit e3a58fde9160783faafca75f1953283c1bb7d2b9 Author: Andrea Maggiulli -Date: Thu Mar 24 14:39:00 2016 +0100 +Date: Tue May 24 10:24:56 2016 +0200 - Added Israelian calendar. + Fix tests , if something wrong a test have to fail. - QLNet/QLNet.csproj | 1 + - QLNet/Time/Calendars/Israel.cs | 402 +++++++++++++++++++++++++++++++++++++++++ - 2 files changed, 403 insertions(+) + Test/T_Bonds.cs | 12 ++++++------ + Test/T_Swaps.cs | 1 - + 2 files changed, 6 insertions(+), 7 deletions(-) -commit 6dd29eac99ed24bee63ed64f2c55e1cf5e937bbd +commit 28948c78dc98a099b64cd330885f4ee3c5ccba2f Author: Andrea Maggiulli -Date: Thu Mar 24 12:46:50 2016 +0100 +Date: Tue May 24 10:15:10 2016 +0200 - Added Romanian calendar. + Fix tests , if something wrong a test have to fail. - QLNet/QLNet.csproj | 1 + - QLNet/Time/Calendars/Romania.cs | 86 +++++++++++++++++++++++++++++++++++++++++ - 2 files changed, 87 insertions(+) + Test/T_TermStructures.cs | 22 +++++++++++----------- + 1 file changed, 11 insertions(+), 11 deletions(-) -commit ded5d2aad9a15baa163bc4c48e845d696cf25e63 -Merge: 03e7720 8e6346f +commit c9306af2ffab1dd546090c4c66acd9fbacbb132f Author: Andrea Maggiulli -Date: Thu Mar 24 12:03:18 2016 +0100 +Date: Mon May 23 14:07:49 2016 +0200 - Fix Indentation ( CID 78809 ) + Disabled failing test. -commit 8e6346f8f4abec76f423863342085b7483b209cb -Author: Andrea Maggiulli -Date: Thu Mar 24 12:02:07 2016 +0100 - - Fix Indentation ( CID 78809 ) + Test/T_Piecewiseyieldcurve.cs | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) - QLNet/Termstructures/Volatility/InterpolatedSmileSection.cs | 3 ++- - 1 file changed, 2 insertions(+), 1 deletion(-) \ No newline at end of file +commit 3eac6d3949e0e3cb2aa1ee531847385f0f18dd86 +Author: Andrea Maggiulli +Date: Mon May 23 13:58:24 2016 +0200 + + Fixed null values in Pricing Engines, thx @tomislav-t for spotting it. + + QLNet/Pricingengines/mclongstaffschwartzengine.cs | 368 +++++++------- + QLNet/Pricingengines/mcsimulation.cs | 46 +- + .../vanilla/MCEuropeanHestonEngine.cs | 10 +- + .../vanilla/MCHestonHullWhiteEngine.cs | 12 +- + QLNet/Pricingengines/vanilla/mcamericanengine.cs | 533 +++++++++++---------- + QLNet/Pricingengines/vanilla/mceuropeanengine.cs | 312 ++++++------ + QLNet/Pricingengines/vanilla/mcvanillaengine.cs | 35 +- + 7 files changed, 709 insertions(+), 607 deletions(-) + +commit 51ac0d337d6b145da36703afa35bd374e90958d1 +Author: Andrea Maggiulli +Date: Fri May 20 16:36:47 2016 +0200 + + Fixed all tests Dispose and making IndexHistoryCleaner disposable too. + + Test/T_AmericanOption.cs | 230 +++++++++++++++++--------------- + Test/T_AssetSwap.cs | 25 +++- + Test/T_Bermudanswaption.cs | 19 ++- + Test/T_Bonds.cs | 151 +++++++++++---------- + Test/T_CapFloor.cs | 18 ++- + Test/T_EuropeanOption.cs | 59 +++----- + Test/T_HybridHestonHullWhiteProcess.cs | 32 ++--- + Test/T_InflationCapFloorTest.cs | 17 ++- + Test/T_InflationCapFlooredCouponTest.cs | 18 ++- + Test/T_LiborMarketModel.cs | 35 ++--- + Test/T_LiborMarketModelProcess.cs | 36 +++-- + Test/T_LinearLeastSquaresRegression.cs | 42 +++--- + Test/T_OptionletStripper.cs | 23 ++-- + Test/T_OvernightIndexedSwap.cs | 20 ++- + Test/T_PathGenerator.cs | 31 +++-- + Test/T_Piecewiseyieldcurve.cs | 31 +++-- + Test/T_Swaps.cs | 46 +++---- + Test/T_Swaption.cs | 47 +++---- + Test/T_SwaptionVolatilitymatrix.cs | 34 ++--- + Test/T_TermStructures.cs | 50 +++---- + Test/Utilities.cs | 7 +- + 21 files changed, 525 insertions(+), 446 deletions(-) diff --git a/Examples/BermudanSwaption/Properties/AssemblyInfo.cs b/Examples/BermudanSwaption/Properties/AssemblyInfo.cs index 3229526c3..6b9816244 100644 --- a/Examples/BermudanSwaption/Properties/AssemblyInfo.cs +++ b/Examples/BermudanSwaption/Properties/AssemblyInfo.cs @@ -5,12 +5,12 @@ // Le informazioni generali relative a un assembly sono controllate dal seguente // insieme di attributi. Per modificare le informazioni associate a un assembly // occorre quindi modificare i valori di questi attributi. -[assembly: AssemblyTitle("BermudanSwaption")] +[assembly: AssemblyTitle( "QLNet BermudanSwaption Example" )] [assembly: AssemblyDescription("")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("")] -[assembly: AssemblyProduct("BermudanSwaption")] -[assembly: AssemblyCopyright("Copyright © 2010")] +[assembly: AssemblyProduct( "QLNet Examples" )] +[assembly: AssemblyCopyright( "Copyright (c) 2008-2016 Andrea Maggiulli (a.maggiulli@gmail.com)" )] [assembly: AssemblyTrademark("")] [assembly: AssemblyCulture("")] @@ -32,5 +32,5 @@ // È possibile specificare tutti i valori oppure impostare i valori predefiniti per i numeri relativi alla build e alla revisione // utilizzando l'asterisco (*) come descritto di seguito: // [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("1.7.0.0")] -[assembly: AssemblyFileVersion("1.7.0.0")] +[assembly: AssemblyVersion("1.8.0.0")] +[assembly: AssemblyFileVersion("1.8.0.0")] diff --git a/Examples/Bonds/Properties/AssemblyInfo.cs b/Examples/Bonds/Properties/AssemblyInfo.cs index 8d490f65a..9fe0fa58e 100644 --- a/Examples/Bonds/Properties/AssemblyInfo.cs +++ b/Examples/Bonds/Properties/AssemblyInfo.cs @@ -5,12 +5,12 @@ // General Information about an assembly is controlled through the following // set of attributes. Change these attribute values to modify the information // associated with an assembly. -[assembly: AssemblyTitle("Bonds")] +[assembly: AssemblyTitle( "QLNet Bonds Example" )] [assembly: AssemblyDescription("")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("")] -[assembly: AssemblyProduct("Bonds")] -[assembly: AssemblyCopyright("Copyright © 2008")] +[assembly: AssemblyProduct( "QLNet Examples" )] +[assembly: AssemblyCopyright( "Copyright (c) 2008-2016 Andrea Maggiulli (a.maggiulli@gmail.com)" )] [assembly: AssemblyTrademark("")] [assembly: AssemblyCulture("")] @@ -32,5 +32,5 @@ // You can specify all the values or you can default the Build and Revision Numbers // by using the '*' as shown below: // [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("1.7.0.0")] -[assembly: AssemblyFileVersion("1.7.0.0")] +[assembly: AssemblyVersion("1.8.0.0")] +[assembly: AssemblyFileVersion("1.8.0.0")] diff --git a/Examples/CVAIRS/CVAIRS.cs b/Examples/CVAIRS/CVAIRS.cs new file mode 100644 index 000000000..f8383eab7 --- /dev/null +++ b/Examples/CVAIRS/CVAIRS.cs @@ -0,0 +1,189 @@ +// Copyright (C) 2008-2016 Andrea Maggiulli (a.maggiulli@gmail.com) +// +// This file is part of QLNet Project https://github.com/amaggiulli/qlnet +// QLNet is free software: you can redistribute it and/or modify it +// under the terms of the QLNet license. You should have received a +// copy of the license along with this program; if not, license is +// available online at . +// +// QLNet is a based on QuantLib, a free-software/open-source library +// for financial quantitative analysts and developers - http://quantlib.org/ +// The QuantLib license is available online at http://quantlib.org/license.shtml. +// +// This program is distributed in the hope that it will be useful, but WITHOUT +// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +// FOR A PARTICULAR PURPOSE. See the license for more details. +using System; +using System.Collections.Generic; +using QLNet; + +namespace CVAIRS +{ + class CVAIRS + { + static void Main( string[] args ) + { + try + { + + DateTime timer = DateTime.Now; + Calendar calendar = new TARGET(); + Date todaysDate = new Date(10,Month.March, 2004); + // must be a business day + todaysDate = calendar.adjust(todaysDate); + + Settings.setEvaluationDate(todaysDate); + + IborIndex yieldIndx = new Euribor3M(); + int[] tenorsSwapMkt = {5,10,15,20,25,30}; + + // rates ignoring counterparty risk: + double[] ratesSwapmkt = {.03249,.04074,.04463,.04675,.04775,.04811}; + + List swapHelpers = new List(); + for (int i = 0; i < tenorsSwapMkt.Length; i++) + swapHelpers.Add(new SwapRateHelper(new Handle(new SimpleQuote(ratesSwapmkt[i])), + new Period(tenorsSwapMkt[i],TimeUnit.Years), + new TARGET(), + Frequency.Quarterly, + BusinessDayConvention.ModifiedFollowing, + new ActualActual(ActualActual.Convention.ISDA), + yieldIndx)); + + YieldTermStructure swapTS = new PiecewiseYieldCurve(2, new TARGET(), swapHelpers, + new ActualActual(ActualActual.Convention.ISDA)); + swapTS.enableExtrapolation(); + + IPricingEngine riskFreeEngine = new DiscountingSwapEngine(new Handle(swapTS)); + + List> defaultIntensityTS = + new List>(); + + int[] defaultTenors = {0,12,36,60,84,120,180,240,300,360}; // months + // Three risk levels: + double[] intensitiesLow = {0.0036,0.0036,0.0065,0.0099,0.0111,0.0177,0.0177,0.0177,0.0177,0.0177,0.0177}; + double[] intensitiesMedium = {0.0202,0.0202,0.0231,0.0266,0.0278,0.0349,0.0349,0.0349,0.0349,0.0349,0.0349}; + double[] intensitiesHigh = {0.0534,0.0534,0.0564,0.06,0.0614,0.0696,0.0696,0.0696,0.0696,0.0696,0.0696}; + // Recovery rates: + double ctptyRRLow = 0.4, ctptyRRMedium = 0.35, ctptyRRHigh = 0.3; + + List defaultTSDates = new List(); + List intesitiesVLow = new List(), + intesitiesVMedium = new List(), + intesitiesVHigh = new List(); + + for (int i = 0; i < defaultTenors.Length; i++) + { + defaultTSDates.Add(new TARGET().advance(todaysDate,new Period(defaultTenors[i], TimeUnit.Months))); + intesitiesVLow.Add(intensitiesLow[i]); + intesitiesVMedium.Add(intensitiesMedium[i]); + intesitiesVHigh.Add(intensitiesHigh[i]); + } + + defaultIntensityTS.Add(new Handle( + new InterpolatedHazardRateCurve( + defaultTSDates, + intesitiesVLow, + new Actual360(), + new TARGET()))); + defaultIntensityTS.Add(new Handle( + new InterpolatedHazardRateCurve( + defaultTSDates, + intesitiesVMedium, + new Actual360(), + new TARGET()))); + defaultIntensityTS.Add(new Handle( + new InterpolatedHazardRateCurve( + defaultTSDates, + intesitiesVHigh, + new Actual360(), + new TARGET()))); + + double blackVol = 0.15; + IPricingEngine ctptySwapCvaLow = new CounterpartyAdjSwapEngine(new Handle(swapTS), + blackVol,defaultIntensityTS[0],ctptyRRLow); + + IPricingEngine ctptySwapCvaMedium = new CounterpartyAdjSwapEngine(new Handle(swapTS), + blackVol,defaultIntensityTS[1],ctptyRRMedium); + + IPricingEngine ctptySwapCvaHigh = new CounterpartyAdjSwapEngine(new Handle(swapTS), + blackVol,defaultIntensityTS[2],ctptyRRHigh); + + defaultIntensityTS[0].link.enableExtrapolation(); + defaultIntensityTS[1].link.enableExtrapolation(); + defaultIntensityTS[2].link.enableExtrapolation(); + + // SWAP RISKY REPRICE---------------------------------------------- + + // fixed leg + Frequency fixedLegFrequency = Frequency.Quarterly; + BusinessDayConvention fixedLegConvention = BusinessDayConvention.ModifiedFollowing; + DayCounter fixedLegDayCounter = new ActualActual(ActualActual.Convention.ISDA); + DayCounter floatingLegDayCounter = new ActualActual(ActualActual.Convention.ISDA); + + VanillaSwap.Type swapType = + //VanillaSwap::Receiver ; + VanillaSwap.Type.Payer; + IborIndex yieldIndxS = new Euribor3M(new Handle(swapTS)); + List riskySwaps = new List(); + for (int i = 0; i < tenorsSwapMkt.Length; i++) + riskySwaps.Add(new MakeVanillaSwap(new Period(tenorsSwapMkt[i],TimeUnit.Years), + yieldIndxS, + ratesSwapmkt[i], + new Period(0,TimeUnit.Days)) + .withSettlementDays(2) + .withFixedLegDayCount(fixedLegDayCounter) + .withFixedLegTenor(new Period(fixedLegFrequency)) + .withFixedLegConvention(fixedLegConvention) + .withFixedLegTerminationDateConvention(fixedLegConvention) + .withFixedLegCalendar(calendar) + .withFloatingLegCalendar(calendar) + .withNominal(100.0) + .withType(swapType).value()); + + Console.WriteLine("-- Correction in the contract fix rate in bp --" ); + /* The paper plots correction to be substracted, here is printed + with its sign + */ + for (int i = 0; i < riskySwaps.Count; i++) + { + riskySwaps[i].setPricingEngine(riskFreeEngine); + // should recover the input here: + double nonRiskyFair = riskySwaps[i].fairRate(); + Console.Write( (tenorsSwapMkt[i]).ToString( "0" ).PadLeft( 6 ) ); + Console.Write( " | " + nonRiskyFair.ToString( "P3" ).PadLeft( 6 ) ); + // Low Risk: + riskySwaps[i].setPricingEngine(ctptySwapCvaLow); + Console.Write( " | " + ( 10000.0 * ( riskySwaps[i].fairRate() - nonRiskyFair ) ).ToString( "#0.00" ).PadLeft( 6 ) ); + //cout << " | " << setw(6) << riskySwaps[i].NPV() ; + + // Medium Risk: + riskySwaps[i].setPricingEngine(ctptySwapCvaMedium); + Console.Write( " | " + ( 10000.0 * ( riskySwaps[i].fairRate() - nonRiskyFair ) ).ToString( "#0.00" ).PadLeft( 6 ) ); + //cout << " | " << setw(6) << riskySwaps[i].NPV() ; + + riskySwaps[i].setPricingEngine(ctptySwapCvaHigh); + Console.Write( " | " + ( 10000.0 * ( riskySwaps[i].fairRate() - nonRiskyFair ) ).ToString( "#0.00" ).PadLeft( 6 ) ); + //cout << " | " << setw(6) << riskySwaps[i].NPV() ; + + Console.WriteLine(); + } + + Console.WriteLine(); + + Console.WriteLine(" \nRun completed in {0}", DateTime.Now - timer); + Console.WriteLine(); + + Console.Write("Press any key to continue ..."); + Console.ReadKey(); + + } + catch (Exception e) + { + Console.Write(e.Message); + Console.Write( "Press any key to continue ..." ); + Console.ReadKey(); + } + } + } +} diff --git a/Examples/CVAIRS/CVAIRS.csproj b/Examples/CVAIRS/CVAIRS.csproj new file mode 100644 index 000000000..ea8cd76ca --- /dev/null +++ b/Examples/CVAIRS/CVAIRS.csproj @@ -0,0 +1,61 @@ + + + + + Debug + AnyCPU + {46817C48-9DE1-4A56-82CF-3B7A3BEF712B} + Exe + Properties + CVAIRS + CVAIRS + v4.0 + 512 + + + AnyCPU + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + AnyCPU + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + + + + + + + + + + + + + + {f6e762bd-dcdf-4ca0-abad-cb21c7d03bec} + QLNet + + + + + \ No newline at end of file diff --git a/Examples/CVAIRS/Properties/AssemblyInfo.cs b/Examples/CVAIRS/Properties/AssemblyInfo.cs new file mode 100644 index 000000000..3eaa44bb9 --- /dev/null +++ b/Examples/CVAIRS/Properties/AssemblyInfo.cs @@ -0,0 +1,36 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle( "QLNet CVAIRS Example" )] +[assembly: AssemblyDescription( "" )] +[assembly: AssemblyConfiguration( "" )] +[assembly: AssemblyCompany( "" )] +[assembly: AssemblyProduct( "QLNet Examples" )] +[assembly: AssemblyCopyright( "Copyright (c) 2008-2016 Andrea Maggiulli (a.maggiulli@gmail.com)" )] +[assembly: AssemblyTrademark( "" )] +[assembly: AssemblyCulture( "" )] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible( false )] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[assembly: Guid( "c4a8eb32-aee9-471f-98f0-43dc343ad495" )] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the values or you can default the Build and Revision Numbers +// by using the '*' as shown below: +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion( "1.8.0.0" )] +[assembly: AssemblyFileVersion( "1.8.0.0" )] diff --git a/Examples/CallableBonds/Properties/AssemblyInfo.cs b/Examples/CallableBonds/Properties/AssemblyInfo.cs index 48afbe0dc..aff426270 100644 --- a/Examples/CallableBonds/Properties/AssemblyInfo.cs +++ b/Examples/CallableBonds/Properties/AssemblyInfo.cs @@ -5,12 +5,12 @@ // Le informazioni generali relative a un assembly sono controllate dal seguente // set di attributi. Per modificare le informazioni associate a un assembly // occorre quindi modificare i valori di questi attributi. -[assembly: AssemblyTitle("CallableBonds")] +[assembly: AssemblyTitle( "QLNet CallableBonds Example" )] [assembly: AssemblyDescription("")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("")] -[assembly: AssemblyProduct("CallableBonds")] -[assembly: AssemblyCopyright("Copyright © 2012")] +[assembly: AssemblyProduct( "QLNet Examples" )] +[assembly: AssemblyCopyright( "Copyright (c) 2008-2016 Andrea Maggiulli (a.maggiulli@gmail.com)" )] [assembly: AssemblyTrademark("")] [assembly: AssemblyCulture("")] @@ -32,5 +32,5 @@ // È possibile specificare tutti i valori oppure impostare valori predefiniti per i numeri relativi alla revisione e alla build // utilizzando l'asterisco (*) come descritto di seguito: // [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("1.7.0.0")] -[assembly: AssemblyFileVersion("1.7.0.0")] +[assembly: AssemblyVersion("1.8.0.0")] +[assembly: AssemblyFileVersion("1.8.0.0")] diff --git a/Examples/EquityOption/Properties/AssemblyInfo.cs b/Examples/EquityOption/Properties/AssemblyInfo.cs index bcaea2ef1..cb15ea6f6 100644 --- a/Examples/EquityOption/Properties/AssemblyInfo.cs +++ b/Examples/EquityOption/Properties/AssemblyInfo.cs @@ -5,12 +5,12 @@ // General Information about an assembly is controlled through the following // set of attributes. Change these attribute values to modify the information // associated with an assembly. -[assembly: AssemblyTitle("EquityOption")] +[assembly: AssemblyTitle( "QLNet EquityOption Example" )] [assembly: AssemblyDescription("")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("")] -[assembly: AssemblyProduct("EquityOption")] -[assembly: AssemblyCopyright("Copyright © 2008")] +[assembly: AssemblyProduct( "QLNet Examples" )] +[assembly: AssemblyCopyright( "Copyright (c) 2008-2016 Andrea Maggiulli (a.maggiulli@gmail.com)" )] [assembly: AssemblyTrademark("")] [assembly: AssemblyCulture("")] diff --git a/Examples/FRA/Properties/AssemblyInfo.cs b/Examples/FRA/Properties/AssemblyInfo.cs index 7585424bf..480370704 100644 --- a/Examples/FRA/Properties/AssemblyInfo.cs +++ b/Examples/FRA/Properties/AssemblyInfo.cs @@ -5,12 +5,12 @@ // Le informazioni generali relative a un assembly sono controllate dal seguente // insieme di attributi. Per modificare le informazioni associate a un assembly // occorre quindi modificare i valori di questi attributi. -[assembly: AssemblyTitle("FRA")] +[assembly: AssemblyTitle( "QLNet FRA Example" )] [assembly: AssemblyDescription("")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("")] -[assembly: AssemblyProduct("FRA")] -[assembly: AssemblyCopyright("Copyright © 2008")] +[assembly: AssemblyProduct( "QLNet Examples" )] +[assembly: AssemblyCopyright( "Copyright (c) 2008-2016 Andrea Maggiulli (a.maggiulli@gmail.com)" )] [assembly: AssemblyTrademark("")] [assembly: AssemblyCulture("")] diff --git a/Examples/FittedBondCurve/Properties/AssemblyInfo.cs b/Examples/FittedBondCurve/Properties/AssemblyInfo.cs index 3e7a42f87..54889acd3 100644 --- a/Examples/FittedBondCurve/Properties/AssemblyInfo.cs +++ b/Examples/FittedBondCurve/Properties/AssemblyInfo.cs @@ -5,12 +5,12 @@ // General Information about an assembly is controlled through the following // set of attributes. Change these attribute values to modify the information // associated with an assembly. -[assembly: AssemblyTitle( "FittedBondCurve" )] +[assembly: AssemblyTitle( "QLNet FittedBondCurve Example" )] [assembly: AssemblyDescription( "" )] [assembly: AssemblyConfiguration( "" )] -[assembly: AssemblyCompany( "Microsoft" )] -[assembly: AssemblyProduct( "FittedBondCurve" )] -[assembly: AssemblyCopyright( "Copyright © Microsoft 2016" )] +[assembly: AssemblyCompany( "" )] +[assembly: AssemblyProduct( "QLNet Examples" )] +[assembly: AssemblyCopyright( "Copyright (c) 2008-2016 Andrea Maggiulli (a.maggiulli@gmail.com)" )] [assembly: AssemblyTrademark( "" )] [assembly: AssemblyCulture( "" )] diff --git a/Examples/Repo/Properties/AssemblyInfo.cs b/Examples/Repo/Properties/AssemblyInfo.cs index d15456f92..562bc1eeb 100644 --- a/Examples/Repo/Properties/AssemblyInfo.cs +++ b/Examples/Repo/Properties/AssemblyInfo.cs @@ -5,12 +5,12 @@ // General Information about an assembly is controlled through the following // set of attributes. Change these attribute values to modify the information // associated with an assembly. -[assembly: AssemblyTitle("Repo")] +[assembly: AssemblyTitle( "QLNet Repo Example" )] [assembly: AssemblyDescription("")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("")] -[assembly: AssemblyProduct("Repo")] -[assembly: AssemblyCopyright("Copyright © 2008")] +[assembly: AssemblyProduct( "QLNet Examples" )] +[assembly: AssemblyCopyright( "Copyright (c) 2008-2016 Andrea Maggiulli (a.maggiulli@gmail.com)" )] [assembly: AssemblyTrademark("")] [assembly: AssemblyCulture("")] diff --git a/Examples/Swap/Properties/AssemblyInfo.cs b/Examples/Swap/Properties/AssemblyInfo.cs index efcc40745..1f2e10818 100644 --- a/Examples/Swap/Properties/AssemblyInfo.cs +++ b/Examples/Swap/Properties/AssemblyInfo.cs @@ -5,12 +5,12 @@ // General Information about an assembly is controlled through the following // set of attributes. Change these attribute values to modify the information // associated with an assembly. -[assembly: AssemblyTitle("Swap")] +[assembly: AssemblyTitle( "QLNet Swap Example" )] [assembly: AssemblyDescription("")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("")] -[assembly: AssemblyProduct("Swap")] -[assembly: AssemblyCopyright("Copyright © 2008")] +[assembly: AssemblyProduct( "QLNet Examples" )] +[assembly: AssemblyCopyright( "Copyright (c) 2008-2016 Andrea Maggiulli (a.maggiulli@gmail.com)" )] [assembly: AssemblyTrademark("")] [assembly: AssemblyCulture("")] diff --git a/News.txt b/News.txt index 1d69a3de0..a3c7ac620 100644 --- a/News.txt +++ b/News.txt @@ -1,79 +1,42 @@ -QLNet 1.7 +QLNet 1.8 ========================= -QLNet 1.7 stable version. +QLNet 1.8 stable version. The most notable changes are included below. A detailed list of changes is available in ChangeLog.txt. -TERM STRUCTURES +FRAMEWORK -+ Added FittedBondDiscountCurve with example project. ++ Refactored code to be compatible with .NET Core , created VS 2015 solution QLNet_Core.sln + that build the .NET Core version. + ++ Refactored test project to work with Microsoft UnitTesting and Xunit. INTEREST RATES -+ Added rate helper to bootstrap on cross-currency swaps . - The curve to be bootstrapped can be the one for either of the two currencies. ++ Fixed links to documentation for LIBOR indexes. -+ Added the possibility for bootstrap helpers to define their pillar - date in different ways . For each helper, the date of the corresponding - node can be defined as the maturity date of the corresponding instrument, - as the latest date used on the term structure to price the instrument, - or as a custom date. Currently, the feature is enabled for FRAs and swaps. +INSTRUMENTS -+ Added the possibility to pass weight when fitting a bond discount - curve. Also, it is now possible to fit a spread over an existing - term structure. ++ Added basic CVA IRS pricing engine. -INFLATION +CURRENCIES -+ Added Kerkhof seasonality model. - -+ Retrieve inflation fixings from the first day of the month . - This avoids the need to store them for each day of the corresponding month. - -VOLATILITY - -+ Improve consistency between caplet stripping and pricing. - -MODELS - -+ Added Heston model. - -SETTINGS - -+ Make SavedSettings disposable and update tests accordingly. - Now the full test suite can be launched from Visual Studio IDE - without errors ( false negative ) . ++ Added Ukrainian hryvnia. DATE/TIME -+ Added Romanian and Israelian calendars. - -+ Added ECB reserve maintenance periods for 2016. - -+ Updated South Korean calendar until the end of 2032. - -+ Added new Mountain Day holiday for Japan. - -+ Remove MLK day from list of US holidays before 1983. - -+ Added Christmas Eve to BOVESPA holidays. - -+ Added intraday component to dates. Date specifications now include hours, - minutes, seconds and milliseconds. Day counters are aware of the added data - and include them in results. ++ Added new Ukrainian holiday, Defender's Day. MATH -+ Added polynomial and abcd functions. - -+ Added Pascal triangle coefficients. - -+ Added Goldstein line-search method. - -PATTERNS - -+ Use WeakEventSource in Observer/Observable pattern to avoid memory leaks. ++ Added mixed log interpolation. ++ Added FlatExtrapolator2D ++ Added BackwardflatLinear Interpolation. ++ Added AbcdInterpolation. ++ Implemented Lagrange boundary condition for cubic interpolation +PRICING ENGINES ++ Added CounterpartyAdjSwapEngine engine with example program. diff --git a/QLNet/Cashflows/CPICoupon.cs b/QLNet/Cashflows/CPICoupon.cs index 6093bddd7..309ad016c 100644 --- a/QLNet/Cashflows/CPICoupon.cs +++ b/QLNet/Cashflows/CPICoupon.cs @@ -165,12 +165,12 @@ public CPICashFlow(double notional, frequency_=frequency; if(Math.Abs(baseFixing_) <= 1e-16) - throw new ApplicationException("|baseFixing|<1e-16, future divide-by-zero error"); + throw new Exception("|baseFixing|<1e-16, future divide-by-zero error"); if (interpolation_ != InterpolationType.AsIndex) { if ( frequency_ == Frequency.NoFrequency) - throw new ApplicationException ("non-index interpolation w/o frequency"); + throw new Exception ("non-index interpolation w/o frequency"); } } @@ -179,7 +179,7 @@ public CPICashFlow(double notional, public virtual double baseFixing() {return baseFixing_;} //! you may not have a valid date - public override Date baseDate() {throw new ApplicationException();} + public override Date baseDate() {throw new Exception();} //! do you want linear/constant/as-index interpolation of future data? public virtual InterpolationType interpolation() { return interpolation_; } @@ -264,7 +264,7 @@ public CPILeg(Schedule schedule, public override List value() { if (notionals_.empty()) - throw new ApplicationException("no notional given"); + throw new Exception("no notional given"); int n = schedule_.Count - 1; List leg = new List(n + 1); @@ -272,7 +272,7 @@ public override List value() if (n > 0) { if (fixedRates_.empty() && spreads_.empty()) - throw new ApplicationException("no fixedRates or spreads given"); + throw new Exception("no fixedRates or spreads given"); Date refStart, start, refEnd, end; @@ -304,8 +304,7 @@ public override List value() if (Utils.Get(fixedRates_, i, 1.0) == 0.0) { // fixed coupon - leg.Add(new FixedRateCoupon(Utils.Get(notionals_, i, 0.0), - paymentDate, + leg.Add( new FixedRateCoupon( paymentDate,Utils.Get( notionals_, i, 0.0 ), Utils.effectiveFixedRate(spreads_, caps_, floors_, i), paymentDayCounter_, start, end, refStart, refEnd, exCouponDate)); } @@ -339,7 +338,7 @@ public override List value() else { // cap/floorlet - throw new ApplicationException("caps/floors on CPI coupons not implemented."); + throw new Exception("caps/floors on CPI coupons not implemented."); } } } diff --git a/QLNet/Cashflows/CappedFlooredCoupon.cs b/QLNet/Cashflows/CappedFlooredCoupon.cs index 18738c711..412f90844 100644 --- a/QLNet/Cashflows/CappedFlooredCoupon.cs +++ b/QLNet/Cashflows/CappedFlooredCoupon.cs @@ -59,7 +59,7 @@ public class CappedFlooredCoupon : FloatingRateCoupon public CappedFlooredCoupon() { } public CappedFlooredCoupon(FloatingRateCoupon underlying, double? cap = null, double? floor = null) - : base(underlying.nominal(), underlying.date(), underlying.accrualStartDate(), underlying.accrualEndDate(), underlying.fixingDays, underlying.index(), underlying.gearing(), underlying.spread(), underlying.refPeriodStart, underlying.refPeriodEnd, underlying.dayCounter(), underlying.isInArrears()) + : base(underlying.date(), underlying.nominal(), underlying.accrualStartDate(), underlying.accrualEndDate(), underlying.fixingDays, underlying.index(), underlying.gearing(), underlying.spread(), underlying.referencePeriodStart, underlying.referencePeriodEnd, underlying.dayCounter(), underlying.isInArrears()) { underlying_ = underlying; isCapped_ = false; @@ -93,7 +93,7 @@ public CappedFlooredCoupon(FloatingRateCoupon underlying, double? cap = null, do } if (isCapped_ && isFloored_) if (!(cap >= floor)) - throw new ApplicationException("cap level (" + cap + ") less than floor level (" + floor + ")"); + throw new Exception("cap level (" + cap + ") less than floor level (" + floor + ")"); underlying.registerWith(update); } //! \name Coupon interface @@ -101,7 +101,7 @@ public CappedFlooredCoupon(FloatingRateCoupon underlying, double? cap = null, do public override double rate() { if (underlying_.pricer() == null) - throw new ApplicationException("pricer not set"); + throw new Exception("pricer not set"); double swapletRate = underlying_.rate(); double floorletRate = 0.0; @@ -165,7 +165,7 @@ public override void setPricer(FloatingRateCouponPricer pricer) // Factory - for Leg generators public virtual CashFlow factory(double nominal, Date paymentDate, Date startDate, Date endDate, int fixingDays, InterestRateIndex index, double gearing, double spread, double? cap, double? floor, Date refPeriodStart, Date refPeriodEnd, DayCounter dayCounter, bool isInArrears) { - return new CappedFlooredCoupon(new FloatingRateCoupon(nominal, paymentDate, startDate, endDate, fixingDays, index, gearing, spread, refPeriodStart, refPeriodEnd, dayCounter, isInArrears), cap, floor); + return new CappedFlooredCoupon( new FloatingRateCoupon( paymentDate, nominal, startDate, endDate, fixingDays, index, gearing, spread, refPeriodStart, refPeriodEnd, dayCounter, isInArrears ), cap, floor ); } } @@ -174,8 +174,8 @@ public class CappedFlooredIborCoupon : CappedFlooredCoupon // need by CashFlowVectors public CappedFlooredIborCoupon() { } - public CappedFlooredIborCoupon(double nominal, - Date paymentDate, + public CappedFlooredIborCoupon(Date paymentDate, + double nominal, Date startDate, Date endDate, int fixingDays, @@ -188,14 +188,14 @@ public CappedFlooredIborCoupon(double nominal, Date refPeriodEnd = null, DayCounter dayCounter = null, bool isInArrears = false) - : base(new IborCoupon(nominal, paymentDate, startDate, endDate, fixingDays, index, gearing, spread, refPeriodStart, refPeriodEnd, dayCounter, isInArrears) as FloatingRateCoupon, cap, floor) + : base( new IborCoupon( paymentDate, nominal, startDate, endDate, fixingDays, index, gearing, spread, refPeriodStart, refPeriodEnd, dayCounter, isInArrears ) as FloatingRateCoupon, cap, floor ) { } // Factory - for Leg generators public virtual CashFlow factory(double nominal, Date paymentDate, Date startDate, Date endDate, int fixingDays, IborIndex index, double gearing, double spread, double? cap, double? floor, Date refPeriodStart, Date refPeriodEnd, DayCounter dayCounter, bool isInArrears) { - return new CappedFlooredIborCoupon(nominal, paymentDate, startDate, endDate, fixingDays, index, gearing, spread, cap, floor, refPeriodStart, refPeriodEnd, dayCounter, isInArrears); + return new CappedFlooredIborCoupon( paymentDate, nominal, startDate, endDate, fixingDays, index, gearing, spread, cap, floor, refPeriodStart, refPeriodEnd, dayCounter, isInArrears ); } } diff --git a/QLNet/Cashflows/CappedFlooredYoYInflationCoupon.cs b/QLNet/Cashflows/CappedFlooredYoYInflationCoupon.cs index 5784a237d..b4b317b11 100644 --- a/QLNet/Cashflows/CappedFlooredYoYInflationCoupon.cs +++ b/QLNet/Cashflows/CappedFlooredYoYInflationCoupon.cs @@ -71,8 +71,8 @@ public CappedFlooredYoYInflationCoupon(YoYInflationCoupon underlying, underlying.dayCounter(), underlying.gearing(), underlying.spread(), - underlying.refPeriodStart, - underlying.refPeriodEnd) + underlying.referencePeriodStart, + underlying.referencePeriodEnd) { underlying_ = underlying; @@ -226,7 +226,7 @@ protected virtual void setCommon(double? cap, double? floor) if (isCapped_ && isFloored_) { if ( cap < floor ) - throw new ApplicationException( "cap level (" + cap + + throw new Exception( "cap level (" + cap + ") less than floor level (" + floor + ")"); } diff --git a/QLNet/Cashflows/CashFlows.cs b/QLNet/Cashflows/CashFlows.cs index 4f82c49eb..83ae6daff 100644 --- a/QLNet/Cashflows/CashFlows.cs +++ b/QLNet/Cashflows/CashFlows.cs @@ -105,8 +105,8 @@ public static double simpleDuration(Leg leg,InterestRate y, bool includeSettleme Coupon coupon = leg[i] as Coupon; if (coupon != null) { - refStartDate = coupon.refPeriodStart; - refEndDate = coupon.refPeriodEnd; + refStartDate = coupon.referencePeriodStart; + refEndDate = coupon.referencePeriodEnd; } else { @@ -170,8 +170,8 @@ public static double modifiedDuration(Leg leg,InterestRate y, bool includeSettle Coupon coupon = leg[i] as Coupon; if (coupon != null) { - refStartDate = coupon.refPeriodStart; - refEndDate = coupon.refPeriodEnd; + refStartDate = coupon.referencePeriodStart; + refEndDate = coupon.referencePeriodEnd; } else { @@ -360,11 +360,12 @@ public BPSCalculator(YieldTermStructure discountCurve) // visitor classes should implement the generic visit method in the following form public void visit(object o) { - Type[] types = new Type[] { o.GetType() }; - MethodInfo methodInfo = this.GetType().GetMethod("visit", types); - if (methodInfo != null) { + Type[] types = new Type[] { o.GetType() }; + MethodInfo methodInfo = Utils.GetMethodInfo( this, "visit", types ); + + if (methodInfo != null) { methodInfo.Invoke(this, new object[] { o }); - } + } } public void visit(Coupon c) { @@ -555,7 +556,7 @@ public static Date referencePeriodStart(Leg leg, bool includeSettlementDateFlows { Coupon cp = x as Coupon; if (cp != null) - return cp.refPeriodStart; + return cp.referencePeriodStart; } return null; } @@ -569,7 +570,7 @@ public static Date referencePeriodEnd(Leg leg, bool includeSettlementDateFlows,D { Coupon cp = x as Coupon; if (cp != null) - return cp.refPeriodEnd; + return cp.referencePeriodEnd; } return null; } @@ -827,8 +828,8 @@ public static double npv(Leg leg, InterestRate yield, bool includeSettlementDate Coupon coupon = leg[i] as Coupon; if (coupon != null ) { - refStartDate = coupon.refPeriodStart; - refEndDate = coupon.refPeriodEnd; + refStartDate = coupon.referencePeriodStart; + refEndDate = coupon.referencePeriodEnd; } else { @@ -1048,8 +1049,8 @@ public static double convexity(Leg leg, InterestRate yield, bool includeSettleme Coupon coupon = leg[i] as Coupon; if (coupon != null ) { - refStartDate = coupon.refPeriodStart; - refEndDate = coupon.refPeriodEnd; + refStartDate = coupon.referencePeriodStart; + refEndDate = coupon.referencePeriodEnd; } else { diff --git a/QLNet/Cashflows/Cashflowvectors.cs b/QLNet/Cashflows/Cashflowvectors.cs index 47135d95d..e852b525f 100644 --- a/QLNet/Cashflows/Cashflowvectors.cs +++ b/QLNet/Cashflows/Cashflowvectors.cs @@ -81,8 +81,7 @@ public static List FloatingLeg FloatingDigitalLeg yoyInflationLeg(List notionals_, int n = schedule_.Count -1 ; if (notionals_.empty()) - throw new ApplicationException("no notional given"); + throw new Exception("no notional given"); if (notionals_.Count > n) - throw new ApplicationException("too many nominals (" + notionals_.Count + + throw new Exception("too many nominals (" + notionals_.Count + "), only " + n + " required"); if ( gearings_ != null && gearings_.Count > n ) - throw new ApplicationException("too many gearings (" + gearings_.Count + + throw new Exception("too many gearings (" + gearings_.Count + "), only " + n + " required"); if ( spreads_ != null && spreads_.Count > n ) - throw new ApplicationException("too many spreads (" + spreads_.Count + + throw new Exception("too many spreads (" + spreads_.Count + "), only " + n + " required"); if ( caps_ != null && caps_.Count > n ) - throw new ApplicationException("too many caps (" + caps_.Count + + throw new Exception("too many caps (" + caps_.Count + "), only " + n + " required"); if ( floors_ != null && floors_.Count > n ) - throw new ApplicationException("too many floors (" + floors_.Count + + throw new Exception("too many floors (" + floors_.Count + "), only " + n + " required"); @@ -316,8 +314,7 @@ public static List yoyInflationLeg(List notionals_, if (Utils.Get(gearings_, i, 1.0) == 0.0) { // fixed coupon - leg.Add(new FixedRateCoupon(Utils.Get(notionals_, i, 1.0), - paymentDate, + leg.Add( new FixedRateCoupon( paymentDate,Utils.Get( notionals_, i, 1.0 ), Utils.effectiveFixedRate(spreads_, caps_, floors_, i), paymentDayCounter_, diff --git a/QLNet/Cashflows/CmsCoupon.cs b/QLNet/Cashflows/CmsCoupon.cs index 0e091f9a6..2dd174ebc 100644 --- a/QLNet/Cashflows/CmsCoupon.cs +++ b/QLNet/Cashflows/CmsCoupon.cs @@ -42,8 +42,9 @@ public CmsCoupon(double nominal, Date refPeriodStart = null, Date refPeriodEnd = null, DayCounter dayCounter = null, - bool isInArrears = false ) - : base(nominal, paymentDate, startDate, endDate, fixingDays, swapIndex, gearing, spread, refPeriodStart, refPeriodEnd, dayCounter, isInArrears) { + bool isInArrears = false ) + : base( paymentDate, nominal, startDate, endDate, fixingDays, swapIndex, gearing, spread, refPeriodStart, refPeriodEnd, dayCounter, isInArrears ) + { swapIndex_ = swapIndex; } //! \name Inspectors diff --git a/QLNet/Cashflows/ConundrumPricer.cs b/QLNet/Cashflows/ConundrumPricer.cs index 0ac045dba..bede4401e 100644 --- a/QLNet/Cashflows/ConundrumPricer.cs +++ b/QLNet/Cashflows/ConundrumPricer.cs @@ -272,7 +272,7 @@ private double calibrationOfShift(double Rs) { try { calibratedShift_ = solver.solve(objectiveFunction_, accuracy_, Math.Max(Math.Min(initialGuess, upper * .99), lower * .99), lower, upper); } catch (Exception e) { - throw new ApplicationException("meanReversion: " + meanReversion_.link.value() + ", swapRateValue: " + swapRateValue_ + ", swapStartTime: " + swapStartTime_ + ", shapedPaymentTime: " + shapedPaymentTime_ + "\n error message: " + e.Message); + throw new Exception("meanReversion: " + meanReversion_.link.value() + ", swapRateValue: " + swapRateValue_ + ", swapStartTime: " + swapStartTime_ + ", shapedPaymentTime: " + shapedPaymentTime_ + "\n error message: " + e.Message); } tmpRs_ = Rs; } @@ -296,7 +296,7 @@ private double derRs_derX(double x) { numerator += shapedSwapPaymentTimes_.Last() * swapPaymentDiscounts_.Last() * Math.Exp(-shapedSwapPaymentTimes_.Last() * x) * sqrtDenominator; numerator -= (discountAtStart_ - swapPaymentDiscounts_.Last() * Math.Exp(-shapedSwapPaymentTimes_.Last() * x)) * derSqrtDenominator; if (!(denominator != 0)) - throw new ApplicationException("GFunctionWithShifts::derRs_derX: denominator == 0"); + throw new Exception("GFunctionWithShifts::derRs_derX: denominator == 0"); return numerator / denominator; } @@ -304,7 +304,7 @@ private double derZ_derX(double x) { double sqrtDenominator = (1.0 - discountRatio_ * Math.Exp(-shapedSwapPaymentTimes_.Last() * x)); double denominator = sqrtDenominator * sqrtDenominator; if (!(denominator != 0)) - throw new ApplicationException("GFunctionWithShifts::derZ_derX: denominator == 0"); + throw new Exception("GFunctionWithShifts::derZ_derX: denominator == 0"); double numerator = 0; numerator -= shapedPaymentTime_ * Math.Exp(-shapedPaymentTime_ * x) * sqrtDenominator; @@ -342,7 +342,7 @@ private double der2Rs_derX2(double x) { double numerator = derNumOfDerR * denOfDerR - numOfDerR * derDenOfDerR; if (!(denominator != 0)) - throw new ApplicationException("GFunctionWithShifts::der2Rs_derX2: denominator == 0"); + throw new Exception("GFunctionWithShifts::der2Rs_derX2: denominator == 0"); return numerator / denominator; } @@ -351,7 +351,7 @@ private double der2Z_derX2(double x) { double derDenOfZfunction = shapedSwapPaymentTimes_.Last() * discountRatio_ * Math.Exp(-shapedSwapPaymentTimes_.Last() * x); double denominator = Math.Pow(denOfZfunction, 4); if (!(denominator != 0)) - throw new ApplicationException("GFunctionWithShifts::der2Z_derX2: denominator == 0"); + throw new Exception("GFunctionWithShifts::der2Z_derX2: denominator == 0"); double numOfDerZ = 0; numOfDerZ -= shapedPaymentTime_ * Math.Exp(-shapedPaymentTime_ * x) * denOfZfunction; @@ -540,7 +540,11 @@ protected HaganPricer(Handle swaptionVol, GFunction if (meanReversion_.link != null) meanReversion_.registerWith(update); } - + + protected virtual double optionletPrice(Option.Type optionType,double strike) + { + throw new NotImplementedException(); + } public override void initialize(FloatingRateCoupon coupon) { coupon_ = coupon as CmsCoupon; Utils.QL_REQUIRE( coupon_ != null, () => "CMS coupon needed" ); @@ -595,7 +599,7 @@ public override void initialize(FloatingRateCoupon coupon) { gFunction_ = GFunctionFactory.newGFunctionWithShifts(coupon_, meanReversion_); break; default: - throw new ApplicationException("unknown/illegal gFunction type"); + throw new Exception("unknown/illegal gFunction type"); } vanillaOptionPricer_ = new BlackVanillaOptionPricer(swapRateValue_, fixingDate_, swapTenor_, swaptionVolatility().link); } diff --git a/QLNet/Cashflows/Coupon.cs b/QLNet/Cashflows/Coupon.cs index 7d7d9f64b..c93ecbf7f 100644 --- a/QLNet/Cashflows/Coupon.cs +++ b/QLNet/Cashflows/Coupon.cs @@ -1,6 +1,6 @@ /* Copyright (C) 2008 Siarhei Novik (snovik@gmail.com) - Copyright (C) 2008, 2009 , 2010 Andrea Maggiulli (a.maggiulli@gmail.com) + Copyright (C) 2008-2016 Andrea Maggiulli (a.maggiulli@gmail.com) This file is part of QLNet Project https://github.com/amaggiulli/qlnet @@ -25,79 +25,93 @@ namespace QLNet // still abstract and provides derived classes with methods for accrual period calculations. public abstract class Coupon : CashFlow { - protected double nominal_; - protected double? amount_ = null; - protected Date paymentDate_, accrualStartDate_, accrualEndDate_, refPeriodStart_, refPeriodEnd_, exCouponDate_; - - // access to properties - public override Date exCouponDate() { return exCouponDate_; } - public double nominal() { return nominal_; } - public override Date date() { return paymentDate_; } - public Date accrualStartDate() { return accrualStartDate_; } - public Date accrualEndDate() { return accrualEndDate_; } - public Date refPeriodStart { get { return refPeriodStart_; } } - public Date refPeriodEnd { get { return refPeriodEnd_; } } - - // virtual get methods to be defined in derived classes - public abstract double rate(); //! accrued rate - public abstract DayCounter dayCounter(); //! day counter for accrual calculation - public abstract double accruedAmount(Date d); //! accrued amount at the given date - //public virtual FloatingRateCouponPricer pricer() { return null; } - - // Constructors public Coupon() { } // default constructor // coupon does not adjust the payment date which must already be a business day - public Coupon(double nominal, Date paymentDate, Date accrualStartDate, Date accrualEndDate, - Date refPeriodStart = null, Date refPeriodEnd = null, Date exCouponDate = null, double? amount = null) + public Coupon( Date paymentDate, + double nominal, + Date accrualStartDate, + Date accrualEndDate, + Date refPeriodStart = null, + Date refPeriodEnd = null, + Date exCouponDate = null ) { - nominal_ = nominal; - amount_ = amount; paymentDate_ = paymentDate; + nominal_ = nominal; accrualStartDate_ = accrualStartDate; accrualEndDate_ = accrualEndDate; refPeriodStart_ = refPeriodStart; refPeriodEnd_ = refPeriodEnd; - exCouponDate_ = exCouponDate; + exCouponDate_ = exCouponDate; + accrualPeriod_ = null; - if (refPeriodStart_ == null) refPeriodStart_ = accrualStartDate_; - if (refPeriodEnd_ == null) refPeriodEnd_ = accrualEndDate_; + if ( refPeriodStart_ == null ) refPeriodStart_ = accrualStartDate_; + if ( refPeriodEnd_ == null ) refPeriodEnd_ = accrualEndDate_; } + // Event interface + public override Date date() { return paymentDate_; } + + // CashFlow interface + public override Date exCouponDate() { return exCouponDate_; } + // Inspectors + public double nominal() { return nominal_; } + //! start of the accrual period + public Date accrualStartDate() { return accrualStartDate_; } + //! end of the accrual period + public Date accrualEndDate() { return accrualEndDate_; } + //! start date of the reference period + public Date referencePeriodStart { get { return refPeriodStart_; } } + //! end date of the reference period + public Date referencePeriodEnd { get { return refPeriodEnd_; } } //! accrual period as fraction of year - public double accrualPeriod() + public double accrualPeriod() { - return dayCounter().yearFraction(accrualStartDate_, accrualEndDate_, refPeriodStart_, refPeriodEnd_); + if ( accrualPeriod_ == null ) + accrualPeriod_ = dayCounter().yearFraction( accrualStartDate_, + accrualEndDate_, refPeriodStart_, refPeriodEnd_ ); + return accrualPeriod_.Value; } - //! accrual period in days - public int accrualDays() - { - return dayCounter().dayCount(accrualStartDate_, accrualEndDate_); + public int accrualDays() + { + return dayCounter().dayCount( accrualStartDate_, accrualEndDate_ ); } - - - //! accrued period as fraction of year at the given date - public double accruedPeriod(Date d) + //! accrued rate + public abstract double rate(); + //! day counter for accrual calculation + public abstract DayCounter dayCounter(); + //! accrued period as fraction of year at the given date + public double accruedPeriod( Date d ) { - if (d <= accrualStartDate_ || d > paymentDate_) - return 0.0; - else - return dayCounter().yearFraction(accrualStartDate_, - Date.Min(d, accrualEndDate_), - refPeriodStart_, - refPeriodEnd_); + if ( d <= accrualStartDate_ || d > paymentDate_ ) + return 0.0; + else + return dayCounter().yearFraction( accrualStartDate_, + Date.Min( d, accrualEndDate_ ), + refPeriodStart_, + refPeriodEnd_ ); } //! accrued days at the given date - public int accruedDays(Date d) + public int accruedDays( Date d ) { - if (d <= accrualStartDate_ || d > paymentDate_) + if ( d <= accrualStartDate_ || d > paymentDate_ ) return 0; - else - return dayCounter().dayCount(accrualStartDate_,Date.Min(d, accrualEndDate_)); + else + return dayCounter().dayCount( accrualStartDate_, Date.Min( d, accrualEndDate_ ) ); } + //! accrued amount at the given date + public abstract double accruedAmount( Date d ); + protected double nominal_; + protected Date paymentDate_; + protected Date accrualStartDate_; + protected Date accrualEndDate_; + protected Date refPeriodStart_; + protected Date refPeriodEnd_; + protected Date exCouponDate_; + protected double? accrualPeriod_; } } diff --git a/QLNet/Cashflows/CouponPricer.cs b/QLNet/Cashflows/CouponPricer.cs index 6451af0ad..49ff803d0 100644 --- a/QLNet/Cashflows/CouponPricer.cs +++ b/QLNet/Cashflows/CouponPricer.cs @@ -1,7 +1,7 @@ /* Copyright (C) 2008 Siarhei Novik (snovik@gmail.com) Copyright (C) 2008 Toyin Akin (toyin_akin@hotmail.com) - Copyright (C) 2008, 2009 , 2010 Andrea Maggiulli (a.maggiulli@gmail.com) + Copyright (C) 2008-2016 Andrea Maggiulli (a.maggiulli@gmail.com) This file is part of QLNet Project https://github.com/amaggiulli/qlnet @@ -17,313 +17,415 @@ under the terms of the QLNet license. You should have received a This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the license for more details. -*/ -using System; -using System.Collections.Generic; -using System.Reflection; - -namespace QLNet { - - //! generic pricer for floating-rate coupons - public abstract class FloatingRateCouponPricer : IObservable, IObserver { - //! \name required interface - //@{ - public abstract double swapletPrice(); - public abstract double swapletRate(); - public abstract double capletPrice(double effectiveCap); - public abstract double capletRate(double effectiveCap); - public abstract double floorletPrice(double effectiveFloor); - public abstract double floorletRate(double effectiveFloor); - public abstract void initialize(FloatingRateCoupon coupon); - protected abstract double optionletPrice(Option.Type optionType, double effStrike); - - #region Observer & observable - private readonly WeakEventSource eventSource = new WeakEventSource(); - public event Callback notifyObserversEvent - { - add { eventSource.Subscribe(value); } - remove { eventSource.Unsubscribe(value); } - } - - public void registerWith(Callback handler) { notifyObserversEvent += handler; } - public void unregisterWith(Callback handler) { notifyObserversEvent -= handler; } - protected void notifyObservers() - { - eventSource.Raise(); - } - - // observer interface - public void update() { notifyObservers(); } - #endregion - } - - //! base pricer for capped/floored Ibor coupons - public abstract class IborCouponPricer : FloatingRateCouponPricer { - public IborCouponPricer() - : this(new Handle()) { - } - public IborCouponPricer(Handle v) { - capletVol_ = v; - if (!capletVol_.empty()) - capletVol_.registerWith(update); - } - - public Handle capletVolatility() { - return capletVol_; - } - public void setCapletVolatility() { - setCapletVolatility(new Handle()); - } - public void setCapletVolatility(Handle v) { - capletVol_.unregisterWith(update); - capletVol_ = v; - if (!capletVol_.empty()) - capletVol_.registerWith(update); - - update(); - } - private Handle capletVol_; - } - - //! Black-formula pricer for capped/floored Ibor coupons - public class BlackIborCouponPricer : IborCouponPricer { - public BlackIborCouponPricer() - : this(new Handle()) { - } - public BlackIborCouponPricer(Handle v) - : base(v) { - } - - //===========================================================================// - // BlackIborCouponPricer // - //===========================================================================// - - public override void initialize(FloatingRateCoupon coupon) { - coupon_ = coupon as IborCoupon; - if (coupon_ == null) throw new ApplicationException("Libor coupon required"); - gearing_ = coupon_.gearing(); - spread_ = coupon_.spread(); - Date paymentDate = coupon_.date(); - IborIndex index = coupon_.index() as IborIndex; - Handle rateCurve = index.forwardingTermStructure(); - - if (paymentDate > rateCurve.link.referenceDate()) - discount_ = rateCurve.link.discount(paymentDate); - else - discount_ = 1.0; - - spreadLegValue_ = spread_ * coupon_.accrualPeriod() * discount_; - } - // - public override double swapletPrice() { - // past or future fixing is managed in InterestRateIndex::fixing() - - double swapletPrice = adjustedFixing() * coupon_.accrualPeriod() * discount_; - return gearing_ * swapletPrice + spreadLegValue_; - } - public override double swapletRate() { - return swapletPrice() / (coupon_.accrualPeriod() * discount_); - } - public override double capletPrice(double effectiveCap) { - double capletPrice = optionletPrice(Option.Type.Call, effectiveCap); - return gearing_ * capletPrice; - } - public override double capletRate(double effectiveCap) { - return capletPrice(effectiveCap) / (coupon_.accrualPeriod() * discount_); - } - public override double floorletPrice(double effectiveFloor) { - double floorletPrice = optionletPrice(Option.Type.Put, effectiveFloor); - return gearing_ * floorletPrice; - } - public override double floorletRate(double effectiveFloor) { - return floorletPrice(effectiveFloor) / (coupon_.accrualPeriod() * discount_); - } - - protected override double optionletPrice(Option.Type optionType, double effStrike) { - Date fixingDate = coupon_.fixingDate(); - if (fixingDate <= Settings.evaluationDate()) { - // the amount is determined - double a; - double b; - if (optionType == Option.Type.Call) { - a = coupon_.indexFixing(); - b = effStrike; - } else { - a = effStrike; - b = coupon_.indexFixing(); - } - return Math.Max(a - b, 0.0) * coupon_.accrualPeriod() * discount_; - } else { - // not yet determined, use Black model - Utils.QL_REQUIRE( !capletVolatility().empty(),()=> "missing optionlet volatility" ); - - - double stdDev = Math.Sqrt(capletVolatility().link.blackVariance(fixingDate, effStrike)); - double fixing = Utils.blackFormula(optionType, effStrike, adjustedFixing(), stdDev); - return fixing * coupon_.accrualPeriod() * discount_; +*/ +using System; +using System.Collections.Generic; +using System.Reflection; + +namespace QLNet +{ + + //! generic pricer for floating-rate coupons + public abstract class FloatingRateCouponPricer : IObservable, IObserver + { + //! \name required interface + //@{ + public abstract double swapletPrice(); + public abstract double swapletRate(); + public abstract double capletPrice( double effectiveCap ); + public abstract double capletRate( double effectiveCap ); + public abstract double floorletPrice( double effectiveFloor ); + public abstract double floorletRate( double effectiveFloor ); + public abstract void initialize( FloatingRateCoupon coupon ); + + #region Observer & observable + private readonly WeakEventSource eventSource = new WeakEventSource(); + public event Callback notifyObserversEvent + { + add { eventSource.Subscribe( value ); } + remove { eventSource.Unsubscribe( value ); } + } + + public void registerWith( Callback handler ) { notifyObserversEvent += handler; } + public void unregisterWith( Callback handler ) { notifyObserversEvent -= handler; } + protected void notifyObservers() + { + eventSource.Raise(); + } + + // observer interface + public void update() { notifyObservers(); } + #endregion + } + + //! base pricer for capped/floored Ibor coupons + public abstract class IborCouponPricer : FloatingRateCouponPricer + { + public IborCouponPricer( Handle v = null ) + { + capletVol_ = v ?? new Handle(); + if ( !capletVol_.empty() ) + capletVol_.registerWith( update ); + } + + public Handle capletVolatility() + { + return capletVol_; + } + + public void setCapletVolatility( Handle v = null) + { + capletVol_.unregisterWith( update ); + capletVol_ = v ?? new Handle(); + if ( !capletVol_.empty() ) + capletVol_.registerWith( update ); + + update(); + } + private Handle capletVol_; + } + + /*! Black-formula pricer for capped/floored Ibor coupons + References for timing adjustments + Black76 Hull, Options, Futures and other + derivatives, 4th ed., page 550 + BivariateLognormal http://ssrn.com/abstract=2170721 + The bivariate lognormal adjustment implementation is + still considered experimental */ + public class BlackIborCouponPricer : IborCouponPricer + { + public enum TimingAdjustment { Black76, BivariateLognormal }; + public BlackIborCouponPricer( Handle v = null, + TimingAdjustment timingAdjustment = TimingAdjustment.Black76, + Handle correlation = null) + : base( v ) + { + timingAdjustment_ = timingAdjustment; + correlation_ = correlation ?? new Handle(new SimpleQuote(1.0)); + + Utils.QL_REQUIRE( timingAdjustment_ == TimingAdjustment.Black76 || + timingAdjustment_ == TimingAdjustment.BivariateLognormal,()=> + "unknown timing adjustment (code " + timingAdjustment_ + ")" ); + correlation_.registerWith(update); + } + + + public override void initialize( FloatingRateCoupon coupon ) + { + gearing_ = coupon.gearing(); + spread_ = coupon.spread(); + accrualPeriod_ = coupon.accrualPeriod(); + Utils.QL_REQUIRE(accrualPeriod_ != 0.0,()=> "null accrual period"); + + index_ = coupon.index() as IborIndex; + if (index_ == null) + { + // check if the coupon was right + IborCoupon c = coupon as IborCoupon; + Utils.QL_REQUIRE(c!=null,()=> "IborCoupon required"); + // coupon was right, index is not + Utils.QL_FAIL("IborIndex required"); + } + + Handle rateCurve = index_.forwardingTermStructure(); + Date paymentDate = coupon.date(); + if ( paymentDate > rateCurve.link.referenceDate() ) + discount_ = rateCurve.link.discount( paymentDate ); + else + discount_ = 1.0; + + spreadLegValue_ = spread_ * accrualPeriod_ * discount_; + + coupon_ = coupon ; + } + public override double swapletPrice() + { + // past or future fixing is managed in InterestRateIndex::fixing() + + double swapletPrice = adjustedFixing() * accrualPeriod_ * discount_; + return gearing_ * swapletPrice + spreadLegValue_; + } + public override double swapletRate() + { + return swapletPrice() / ( accrualPeriod_ * discount_ ); + } + public override double capletPrice( double effectiveCap ) + { + double capletPrice = optionletPrice( Option.Type.Call, effectiveCap ); + return gearing_ * capletPrice; + } + public override double capletRate( double effectiveCap ) + { + return capletPrice( effectiveCap ) / ( accrualPeriod_ * discount_ ); + } + public override double floorletPrice( double effectiveFloor ) + { + double floorletPrice = optionletPrice( Option.Type.Put, effectiveFloor ); + return gearing_ * floorletPrice; + } + public override double floorletRate( double effectiveFloor ) + { + return floorletPrice( effectiveFloor ) / ( accrualPeriod_ * discount_ ); + } + + protected double optionletPrice( Option.Type optionType, double effStrike ) + { + Date fixingDate = coupon_.fixingDate(); + if ( fixingDate <= Settings.evaluationDate() ) + { + // the amount is determined + double a; + double b; + if ( optionType == Option.Type.Call ) + { + a = coupon_.indexFixing(); + b = effStrike; + } + else + { + a = effStrike; + b = coupon_.indexFixing(); + } + return Math.Max( a - b, 0.0 ) * accrualPeriod_ * discount_; + } + else + { + // not yet determined, use Black model + Utils.QL_REQUIRE( !capletVolatility().empty(), () => "missing optionlet volatility" ); + + double stdDev = Math.Sqrt( capletVolatility().link.blackVariance( fixingDate, effStrike ) ); + double shift = capletVolatility().link.displacement(); + bool shiftedLn = capletVolatility().link.volatilityType() == VolatilityType.ShiftedLognormal; + double fixing = + shiftedLn + ? Utils.blackFormula(optionType, effStrike, adjustedFixing(),stdDev, 1.0, shift) + : Utils.bachelierBlackFormula(optionType, effStrike,adjustedFixing(), stdDev, 1.0); + return fixing * accrualPeriod_ * discount_; + } + } + protected virtual double adjustedFixing( double? fixing = null) + { + if (fixing == null) + fixing = coupon_.indexFixing(); + + if (!coupon_.isInArrears() && timingAdjustment_ == TimingAdjustment.Black76) + return fixing.Value; + + Utils.QL_REQUIRE(!capletVolatility().empty(),()=> "missing optionlet volatility"); + Date d1 = coupon_.fixingDate(); + Date referenceDate = capletVolatility().link.referenceDate(); + if (d1 <= referenceDate) + return fixing.Value; + Date d2 = index_.valueDate(d1); + Date d3 = index_.maturityDate(d2); + double tau = index_.dayCounter().yearFraction(d2, d3); + double variance = capletVolatility().link.blackVariance(d1, fixing.Value); + + double shift = capletVolatility().link.displacement(); + bool shiftedLn = capletVolatility().link.volatilityType() == VolatilityType.ShiftedLognormal; + + double adjustment = shiftedLn + ? (fixing.Value + shift)*(fixing.Value + shift)*variance*tau/(1.0 + fixing.Value*tau) + : variance*tau/(1.0 + fixing.Value*tau); + + if (timingAdjustment_ == TimingAdjustment.BivariateLognormal) + { + Utils.QL_REQUIRE(!correlation_.empty(),()=> "no correlation given"); + Date d4 = coupon_.date(); + Date d5 = d4 >= d3 ? d3 : d2; + double tau2 = index_.dayCounter().yearFraction(d5, d4); + if (d4 >= d3) + adjustment = 0.0; + // if d4 < d2 (payment before index start) we just apply the + // Black76 in arrears adjustment + if (tau2 > 0.0) + { + double fixing2 = (index_.forwardingTermStructure().link.discount(d5)/ + index_.forwardingTermStructure().link.discount(d4) - + 1.0)/ tau2; + adjustment -= shiftedLn + ? correlation_.link.value()*tau2*variance* (fixing.Value + shift)*(fixing2 + shift)/ (1.0 + fixing2*tau2) + : correlation_.link.value()*tau2*variance/ (1.0 + fixing2*tau2); } - } - - protected double adjustedFixing() { return adjustedFixing(null); } - protected virtual double adjustedFixing(double? fixing_) { - - double adjustement = 0.0; - double fixing = (fixing_ == null) ? coupon_.indexFixing() : fixing_.GetValueOrDefault(); - - if (!coupon_.isInArrears()) { - adjustement = 0.0; - } else { - // see Hull, 4th ed., page 550 - Utils.QL_REQUIRE( !capletVolatility().empty(),()=> "missing optionlet volatility" ); - - Date d1 = coupon_.fixingDate(); - Date referenceDate = capletVolatility().link.referenceDate(); - if (d1 <= referenceDate) { - adjustement = 0.0; - } else { - Date d2 = coupon_.index().maturityDate(d1); - double tau = coupon_.index().dayCounter().yearFraction(d1, d2); - double variance = capletVolatility().link.blackVariance(d1, fixing); - adjustement = fixing * fixing * variance * tau / (1.0 + fixing * tau); - } - } - return fixing + adjustement; - } - - private IborCoupon coupon_; - private double discount_; - private double gearing_; - private double spread_; - private double spreadLegValue_; - } - - //! base pricer for vanilla CMS coupons - public abstract class CmsCouponPricer : FloatingRateCouponPricer { - public CmsCouponPricer(Handle v = null) { - if (v.link == null) - swaptionVol_ = new Handle(); - else - swaptionVol_ = v; - - swaptionVol_.registerWith(update); - } - - public Handle swaptionVolatility() { - return swaptionVol_; - } - public void setSwaptionVolatility() { - setSwaptionVolatility(new Handle()); - } - public void setSwaptionVolatility(Handle v) { - if (swaptionVol_ != null) - swaptionVol_.unregisterWith(update); - swaptionVol_ = v; - if (swaptionVol_ != null) - swaptionVol_.registerWith(update); - update(); - } - private Handle swaptionVol_; - } - - - //===========================================================================// - // CouponSelectorToSetPricer // - //===========================================================================// - - public class PricerSetter : IAcyclicVisitor { - private FloatingRateCouponPricer pricer_; - public PricerSetter(FloatingRateCouponPricer pricer) { - pricer_ = pricer; - } - - public void visit(object o) { - Type[] types = new Type[] { o.GetType() }; - MethodInfo methodInfo = this.GetType().GetMethod("visit", types); - if (methodInfo != null) { - methodInfo.Invoke(this, new object[] { o }); - } - } - - public void visit(CashFlow c) { - // nothing to do - } - public void visit(Coupon c) { - // nothing to do - } - public void visit(IborCoupon c) { - IborCouponPricer pricer = pricer_ as IborCouponPricer; - if (pricer == null) - throw new ApplicationException("pricer not compatible with Ibor coupon"); - c.setPricer(pricer); - } - public void visit(CappedFlooredIborCoupon c) { - IborCouponPricer pricer = pricer_ as IborCouponPricer; - if (pricer == null) - throw new ApplicationException("pricer not compatible with Ibor coupon"); - c.setPricer(pricer); - } - public void visit(DigitalIborCoupon c) { - IborCouponPricer pricer = pricer_ as IborCouponPricer; - if (pricer == null) - throw new ApplicationException("pricer not compatible with Ibor coupon"); - c.setPricer(pricer); - } - public void visit(CmsCoupon c) { - CmsCouponPricer pricer = pricer_ as CmsCouponPricer; - if (pricer == null) - throw new ApplicationException("pricer not compatible with CMS coupon"); - c.setPricer(pricer); - } - public void visit(CappedFlooredCoupon c) - { - CmsCouponPricer pricer = pricer_ as CmsCouponPricer; - if (pricer == null) - throw new ApplicationException("pricer not compatible with CMS coupon"); - c.setPricer(pricer); - } - public void visit(CappedFlooredCmsCoupon c) { - CmsCouponPricer pricer = pricer_ as CmsCouponPricer; - if (pricer == null) - throw new ApplicationException("pricer not compatible with CMS coupon"); - c.setPricer(pricer); - } - public void visit(DigitalCmsCoupon c) { - CmsCouponPricer pricer = pricer_ as CmsCouponPricer; - if (pricer == null) - throw new ApplicationException("pricer not compatible with CMS coupon"); - c.setPricer(pricer); - } - //public void visit(RangeAccrualFloatersCoupon c) - //{ - // if (!(pricer_ is RangeAccrualPricer)) - // throw new ApplicationException("pricer not compatible with range-accrual coupon"); - // c.setPricer(pricer_ as RangeAccrualPricer); - //} - } - - partial class Utils { - public static void setCouponPricer(List leg, FloatingRateCouponPricer pricer) { - PricerSetter setter = new PricerSetter(pricer); - foreach (CashFlow cf in leg) { - cf.accept(setter); - } - } - - public static void setCouponPricers(List leg, List pricers) { - throw new NotImplementedException(); - //int nCashFlows = leg.Count; - //if (!(nCashFlows > 0)) - // throw new ApplicationException("no cashflows"); - - //int nPricers = pricers.Count; - //if (!(nCashFlows >= nPricers)) - // throw new ApplicationException("mismatch between leg size (" + nCashFlows + ") and number of pricers (" + nPricers + ")"); - - //for (int i = 0; i < nCashFlows; ++i) - //{ - // PricerSetter[] setter = new PricerSetter[i](i < nPricers ? pricers : pricers[nPricers - 1]); - // leg[i].accept(setter); - //} - } - } + } + return fixing.Value + adjustment; + } + + protected double gearing_; + protected double spread_; + protected double accrualPeriod_; + protected IborIndex index_; + protected double discount_; + protected double spreadLegValue_; + protected FloatingRateCoupon coupon_; + + private TimingAdjustment timingAdjustment_; + private Handle correlation_; + + + } + + //! base pricer for vanilla CMS coupons + public abstract class CmsCouponPricer : FloatingRateCouponPricer + { + public CmsCouponPricer( Handle v = null ) + { + swaptionVol_ = v ?? new Handle(); + swaptionVol_.registerWith( update ); + } + + public Handle swaptionVolatility() {return swaptionVol_;} + + public void setSwaptionVolatility( Handle v = null) + { + swaptionVol_.unregisterWith( update ); + swaptionVol_ = v ?? new Handle(); + swaptionVol_.registerWith( update ); + update(); + } + private Handle swaptionVol_; + } + + /*! (CMS) coupon pricer that has a mean reversion parameter which can be + used to calibrate to cms market quotes */ + public interface IMeanRevertingPricer + { + double meanReversion() ; + void setMeanReversion(Handle q) ; + } + + //===========================================================================// + // CouponSelectorToSetPricer // + //===========================================================================// + + public class PricerSetter : IAcyclicVisitor + { + private FloatingRateCouponPricer pricer_; + public PricerSetter( FloatingRateCouponPricer pricer ) + { + pricer_ = pricer; + } + + public void visit( object o ) + { + Type[] types = new Type[] { o.GetType() }; + MethodInfo methodInfo = Utils.GetMethodInfo( this, "visit", types ); + if ( methodInfo != null ) + { + methodInfo.Invoke( this, new object[] { o } ); + } + } + + public void visit( CashFlow c ) + { + // nothing to do + } + public void visit( Coupon c ) + { + // nothing to do + } + public void visit(FloatingRateCoupon c) + { + c.setPricer(pricer_); + } + public void visit( CappedFlooredCoupon c ) + { + c.setPricer( pricer_ ); + } + public void visit( IborCoupon c ) + { + IborCouponPricer iborCouponPricer = pricer_ as IborCouponPricer; + Utils.QL_REQUIRE( iborCouponPricer!=null,()=> "pricer not compatible with Ibor coupon" ); + c.setPricer( iborCouponPricer ); + } + public void visit( DigitalIborCoupon c ) + { + IborCouponPricer iborCouponPricer = pricer_ as IborCouponPricer; + Utils.QL_REQUIRE( iborCouponPricer!= null,()=> "pricer not compatible with Ibor coupon" ); + c.setPricer( iborCouponPricer ); + } + public void visit( CappedFlooredIborCoupon c ) + { + IborCouponPricer iborCouponPricer = pricer_ as IborCouponPricer; + Utils.QL_REQUIRE( iborCouponPricer != null, () => "pricer not compatible with Ibor coupon" ); + c.setPricer( iborCouponPricer ); + } + public void visit( CmsCoupon c ) + { + CmsCouponPricer cmsCouponPricer = pricer_ as CmsCouponPricer; + Utils.QL_REQUIRE( cmsCouponPricer!=null,()=> "pricer not compatible with CMS coupon" ); + c.setPricer( cmsCouponPricer ); + } + //public void visit(CmsSpreadCoupon c) + //{ + // CmsSpreadCouponPricer cmsSpreadCouponPricer = pricer_ as CmsSpreadCouponPricer; + // Utils.QL_REQUIRE(cmsSpreadCouponPricer!=null,()=>"pricer not compatible with CMS spread coupon"); + // c.setPricer(cmsSpreadCouponPricer); + //} + public void visit( CappedFlooredCmsCoupon c ) + { + CmsCouponPricer cmsCouponPricer = pricer_ as CmsCouponPricer; + Utils.QL_REQUIRE( cmsCouponPricer != null, () => "pricer not compatible with CMS coupon" ); + c.setPricer( cmsCouponPricer ); + } + //public void visit(CappedFlooredCmsSpreadCoupon c) + //{ + // CmsSpreadCouponPricer cmsSpreadCouponPricer = pricer_ as CmsSpreadCouponPricer; + // QL_REQUIRE(cmsSpreadCouponPricer!=null,()=>"pricer not compatible with CMS spread coupon"); + // c.setPricer(cmsSpreadCouponPricer); + //} + public void visit( DigitalCmsCoupon c ) + { + CmsCouponPricer cmsCouponPricer = pricer_ as CmsCouponPricer; + Utils.QL_REQUIRE( cmsCouponPricer != null, () => "pricer not compatible with CMS coupon" ); + c.setPricer( cmsCouponPricer ); + } + //public void visit(DigitalCmsSpreadCoupon c) + //{ + // CmsSpreadCouponPricer cmsSpreadCouponPricer = pricer_ as CmsSpreadCouponPricer; + // Utils.QL_REQUIRE(cmsSpreadCouponPricer!=null,()=> "pricer not compatible with CMS spread coupon"); + // c.setPricer(cmsSpreadCouponPricer); + //} + public void visit(RangeAccrualFloatersCoupon c) + { + RangeAccrualPricer rangeAccrualPricer = pricer_ as RangeAccrualPricer; + Utils.QL_REQUIRE(rangeAccrualPricer!=null,()=> "pricer not compatible with range-accrual coupon"); + c.setPricer(rangeAccrualPricer); + } + //public void visit(SubPeriodsCoupon c) + //{ + // SubPeriodsPricer subPeriodsPricer = pricer_ as SubPeriodsPricer; + // Utils.QL_REQUIRE(subPeriodsPricer!=null,()=> "pricer not compatible with sub-period coupon"); + // c.setPricer(subPeriodsPricer); + //} + } + + partial class Utils + { + public static void setCouponPricer( List leg, FloatingRateCouponPricer pricer ) + { + PricerSetter setter = new PricerSetter( pricer ); + foreach ( CashFlow cf in leg ) + { + cf.accept( setter ); + } + } + + public static void setCouponPricers( List leg, List pricers ) + { + int nCashFlows = leg.Count; + Utils.QL_REQUIRE(nCashFlows>0,()=> "no cashflows"); + + int nPricers = pricers.Count; + Utils.QL_REQUIRE(nCashFlows >= nPricers,()=> + "mismatch between leg size (" + nCashFlows + + ") and number of pricers (" + nPricers + ")"); + + for (int i = 0; i < nCashFlows; ++i) + { + PricerSetter setter = new PricerSetter(i < nPricers ? pricers[i] : pricers[nPricers - 1]); + leg[i].accept(setter); + } + } + } } diff --git a/QLNet/Cashflows/DigitalCoupon.cs b/QLNet/Cashflows/DigitalCoupon.cs index 41563bd9d..ac3cc3e4f 100644 --- a/QLNet/Cashflows/DigitalCoupon.cs +++ b/QLNet/Cashflows/DigitalCoupon.cs @@ -83,7 +83,7 @@ public DigitalCoupon(FloatingRateCoupon underlying, bool isPutATMIncluded = false, double? putDigitalPayoff = null, DigitalReplication replication = null) - : base(underlying.nominal(), underlying.date(), underlying.accrualStartDate(), underlying.accrualEndDate(), underlying.fixingDays, underlying.index(), underlying.gearing(), underlying.spread(), underlying.refPeriodStart, underlying.refPeriodEnd, underlying.dayCounter(), underlying.isInArrears()) + : base(underlying.date(), underlying.nominal(), underlying.accrualStartDate(), underlying.accrualEndDate(), underlying.fixingDays, underlying.index(), underlying.gearing(), underlying.spread(), underlying.referencePeriodStart, underlying.referencePeriodEnd, underlying.dayCounter(), underlying.isInArrears()) { if (replication == null) replication = new DigitalReplication(); @@ -104,24 +104,24 @@ public DigitalCoupon(FloatingRateCoupon underlying, if (!(replication.gap() > 0.0)) - throw new ApplicationException("Non positive epsilon not allowed"); + throw new Exception("Non positive epsilon not allowed"); if (putStrike == null) if (!(putDigitalPayoff == null)) - throw new ApplicationException("Put Cash rate non allowed if put strike is null"); + throw new Exception("Put Cash rate non allowed if put strike is null"); if (callStrike == null) if (!(callDigitalPayoff == null)) - throw new ApplicationException("Call Cash rate non allowed if call strike is null"); + throw new Exception("Call Cash rate non allowed if call strike is null"); if (callStrike != null) { if (!(callStrike >= 0.0)) - throw new ApplicationException("negative call strike not allowed"); + throw new Exception("negative call strike not allowed"); hasCallStrike_ = true; callStrike_ = callStrike.GetValueOrDefault(); if (!(callStrike_ >= replication.gap() / 2.0)) - throw new ApplicationException("call strike < eps/2"); + throw new Exception("call strike < eps/2"); switch (callPosition) { @@ -132,7 +132,7 @@ public DigitalCoupon(FloatingRateCoupon underlying, callCsi_ = -1.0; break; default: - throw new ApplicationException("unsupported position type"); + throw new Exception("unsupported position type"); } if (callDigitalPayoff != null) { @@ -143,7 +143,7 @@ public DigitalCoupon(FloatingRateCoupon underlying, if (putStrike != null) { if (!(putStrike >= 0.0)) - throw new ApplicationException("negative put strike not allowed"); + throw new Exception("negative put strike not allowed"); hasPutStrike_ = true; putStrike_ = putStrike.GetValueOrDefault(); @@ -156,7 +156,7 @@ public DigitalCoupon(FloatingRateCoupon underlying, putCsi_ = -1.0; break; default: - throw new ApplicationException("unsupported position type"); + throw new Exception("unsupported position type"); } if (putDigitalPayoff != null) { @@ -184,7 +184,7 @@ public DigitalCoupon(FloatingRateCoupon underlying, callRightEps_ = 0.0; break; default: - throw new ApplicationException("unsupported position type"); + throw new Exception("unsupported position type"); } } if (hasPutStrike_) @@ -200,7 +200,7 @@ public DigitalCoupon(FloatingRateCoupon underlying, putRightEps_ = replication.gap(); break; default: - throw new ApplicationException("unsupported position type"); + throw new Exception("unsupported position type"); } } break; @@ -218,7 +218,7 @@ public DigitalCoupon(FloatingRateCoupon underlying, callRightEps_ = replication.gap(); break; default: - throw new ApplicationException("unsupported position type"); + throw new Exception("unsupported position type"); } } if (hasPutStrike_) @@ -234,12 +234,12 @@ public DigitalCoupon(FloatingRateCoupon underlying, putRightEps_ = 0.0; break; default: - throw new ApplicationException("unsupported position type"); + throw new Exception("unsupported position type"); } } break; default: - throw new ApplicationException("unsupported position type"); + throw new Exception("unsupported position type"); } underlying.registerWith(update); @@ -252,7 +252,7 @@ public override double rate() { if (underlying_.pricer() == null) - throw new ApplicationException("pricer not set"); + throw new Exception("pricer not set"); Date fixingDate = underlying_.fixingDate(); Date today = Settings.evaluationDate(); @@ -289,7 +289,7 @@ public double callStrike() if (hasCall()) return callStrike_; else - throw new ApplicationException("callStrike has not been set"); + throw new Exception("callStrike has not been set"); // return null; } public double putStrike() @@ -297,7 +297,7 @@ public double putStrike() if (hasPut()) return putStrike_; else - throw new ApplicationException("putStrike has not been set"); + throw new Exception("putStrike has not been set"); // return null; } public double callDigitalPayoff() @@ -305,7 +305,7 @@ public double callDigitalPayoff() if (isCallCashOrNothing_) return callDigitalPayoff_; else - throw new ApplicationException("callDigitalPayoff has not been set"); + throw new Exception("callDigitalPayoff has not been set"); // return null; } public double putDigitalPayoff() @@ -313,7 +313,7 @@ public double putDigitalPayoff() if (isPutCashOrNothing_) return putDigitalPayoff_; else - throw new ApplicationException("putDigitalPayoff has not been set"); + throw new Exception("putDigitalPayoff has not been set"); // return null; } public bool hasPut() diff --git a/QLNet/Cashflows/Dividend.cs b/QLNet/Cashflows/Dividend.cs index f4c8213ae..e3d4b471e 100644 --- a/QLNet/Cashflows/Dividend.cs +++ b/QLNet/Cashflows/Dividend.cs @@ -79,7 +79,7 @@ public FractionalDividend(double rate, double nominal, Date date) //! \name Dividend interface public override double amount() { - if (nominal_ == null) throw new ApplicationException("no nominal given"); + if (nominal_ == null) throw new Exception("no nominal given"); return rate_ * nominal_.GetValueOrDefault(); } @@ -96,7 +96,7 @@ public static List DividendVector(List dividendDates, List items = new List(dividendDates.Count); for (int i = 0; i < dividendDates.Count; i++) diff --git a/QLNet/Cashflows/FixedRateCoupon.cs b/QLNet/Cashflows/FixedRateCoupon.cs index cd2163f23..465d61e3b 100644 --- a/QLNet/Cashflows/FixedRateCoupon.cs +++ b/QLNet/Cashflows/FixedRateCoupon.cs @@ -27,26 +27,27 @@ namespace QLNet public class FixedRateCoupon : Coupon { // constructors - public FixedRateCoupon(double nominal, Date paymentDate, double rate, DayCounter dayCounter, + public FixedRateCoupon(Date paymentDate, double nominal, double rate, DayCounter dayCounter, Date accrualStartDate, Date accrualEndDate, - Date refPeriodStart = null, Date refPeriodEnd = null,Date exCouponDate = null,double? amount = null) - : base(nominal, paymentDate, accrualStartDate, accrualEndDate, refPeriodStart, refPeriodEnd, exCouponDate,amount) + Date refPeriodStart = null, Date refPeriodEnd = null,Date exCouponDate = null) + : base( paymentDate, nominal, accrualStartDate, accrualEndDate, refPeriodStart, refPeriodEnd, exCouponDate ) { rate_ = new InterestRate(rate, dayCounter, Compounding.Simple,Frequency.Annual); } - public FixedRateCoupon(double nominal, Date paymentDate, InterestRate interestRate, + public FixedRateCoupon(Date paymentDate, double nominal, InterestRate interestRate, Date accrualStartDate, Date accrualEndDate, - Date refPeriodStart = null, Date refPeriodEnd = null, Date exCouponDate = null, double? amount = null) - : base(nominal, paymentDate, accrualStartDate, accrualEndDate, refPeriodStart, refPeriodEnd,exCouponDate, amount) + Date refPeriodStart = null, Date refPeriodEnd = null, Date exCouponDate = null, double? amount = null) + : base( paymentDate, nominal, accrualStartDate, accrualEndDate, refPeriodStart, refPeriodEnd, exCouponDate ) { + amount_ = amount; rate_ = interestRate; } //! CashFlow interface public override double amount() { - if (amount_ != null) + if ( amount_ != null ) return amount_.Value; return nominal()*(rate_.compoundFactor(accrualStartDate_, @@ -74,6 +75,7 @@ public override double accruedAmount(Date d) } private InterestRate rate_; + private double? amount_; } @@ -197,7 +199,7 @@ public override List value() { if (!(firstPeriodDC_ == null || firstPeriodDC_ == rate.dayCounter())) throw new ArgumentException("regular first coupon does not allow a first-period day count"); - leg.Add(new FixedRateCoupon(nominal, paymentDate, rate, start, end, start, end, exCouponDate)); + leg.Add( new FixedRateCoupon( paymentDate, nominal, rate, start, end, start, end, exCouponDate ) ); } else { @@ -206,7 +208,7 @@ public override List value() InterestRate r = new InterestRate(rate.rate(), (firstPeriodDC_ == null || firstPeriodDC_.empty()) ? rate.dayCounter() : firstPeriodDC_, rate.compounding(), rate.frequency()); - leg.Add(new FixedRateCoupon(nominal, paymentDate, r, start, end, refer, end, exCouponDate)); + leg.Add( new FixedRateCoupon( paymentDate, nominal, r, start, end, refer, end, exCouponDate ) ); } // regular periods @@ -226,7 +228,7 @@ public override List value() if ((i - 1) < notionals_.Count) nominal = notionals_[i - 1]; else nominal = notionals_.Last(); - leg.Add(new FixedRateCoupon(nominal, paymentDate, rate, start, end, start, end, exCouponDate)); + leg.Add( new FixedRateCoupon( paymentDate, nominal, rate, start, end, start, end, exCouponDate ) ); } if (schedule_.Count > 2) { @@ -248,11 +250,11 @@ public override List value() else nominal = notionals_.Last(); if (schedule_.isRegular(N-1)) - leg.Add(new FixedRateCoupon(nominal, paymentDate, rate, start, end, start, end, exCouponDate)); + leg.Add( new FixedRateCoupon( paymentDate, nominal, rate, start, end, start, end, exCouponDate ) ); else { Date refer = start + schedule_.tenor(); refer = schCalendar.adjust(refer, schedule_.businessDayConvention()); - leg.Add(new FixedRateCoupon(nominal, paymentDate, rate, start, end, start, refer, exCouponDate)); + leg.Add( new FixedRateCoupon( paymentDate, nominal, rate, start, end, start, refer, exCouponDate ) ); } } return leg; diff --git a/QLNet/Cashflows/FloatingRateCoupon.cs b/QLNet/Cashflows/FloatingRateCoupon.cs index 3ae2a3fd8..ec2630d89 100644 --- a/QLNet/Cashflows/FloatingRateCoupon.cs +++ b/QLNet/Cashflows/FloatingRateCoupon.cs @@ -32,9 +32,9 @@ public class FloatingRateCoupon : Coupon, IObserver protected bool isInArrears_; protected FloatingRateCouponPricer pricer_; - // constructors - public FloatingRateCoupon(double nominal, - Date paymentDate, + // constructors + public FloatingRateCoupon(Date paymentDate, + double nominal, Date startDate, Date endDate, int fixingDays, @@ -44,8 +44,8 @@ public FloatingRateCoupon(double nominal, Date refPeriodStart = null, Date refPeriodEnd = null, DayCounter dayCounter = null, - bool isInArrears = false) - : base(nominal, paymentDate, startDate, endDate, refPeriodStart, refPeriodEnd) + bool isInArrears = false) + : base( paymentDate, nominal, startDate, endDate, refPeriodStart, refPeriodEnd ) { index_ = index; dayCounter_ = dayCounter ?? new DayCounter() ; @@ -164,8 +164,8 @@ public virtual double convexityAdjustment() public virtual CashFlow factory(double nominal, Date paymentDate, Date startDate, Date endDate, int fixingDays, InterestRateIndex index, double gearing, double spread, Date refPeriodStart, Date refPeriodEnd, DayCounter dayCounter, bool isInArrears) - { - return new FloatingRateCoupon(nominal, paymentDate, startDate, endDate, fixingDays, + { + return new FloatingRateCoupon( paymentDate, nominal, startDate, endDate, fixingDays, index, gearing, spread, refPeriodStart, refPeriodEnd, dayCounter, isInArrears); } } diff --git a/QLNet/Cashflows/Iborcoupon.cs b/QLNet/Cashflows/Iborcoupon.cs index 3d468e64d..218f26143 100644 --- a/QLNet/Cashflows/Iborcoupon.cs +++ b/QLNet/Cashflows/Iborcoupon.cs @@ -26,12 +26,10 @@ namespace QLNet // Coupon paying a Libor-type index public class IborCoupon : FloatingRateCoupon { - private IborIndex iborIndex_; - public IborCoupon() { } - public IborCoupon(double nominal, - Date paymentDate, + public IborCoupon(Date paymentDate, + double nominal, Date startDate, Date endDate, int fixingDays, @@ -41,90 +39,94 @@ public IborCoupon(double nominal, Date refPeriodStart = null, Date refPeriodEnd = null, DayCounter dayCounter = null, - bool isInArrears = false) : - base(nominal, paymentDate, startDate, endDate, fixingDays, iborIndex, gearing, spread, + bool isInArrears = false) : + base( paymentDate, nominal, startDate, endDate, fixingDays, iborIndex, gearing, spread, refPeriodStart, refPeriodEnd, dayCounter, isInArrears) { iborIndex_ = iborIndex; + + fixingDate_ = fixingDate(); + + Calendar fixingCalendar = index_.fixingCalendar(); + int indexFixingDays = index_.fixingDays(); + + fixingValueDate_ = fixingCalendar.advance(fixingDate_, indexFixingDays, TimeUnit.Days); + + #if QL_USE_INDEXED_COUPON + fixingEndDate_ = index_->maturityDate(fixingValueDate_); + #else + if (isInArrears_) + fixingEndDate_ = index_.maturityDate(fixingValueDate_); + else + { + // par coupon approximation + Date nextFixingDate = fixingCalendar.advance(accrualEndDate_, -fixingDays_, TimeUnit.Days); + fixingEndDate_ = fixingCalendar.advance(nextFixingDate, indexFixingDays, TimeUnit.Days); + } + #endif + + DayCounter dc = index_.dayCounter(); + spanningTime_ = dc.yearFraction(fixingValueDate_,fixingEndDate_); + Utils.QL_REQUIRE(spanningTime_>0.0,()=> + "\n cannot calculate forward rate between " + + fixingValueDate_ + " and " + fixingEndDate_ + + ":\n non positive time (" + spanningTime_ + + ") using " + dc.name() + " daycounter"); } + // Inspectors + public IborIndex iborIndex() {return iborIndex_;} + + //! FloatingRateCoupon interface //! Implemented in order to manage the case of par coupon public override double indexFixing() { -#if QL_USE_INDEXED_COUPON - return index_.fixing(fixingDate()); -#else - if (isInArrears()) + /* instead of just returning index_->fixing(fixingValueDate_) + its logic is duplicated here using a specialized iborIndex + forecastFixing overload which + 1) allows to save date/time recalculations, and + 2) takes into account par coupon needs + */ + Date today = Settings.evaluationDate(); + + if (fixingDate_ > today) + return iborIndex_.forecastFixing(fixingValueDate_,fixingEndDate_,spanningTime_); + + if (fixingDate_ < today || Settings.enforcesTodaysHistoricFixings) { - return index_.fixing(fixingDate()); + // do not catch exceptions + double? result = index_.pastFixing(fixingDate_); + Utils.QL_REQUIRE(result != null,()=> "Missing " + index_.name() + " fixing for " + fixingDate_); + return result.Value; } - else + + try + { + double? result = index_.pastFixing(fixingDate_); + if (result != null) + return result.Value; + + } + catch (Exception) { - Date today = Settings.evaluationDate(); - Date fixingDate = this.fixingDate(); - - TimeSeries fixings = IndexManager.instance().getHistory(index_.name()).value(); - if (fixings.ContainsKey(fixingDate)) - { - return fixings[fixingDate]; - } - else - { - if (fixingDate < today) - { - // must have been fixed - if (IndexManager.MissingPastFixingCallBack == null) - { - throw new ArgumentException("Missing " + index_.name() + " fixing for " + fixingDate); - } - else - { - // try to load missing fixing from external source - double fixing = IndexManager.MissingPastFixingCallBack(index_, fixingDate); - // add to history - index_.addFixing(fixingDate, fixing); - return fixing; - } - } - if (fixingDate == today) - { - // might have been fixed - // fall through and forecast - } - } - - // forecast: 0) forecasting curve - Handle termStructure = iborIndex_.forwardingTermStructure(); - if (termStructure.empty()) - throw new ApplicationException("null term structure set to this instance of " + - index_.name()); - // forecast: 1) startDiscount - Date fixingValueDate = index_.fixingCalendar().advance(fixingDate, index_.fixingDays(), TimeUnit.Days); - double startDiscount = termStructure.link.discount(fixingValueDate); - // forecast: 2) endDiscount - Date nextFixingDate = index_.fixingCalendar().advance(accrualEndDate_, -fixingDays, TimeUnit.Days); - Date nextFixingValueDate = index_.fixingCalendar().advance(nextFixingDate, index_.fixingDays(), TimeUnit.Days); - double endDiscount = termStructure.link.discount(nextFixingValueDate); - // forecast: 3) spanningTime - double spanningTime = index_.dayCounter().yearFraction(fixingValueDate, nextFixingValueDate); - if (!(spanningTime > 0.0)) - throw new ApplicationException("cannot calculate forward rate between " + - fixingValueDate + " and " + nextFixingValueDate + - ": non positive time using " + index_.dayCounter().name()); - // forecast: 4) implied fixing - return (startDiscount / endDiscount - 1.0) / spanningTime; + // fall through and forecast } -#endif + return iborIndex_.forecastFixing(fixingValueDate_,fixingEndDate_,spanningTime_); + } // Factory - for Leg generators public override CashFlow factory(double nominal, Date paymentDate, Date startDate, Date endDate, int fixingDays, InterestRateIndex index, double gearing, double spread, Date refPeriodStart, Date refPeriodEnd, DayCounter dayCounter, bool isInArrears) - { - return new IborCoupon(nominal, paymentDate, startDate, endDate, fixingDays, + { + return new IborCoupon( paymentDate, nominal, startDate, endDate, fixingDays, (IborIndex)index, gearing, spread, refPeriodStart, refPeriodEnd, dayCounter, isInArrears); - } + } + + private IborIndex iborIndex_; + private Date fixingDate_, fixingValueDate_, fixingEndDate_; + private double spanningTime_; } //! helper class building a sequence of capped/floored ibor-rate coupons diff --git a/QLNet/Cashflows/InflationCoupon.cs b/QLNet/Cashflows/InflationCoupon.cs index 85bbffce3..dc0931a1a 100644 --- a/QLNet/Cashflows/InflationCoupon.cs +++ b/QLNet/Cashflows/InflationCoupon.cs @@ -42,7 +42,7 @@ public InflationCoupon(Date paymentDate, Date refPeriodStart = null, Date refPeriodEnd = null, Date exCouponDate = null) - : base(nominal, paymentDate, startDate, endDate, refPeriodStart, refPeriodEnd, exCouponDate) // ref period is before lag + : base( paymentDate, nominal, startDate, endDate, refPeriodStart, refPeriodEnd, exCouponDate ) // ref period is before lag { index_ = index; observationLag_ = observationLag; @@ -81,7 +81,7 @@ public override double accruedAmount(Date d) public override double rate() { if (pricer_ == null) - throw new ApplicationException("pricer not set"); + throw new Exception("pricer not set"); // we know it is the correct type because checkPricerImpl checks on setting // in general pricer_ will be a derived class, as will *this on calling @@ -118,7 +118,7 @@ public virtual double indexFixing() public void setPricer(InflationCouponPricer pricer) { if (!checkPricerImpl(pricer)) - throw new ApplicationException("pricer given is wrong type"); + throw new Exception("pricer given is wrong type"); if (pricer_ != null) pricer_.unregisterWith(update); diff --git a/QLNet/Cashflows/InflationCouponPricer.cs b/QLNet/Cashflows/InflationCouponPricer.cs index 726cddc4b..7b490978c 100644 --- a/QLNet/Cashflows/InflationCouponPricer.cs +++ b/QLNet/Cashflows/InflationCouponPricer.cs @@ -101,7 +101,7 @@ public virtual Handle capletVolatility() public virtual void setCapletVolatility(Handle capletVol) { if ( capletVol.empty() ) - throw new ApplicationException("empty capletVol handle"); + throw new Exception("empty capletVol handle"); capletVol_ = capletVol; capletVol_.registerWith(update); @@ -192,7 +192,7 @@ protected virtual double optionletPrice(Option.Type optionType, double effStrike { // not yet determined, use Black/DD1/Bachelier/whatever from Impl if ( capletVolatility().empty() ) - throw new ApplicationException ("missing optionlet volatility"); + throw new Exception ("missing optionlet volatility"); double stdDev = Math.Sqrt(capletVolatility().link.totalVariance(fixingDate,effStrike)); @@ -211,7 +211,7 @@ protected virtual double optionletPrice(Option.Type optionType, double effStrike protected virtual double optionletPriceImp(Option.Type t, double strike, double forward, double stdDev) { - throw new ApplicationException("you must implement this to get a vol-dependent price"); + throw new Exception("you must implement this to get a vol-dependent price"); } protected virtual double adjustedFixing() diff --git a/QLNet/Cashflows/OvernightIndexedCoupon.cs b/QLNet/Cashflows/OvernightIndexedCoupon.cs index ad7e3b89b..c8156b385 100644 --- a/QLNet/Cashflows/OvernightIndexedCoupon.cs +++ b/QLNet/Cashflows/OvernightIndexedCoupon.cs @@ -31,7 +31,7 @@ public override void initialize(FloatingRateCoupon coupon) { coupon_ = coupon as OvernightIndexedCoupon; if (coupon_ == null) - throw new ApplicationException("wrong coupon type"); + throw new Exception("wrong coupon type"); } public override double swapletRate() @@ -55,7 +55,7 @@ public override double swapletRate() index.name()).value()[fixingDates[i]]; if (pastFixing == default(double) ) - throw new ApplicationException("Missing " + index.name() + " fixing for " + throw new Exception("Missing " + index.name() + " fixing for " + fixingDates[i].ToString()); compoundFactor *= (1.0 + pastFixing*dt[i]); @@ -108,17 +108,16 @@ public override double swapletRate() } public override double swapletPrice() - { throw new ApplicationException("swapletPrice not available"); } + { throw new Exception("swapletPrice not available"); } public override double capletPrice(double d) - { throw new ApplicationException("capletPrice not available"); } + { throw new Exception("capletPrice not available"); } public override double capletRate(double d) - { throw new ApplicationException("capletRate not available"); } + { throw new Exception("capletRate not available"); } public override double floorletPrice(double d) - { throw new ApplicationException("floorletPrice not available"); } + { throw new Exception("floorletPrice not available"); } public override double floorletRate(double d) - { throw new ApplicationException("floorletRate not available"); } - protected override double optionletPrice(Option.Type t, double d) - { throw new ApplicationException("optionletPrice not available"); } + { throw new Exception("floorletRate not available"); } + } @@ -135,7 +134,7 @@ public OvernightIndexedCoupon( Date refPeriodStart = null, Date refPeriodEnd = null, DayCounter dayCounter = null) - : base(nominal, paymentDate,startDate, endDate, + : base( paymentDate, nominal, startDate, endDate, overnightIndex.fixingDays(), overnightIndex, gearing, spread, refPeriodStart, refPeriodEnd, diff --git a/QLNet/Cashflows/RangeAccrual.cs b/QLNet/Cashflows/RangeAccrual.cs new file mode 100644 index 000000000..1ccc262d6 --- /dev/null +++ b/QLNet/Cashflows/RangeAccrual.cs @@ -0,0 +1,667 @@ +// Copyright (C) 2008-2016 Andrea Maggiulli (a.maggiulli@gmail.com) +// +// This file is part of QLNet Project https://github.com/amaggiulli/qlnet +// QLNet is free software: you can redistribute it and/or modify it +// under the terms of the QLNet license. You should have received a +// copy of the license along with this program; if not, license is +// available online at . +// +// QLNet is a based on QuantLib, a free-software/open-source library +// for financial quantitative analysts and developers - http://quantlib.org/ +// The QuantLib license is available online at http://quantlib.org/license.shtml. +// +// This program is distributed in the hope that it will be useful, but WITHOUT +// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +// FOR A PARTICULAR PURPOSE. See the license for more details. +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +namespace QLNet +{ + public class RangeAccrualFloatersCoupon : FloatingRateCoupon + { + public RangeAccrualFloatersCoupon(Date paymentDate, + double nominal, + IborIndex index, + Date startDate, + Date endDate, + int fixingDays, + DayCounter dayCounter, + double gearing, + double spread, + Date refPeriodStart, + Date refPeriodEnd, + Schedule observationsSchedule, + double lowerTrigger, + double upperTrigger) + :base(paymentDate, nominal, startDate, endDate,fixingDays, index, gearing, spread,refPeriodStart, refPeriodEnd, + dayCounter) + { + observationsSchedule_ = observationsSchedule; + lowerTrigger_ = lowerTrigger; + upperTrigger_ = upperTrigger; + + Utils.QL_REQUIRE(lowerTrigger_ "lowerTrigger_>=upperTrigger"); + Utils.QL_REQUIRE(observationsSchedule_.startDate()==startDate,()=> "incompatible start date"); + Utils.QL_REQUIRE(observationsSchedule_.endDate()==endDate,()=> "incompatible end date"); + + observationDates_ = observationsSchedule_.dates(); + observationDates_.RemoveAt(observationDates_.Count-1); //remove end date + observationDates_.RemoveAt(0); //remove start date + observationsNo_ = observationDates_.Count; + + Handle rateCurve = index.forwardingTermStructure(); + Date referenceDate = rateCurve.link.referenceDate(); + + startTime_ = dayCounter.yearFraction(referenceDate, startDate); + endTime_ = dayCounter.yearFraction(referenceDate, endDate); + observationTimes_ = new List(); + for(int i=0;i observationDates() {return observationDates_;} + public List observationTimes() {return observationTimes_;} + public Schedule observationsSchedule() {return observationsSchedule_;} + + public double priceWithoutOptionality(Handle discountCurve) + { + return accrualPeriod() * (gearing_*indexFixing()+spread_) * + nominal() * discountCurve.link.discount(date()); + } + + + private double startTime_; + private double endTime_; + + private Schedule observationsSchedule_; + private List observationDates_; + private List observationTimes_; + private int observationsNo_; + + private double lowerTrigger_; + private double upperTrigger_; + + } + + public class RangeAccrualPricer: FloatingRateCouponPricer + { + // Observer interface + public override double swapletPrice() {throw new NotImplementedException();} + public override double swapletRate() {return swapletPrice()/(accrualFactor_*discount_);} + public override double capletPrice(double effectiveCap) + { + Utils.QL_FAIL("RangeAccrualPricer::capletPrice not implemented"); + return 0; + } + public override double capletRate(double effectiveCap) + { + Utils.QL_FAIL("RangeAccrualPricer::capletRate not implemented"); + return 0; + } + public override double floorletPrice(double effectiveFloor) + { + Utils.QL_FAIL("RangeAccrualPricer::floorletPrice not implemented"); + return 0; + } + public override double floorletRate(double effectiveFloor) + { + Utils.QL_FAIL("RangeAccrualPricer::floorletRate not implemented"); + return 0; + } + public override void initialize(FloatingRateCoupon coupon) + { + coupon_ = coupon as RangeAccrualFloatersCoupon; + Utils.QL_REQUIRE(coupon_!=null,()=> "range-accrual coupon required"); + gearing_ = coupon_.gearing(); + spread_ = coupon_.spread(); + + Date paymentDate = coupon_.date(); + + IborIndex index = coupon_.index() as IborIndex; + Utils.QL_REQUIRE(index!=null,()=> "invalid index"); + Handle rateCurve = index.forwardingTermStructure(); + discount_ = rateCurve.link.discount(paymentDate); + accrualFactor_ = coupon_.accrualPeriod(); + spreadLegValue_ = spread_*accrualFactor_*discount_; + + startTime_ = coupon_.startTime(); + endTime_ = coupon_.endTime(); + observationTimes_ = coupon_.observationTimes(); + lowerTrigger_ = coupon_.lowerTrigger(); + upperTrigger_ = coupon_.upperTrigger(); + observationsNo_ = coupon_.observationsNo(); + + List observationDates = coupon_.observationsSchedule().dates(); + Utils.QL_REQUIRE(observationDates.Count == observationsNo_ + 2,()=> "incompatible size of initialValues vector"); + initialValues_ = new InitializedList(observationDates.Count, 0.0); + + Calendar calendar = index.fixingCalendar(); + for (int i = 0; i < observationDates.Count; i++) + { + initialValues_[i] = index.fixing( + calendar.advance(observationDates[i],-coupon_.fixingDays,TimeUnit.Days)); + } + + } + + protected RangeAccrualFloatersCoupon coupon_; + protected double startTime_; // S + protected double endTime_; // T + protected double accrualFactor_; // T-S + protected List observationTimeLags_; // d + protected List observationTimes_; // U + protected List initialValues_; + protected int observationsNo_; + protected double lowerTrigger_; + protected double upperTrigger_; + protected double discount_; + protected double gearing_; + protected double spread_; + protected double spreadLegValue_; + } + + public class RangeAccrualPricerByBgm : RangeAccrualPricer + { + public RangeAccrualPricerByBgm(double correlation, + SmileSection smilesOnExpiry, + SmileSection smilesOnPayment, + bool withSmile, + bool byCallSpread) + { + correlation_ = correlation; + withSmile_ = withSmile; + byCallSpread_ = byCallSpread; + smilesOnExpiry_ = smilesOnExpiry; + smilesOnPayment_ = smilesOnPayment; + eps_ = 1.0e-8; + } + // Observer interface + public override double swapletPrice() + { + double result = 0.0; + double deflator = discount_*initialValues_[0]; + for(int i=0;i 0 ? driftBeforeFixing : driftAfterFixing; + } + protected double derDriftDerLambdaS(double U, double lambdaS, double lambdaT,double correlation) + { + double p = (U - startTime_)/accrualFactor_; + double q = (endTime_ - U)/accrualFactor_; + double L0T = initialValues_.Last(); + + double driftBeforeFixing = p*accrualFactor_*L0T/(1.0 + L0T*accrualFactor_) + *(q*lambdaT*correlation) + 2*q*lambdaS + p*lambdaT*correlation; + double driftAfterFixing = 0.0; + + return startTime_ > 0 ? driftBeforeFixing : driftAfterFixing; + } + protected double derDriftDerLambdaT(double U, double lambdaS, double lambdaT,double correlation) + { + double p = (U - startTime_)/accrualFactor_; + double q = (endTime_ - U)/accrualFactor_; + double L0T = initialValues_.Last(); + + double driftBeforeFixing = p*accrualFactor_*L0T/(1.0 + L0T*accrualFactor_) + *(2*p*lambdaT + q*lambdaS*correlation) + +p*lambdaS*correlation; + double driftAfterFixing = (p*accrualFactor_*L0T/(1.0 + L0T*accrualFactor_) - 0.5) + *2*lambdaT; + + return startTime_ > 0 ? driftBeforeFixing : driftAfterFixing; + } + + protected double lambda(double U, double lambdaS, double lambdaT) + { + double p = (U - startTime_)/accrualFactor_; + double q = (endTime_ - U)/accrualFactor_; + + return startTime_ > 0 ? q*lambdaS + p*lambdaT : lambdaT; + } + protected double derLambdaDerLambdaS(double U) + { + return startTime_ > 0 ? (endTime_ - U)/accrualFactor_ : 0.0; + } + + protected double derLambdaDerLambdaT(double U) + { + return startTime_ > 0 ? (U - startTime_)/accrualFactor_ : 0.0; + } + + protected List driftsOverPeriod(double U, double lambdaS, double lambdaT,double correlation) + { + List result = new List(); + + double p = (U-startTime_)/accrualFactor_; + double q = (endTime_-U)/accrualFactor_; + double L0T = initialValues_.Last(); + + double driftBeforeFixing = + p*accrualFactor_*L0T/(1.0+L0T*accrualFactor_)*(p*lambdaT*lambdaT + q*lambdaS*lambdaT*correlation) + + q*lambdaS*lambdaS + p*lambdaS*lambdaT*correlation + -0.5*lambda(U,lambdaS,lambdaT)*lambda(U,lambdaS,lambdaT); + double driftAfterFixing = (p*accrualFactor_*L0T/(1.0+L0T*accrualFactor_)-0.5)*lambdaT*lambdaT; + + result.Add(driftBeforeFixing); + result.Add(driftAfterFixing); + + return result; + } + protected List lambdasOverPeriod(double U, double lambdaS,double lambdaT) + { + List result = new List(); + + double p = (U - startTime_)/accrualFactor_; + double q = (endTime_ - U)/accrualFactor_; + + double lambdaBeforeFixing = q*lambdaS + p*lambdaT; + double lambdaAfterFixing = lambdaT; + + result.Add(lambdaBeforeFixing); + result.Add(lambdaAfterFixing); + + return result; + } + + protected double digitalRangePrice(double lowerTrigger,double upperTrigger,double initialValue,double expiry, + double deflator) + { + double lowerPrice = digitalPrice(lowerTrigger, initialValue, expiry, deflator); + double upperPrice = digitalPrice(upperTrigger, initialValue, expiry, deflator); + double result = lowerPrice - upperPrice; + Utils.QL_REQUIRE(result > 0.0,()=> + "RangeAccrualPricerByBgm::digitalRangePrice:\n digitalPrice(" + upperTrigger + + "): " + upperPrice + " > digitalPrice(" + lowerTrigger + "): " + lowerPrice); + return result; + } + + protected double digitalPrice(double strike,double initialValue,double expiry,double deflator) + { + double result = deflator; + if (strike > eps_/2) + { + result = withSmile_ + ? digitalPriceWithSmile(strike, initialValue, expiry, deflator) + : digitalPriceWithoutSmile(strike, initialValue, expiry, deflator); + } + return result; + } + + protected double digitalPriceWithoutSmile(double strike,double initialValue,double expiry,double deflator) + { + double lambdaS = smilesOnExpiry_.volatility(strike); + double lambdaT = smilesOnPayment_.volatility(strike); + + List lambdaU = lambdasOverPeriod(expiry, lambdaS, lambdaT); + double variance = startTime_*lambdaU[0]*lambdaU[0] + (expiry - startTime_)*lambdaU[1]*lambdaU[1]; + + double lambdaSATM = smilesOnExpiry_.volatility(initialValue); + double lambdaTATM = smilesOnPayment_.volatility(initialValue); + //drift of Lognormal process (of Libor) "a_U()" nel paper + List muU = driftsOverPeriod(expiry, lambdaSATM, lambdaTATM, correlation_); + double adjustment = (startTime_*muU[0] + (expiry - startTime_)*muU[1]); + + + double d2 = (Math.Log(initialValue/strike) + adjustment - 0.5*variance)/Math.Sqrt(variance); + + CumulativeNormalDistribution phi = new CumulativeNormalDistribution(); + double result = deflator*phi.value(d2); + + Utils.QL_REQUIRE(result > 0.0,()=> + "RangeAccrualPricerByBgm::digitalPriceWithoutSmile: result< 0. Result:" + result); + Utils.QL_REQUIRE(result/deflator <= 1.0,()=> + "RangeAccrualPricerByBgm::digitalPriceWithoutSmile: result/deflator > 1. Ratio: " + + result/deflator + " result: " + result + " deflator: " + deflator); + + return result; + } + + protected double digitalPriceWithSmile(double strike,double initialValue,double expiry,double deflator) + { + double result; + if (byCallSpread_) + { + // Previous strike + double previousStrike = strike - eps_/2; + double lambdaS = smilesOnExpiry_.volatility(previousStrike); + double lambdaT = smilesOnPayment_.volatility(previousStrike); + + //drift of Lognormal process (of Libor) "a_U()" nel paper + List lambdaU = lambdasOverPeriod(expiry, lambdaS, lambdaT); + double previousVariance = Math.Max(startTime_, 0.0)*lambdaU[0]*lambdaU[0] + + Math.Min(expiry - startTime_, expiry)*lambdaU[1]*lambdaU[1]; + + double lambdaSATM = smilesOnExpiry_.volatility(initialValue); + double lambdaTATM = smilesOnPayment_.volatility(initialValue); + List muU = driftsOverPeriod(expiry, lambdaSATM, lambdaTATM, correlation_); + double previousAdjustment = Math.Exp(Math.Max(startTime_, 0.0)*muU[0] + + Math.Min(expiry - startTime_, expiry)*muU[1]); + double previousForward = initialValue*previousAdjustment; + + // Next strike + double nextStrike = strike + eps_/2; + lambdaS = smilesOnExpiry_.volatility(nextStrike); + lambdaT = smilesOnPayment_.volatility(nextStrike); + + lambdaU = lambdasOverPeriod(expiry, lambdaS, lambdaT); + double nextVariance = Math.Max(startTime_, 0.0)*lambdaU[0]*lambdaU[0] + + Math.Min(expiry - startTime_, expiry)*lambdaU[1]*lambdaU[1]; + //drift of Lognormal process (of Libor) "a_U()" nel paper + muU = driftsOverPeriod(expiry, lambdaSATM, lambdaTATM, correlation_); + double nextAdjustment = Math.Exp(Math.Max(startTime_, 0.0)*muU[0] + + Math.Min(expiry - startTime_, expiry)*muU[1]); + double nextForward = initialValue*nextAdjustment; + + result = callSpreadPrice(previousForward, nextForward, previousStrike, nextStrike, + deflator, previousVariance, nextVariance); + } + else + { + result = digitalPriceWithoutSmile(strike, initialValue, expiry, deflator) + + smileCorrection(strike, initialValue, expiry, deflator); + } + + Utils.QL_REQUIRE(result > -Math.Pow(eps_, .5),()=> + "RangeAccrualPricerByBgm::digitalPriceWithSmile: result< 0 Result:" + result); + Utils.QL_REQUIRE(result/deflator <= 1.0 + Math.Pow(eps_, .2),()=> + "RangeAccrualPricerByBgm::digitalPriceWithSmile: result/deflator > 1. Ratio: " + + result/deflator + " result: " + result + " deflator: " + deflator); + + return result; + } + + protected double callSpreadPrice(double previousForward, + double nextForward, + double previousStrike, + double nextStrike, + double deflator, + double previousVariance, + double nextVariance) + { + double nextCall = Utils.blackFormula(Option.Type.Call, nextStrike, nextForward, + Math.Sqrt(nextVariance), deflator); + double previousCall = Utils.blackFormula(Option.Type.Call, previousStrike, previousForward, + Math.Sqrt(previousVariance), deflator); + + Utils.QL_REQUIRE(nextCall + "RangeAccrualPricerByBgm::callSpreadPrice: nextCall > previousCall" + + "\n nextCall: strike :" + nextStrike + "; variance: " + nextVariance + + " adjusted initial value " + nextForward + + "\n previousCall: strike :" + previousStrike + "; variance: " + previousVariance + + " adjusted initial value " + previousForward ); + + return (previousCall-nextCall)/(nextStrike-previousStrike); + } + + protected double smileCorrection(double strike, + double forward, + double expiry, + double deflator) + { + double previousStrike = strike - eps_/2; + double nextStrike = strike + eps_/2; + + double derSmileS = (smilesOnExpiry_.volatility(nextStrike) - + smilesOnExpiry_.volatility(previousStrike))/eps_; + double derSmileT = (smilesOnPayment_.volatility(nextStrike) - + smilesOnPayment_.volatility(previousStrike))/eps_; + + double lambdaS = smilesOnExpiry_.volatility(strike); + double lambdaT = smilesOnPayment_.volatility(strike); + + double derLambdaDerK = derLambdaDerLambdaS(expiry)*derSmileS + + derLambdaDerLambdaT(expiry)*derSmileT; + + + double lambdaSATM = smilesOnExpiry_.volatility(forward); + double lambdaTATM = smilesOnPayment_.volatility(forward); + List lambdasOverPeriodU = lambdasOverPeriod(expiry, lambdaS, lambdaT); + //drift of Lognormal process (of Libor) "a_U()" nel paper + List muU = driftsOverPeriod(expiry, lambdaSATM, lambdaTATM, correlation_); + + double variance = Math.Max(startTime_, 0.0)*lambdasOverPeriodU[0]*lambdasOverPeriodU[0] + + Math.Min(expiry - startTime_, expiry)*lambdasOverPeriodU[1]*lambdasOverPeriodU[1]; + + double forwardAdjustment = Math.Exp(Math.Max(startTime_, 0.0)*muU[0] + + Math.Min(expiry - startTime_, expiry)*muU[1]); + double forwardAdjusted = forward*forwardAdjustment; + + double d1 = (Math.Log(forwardAdjusted/strike) + 0.5*variance)/Math.Sqrt(variance); + + double sqrtOfTimeToExpiry = (Math.Max(startTime_, 0.0)*lambdasOverPeriodU[0] + + Math.Min(expiry - startTime_, expiry)*lambdasOverPeriodU[1])*(1.0/Math.Sqrt(variance)); + + CumulativeNormalDistribution phi = new CumulativeNormalDistribution(); + NormalDistribution psi = new NormalDistribution(); + double result = -forwardAdjusted*psi.value(d1)*sqrtOfTimeToExpiry*derLambdaDerK; + + result *= deflator; + + Utils.QL_REQUIRE(Math.Abs(result/deflator) <= 1.0 + Math.Pow(eps_, .2),()=> + "RangeAccrualPricerByBgm::smileCorrection: abs(result/deflator) > 1. Ratio: " + + result/deflator + " result: " + result + " deflator: " + deflator); + + return result; + } + + + private double correlation_; // correlation between L(S) and L(T) + private bool withSmile_; + private bool byCallSpread_; + + private SmileSection smilesOnExpiry_; + private SmileSection smilesOnPayment_; + private double eps_; + } + + //! helper class building a sequence of range-accrual floating-rate coupons + public class RangeAccrualLeg + { + public RangeAccrualLeg(Schedule schedule, IborIndex index) + { + schedule_ = schedule; + index_ = index; + paymentAdjustment_ = BusinessDayConvention.Following; + observationConvention_ = BusinessDayConvention.ModifiedFollowing; + } + public RangeAccrualLeg withNotionals(double notional) + { + notionals_ = new InitializedList(1,notional); + return this; + } + public RangeAccrualLeg withNotionals(List notionals) + { + notionals_ = notionals; + return this; + } + public RangeAccrualLeg withPaymentDayCounter(DayCounter dayCounter) + { + paymentDayCounter_ = dayCounter; + return this; + } + public RangeAccrualLeg withPaymentAdjustment(BusinessDayConvention convention) + { + paymentAdjustment_ = convention; + return this; + } + public RangeAccrualLeg withFixingDays(int fixingDays) + { + fixingDays_ = new InitializedList(1,fixingDays); + return this; + } + public RangeAccrualLeg withFixingDays(List fixingDays) + { + fixingDays_ = fixingDays; + return this; + } + public RangeAccrualLeg withGearings(double gearing) + { + gearings_ = new InitializedList(1,gearing); + return this; + } + public RangeAccrualLeg withGearings(List gearings) + { + gearings_ = gearings; + return this; + } + public RangeAccrualLeg withSpreads(double spread) + { + spreads_ = new InitializedList(1,spread); + return this; + } + public RangeAccrualLeg withSpreads(List spreads) + { + spreads_ = spreads; + return this; + } + public RangeAccrualLeg withLowerTriggers(double trigger) + { + lowerTriggers_ = new InitializedList(1,trigger); + return this; + } + public RangeAccrualLeg withLowerTriggers(List triggers) + { + lowerTriggers_ = triggers; + return this; + } + public RangeAccrualLeg withUpperTriggers(double trigger) + { + upperTriggers_ = new InitializedList(1,trigger); + return this; + } + public RangeAccrualLeg withUpperTriggers(List triggers) + { + upperTriggers_ = triggers; + return this; + } + public RangeAccrualLeg withObservationTenor(Period tenor) + { + observationTenor_ = tenor; + return this; + } + public RangeAccrualLeg withObservationConvention(BusinessDayConvention convention) + { + observationConvention_ = convention; + return this; + } + public List Leg() + { + Utils.QL_REQUIRE(!notionals_.empty(),()=> "no notional given"); + + int n = schedule_.Count - 1; + Utils.QL_REQUIRE(notionals_.Count <= n,()=> + "too many nominals (" + notionals_.Count + "), only " + n + " required"); + Utils.QL_REQUIRE(fixingDays_.Count <= n,()=> + "too many fixingDays (" + fixingDays_.Count + "), only " + n + " required"); + Utils.QL_REQUIRE(gearings_.Count <= n,()=> + "too many gearings (" + gearings_.Count + "), only " + n + " required"); + Utils.QL_REQUIRE(spreads_.Count<= n,()=> + "too many spreads (" + spreads_.Count + "), only " + n + " required"); + Utils.QL_REQUIRE(lowerTriggers_.Count <= n,()=> + "too many lowerTriggers (" + lowerTriggers_.Count + "), only " + n + " required"); + Utils.QL_REQUIRE(upperTriggers_.Count <= n,()=> + "too many upperTriggers (" + upperTriggers_.Count + "), only " + n + " required"); + + List leg = new List(); + + + // the following is not always correct + Calendar calendar = schedule_.calendar(); + + Date refStart, start, refEnd, end; + Date paymentDate; + List observationsSchedules = new List(); + + for (int i = 0; i < n; ++i) + { + refStart = start = schedule_.date(i); + refEnd = end = schedule_.date(i + 1); + paymentDate = calendar.adjust(end, paymentAdjustment_); + if (i == 0 && !schedule_.isRegular(i + 1)) + { + BusinessDayConvention bdc = schedule_.businessDayConvention(); + refStart = calendar.adjust(end - schedule_.tenor(), bdc); + } + if (i == n - 1 && !schedule_.isRegular(i + 1)) + { + BusinessDayConvention bdc = schedule_.businessDayConvention(); + refEnd = calendar.adjust(start + schedule_.tenor(), bdc); + } + if (Utils.Get(gearings_, i, 1.0) == 0.0) + { + // fixed coupon + leg.Add( new FixedRateCoupon(paymentDate, + Utils.Get(notionals_, i), + Utils.Get(spreads_, i, 0.0), + paymentDayCounter_, + start, end, refStart, refEnd)); + } + else + { + // floating coupon + observationsSchedules.Add( new Schedule(start, end, + observationTenor_, calendar, + observationConvention_, + observationConvention_, + DateGeneration.Rule.Forward, false)); + + leg.Add( new RangeAccrualFloatersCoupon(paymentDate, + Utils.Get(notionals_, i), + index_, + start, end, + Utils.Get(fixingDays_, i, 2), + paymentDayCounter_, + Utils.Get(gearings_, i, 1.0), + Utils.Get(spreads_, i, 0.0), + refStart, refEnd, + observationsSchedules.Last(), + Utils.Get(lowerTriggers_, i), + Utils.Get(upperTriggers_, i))); + } + } + return leg; + + } + + + private Schedule schedule_; + private IborIndex index_; + private List notionals_; + private DayCounter paymentDayCounter_; + private BusinessDayConvention paymentAdjustment_; + private List fixingDays_; + private List gearings_; + private List spreads_; + private List lowerTriggers_, upperTriggers_; + private Period observationTenor_; + private BusinessDayConvention observationConvention_; + } +} diff --git a/QLNet/Cashflows/SimpleCashFlow.cs b/QLNet/Cashflows/SimpleCashFlow.cs index aafbcff50..cc0db3dd3 100644 --- a/QLNet/Cashflows/SimpleCashFlow.cs +++ b/QLNet/Cashflows/SimpleCashFlow.cs @@ -32,7 +32,7 @@ public class SimpleCashFlow : CashFlow public SimpleCashFlow(double amount, Date date) { - if (date == null) throw new ApplicationException("null date SimpleCashFlow"); + if (date == null) throw new Exception("null date SimpleCashFlow"); amount_ = amount; date_ = date; } diff --git a/QLNet/Cashflows/averagebmacoupon.cs b/QLNet/Cashflows/averagebmacoupon.cs index c47080405..f149eada4 100644 --- a/QLNet/Cashflows/averagebmacoupon.cs +++ b/QLNet/Cashflows/averagebmacoupon.cs @@ -1,216 +1,246 @@ -/* - Copyright (C) 2008, 2009 Siarhei Novik (snovik@gmail.com) - - This file is part of QLNet Project https://github.com/amaggiulli/qlnet - - QLNet is free software: you can redistribute it and/or modify it - under the terms of the QLNet license. You should have received a - copy of the license along with this program; if not, license is - available online at . - - QLNet is a based on QuantLib, a free-software/open-source library - for financial quantitative analysts and developers - http://quantlib.org/ - The QuantLib license is available online at http://quantlib.org/license.shtml. - - This program is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS - FOR A PARTICULAR PURPOSE. See the license for more details. -*/ -using System; -using System.Collections.Generic; -using System.Linq; - -namespace QLNet { - //! Average BMA coupon - /*! %Coupon paying a BMA index, where the coupon rate is a - weighted average of relevant fixings. - - The weighted average is computed based on the - actual calendar days for which a given fixing is valid and - contributing to the given interest period. - - Before weights are computed, the fixing schedule is adjusted - for the index's fixing day gap. See rate() method for details. - */ - public class AverageBMACoupon : FloatingRateCoupon { - private Schedule fixingSchedule_; - private int bmaCutoffDays = 0; // to be verified - - // double gearing = 1.0, double spread = 0.0, - // Date refPeriodStart = Date(), Date refPeriodEnd = Date(), DayCounter dayCounter = DayCounter()); - public AverageBMACoupon(double nominal, Date paymentDate, Date startDate, Date endDate, BMAIndex index, - double gearing, double spread, Date refPeriodStart, Date refPeriodEnd, DayCounter dayCounter) - : base(nominal, paymentDate, startDate, endDate, index.fixingDays(), index, gearing, spread, - refPeriodStart, refPeriodEnd, dayCounter, false) { - fixingSchedule_ = index.fixingSchedule( - index.fixingCalendar() - .advance(startDate, new Period(-index.fixingDays() + bmaCutoffDays, TimeUnit.Days), - BusinessDayConvention.Preceding), endDate); - setPricer(new AverageBMACouponPricer()); - } - - //! \name FloatingRateCoupon interface - //@{ - //! not applicable here; use fixingDates() instead - public override Date fixingDate() { - throw new ApplicationException("no single fixing date for average-BMA coupon"); - } - - //! fixing dates of the rates to be averaged - public List fixingDates() { return fixingSchedule_.dates(); } - - //! not applicable here; use indexFixings() instead - public override double indexFixing() { - throw new ApplicationException("no single fixing date for average-BMA coupon"); - } - - //! fixings of the underlying index to be averaged - public List indexFixings() { return fixingSchedule_.dates().Select(d => index_.fixing(d)).ToList(); } - - public override double convexityAdjustment() { - throw new ApplicationException("not defined for average-BMA coupon"); - } - } - - public class AverageBMACouponPricer : FloatingRateCouponPricer { - private AverageBMACoupon coupon_; - - public override void initialize(FloatingRateCoupon coupon) { - coupon_ = coupon as AverageBMACoupon; - if (coupon_ == null) - throw new ApplicationException("wrong coupon type"); - } - - public override double swapletRate() { - List fixingDates = coupon_.fixingDates(); - InterestRateIndex index = coupon_.index(); - - int cutoffDays = 0; // to be verified - Date startDate = coupon_.accrualStartDate() - cutoffDays, - endDate = coupon_.accrualEndDate() - cutoffDays, - d1 = startDate, - d2 = startDate; - - if (!(fixingDates.Count > 0)) throw new ApplicationException("fixing date list empty"); - if (!(index.valueDate(fixingDates.First()) <= startDate)) - throw new ApplicationException("first fixing date valid after period start"); - if (!(index.valueDate(fixingDates.Last()) >= endDate)) - throw new ApplicationException("last fixing date valid before period end"); - - double avgBMA = 0.0; - int days = 0; - for (int i=0; i= endDate || valueDate >= endDate) - break; - if (fixingDates[i+1] < startDate || nextValueDate <= startDate) - continue; - - d2 = Date.Min(nextValueDate, endDate); - - avgBMA += index.fixing(fixingDates[i]) * (d2 - d1); - - days += d2 - d1; - d1 = d2; - } - avgBMA /= (endDate - startDate); - - if (!(days == endDate - startDate)) - throw new ApplicationException("averaging days " + days + " differ from " + - "interest days " + (endDate - startDate)); - - return coupon_.gearing()*avgBMA + coupon_.spread(); - } - - public override double swapletPrice() { - throw new ApplicationException("not available"); - } - public override double capletPrice(double d) { - throw new ApplicationException("not available"); - } - public override double capletRate(double d) { - throw new ApplicationException("not available"); - } - public override double floorletPrice(double d) { - throw new ApplicationException("not available"); - } - public override double floorletRate(double d) { - throw new ApplicationException("not available"); - } - - // recheck - protected override double optionletPrice(Option.Type t, double d) { - throw new ApplicationException("not available"); - } - } - - //! helper class building a sequence of average BMA coupons - public class AverageBMALeg : RateLegBase { - private BMAIndex index_; - private List gearings_; - private List spreads_; - - public AverageBMALeg(Schedule schedule, BMAIndex index) { - schedule_ = schedule; - index_ = index; - paymentAdjustment_ = BusinessDayConvention.Following; - } - - public AverageBMALeg withPaymentDayCounter(DayCounter dayCounter) { - paymentDayCounter_ = dayCounter; - return this; - } - public AverageBMALeg withGearings(double gearing) { - gearings_ = new List() { gearing }; - return this; - } - public AverageBMALeg withGearings(List gearings) { - gearings_ = gearings; - return this; - } - public AverageBMALeg withSpreads(double spread) { - spreads_ = new List() { spread }; - return this; - } - public AverageBMALeg withSpreads(List spreads) { - spreads_ = spreads; - return this; - } - - public override List value() { - if (notionals_.Count == 0) - throw new ApplicationException("no notional given"); - - List cashflows = new List(); - - // the following is not always correct - Calendar calendar = schedule_.calendar(); - - Date refStart, start, refEnd, end; - Date paymentDate; - - int n = schedule_.Count-1; - for (int i=0; i(notionals_, i, notionals_.Last()), - paymentDate, start, end, - index_, - Utils.Get(gearings_, i, 1.0), - Utils.Get(spreads_, i, 0.0), - refStart, refEnd, - paymentDayCounter_)); - } - - return cashflows; - } - } -} +/* + Copyright (C) 2008, 2009 Siarhei Novik (snovik@gmail.com) + Copyright (C) 2008-2016 Andrea Maggiulli (a.maggiulli@gmail.com) + + This file is part of QLNet Project https://github.com/amaggiulli/qlnet + + QLNet is free software: you can redistribute it and/or modify it + under the terms of the QLNet license. You should have received a + copy of the license along with this program; if not, license is + available online at . + + QLNet is a based on QuantLib, a free-software/open-source library + for financial quantitative analysts and developers - http://quantlib.org/ + The QuantLib license is available online at http://quantlib.org/license.shtml. + + This program is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS + FOR A PARTICULAR PURPOSE. See the license for more details. +*/ +using System; +using System.Collections.Generic; +using System.Linq; + +namespace QLNet +{ + //! Average BMA coupon + /*! %Coupon paying a BMA index, where the coupon rate is a + weighted average of relevant fixings. + + The weighted average is computed based on the + actual calendar days for which a given fixing is valid and + contributing to the given interest period. + + Before weights are computed, the fixing schedule is adjusted + for the index's fixing day gap. See rate() method for details. + */ + public class AverageBMACoupon : FloatingRateCoupon + { + + public AverageBMACoupon( Date paymentDate, + double nominal, + Date startDate, + Date endDate, + BMAIndex index, + double gearing = 1.0, + double spread = 0.0, + Date refPeriodStart = null, + Date refPeriodEnd = null, + DayCounter dayCounter = null ) + : base( paymentDate, nominal, startDate, endDate, index.fixingDays(), index, gearing, spread, + refPeriodStart, refPeriodEnd, dayCounter, false ) + { + fixingSchedule_ = index.fixingSchedule( + index.fixingCalendar() + .advance( startDate, new Period( -index.fixingDays() , TimeUnit.Days ), + BusinessDayConvention.Preceding ), endDate ); + setPricer( new AverageBMACouponPricer() ); + } + + // FloatingRateCoupon interface + //! not applicable here; use fixingDates() instead + public override Date fixingDate() + { + throw new Exception( "no single fixing date for average-BMA coupon" ); + } + //! fixing dates of the rates to be averaged + public List fixingDates() { return fixingSchedule_.dates(); } + + //! not applicable here; use indexFixings() instead + public override double indexFixing() + { + throw new Exception( "no single fixing date for average-BMA coupon" ); + } + //! fixings of the underlying index to be averaged + public List indexFixings() { return fixingSchedule_.dates().Select( d => index_.fixing( d ) ).ToList(); } + + //! not applicable here + public override double convexityAdjustment() + { + throw new Exception( "not defined for average-BMA coupon" ); + } + + private Schedule fixingSchedule_; + } + + public class AverageBMACouponPricer : FloatingRateCouponPricer + { + public override void initialize( FloatingRateCoupon coupon ) + { + coupon_ = coupon as AverageBMACoupon; + if ( coupon_ == null ) + throw new Exception( "wrong coupon type" ); + } + + public override double swapletRate() + { + List fixingDates = coupon_.fixingDates(); + InterestRateIndex index = coupon_.index(); + + int cutoffDays = 0; // to be verified + Date startDate = coupon_.accrualStartDate() - cutoffDays, + endDate = coupon_.accrualEndDate() - cutoffDays, + d1 = startDate, + d2 = startDate; + + if ( !( fixingDates.Count > 0 ) ) throw new Exception( "fixing date list empty" ); + if ( !( index.valueDate( fixingDates.First() ) <= startDate ) ) + throw new Exception( "first fixing date valid after period start" ); + if ( !( index.valueDate( fixingDates.Last() ) >= endDate ) ) + throw new Exception( "last fixing date valid before period end" ); + + double avgBMA = 0.0; + int days = 0; + for ( int i = 0; i < fixingDates.Count - 1; ++i ) + { + Date valueDate = index.valueDate( fixingDates[i] ); + Date nextValueDate = index.valueDate( fixingDates[i + 1] ); + + if ( fixingDates[i] >= endDate || valueDate >= endDate ) + break; + if ( fixingDates[i + 1] < startDate || nextValueDate <= startDate ) + continue; + + d2 = Date.Min( nextValueDate, endDate ); + + avgBMA += index.fixing( fixingDates[i] ) * ( d2 - d1 ); + + days += d2 - d1; + d1 = d2; + } + avgBMA /= ( endDate - startDate ); + + if ( !( days == endDate - startDate ) ) + throw new Exception( "averaging days " + days + " differ from " + + "interest days " + ( endDate - startDate ) ); + + return coupon_.gearing() * avgBMA + coupon_.spread(); + } + public override double swapletPrice() + { + throw new Exception( "not available" ); + } + public override double capletPrice( double d ) + { + throw new Exception( "not available" ); + } + public override double capletRate( double d ) + { + throw new Exception( "not available" ); + } + public override double floorletPrice( double d ) + { + throw new Exception( "not available" ); + } + public override double floorletRate( double d ) + { + throw new Exception( "not available" ); + } + + // recheck + //protected override double optionletPrice( Option.Type t, double d ) + //{ + // throw new Exception( "not available" ); + //} + + private AverageBMACoupon coupon_; + } + + //! helper class building a sequence of average BMA coupons + public class AverageBMALeg : RateLegBase + { + private BMAIndex index_; + private List gearings_; + private List spreads_; + + public AverageBMALeg( Schedule schedule, BMAIndex index ) + { + schedule_ = schedule; + index_ = index; + paymentAdjustment_ = BusinessDayConvention.Following; + } + + public AverageBMALeg withPaymentDayCounter( DayCounter dayCounter ) + { + paymentDayCounter_ = dayCounter; + return this; + } + public AverageBMALeg withGearings( double gearing ) + { + gearings_ = new List() { gearing }; + return this; + } + public AverageBMALeg withGearings( List gearings ) + { + gearings_ = gearings; + return this; + } + public AverageBMALeg withSpreads( double spread ) + { + spreads_ = new List() { spread }; + return this; + } + public AverageBMALeg withSpreads( List spreads ) + { + spreads_ = spreads; + return this; + } + + public override List value() + { + if ( notionals_.Count == 0 ) + throw new Exception( "no notional given" ); + + List cashflows = new List(); + + // the following is not always correct + Calendar calendar = schedule_.calendar(); + + Date refStart, start, refEnd, end; + Date paymentDate; + + int n = schedule_.Count - 1; + for ( int i = 0; i < n; ++i ) + { + refStart = start = schedule_.date( i ); + refEnd = end = schedule_.date( i + 1 ); + paymentDate = calendar.adjust( end, paymentAdjustment_ ); + if ( i == 0 && !schedule_.isRegular( i + 1 ) ) + refStart = calendar.adjust( end - schedule_.tenor(), paymentAdjustment_ ); + if ( i == n - 1 && !schedule_.isRegular( i + 1 ) ) + refEnd = calendar.adjust( start + schedule_.tenor(), paymentAdjustment_ ); + + cashflows.Add( new AverageBMACoupon( paymentDate, + Utils.Get( notionals_, i, notionals_.Last() ), + start, end, + index_, + Utils.Get( gearings_, i, 1.0 ), + Utils.Get( spreads_, i, 0.0 ), + refStart, refEnd, + paymentDayCounter_ ) ); + } + + return cashflows; + } + } +} diff --git a/QLNet/Currencies/Europe.cs b/QLNet/Currencies/Europe.cs index 74e1b8bc8..e7d72c53d 100644 --- a/QLNet/Currencies/Europe.cs +++ b/QLNet/Currencies/Europe.cs @@ -353,4 +353,15 @@ public class PTECurrency : Currency { public PTECurrency() : base("Portuguese escudo", "PTE", 620, "Esc", "", 100, new Rounding(), "%1$.0f %3%", new EURCurrency()) { } } + + //! Ukrainian hryvnia + /*! The ISO three-letter code is UAH; the numeric code is 980. + It is divided in 100 kopiykas. + + \ingroup currencies + */ + public class UAHCurrency : Currency + { + public UAHCurrency() : base( "Ukrainian hryvnia", "UAH", 980, "hrn", "", 100, new Rounding(), "%1$.2f %3%" ) { } + } } diff --git a/QLNet/Error.cs b/QLNet/Error.cs index 1b6d03933..2cae2ac46 100644 --- a/QLNet/Error.cs +++ b/QLNet/Error.cs @@ -25,7 +25,7 @@ public static ArgumentException UnknownFrequency(Frequency f) { public static ArgumentException UnknownBusinessDayConvention(BusinessDayConvention c) { return new ArgumentException("Unknown business-day convention: " + c); } - public static ApplicationException MissingImplementation() { - return new ApplicationException("No implementation provided"); } + public static Exception MissingImplementation() { + return new Exception("No implementation provided"); } } } diff --git a/QLNet/Event.cs b/QLNet/Event.cs index 3c0460bd8..d861e9095 100644 --- a/QLNet/Event.cs +++ b/QLNet/Event.cs @@ -1,5 +1,6 @@ /* Copyright (C) 2008 Siarhei Novik (snovik@gmail.com) + Copyright (C) 2008-2016 Andrea Maggiulli (a.maggiulli@gmail.com) This file is part of QLNet Project https://github.com/amaggiulli/qlnet @@ -36,7 +37,7 @@ the event date is the same as the refDate. public virtual bool hasOccurred(Date d = null, bool? includeRefDate = null) { Date refDate = d ?? Settings.evaluationDate(); - bool includeRefDateEvent =includeRefDate != null ? includeRefDate.Value : Settings.includeReferenceDateEvents; + bool includeRefDateEvent = includeRefDate ?? Settings.includeReferenceDateEvents; if (includeRefDateEvent) return date() < refDate; else @@ -74,4 +75,18 @@ public virtual void accept(IAcyclicVisitor v) #endregion } + + // used to create an Event instance. + // to be replaced with specific events as soon as we find out which. + public class simple_event : Event + { + public simple_event(Date date) + { + date_ = date; + } + public override Date date() { return date_; } + + private Date date_; + + } } diff --git a/QLNet/Exercise.cs b/QLNet/Exercise.cs index f1c1d18cb..8557ee1e6 100644 --- a/QLNet/Exercise.cs +++ b/QLNet/Exercise.cs @@ -67,7 +67,7 @@ public AmericanExercise(Date earliestDate, Date latestDate, bool payoffAtExpiry : base(Type.American, payoffAtExpiry) { if (!(earliestDate <= latestDate)) - throw new ApplicationException("earliest > latest exercise date"); + throw new Exception("earliest > latest exercise date"); dates_ = new InitializedList(2); dates_[0] = earliestDate; dates_[1] = latestDate; @@ -88,7 +88,7 @@ public BermudanExercise(List dates, bool payoffAtExpiry) : base(Type.Bermudan, payoffAtExpiry) { if (dates.Count == 0) - throw new ApplicationException("no exercise date given"); + throw new Exception("no exercise date given"); dates_ = dates; dates_.Sort(); diff --git a/QLNet/Handle.cs b/QLNet/Handle.cs index ff8394729..e3df77b0c 100644 --- a/QLNet/Handle.cs +++ b/QLNet/Handle.cs @@ -50,7 +50,7 @@ public T link get { if (empty()) - throw new ApplicationException("empty Handle cannot be dereferenced"); + throw new Exception("empty Handle cannot be dereferenced"); return link_.currentLink(); } } diff --git a/QLNet/Index.cs b/QLNet/Index.cs index 7609f12bc..37af08c83 100644 --- a/QLNet/Index.cs +++ b/QLNet/Index.cs @@ -1,6 +1,6 @@ /* Copyright (C) 2008 Siarhei Novik (snovik@gmail.com) - Copyright (C) 2008, 2009 , 2010 Andrea Maggiulli (a.maggiulli@gmail.com) + Copyright (C) 2008-2016 Andrea Maggiulli (a.maggiulli@gmail.com) This file is part of QLNet Project https://github.com/amaggiulli/qlnet @@ -16,95 +16,117 @@ under the terms of the QLNet license. You should have received a This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the license for more details. -*/ -using System; -using System.Collections.Generic; - -namespace QLNet { - // purely virtual base class for indexes - // this class performs no check that the provided/requested fixings are for dates in the past, - // i.e. for dates less than or equal to the evaluation date. It is up to the client code to take care of - // possible inconsistencies due to "seeing in the future" - - // dates passed as arguments must be the actual calendar date of the fixing - // no settlement days must be used. - public abstract class Index : IObservable { - - //! Returns the name of the index. - //! \warning This method is used for output and comparison between indexes. - // It is not meant to be used for writing switch-on-type code. - public abstract string name(); - - public abstract Calendar fixingCalendar(); //! returns the calendar defining valid fixing dates - public abstract bool isValidFixingDate(Date fixingDate); //! returns TRUE if the fixing date is a valid one - - //! returns the fixing at the given date - /*! the date passed as arguments must be the actual calendar date of the fixing; no settlement days must be used. */ - public virtual double fixing(Date fixingDate) { return fixing(fixingDate, false); } - public abstract double fixing(Date fixingDate, bool forecastTodaysFixing); - - //! returns the fixing TimeSeries - public ObservableValue> timeSeries() { return IndexManager.instance().getHistory(name()); } - - //! clears all stored historical fixings - public void clearFixings() { IndexManager.instance().clearHistory(name()); } - - // stores the historical fixing at the given date - public virtual void addFixing(Date d, double v) { addFixing(d, v, false); } - public virtual void addFixing(Date d, double v, bool forceOverwrite) { - addFixings(new TimeSeries() { { d, v } }, forceOverwrite); - } - - // stores historical fixings at the given dates - public void addFixings(List d, List v) { addFixings(d, v, false); } - public void addFixings(List d, List v, bool forceOverwrite) { - if ((d.Count != v.Count) || d.Count == 0) - throw new ArgumentException("Wrong collection dimensions when creating index fixings"); - - TimeSeries t = new TimeSeries(); - for(int i=0; i source) { addFixings(source, false); } - public void addFixings(Dictionary source, bool forceOverwrite) { - ObservableValue> target = IndexManager.instance().getHistory(name()); - foreach (Date d in source.Keys) { - if (isValidFixingDate(d)) - if (!target.value().ContainsKey(d)) - target.value().Add(d, source[d]); - else - if (forceOverwrite) - target.value()[d] = source[d]; - else if (Utils.close(target.value()[d], source[d])) - continue; - else - throw new ArgumentException("Duplicated fixing provided: " + d + ", " + source[d] + - " while " + target.value()[d] + " value is already present"); - else - throw new ArgumentException("Invalid fixing provided: " + d.DayOfWeek + " " + d + ", " + source[d]); - } - - IndexManager.instance().setHistory(name(), target); - } - - - #region observable interface - private readonly WeakEventSource eventSource = new WeakEventSource(); - public event Callback notifyObserversEvent - { - add { eventSource.Subscribe(value); } - remove { eventSource.Unsubscribe(value); } - } - - public void registerWith(Callback handler) { notifyObserversEvent += handler; } - public void unregisterWith(Callback handler) { notifyObserversEvent -= handler; } - protected void notifyObservers() - { - eventSource.Raise(); - } - #endregion - } +*/ +using System; +using System.Collections.Generic; + +namespace QLNet +{ + // purely virtual base class for indexes + // this class performs no check that the provided/requested fixings are for dates in the past, + // i.e. for dates less than or equal to the evaluation date. It is up to the client code to take care of + // possible inconsistencies due to "seeing in the future" + public abstract class Index : IObservable + { + // Returns the name of the index. + // This method is used for output and comparison between indexes. + // It is not meant to be used for writing switch-on-type code. + public abstract string name(); + + // Returns the calendar defining valid fixing dates + public abstract Calendar fixingCalendar(); + + // Returns TRUE if the fixing date is a valid one + public abstract bool isValidFixingDate( Date fixingDate ); + + // Returns the fixing at the given date + // The date passed as arguments must be the actual calendar date of the fixing; no settlement days must be used. + public abstract double fixing( Date fixingDate, bool forecastTodaysFixing = false); + + // Returns the fixing TimeSeries + public ObservableValue> timeSeries() { return IndexManager.instance().getHistory( name() ); } + + // Check if index allows for native fixings. + // If this returns false, calls to addFixing and similar methods will raise an exception. + public virtual bool allowsNativeFixings() { return true; } + + // Stores the historical fixing at the given date + // The date passed as arguments must be the actual calendar date of the fixing; no settlement days must be used. + public virtual void addFixing( Date d, double v, bool forceOverwrite = false ) + { + checkNativeFixingsAllowed(); + addFixings( new TimeSeries() { { d, v } }, forceOverwrite ); + } + + // Stores historical fixings from a TimeSeries + // The dates in the TimeSeries must be the actual calendar dates of the fixings; no settlement days must be used. + public void addFixings( Dictionary source, bool forceOverwrite = false ) + { + checkNativeFixingsAllowed(); + ObservableValue> target = IndexManager.instance().getHistory( name() ); + foreach ( Date d in source.Keys ) + { + if ( isValidFixingDate( d ) ) + if ( !target.value().ContainsKey( d ) ) + target.value().Add( d, source[d] ); + else + if ( forceOverwrite ) + target.value()[d] = source[d]; + else if ( Utils.close( target.value()[d], source[d] ) ) + continue; + else + throw new ArgumentException( "Duplicated fixing provided: " + d + ", " + source[d] + + " while " + target.value()[d] + " value is already present" ); + else + throw new ArgumentException( "Invalid fixing provided: " + d.DayOfWeek + " " + d + ", " + source[d] ); + } + + IndexManager.instance().setHistory( name(), target ); + } + + // Stores historical fixings at the given dates + // The dates passed as arguments must be the actual calendar dates of the fixings; no settlement days must be used. + public void addFixings( List d, List v, bool forceOverwrite = false ) + { + if ( ( d.Count != v.Count ) || d.Count == 0 ) + throw new ArgumentException( "Wrong collection dimensions when creating index fixings" ); + + TimeSeries t = new TimeSeries(); + for ( int i = 0; i < d.Count; i++ ) + t.Add( d[i], v[i] ); + addFixings( t, forceOverwrite ); + } + + // Clears all stored historical fixings + public void clearFixings() + { + checkNativeFixingsAllowed(); + IndexManager.instance().clearHistory( name() ); + } + + // Check if index allows for native fixings + private void checkNativeFixingsAllowed() + { + Utils.QL_REQUIRE( allowsNativeFixings(), ()=> + "native fixings not allowed for " + name() + "; refer to underlying indices instead" ); + } + + + + #region observable interface + private readonly WeakEventSource eventSource = new WeakEventSource(); + public event Callback notifyObserversEvent + { + add { eventSource.Subscribe( value ); } + remove { eventSource.Unsubscribe( value ); } + } + + public void registerWith( Callback handler ) { notifyObserversEvent += handler; } + public void unregisterWith( Callback handler ) { notifyObserversEvent -= handler; } + protected void notifyObservers() + { + eventSource.Raise(); + } + #endregion + } } \ No newline at end of file diff --git a/QLNet/Indexes/IBORIndex.cs b/QLNet/Indexes/IBORIndex.cs index 7e91de360..be87b0496 100644 --- a/QLNet/Indexes/IBORIndex.cs +++ b/QLNet/Indexes/IBORIndex.cs @@ -1,8 +1,8 @@ /* Copyright (C) 2008 Siarhei Novik (snovik@gmail.com) - Copyright (C) 2008, 2009 , 2010 Andrea Maggiulli (a.maggiulli@gmail.com) + Copyright (C) 2008-2016 Andrea Maggiulli (a.maggiulli@gmail.com) Copyright (C) 2008 Toyin Akin (toyin_akin@hotmail.com) - * + This file is part of QLNet Project https://github.com/amaggiulli/qlnet QLNet is free software: you can redistribute it and/or modify it @@ -17,89 +17,103 @@ under the terms of the QLNet license. You should have received a This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the license for more details. -*/ -using System; - -namespace QLNet { - //! base class for Inter-Bank-Offered-Rate indexes (e.g. %Libor, etc.) - public class IborIndex : InterestRateIndex { - protected BusinessDayConvention convention_; - public BusinessDayConvention businessDayConvention() { return convention_; } - - protected Handle termStructure_; - // InterestRateIndex interface - public Handle forwardingTermStructure() { return termStructure_; } - - bool endOfMonth_; - public bool endOfMonth() { return endOfMonth_; } - - // need by CashFlowVectors - public IborIndex() { } - - public IborIndex(string familyName, Period tenor, int settlementDays, Currency currency, - Calendar fixingCalendar, BusinessDayConvention convention, bool endOfMonth, - DayCounter dayCounter) - : this(familyName, tenor, settlementDays, currency, - fixingCalendar, convention, endOfMonth, - dayCounter, new Handle()) { } - - public IborIndex(string familyName, Period tenor, int settlementDays, Currency currency, - Calendar fixingCalendar, BusinessDayConvention convention, bool endOfMonth, - DayCounter dayCounter, Handle h) : - base(familyName, tenor, settlementDays, currency, fixingCalendar, dayCounter) { - convention_ = convention; - termStructure_ = h; - endOfMonth_ = endOfMonth; - - // observer interface - if (!termStructure_.empty()) - termStructure_.registerWith(update); - } - - //! Date calculations - public override Date maturityDate(Date valueDate) { - return fixingCalendar().advance(valueDate, tenor_, convention_, endOfMonth_); - } - - protected override double forecastFixing(Date fixingDate) { - if (termStructure_.empty()) - throw new ArgumentException("null term structure set to this instance of " + name()); - - Date fixingValueDate = valueDate(fixingDate); - Date endValueDate = maturityDate(fixingValueDate); - double fixingDiscount = termStructure_.link.discount(fixingValueDate); - double endDiscount = termStructure_.link.discount(endValueDate); - double fixingPeriod = dayCounter().yearFraction(fixingValueDate, endValueDate); - return (fixingDiscount / endDiscount - 1.0) / fixingPeriod; - } - - //! returns a copy of itself linked to a different forwarding curve - public virtual IborIndex clone(Handle forwarding) - { - return new IborIndex(familyName(), tenor(), fixingDays(), currency(), fixingCalendar(), - businessDayConvention(), endOfMonth(), dayCounter(), forwarding); - } - } - - public class OvernightIndex : IborIndex - { - public OvernightIndex(string familyName, - int settlementDays, - Currency currency, - Calendar fixingCalendar, - DayCounter dayCounter, - Handle h) : - - base(familyName, new Period(1,TimeUnit.Days), settlementDays, - currency,fixingCalendar, BusinessDayConvention.Following, false, dayCounter, h) - {} - - //! returns a copy of itself linked to a different forwarding curve - public new IborIndex clone(Handle h) - { - return new OvernightIndex(familyName(), fixingDays(), currency(), fixingCalendar(), - dayCounter(), h); - - } - }; +*/ +using System; + +namespace QLNet +{ + //! base class for Inter-Bank-Offered-Rate indexes (e.g. %Libor, etc.) + public class IborIndex : InterestRateIndex + { + public IborIndex( string familyName, + Period tenor, + int settlementDays, + Currency currency, + Calendar fixingCalendar, + BusinessDayConvention convention, + bool endOfMonth, + DayCounter dayCounter, + Handle h = null) + :base( familyName, tenor, settlementDays, currency, fixingCalendar, dayCounter ) + { + + convention_ = convention; + termStructure_ = h ?? new Handle(); + endOfMonth_ = endOfMonth; + + // observer interface + if ( !termStructure_.empty() ) + termStructure_.registerWith( update ); + } + + // InterestRateIndex interface + public override Date maturityDate( Date valueDate ) + { + return fixingCalendar().advance( valueDate, tenor_, convention_, endOfMonth_ ); + } + public override double forecastFixing( Date fixingDate ) + { + Date d1 = valueDate( fixingDate ); + Date d2 = maturityDate( d1 ); + double t = dayCounter_.yearFraction( d1, d2 ); + Utils.QL_REQUIRE( t > 0.0,()=> + "\n cannot calculate forward rate between " + + d1 + " and " + d2 + + ":\n non positive time (" + t + + ") using " + dayCounter_.name() + " daycounter" ); + return forecastFixing( d1, d2, t ); + } + // Inspectors + public BusinessDayConvention businessDayConvention() { return convention_; } + public bool endOfMonth() { return endOfMonth_; } + // the curve used to forecast fixings + public Handle forwardingTermStructure() { return termStructure_; } + // Other methods + // returns a copy of itself linked to a different forwarding curve + public virtual IborIndex clone( Handle forwarding ) + { + return new IborIndex( familyName(), tenor(), fixingDays(), currency(), fixingCalendar(), + businessDayConvention(), endOfMonth(), dayCounter(), forwarding ); + } + + protected BusinessDayConvention convention_; + protected Handle termStructure_; + protected bool endOfMonth_; + + + public double forecastFixing(Date d1,Date d2, double t) + { + Utils.QL_REQUIRE( !termStructure_.empty(),()=> "null term structure set to this instance of " + name() ); + double disc1 = termStructure_.link.discount( d1 ); + double disc2 = termStructure_.link.discount( d2 ); + return ( disc1 / disc2 - 1.0 ) / t; + } + + + // need by CashFlowVectors + public IborIndex() { } + + } + + public class OvernightIndex : IborIndex + { + public OvernightIndex( string familyName, + int settlementDays, + Currency currency, + Calendar fixingCalendar, + DayCounter dayCounter, + Handle h = null) : + + base( familyName, new Period( 1, TimeUnit.Days ), settlementDays, + currency, fixingCalendar, BusinessDayConvention.Following, false, dayCounter, h ) + {} + + //! returns a copy of itself linked to a different forwarding curve + public new IborIndex clone( Handle h ) + { + return new OvernightIndex( familyName(), fixingDays(), currency(), fixingCalendar(), + dayCounter(), h ); + + } + } } diff --git a/QLNet/Indexes/Ibor/Audlibor.cs b/QLNet/Indexes/Ibor/Audlibor.cs index 4062c2980..308204706 100644 --- a/QLNet/Indexes/Ibor/Audlibor.cs +++ b/QLNet/Indexes/Ibor/Audlibor.cs @@ -15,26 +15,23 @@ under the terms of the QLNet license. You should have received a This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the license for more details. -*/ - -namespace QLNet { - - //! %AUD %LIBOR rate -// ! Australian Dollar LIBOR fixed by BBA. -// -// See . -// - public class AUDLibor : Libor - { - public AUDLibor(Period tenor) - : base("AUDLibor", tenor, 2, new AUDCurrency(), new Australia(), new Actual360(), new Handle()) - { - } - - public AUDLibor(Period tenor, Handle h) - : base("AUDLibor", tenor, 2, new AUDCurrency(), new Australia(), new Actual360(), h) - { - } - } - +*/ + +namespace QLNet +{ + + //! %AUD %LIBOR rate + /*! Australian Dollar LIBOR discontinued as of 2013. + */ + public class AUDLibor : Libor + { + public AUDLibor( Period tenor ) + : base( "AUDLibor", tenor, 2, new AUDCurrency(), new Australia(), new Actual360(), new Handle() ) + {} + + public AUDLibor( Period tenor, Handle h ) + : base( "AUDLibor", tenor, 2, new AUDCurrency(), new Australia(), new Actual360(), h ) + {} + } + } diff --git a/QLNet/Indexes/Ibor/Cadlibor.cs b/QLNet/Indexes/Ibor/Cadlibor.cs index 21eb7c804..b3c6e554f 100644 --- a/QLNet/Indexes/Ibor/Cadlibor.cs +++ b/QLNet/Indexes/Ibor/Cadlibor.cs @@ -15,43 +15,37 @@ under the terms of the QLNet license. You should have received a This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the license for more details. -*/ - -namespace QLNet { - - //! %CAD LIBOR rate -// ! Canadian Dollar LIBOR fixed by BBA. -// -// See . -// -// \warning This is the rate fixed in London by BBA. Use CDOR if -// you're interested in the Canadian fixing by IDA. -// - public class CADLibor : Libor - { - public CADLibor(Period tenor) - : base("CADLibor", tenor, 2, new CADCurrency(), new Canada(), new Actual360(), new Handle()) - { - } - - public CADLibor(Period tenor, Handle h) - : base("CADLibor", tenor, 2, new CADCurrency(), new Canada(), new Actual360(), h) - { - } - } - - //! Overnight %CAD %Libor index - public class CADLiborON : DailyTenorLibor - { - public CADLiborON() - : base("CADLibor", 0, new CADCurrency(), new Canada(), new Actual360(), new Handle()) - { - } - - public CADLiborON(Handle h) - : base("CADLibor", 0, new CADCurrency(), new Canada(), new Actual360(), h) - { - } - } - +*/ + +namespace QLNet +{ + + //! %CAD LIBOR rate + /*! Canadian Dollar LIBOR discontinued as of 2013. + \warning This is the rate fixed in London by BBA. Use CDOR if + you're interested in the Canadian fixing by IDA. + */ + public class CADLibor : Libor + { + public CADLibor( Period tenor ) + : base( "CADLibor", tenor, 2, new CADCurrency(), new Canada(), new Actual360(), new Handle() ) + {} + + public CADLibor( Period tenor, Handle h ) + : base( "CADLibor", tenor, 2, new CADCurrency(), new Canada(), new Actual360(), h ) + {} + } + + //! Overnight %CAD %Libor index + public class CADLiborON : DailyTenorLibor + { + public CADLiborON() + : base( "CADLibor", 0, new CADCurrency(), new Canada(), new Actual360(), new Handle() ) + {} + + public CADLiborON( Handle h ) + : base( "CADLibor", 0, new CADCurrency(), new Canada(), new Actual360(), h ) + {} + } + } \ No newline at end of file diff --git a/QLNet/Indexes/Ibor/Chflibor.cs b/QLNet/Indexes/Ibor/Chflibor.cs index aa3bb87a6..a7f7a3aa0 100644 --- a/QLNet/Indexes/Ibor/Chflibor.cs +++ b/QLNet/Indexes/Ibor/Chflibor.cs @@ -16,31 +16,35 @@ under the terms of the QLNet license. You should have received a This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the license for more details. -*/ +*/ + +namespace QLNet +{ + + //! %CHF %LIBOR rate + /*! Swiss Franc LIBOR fixed by ICE. -namespace QLNet { + See . - //! %CHF %LIBOR rate - // ! Swiss Franc LIBOR fixed by BBA. - // - // See . - // - // \warning This is the rate fixed in London by BBA. Use ZIBOR if - // you're interested in the Zurich fixing. - // - public class CHFLibor : Libor { - public CHFLibor(Period tenor) - : base("CHFLibor", tenor, 2, new CHFCurrency(), new Switzerland(), new Actual360(), new Handle()) { - } - - public CHFLibor(Period tenor, Handle h) - : base("CHFLibor", tenor, 2, new CHFCurrency(), new Switzerland(), new Actual360(), h) { - } - } - - //! base class for the one day deposit BBA %CHF %LIBOR indexes - public class DailyTenorCHFLibor : DailyTenorLibor { - public DailyTenorCHFLibor(int settlementDays, Handle h) - : base("CHFLibor", settlementDays, new CHFCurrency(), new Switzerland(), new Actual360(), h) {} - }; + \warning This is the rate fixed in London by BBA. Use ZIBOR if + you're interested in the Zurich fixing. + */ + public class CHFLibor : Libor + { + public CHFLibor( Period tenor ) + : base( "CHFLibor", tenor, 2, new CHFCurrency(), new Switzerland(), new Actual360(), new Handle() ) + {} + + public CHFLibor( Period tenor, Handle h ) + : base( "CHFLibor", tenor, 2, new CHFCurrency(), new Switzerland(), new Actual360(), h ) + {} + } + + //! base class for the one day deposit BBA %CHF %LIBOR indexes + public class DailyTenorCHFLibor : DailyTenorLibor + { + public DailyTenorCHFLibor( int settlementDays, Handle h ) + : base( "CHFLibor", settlementDays, new CHFCurrency(), new Switzerland(), new Actual360(), h ) + { } + } } diff --git a/QLNet/Indexes/Ibor/Dkklibor.cs b/QLNet/Indexes/Ibor/Dkklibor.cs index ea369cc4c..bdb98e8f7 100644 --- a/QLNet/Indexes/Ibor/Dkklibor.cs +++ b/QLNet/Indexes/Ibor/Dkklibor.cs @@ -15,25 +15,23 @@ under the terms of the QLNet license. You should have received a This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the license for more details. -*/ - -namespace QLNet { - - //! %DKK %LIBOR rate -// ! Danish Krona LIBOR fixed by BBA. -// -// See . -// - public class DKKLibor : Libor - { - public DKKLibor(Period tenor) - : base("DKKLibor", tenor, 2, new DKKCurrency(), new Denmark(), new Actual360(), new Handle()) - { - } - public DKKLibor(Period tenor, Handle h) - : base("DKKLibor", tenor, 2, new DKKCurrency(), new Denmark(), new Actual360(), h) - { - } - } - +*/ + +namespace QLNet +{ + + //! %DKK %LIBOR rate + /*! Danish Krona LIBOR discontinued as of 2013. + */ + public class DKKLibor : Libor + { + public DKKLibor( Period tenor ) + : base( "DKKLibor", tenor, 2, new DKKCurrency(), new Denmark(), new Actual360(), new Handle() ) + {} + + public DKKLibor( Period tenor, Handle h ) + : base( "DKKLibor", tenor, 2, new DKKCurrency(), new Denmark(), new Actual360(), h ) + {} + } + } diff --git a/QLNet/Indexes/Ibor/Euribor.cs b/QLNet/Indexes/Ibor/Euribor.cs index 65600bc13..78d4fc18c 100644 --- a/QLNet/Indexes/Ibor/Euribor.cs +++ b/QLNet/Indexes/Ibor/Euribor.cs @@ -59,7 +59,7 @@ public Euribor(Period tenor, Handle h) : Utils.euriborConvention(tenor), Utils.euriborEOM(tenor), new Actual360(), h) { if (this.tenor().units() == TimeUnit.Days) - throw new ApplicationException("for daily tenors (" + this.tenor() + ") dedicated DailyTenor constructor must be used"); + throw new Exception("for daily tenors (" + this.tenor() + ") dedicated DailyTenor constructor must be used"); } } @@ -76,7 +76,7 @@ public Euribor365(Period tenor, Handle h) new EURCurrency(), new TARGET(), Utils.euriborConvention(tenor), Utils.euriborEOM(tenor), new Actual365Fixed(), h) { if (this.tenor().units() == TimeUnit.Days) - throw new ApplicationException("for daily tenors (" + this.tenor() + ") dedicated DailyTenor constructor must be used"); + throw new Exception("for daily tenors (" + this.tenor() + ") dedicated DailyTenor constructor must be used"); } } diff --git a/QLNet/Indexes/Ibor/Eurlibor.cs b/QLNet/Indexes/Ibor/Eurlibor.cs index 584ca4098..4006aacb2 100644 --- a/QLNet/Indexes/Ibor/Eurlibor.cs +++ b/QLNet/Indexes/Ibor/Eurlibor.cs @@ -1,290 +1,345 @@ -/* - Copyright (C) 2008 Toyin Akin (toyin_akin@hotmail.com) - Copyright (C) 2008 Siarhei Novik (snovik@gmail.com) - - This file is part of QLNet Project https://github.com/amaggiulli/qlnet - - QLNet is free software: you can redistribute it and/or modify it - under the terms of the QLNet license. You should have received a - copy of the license along with this program; if not, license is - available online at . - - QLNet is a based on QuantLib, a free-software/open-source library - for financial quantitative analysts and developers - http://quantlib.org/ - The QuantLib license is available online at http://quantlib.org/license.shtml. - - This program is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS - FOR A PARTICULAR PURPOSE. See the license for more details. -*/ -using System; - -namespace QLNet { - public static partial class Utils { - public static BusinessDayConvention eurliborConvention(Period p) { - switch (p.units()) { - case TimeUnit.Days: - case TimeUnit.Weeks: - return BusinessDayConvention.Following; - case TimeUnit.Months: - case TimeUnit.Years: - return BusinessDayConvention.ModifiedFollowing; - default: - throw new ArgumentException("Unknown TimeUnit: " + p.units()); - } - } - - public static bool eurliborEOM(Period p) { - switch (p.units()) { - case TimeUnit.Days: - case TimeUnit.Weeks: - return false; - case TimeUnit.Months: - case TimeUnit.Years: - return true; - default: - throw new ArgumentException("Unknown TimeUnit: " + p.units()); - } - } - } - - /// - /// base class for all BBA %EUR %LIBOR indexes but the O/N - /// ! Euro LIBOR fixed by BBA. - /// - /// See . - /// - /// \warning This is the rate fixed in London by BBA. Use Euribor if - /// you're interested in the fixing by the ECB. - /// - public class EURLibor : IborIndex { - private Calendar target_; - - // http://www.bba.org.uk/bba/jsp/polopoly.jsp?d=225&a=1412 : - // JoinBusinessDays is the fixing calendar for - // all indexes but o/n - - public EURLibor(Period tenor) - : base("EURLibor", tenor, 2, new EURCurrency(), new JointCalendar(new UnitedKingdom(UnitedKingdom.Market.Exchange), new TARGET(), - JointCalendar.JointCalendarRule.JoinHolidays), - Utils.eurliborConvention(tenor), Utils.eurliborEOM(tenor), new Actual360(), - new Handle()) { - target_ = new TARGET(); - if (!(this.tenor().units() != TimeUnit.Days)) - throw new ApplicationException("for daily tenors (" + this.tenor() + ") dedicated DailyTenor constructor must be used"); - } - - public EURLibor(Period tenor, Handle h) - : base("EURLibor", tenor, 2, new EURCurrency(), new JointCalendar(new UnitedKingdom(UnitedKingdom.Market.Exchange), new TARGET(), - JointCalendar.JointCalendarRule.JoinHolidays), - Utils.eurliborConvention(tenor), Utils.eurliborEOM(tenor), new Actual360(), h) { - target_ = new TARGET(); - if (!(this.tenor().units() != TimeUnit.Days)) - throw new ApplicationException("for daily tenors (" + this.tenor() + ") dedicated DailyTenor constructor must be used"); - } - - // ! \name Date calculations - // - // see http://www.bba.org.uk/bba/jsp/polopoly.jsp?d=225&a=1412 - // @{ - // - public override Date valueDate(Date fixingDate) { - - if (!(isValidFixingDate(fixingDate))) - throw new ApplicationException("Fixing date " + fixingDate + " is not valid"); - - // http://www.bba.org.uk/bba/jsp/polopoly.jsp?d=225&a=1412 : - // In the case of EUR the Value Date shall be two TARGET - // business days after the Fixing Date. - return target_.advance(fixingDate, fixingDays_, TimeUnit.Days); - } - public override Date maturityDate(Date valueDate) { - // http://www.bba.org.uk/bba/jsp/polopoly.jsp?d=225&a=1412 : - // In the case of EUR only, maturity dates will be based on days in - // which the Target system is open. - return target_.advance(valueDate, tenor_, convention_, endOfMonth()); - } - } - - //! base class for the one day deposit BBA %EUR %LIBOR indexes - // ! Euro O/N LIBOR fixed by BBA. It can be also used for T/N and S/N - // indexes, even if such indexes do not have BBA fixing. - // - // See . - // - // \warning This is the rate fixed in London by BBA. Use Eonia if - // you're interested in the fixing by the ECB. - // - public class DailyTenorEURLibor : IborIndex { - - // http://www.bba.org.uk/bba/jsp/polopoly.jsp?d=225&a=1412 : - // no o/n or s/n fixings (as the case may be) will take place - // when the principal centre of the currency concerned is - // closed but London is open on the fixing day. - public DailyTenorEURLibor(int settlementDays) - : this(settlementDays, new Handle()) { - } - public DailyTenorEURLibor() - : base("EURLibor", new Period(1, TimeUnit.Days), 0, new EURCurrency(), new TARGET(), - Utils.eurliborConvention(new Period(1, TimeUnit.Days)), Utils.eurliborEOM(new Period(1, TimeUnit.Days)), new Actual360(), new Handle()) { - } - public DailyTenorEURLibor(int settlementDays, Handle h) - : base("EURLibor", new Period(1, TimeUnit.Days), settlementDays, new EURCurrency(), new TARGET(), - Utils.eurliborConvention(new Period(1, TimeUnit.Days)), Utils.eurliborEOM(new Period(1, TimeUnit.Days)), new Actual360(), h) { - } - } - - //! Overnight %EUR %Libor index - public class EURLiborON : DailyTenorEURLibor { - public EURLiborON() - : base(0, new Handle()) { - } - - public EURLiborON(Handle h) - : base(0, h) { - } - } - - //! 1-week %EUR %Libor index - public class EURLiborSW : EURLibor { - public EURLiborSW() - : base(new Period(1, TimeUnit.Weeks), new Handle()) { - } - public EURLiborSW(Handle h) - : base(new Period(1, TimeUnit.Weeks), h) { - } - } - - //! 2-weeks %EUR %Libor index - public class EURLibor2W : EURLibor { - public EURLibor2W() - : base(new Period(2, TimeUnit.Weeks), new Handle()) { - } - public EURLibor2W(Handle h) - : base(new Period(2, TimeUnit.Weeks), h) { - } - } - - - //! 1-month %EUR %Libor index - public class EURLibor1M : EURLibor { - public EURLibor1M() - : base(new Period(1, TimeUnit.Months), new Handle()) { - } - public EURLibor1M(Handle h) - : base(new Period(1, TimeUnit.Months), h) { - } - } - - //! 2-months %EUR %Libor index - public class EURLibor2M : EURLibor { - public EURLibor2M() - : base(new Period(2, TimeUnit.Months), new Handle()) { - } - public EURLibor2M(Handle h) - : base(new Period(2, TimeUnit.Months), h) { - } - } - - //! 3-months %EUR %Libor index - public class EURLibor3M : EURLibor { - public EURLibor3M() - : base(new Period(3, TimeUnit.Months), new Handle()) { - } - public EURLibor3M(Handle h) - : base(new Period(3, TimeUnit.Months), h) { - } - } - - //! 4-months %EUR %Libor index - public class EURLibor4M : EURLibor { - public EURLibor4M() - : base(new Period(4, TimeUnit.Months), new Handle()) { - } - public EURLibor4M(Handle h) - : base(new Period(4, TimeUnit.Months), h) { - } - } - - //! 5-months %EUR %Libor index - public class EURLibor5M : EURLibor { - public EURLibor5M() - : base(new Period(5, TimeUnit.Months), new Handle()) { - } - public EURLibor5M(Handle h) - : base(new Period(5, TimeUnit.Months), h) { - } - } - - //! 6-months %EUR %Libor index - public class EURLibor6M : EURLibor { - public EURLibor6M() - : base(new Period(6, TimeUnit.Months), new Handle()) { - } - public EURLibor6M(Handle h) - : base(new Period(6, TimeUnit.Months), h) { - } - } - - //! 7-months %EUR %Libor index - public class EURLibor7M : EURLibor { - public EURLibor7M() - : base(new Period(7, TimeUnit.Months), new Handle()) { - } - public EURLibor7M(Handle h) - : base(new Period(7, TimeUnit.Months), h) { - } - } - - //! 8-months %EUR %Libor index - public class EURLibor8M : EURLibor { - public EURLibor8M() - : base(new Period(8, TimeUnit.Months), new Handle()) { - } - public EURLibor8M(Handle h) - : base(new Period(8, TimeUnit.Months), h) { - } - } - - //! 9-months %EUR %Libor index - public class EURLibor9M : EURLibor { - public EURLibor9M() - : base(new Period(9, TimeUnit.Months), new Handle()) { - } - public EURLibor9M(Handle h) - : base(new Period(9, TimeUnit.Months), h) { - } - } - - //! 10-months %EUR %Libor index - public class EURLibor10M : EURLibor { - public EURLibor10M() - : base(new Period(10, TimeUnit.Months), new Handle()) { - } - public EURLibor10M(Handle h) - : base(new Period(10, TimeUnit.Months), h) { - } - } - - //! 11-months %EUR %Libor index - public class EURLibor11M : EURLibor { - public EURLibor11M() - : base(new Period(11, TimeUnit.Months), new Handle()) { - } - public EURLibor11M(Handle h) - : base(new Period(11, TimeUnit.Months), h) { - } - } - - //! 1-year %EUR %Libor index - public class EURLibor1Y : EURLibor { - public EURLibor1Y() - : base(new Period(1, TimeUnit.Years), new Handle()) { - } - public EURLibor1Y(Handle h) - : base(new Period(1, TimeUnit.Years), h) { - } - } - - -} +/* + Copyright (C) 2008 Toyin Akin (toyin_akin@hotmail.com) + Copyright (C) 2008 Siarhei Novik (snovik@gmail.com) + + This file is part of QLNet Project https://github.com/amaggiulli/qlnet + + QLNet is free software: you can redistribute it and/or modify it + under the terms of the QLNet license. You should have received a + copy of the license along with this program; if not, license is + available online at . + + QLNet is a based on QuantLib, a free-software/open-source library + for financial quantitative analysts and developers - http://quantlib.org/ + The QuantLib license is available online at http://quantlib.org/license.shtml. + + This program is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS + FOR A PARTICULAR PURPOSE. See the license for more details. +*/ +using System; + +namespace QLNet +{ + public static partial class Utils + { + public static BusinessDayConvention eurliborConvention( Period p ) + { + switch ( p.units() ) + { + case TimeUnit.Days: + case TimeUnit.Weeks: + return BusinessDayConvention.Following; + case TimeUnit.Months: + case TimeUnit.Years: + return BusinessDayConvention.ModifiedFollowing; + default: + throw new ArgumentException( "Unknown TimeUnit: " + p.units() ); + } + } + + public static bool eurliborEOM( Period p ) + { + switch ( p.units() ) + { + case TimeUnit.Days: + case TimeUnit.Weeks: + return false; + case TimeUnit.Months: + case TimeUnit.Years: + return true; + default: + throw new ArgumentException( "Unknown TimeUnit: " + p.units() ); + } + } + } + + //! base class for all ICE %EUR %LIBOR indexes but the O/N + /*! Euro LIBOR fixed by ICE. + + See . + + \warning This is the rate fixed in London by BBA. Use Euribor if + you're interested in the fixing by the ECB. + */ + public class EURLibor : IborIndex + { + private Calendar target_; + + // http://www.bba.org.uk/bba/jsp/polopoly.jsp?d=225&a=1412 : + // JoinBusinessDays is the fixing calendar for + // all indexes but o/n + + public EURLibor( Period tenor ) + : base( "EURLibor", tenor, 2, new EURCurrency(), new JointCalendar( new UnitedKingdom( UnitedKingdom.Market.Exchange ), new TARGET(), + JointCalendar.JointCalendarRule.JoinHolidays ), + Utils.eurliborConvention( tenor ), Utils.eurliborEOM( tenor ), new Actual360(), + new Handle() ) + { + target_ = new TARGET(); + if ( !( this.tenor().units() != TimeUnit.Days ) ) + throw new Exception( "for daily tenors (" + this.tenor() + ") dedicated DailyTenor constructor must be used" ); + } + + public EURLibor( Period tenor, Handle h ) + : base( "EURLibor", tenor, 2, new EURCurrency(), new JointCalendar( new UnitedKingdom( UnitedKingdom.Market.Exchange ), new TARGET(), + JointCalendar.JointCalendarRule.JoinHolidays ), + Utils.eurliborConvention( tenor ), Utils.eurliborEOM( tenor ), new Actual360(), h ) + { + target_ = new TARGET(); + if ( !( this.tenor().units() != TimeUnit.Days ) ) + throw new Exception( "for daily tenors (" + this.tenor() + ") dedicated DailyTenor constructor must be used" ); + } + + /*! \name Date calculations + + See . + @{ + */ + public override Date valueDate( Date fixingDate ) + { + + if ( !( isValidFixingDate( fixingDate ) ) ) + throw new Exception( "Fixing date " + fixingDate + " is not valid" ); + + // http://www.bba.org.uk/bba/jsp/polopoly.jsp?d=225&a=1412 : + // In the case of EUR the Value Date shall be two TARGET + // business days after the Fixing Date. + return target_.advance( fixingDate, fixingDays_, TimeUnit.Days ); + } + public override Date maturityDate( Date valueDate ) + { + // http://www.bba.org.uk/bba/jsp/polopoly.jsp?d=225&a=1412 : + // In the case of EUR only, maturity dates will be based on days in + // which the Target system is open. + return target_.advance( valueDate, tenor_, convention_, endOfMonth() ); + } + } + + //! base class for the one day deposit ICE %EUR %LIBOR indexes + /*! Euro O/N LIBOR fixed by ICE. It can be also used for T/N and S/N + indexes, even if such indexes do not have ICE fixing. + + See . + + \warning This is the rate fixed in London by ICE. Use Eonia if + you're interested in the fixing by the ECB. + */ + public class DailyTenorEURLibor : IborIndex + { + + // http://www.bba.org.uk/bba/jsp/polopoly.jsp?d=225&a=1412 : + // no o/n or s/n fixings (as the case may be) will take place + // when the principal centre of the currency concerned is + // closed but London is open on the fixing day. + public DailyTenorEURLibor( int settlementDays ) + : this( settlementDays, new Handle() ) + {} + + public DailyTenorEURLibor() + : base( "EURLibor", new Period( 1, TimeUnit.Days ), 0, new EURCurrency(), new TARGET(), + Utils.eurliborConvention( new Period( 1, TimeUnit.Days ) ), Utils.eurliborEOM( new Period( 1, TimeUnit.Days ) ), new Actual360(), new Handle() ) + {} + + public DailyTenorEURLibor( int settlementDays, Handle h ) + : base( "EURLibor", new Period( 1, TimeUnit.Days ), settlementDays, new EURCurrency(), new TARGET(), + Utils.eurliborConvention( new Period( 1, TimeUnit.Days ) ), Utils.eurliborEOM( new Period( 1, TimeUnit.Days ) ), new Actual360(), h ) + {} + + } + + //! Overnight %EUR %Libor index + public class EURLiborON : DailyTenorEURLibor + { + public EURLiborON() + : base( 0, new Handle() ) + {} + + public EURLiborON( Handle h ) + : base( 0, h ) + {} + } + + //! 1-week %EUR %Libor index + public class EURLiborSW : EURLibor + { + public EURLiborSW() + : base( new Period( 1, TimeUnit.Weeks ), new Handle() ) + {} + public EURLiborSW( Handle h ) + : base( new Period( 1, TimeUnit.Weeks ), h ) + {} + } + + //! 2-weeks %EUR %Libor index + public class EURLibor2W : EURLibor + { + public EURLibor2W() + : base( new Period( 2, TimeUnit.Weeks ), new Handle() ) + {} + + public EURLibor2W( Handle h ) + : base( new Period( 2, TimeUnit.Weeks ), h ) + {} + + } + + + //! 1-month %EUR %Libor index + public class EURLibor1M : EURLibor + { + public EURLibor1M() + : base( new Period( 1, TimeUnit.Months ), new Handle() ) + {} + + public EURLibor1M( Handle h ) + : base( new Period( 1, TimeUnit.Months ), h ) + {} + + } + + //! 2-months %EUR %Libor index + public class EURLibor2M : EURLibor + { + public EURLibor2M() + : base( new Period( 2, TimeUnit.Months ), new Handle() ) + {} + + public EURLibor2M( Handle h ) + : base( new Period( 2, TimeUnit.Months ), h ) + {} + + } + + //! 3-months %EUR %Libor index + public class EURLibor3M : EURLibor + { + public EURLibor3M() + : base( new Period( 3, TimeUnit.Months ), new Handle() ) + {} + + public EURLibor3M( Handle h ) + : base( new Period( 3, TimeUnit.Months ), h ) + {} + + } + + //! 4-months %EUR %Libor index + public class EURLibor4M : EURLibor + { + public EURLibor4M() + : base( new Period( 4, TimeUnit.Months ), new Handle() ) + {} + + public EURLibor4M( Handle h ) + : base( new Period( 4, TimeUnit.Months ), h ) + {} + + } + + //! 5-months %EUR %Libor index + public class EURLibor5M : EURLibor + { + public EURLibor5M() + : base( new Period( 5, TimeUnit.Months ), new Handle() ) + {} + + public EURLibor5M( Handle h ) + : base( new Period( 5, TimeUnit.Months ), h ) + {} + + } + + //! 6-months %EUR %Libor index + public class EURLibor6M : EURLibor + { + public EURLibor6M() + : base( new Period( 6, TimeUnit.Months ), new Handle() ) + {} + + public EURLibor6M( Handle h ) + : base( new Period( 6, TimeUnit.Months ), h ) + {} + + } + + //! 7-months %EUR %Libor index + public class EURLibor7M : EURLibor + { + public EURLibor7M() + : base( new Period( 7, TimeUnit.Months ), new Handle() ) + {} + + public EURLibor7M( Handle h ) + : base( new Period( 7, TimeUnit.Months ), h ) + {} + + } + + //! 8-months %EUR %Libor index + public class EURLibor8M : EURLibor + { + public EURLibor8M() + : base( new Period( 8, TimeUnit.Months ), new Handle() ) + {} + + public EURLibor8M( Handle h ) + : base( new Period( 8, TimeUnit.Months ), h ) + {} + + } + + //! 9-months %EUR %Libor index + public class EURLibor9M : EURLibor + { + public EURLibor9M() + : base( new Period( 9, TimeUnit.Months ), new Handle() ) + {} + + public EURLibor9M( Handle h ) + : base( new Period( 9, TimeUnit.Months ), h ) + {} + + } + + //! 10-months %EUR %Libor index + public class EURLibor10M : EURLibor + { + public EURLibor10M() + : base( new Period( 10, TimeUnit.Months ), new Handle() ) + {} + + public EURLibor10M( Handle h ) + : base( new Period( 10, TimeUnit.Months ), h ) + {} + + } + + //! 11-months %EUR %Libor index + public class EURLibor11M : EURLibor + { + public EURLibor11M() + : base( new Period( 11, TimeUnit.Months ), new Handle() ) + {} + + public EURLibor11M( Handle h ) + : base( new Period( 11, TimeUnit.Months ), h ) + {} + + } + + //! 1-year %EUR %Libor index + public class EURLibor1Y : EURLibor + { + public EURLibor1Y() + : base( new Period( 1, TimeUnit.Years ), new Handle() ) + {} + + public EURLibor1Y( Handle h ) + : base( new Period( 1, TimeUnit.Years ), h ) + {} + + } + + +} diff --git a/QLNet/Indexes/Ibor/Gbplibor.cs b/QLNet/Indexes/Ibor/Gbplibor.cs index 7d496c540..1cea7d0d9 100644 --- a/QLNet/Indexes/Ibor/Gbplibor.cs +++ b/QLNet/Indexes/Ibor/Gbplibor.cs @@ -16,34 +16,42 @@ under the terms of the QLNet license. You should have received a This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the license for more details. -*/ +*/ + +namespace QLNet +{ + + //! %GBP %LIBOR rate + /*! Pound Sterling LIBOR fixed by ICE. -namespace QLNet { - - //! %GBP %LIBOR rate - // ! Pound Sterling LIBOR fixed by BBA. - // - // See . - // - public class GBPLibor : Libor { - public GBPLibor(Period tenor) - : base("GBPLibor", tenor, 0, new GBPCurrency(), new UnitedKingdom(UnitedKingdom.Market.Exchange), new Actual365Fixed(), - new Handle()) { - } - public GBPLibor(Period tenor, Handle h) - : base("GBPLibor", tenor, 0, new GBPCurrency(), new UnitedKingdom(UnitedKingdom.Market.Exchange), new Actual365Fixed(), h) { - } - } - - //! base class for the one day deposit BBA %GBP %LIBOR indexes - public class DailyTenorGBPLibor : DailyTenorLibor { - public DailyTenorGBPLibor(int settlementDays, Handle h) - : base("GBPLibor", settlementDays, new GBPCurrency(), new UnitedKingdom(UnitedKingdom.Market.Exchange), - new Actual365Fixed(), h) {} - } - - //! Overnight %GBP %Libor index - public class GBPLiborON : DailyTenorGBPLibor { - public GBPLiborON(Handle h) : base(0, h) {} - } + See . + */ + public class GBPLibor : Libor + { + public GBPLibor( Period tenor ) + : base( "GBPLibor", tenor, 0, new GBPCurrency(), new UnitedKingdom( UnitedKingdom.Market.Exchange ), new Actual365Fixed(), + new Handle() ) + {} + + public GBPLibor( Period tenor, Handle h ) + : base( "GBPLibor", tenor, 0, new GBPCurrency(), new UnitedKingdom( UnitedKingdom.Market.Exchange ), new Actual365Fixed(), h ) + {} + + } + + //! Base class for the one day deposit ICE %GBP %LIBOR indexes + public class DailyTenorGBPLibor : DailyTenorLibor + { + public DailyTenorGBPLibor( int settlementDays, Handle h ) + : base( "GBPLibor", settlementDays, new GBPCurrency(), new UnitedKingdom( UnitedKingdom.Market.Exchange ), + new Actual365Fixed(), h ) + {} + } + + //! Overnight %GBP %Libor index + public class GBPLiborON : DailyTenorGBPLibor + { + public GBPLiborON( Handle h ) : base( 0, h ) + {} + } } diff --git a/QLNet/Indexes/Ibor/Jpylibor.cs b/QLNet/Indexes/Ibor/Jpylibor.cs index 6d7d0f1e1..233e4e04d 100644 --- a/QLNet/Indexes/Ibor/Jpylibor.cs +++ b/QLNet/Indexes/Ibor/Jpylibor.cs @@ -16,31 +16,39 @@ under the terms of the QLNet license. You should have received a This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the license for more details. -*/ +*/ + +namespace QLNet +{ + + //! %JPY %LIBOR rate + /*! Japanese Yen LIBOR fixed by ICE. -namespace QLNet { + See . - //! %JPY %LIBOR rate - // ! Japanese Yen LIBOR fixed by BBA. - // - // See . - // - // \warning This is the rate fixed in London by BBA. Use TIBOR if - // you're interested in the Tokio fixing. - // - public class JPYLibor : Libor { - public JPYLibor(Period tenor) - : base("JPYLibor", tenor, 2, new JPYCurrency(), new Japan(), new Actual360(), new Handle()) { - } - public JPYLibor(Period tenor, Handle h) - : base("JPYLibor", tenor, 2, new JPYCurrency(), new Japan(), new Actual360(), h) { - } - } - - //! base class for the one day deposit BBA %JPY %LIBOR indexes - public class DailyTenorJPYLibor : DailyTenorLibor { - public DailyTenorJPYLibor(int settlementDays) : this(settlementDays, new Handle()) { } - public DailyTenorJPYLibor(int settlementDays, Handle h) - : base("JPYLibor", settlementDays, new JPYCurrency(), new Japan(), new Actual360(), h) {} - }; + \warning This is the rate fixed in London by ICE. Use TIBOR if + you're interested in the Tokio fixing. + */ + public class JPYLibor : Libor + { + public JPYLibor( Period tenor ) + : base( "JPYLibor", tenor, 2, new JPYCurrency(), new Japan(), new Actual360(), new Handle() ) + {} + + public JPYLibor( Period tenor, Handle h ) + : base( "JPYLibor", tenor, 2, new JPYCurrency(), new Japan(), new Actual360(), h ) + {} + + } + + //! base class for the one day deposit ICE %JPY %LIBOR indexes + public class DailyTenorJPYLibor : DailyTenorLibor + { + public DailyTenorJPYLibor( int settlementDays ) : this( settlementDays, new Handle() ) + {} + + public DailyTenorJPYLibor( int settlementDays, Handle h ) + : base( "JPYLibor", settlementDays, new JPYCurrency(), new Japan(), new Actual360(), h ) + {} + } } diff --git a/QLNet/Indexes/Ibor/Libor.cs b/QLNet/Indexes/Ibor/Libor.cs index d50693db4..d509ee442 100644 --- a/QLNet/Indexes/Ibor/Libor.cs +++ b/QLNet/Indexes/Ibor/Libor.cs @@ -1,137 +1,156 @@ -/* - Copyright (C) 2008 Siarhei Novik (snovik@gmail.com) - - This file is part of QLNet Project https://github.com/amaggiulli/qlnet - - QLNet is free software: you can redistribute it and/or modify it - under the terms of the QLNet license. You should have received a - copy of the license along with this program; if not, license is - available online at . - - QLNet is a based on QuantLib, a free-software/open-source library - for financial quantitative analysts and developers - http://quantlib.org/ - The QuantLib license is available online at http://quantlib.org/license.shtml. - - This program is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS - FOR A PARTICULAR PURPOSE. See the license for more details. -*/ -using System; - -namespace QLNet { - //! base class for all BBA LIBOR indexes but the EUR, O/N, and S/N ones LIBOR fixed by BBA. - //! See . - public class Libor : IborIndex { - private Calendar financialCenterCalendar_; - private Calendar jointCalendar_; - - //public Libor(string familyName, Period tenor, int settlementDays, Currency currency, Calendar financialCenterCalendar, - // DayCounter dayCounter, YieldTermStructure h = YieldTermStructure()) - public Libor(string familyName, Period tenor, int settlementDays, Currency currency, Calendar financialCenterCalendar, - DayCounter dayCounter, Handle h) - : base(familyName, tenor, settlementDays, currency, - // http://www.bba.org.uk/bba/jsp/polopoly.jsp?d=225&a=1412 : - // UnitedKingdom::Exchange is the fixing calendar for - // a) all currencies but EUR - // b) all indexes but o/n and s/n - new UnitedKingdom(UnitedKingdom.Market.Exchange), - Utils.liborConvention(tenor), Utils.liborEOM(tenor), - dayCounter, h) { - - financialCenterCalendar_ = financialCenterCalendar; - jointCalendar_ = new JointCalendar(new UnitedKingdom(UnitedKingdom.Market.Exchange), - financialCenterCalendar, JointCalendar.JointCalendarRule.JoinHolidays); - if (this.tenor().units() == TimeUnit.Days) - throw new ApplicationException("for daily tenors (" + this.tenor() + - ") dedicated DailyTenor constructor must be used"); - if (currency == new EURCurrency()) - throw new ApplicationException("for EUR Libor dedicated EurLibor constructor must be used"); - } - - public override Date valueDate(Date fixingDate) { - if (!isValidFixingDate(fixingDate)) - throw new ApplicationException("Fixing date " + fixingDate + " is not valid"); - - // http://www.bba.org.uk/bba/jsp/polopoly.jsp?d=225&a=1412 : - // For all currencies other than EUR and GBP the period between - // Fixing Date and Value Date will be two London business days - // after the Fixing Date, or if that day is not both a London - // business day and a business day in the principal financial centre - // of the currency concerned, the next following day which is a - // business day in both centres shall be the Value Date. - Date d = fixingCalendar().advance(fixingDate, fixingDays_, TimeUnit.Days); - return jointCalendar_.adjust(d); - } - - public override Date maturityDate(Date valueDate) { - // Where a deposit is made on the final business day of a - // particular calendar month, the maturity of the deposit shall - // be on the final business day of the month in which it matures - // (not the corresponding date in the month of maturity). Or in - // other words, in line with market convention, BBA LIBOR rates - // are dealt on an end-end basis. For instance a one month - // deposit for value 28th February would mature on 31st March, - // not the 28th of March. - return jointCalendar_.advance(valueDate, tenor_, convention_, endOfMonth()); - } - - //! \name Other methods - public override IborIndex clone(Handle h) { - return new Libor(familyName(), tenor(), fixingDays(), currency(), financialCenterCalendar_, - dayCounter(), h); - } - } - - //! base class for O/N-S/N BBA LIBOR indexes but the EUR ones - // ! One day deposit LIBOR fixed by BBA. - // - // See . - // - public class DailyTenorLibor : IborIndex { - // http://www.bba.org.uk/bba/jsp/polopoly.jsp?d=225&a=1412 : - // no o/n or s/n fixings (as the case may be) will take place - // when the principal centre of the currency concerned is - // closed but London is open on the fixing day. - public DailyTenorLibor(string familyName, int settlementDays, Currency currency, Calendar financialCenterCalendar, - DayCounter dayCounter) - : this(familyName, settlementDays, currency, financialCenterCalendar, dayCounter, new Handle()) { - } - - public DailyTenorLibor(string familyName, int settlementDays, Currency currency, Calendar financialCenterCalendar, - DayCounter dayCounter, Handle h) - : base(familyName, new Period(1, TimeUnit.Days), settlementDays, currency, - new JointCalendar(new UnitedKingdom(UnitedKingdom.Market.Exchange), financialCenterCalendar, JointCalendar.JointCalendarRule.JoinHolidays), - Utils.liborConvention(new Period(1, TimeUnit.Days)), Utils.liborEOM(new Period(1, TimeUnit.Days)), dayCounter, h) { - if (!(currency != new EURCurrency())) - throw new ApplicationException("for EUR Libor dedicated EurLibor constructor must be used"); - } - } - - public static partial class Utils { - public static BusinessDayConvention liborConvention(Period p) { - switch (p.units()) { - case TimeUnit.Days: - case TimeUnit.Weeks: - return BusinessDayConvention.Following; - case TimeUnit.Months: - case TimeUnit.Years: - return BusinessDayConvention.ModifiedFollowing; - default: - throw new ApplicationException("invalid time units"); - } - } - - public static bool liborEOM(Period p) { - switch (p.units()) { - case TimeUnit.Days: - case TimeUnit.Weeks: - return false; - case TimeUnit.Months: - case TimeUnit.Years: - return true; - default: - throw new ApplicationException("invalid time units"); - } - } - } -} +/* + Copyright (C) 2008 Siarhei Novik (snovik@gmail.com) + + This file is part of QLNet Project https://github.com/amaggiulli/qlnet + + QLNet is free software: you can redistribute it and/or modify it + under the terms of the QLNet license. You should have received a + copy of the license along with this program; if not, license is + available online at . + + QLNet is a based on QuantLib, a free-software/open-source library + for financial quantitative analysts and developers - http://quantlib.org/ + The QuantLib license is available online at http://quantlib.org/license.shtml. + + This program is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS + FOR A PARTICULAR PURPOSE. See the license for more details. +*/ +using System; + +namespace QLNet +{ + //! base class for all ICE LIBOR indexes but the EUR, O/N, and S/N ones + /*! LIBOR fixed by ICE. + + See . + */ + public class Libor : IborIndex + { + private Calendar financialCenterCalendar_; + private Calendar jointCalendar_; + + public Libor( string familyName, Period tenor, int settlementDays, Currency currency, Calendar financialCenterCalendar, + DayCounter dayCounter, Handle h ) + : base( familyName, tenor, settlementDays, currency, + // http://www.bba.org.uk/bba/jsp/polopoly.jsp?d=225&a=1412 : + // UnitedKingdom::Exchange is the fixing calendar for + // a) all currencies but EUR + // b) all indexes but o/n and s/n + new UnitedKingdom( UnitedKingdom.Market.Exchange ), + Utils.liborConvention( tenor ), Utils.liborEOM( tenor ), + dayCounter, h ) + { + + financialCenterCalendar_ = financialCenterCalendar; + jointCalendar_ = new JointCalendar( new UnitedKingdom( UnitedKingdom.Market.Exchange ), + financialCenterCalendar, JointCalendar.JointCalendarRule.JoinHolidays ); + if ( this.tenor().units() == TimeUnit.Days ) + throw new Exception( "for daily tenors (" + this.tenor() + + ") dedicated DailyTenor constructor must be used" ); + if ( currency == new EURCurrency() ) + throw new Exception( "for EUR Libor dedicated EurLibor constructor must be used" ); + } + + /*! \name Date calculations + + See . + @{ + */ + public override Date valueDate( Date fixingDate ) + { + if ( !isValidFixingDate( fixingDate ) ) + throw new Exception( "Fixing date " + fixingDate + " is not valid" ); + + // http://www.bba.org.uk/bba/jsp/polopoly.jsp?d=225&a=1412 : + // For all currencies other than EUR and GBP the period between + // Fixing Date and Value Date will be two London business days + // after the Fixing Date, or if that day is not both a London + // business day and a business day in the principal financial centre + // of the currency concerned, the next following day which is a + // business day in both centres shall be the Value Date. + Date d = fixingCalendar().advance( fixingDate, fixingDays_, TimeUnit.Days ); + return jointCalendar_.adjust( d ); + } + + public override Date maturityDate( Date valueDate ) + { + // Where a deposit is made on the final business day of a + // particular calendar month, the maturity of the deposit shall + // be on the final business day of the month in which it matures + // (not the corresponding date in the month of maturity). Or in + // other words, in line with market convention, BBA LIBOR rates + // are dealt on an end-end basis. For instance a one month + // deposit for value 28th February would mature on 31st March, + // not the 28th of March. + return jointCalendar_.advance( valueDate, tenor_, convention_, endOfMonth() ); + } + + //! \name Other methods + public override IborIndex clone( Handle h ) + { + return new Libor( familyName(), tenor(), fixingDays(), currency(), financialCenterCalendar_, + dayCounter(), h ); + } + } + + //! base class for all O/N-S/N BBA LIBOR indexes but the EUR ones + /*! One day deposit LIBOR fixed by ICE. + + See . + */ + public class DailyTenorLibor : IborIndex + { + // http://www.bba.org.uk/bba/jsp/polopoly.jsp?d=225&a=1412 : + // no o/n or s/n fixings (as the case may be) will take place + // when the principal centre of the currency concerned is + // closed but London is open on the fixing day. + public DailyTenorLibor( string familyName, int settlementDays, Currency currency, Calendar financialCenterCalendar, + DayCounter dayCounter ) + : this( familyName, settlementDays, currency, financialCenterCalendar, dayCounter, new Handle() ) + {} + + public DailyTenorLibor( string familyName, int settlementDays, Currency currency, Calendar financialCenterCalendar, + DayCounter dayCounter, Handle h ) + : base( familyName, new Period( 1, TimeUnit.Days ), settlementDays, currency, + new JointCalendar( new UnitedKingdom( UnitedKingdom.Market.Exchange ), financialCenterCalendar, JointCalendar.JointCalendarRule.JoinHolidays ), + Utils.liborConvention( new Period( 1, TimeUnit.Days ) ), Utils.liborEOM( new Period( 1, TimeUnit.Days ) ), dayCounter, h ) + { + if ( !( currency != new EURCurrency() ) ) + throw new Exception( "for EUR Libor dedicated EurLibor constructor must be used" ); + } + } + + public static partial class Utils + { + public static BusinessDayConvention liborConvention( Period p ) + { + switch ( p.units() ) + { + case TimeUnit.Days: + case TimeUnit.Weeks: + return BusinessDayConvention.Following; + case TimeUnit.Months: + case TimeUnit.Years: + return BusinessDayConvention.ModifiedFollowing; + default: + throw new Exception( "invalid time units" ); + } + } + + public static bool liborEOM( Period p ) + { + switch ( p.units() ) + { + case TimeUnit.Days: + case TimeUnit.Weeks: + return false; + case TimeUnit.Months: + case TimeUnit.Years: + return true; + default: + throw new Exception( "invalid time units" ); + } + } + } +} diff --git a/QLNet/Indexes/Ibor/Nzdlibor.cs b/QLNet/Indexes/Ibor/Nzdlibor.cs index c429ef81a..47d92eaf8 100644 --- a/QLNet/Indexes/Ibor/Nzdlibor.cs +++ b/QLNet/Indexes/Ibor/Nzdlibor.cs @@ -15,25 +15,24 @@ under the terms of the QLNet license. You should have received a This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the license for more details. -*/ - -namespace QLNet { - - //! %NZD %LIBOR rate -// ! New Zealand Dollar LIBOR fixed by BBA. -// -// See . -// - public class NZDLibor : Libor - { - public NZDLibor(Period tenor) - : base("NZDLibor", tenor, 2, new NZDCurrency(), new NewZealand(), new Actual360(), new Handle()) - { - } - public NZDLibor(Period tenor, Handle h) - : base("NZDLibor", tenor, 2, new NZDCurrency(), new NewZealand(), new Actual360(), h) - { - } - } - +*/ + +namespace QLNet +{ + + //! %NZD %LIBOR rate + /*! New Zealand Dollar LIBOR discontinued as of 2013. + */ + public class NZDLibor : Libor + { + public NZDLibor( Period tenor ) + : base( "NZDLibor", tenor, 2, new NZDCurrency(), new NewZealand(), new Actual360(), new Handle() ) + {} + + public NZDLibor( Period tenor, Handle h ) + : base( "NZDLibor", tenor, 2, new NZDCurrency(), new NewZealand(), new Actual360(), h ) + {} + + } + } diff --git a/QLNet/Indexes/Ibor/Seklibor.cs b/QLNet/Indexes/Ibor/Seklibor.cs index c59251f4d..94fa04b7b 100644 --- a/QLNet/Indexes/Ibor/Seklibor.cs +++ b/QLNet/Indexes/Ibor/Seklibor.cs @@ -15,24 +15,24 @@ under the terms of the QLNet license. You should have received a This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the license for more details. -*/ - -namespace QLNet { - - //! %SEK %LIBOR rate -// ! Sweden Krone LIBOR fixed by BBA. -// -// See . -// - public class SEKLibor : Libor - { - public SEKLibor(Period tenor) : base("SEKLibor", tenor, 2, new SEKCurrency(), new Sweden(), new Actual360(), new Handle()) - { - } - public SEKLibor(Period tenor, Handle h) - : base("SEKLibor", tenor, 2, new SEKCurrency(), new Sweden(), new Actual360(), h) - { - } - } - +*/ + +namespace QLNet +{ + + //! %SEK %LIBOR rate + /*! Sweden Krone LIBOR discontinued as of 2013. + */ + public class SEKLibor : Libor + { + public SEKLibor( Period tenor ) + : base( "SEKLibor", tenor, 2, new SEKCurrency(), new Sweden(), new Actual360(), new Handle() ) + {} + + public SEKLibor( Period tenor, Handle h ) + : base( "SEKLibor", tenor, 2, new SEKCurrency(), new Sweden(), new Actual360(), h ) + {} + + } + } diff --git a/QLNet/Indexes/Ibor/Trylibor.cs b/QLNet/Indexes/Ibor/Trylibor.cs index 465197380..547f82cd7 100644 --- a/QLNet/Indexes/Ibor/Trylibor.cs +++ b/QLNet/Indexes/Ibor/Trylibor.cs @@ -15,27 +15,28 @@ under the terms of the QLNet license. You should have received a This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the license for more details. -*/ +*/ + +namespace QLNet +{ + + //! %TRY %LIBOR rate + /*! TRY LIBOR fixed by TBA. -namespace QLNet { - - //! %TRY %LIBOR rate -// ! TRY LIBOR fixed by TBA. -// -// See -// -// \todo check end-of-month adjustment. -// - public class TRLibor : IborIndex - { - public TRLibor(Period tenor) - : base("TRLibor", tenor, 0, new TRYCurrency(), new Turkey(), BusinessDayConvention.ModifiedFollowing, false, new Actual360(), new Handle()) - { - } - public TRLibor(Period tenor, Handle h) - : base("TRLibor", tenor, 0, new TRYCurrency(), new Turkey(), BusinessDayConvention.ModifiedFollowing, false, new Actual360(), h) - { - } - } + See + \todo check end-of-month adjustment. + */ + public class TRLibor : IborIndex + { + public TRLibor( Period tenor ) + : base( "TRLibor", tenor, 0, new TRYCurrency(), new Turkey(), BusinessDayConvention.ModifiedFollowing, false, new Actual360(), new Handle() ) + {} + + public TRLibor( Period tenor, Handle h ) + : base( "TRLibor", tenor, 0, new TRYCurrency(), new Turkey(), BusinessDayConvention.ModifiedFollowing, false, new Actual360(), h ) + {} + + } + } diff --git a/QLNet/Indexes/Ibor/Usdlibor.cs b/QLNet/Indexes/Ibor/Usdlibor.cs index 4d9ce5e5d..bdf7f2e3d 100644 --- a/QLNet/Indexes/Ibor/Usdlibor.cs +++ b/QLNet/Indexes/Ibor/Usdlibor.cs @@ -15,30 +15,45 @@ under the terms of the QLNet license. You should have received a This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the license for more details. -*/ +*/ + +namespace QLNet +{ + //! %USD %LIBOR rate + /*! US Dollar LIBOR fixed by ICE. -namespace QLNet { - //! %USD %LIBOR rate - /*! US Dollar LIBOR fixed by BBA. - - See . - */ - public class USDLibor : Libor { - public USDLibor(Period tenor) : this(tenor, new Handle()) { } - public USDLibor(Period tenor, Handle h) - : base("USDLibor", tenor, 2, new USDCurrency(), new UnitedStates(UnitedStates.Market.Settlement), new Actual360(), h) { } - } - - //! base class for the one day deposit BBA %USD %LIBOR indexes - public class DailyTenorUSDLibor : DailyTenorLibor { - public DailyTenorUSDLibor(int settlementDays) : this(settlementDays, new Handle()) {} - public DailyTenorUSDLibor(int settlementDays, Handle h) - : base("USDLibor", settlementDays, new USDCurrency(), new UnitedStates(UnitedStates.Market.Settlement), new Actual360(), h) {} - }; - - //! Overnight %USD %Libor index - public class USDLiborON : DailyTenorUSDLibor { - public USDLiborON() : this(new Handle()) { } - public USDLiborON(Handle h) : base(0, h) {} - } + See . + */ + public class USDLibor : Libor + { + public USDLibor( Period tenor ) : this( tenor, new Handle() ) + {} + + public USDLibor( Period tenor, Handle h ) + : base( "USDLibor", tenor, 2, new USDCurrency(), new UnitedStates( UnitedStates.Market.Settlement ), new Actual360(), h ) + {} + + } + + //! base class for the one day deposit ICE %USD %LIBOR indexes + public class DailyTenorUSDLibor : DailyTenorLibor + { + public DailyTenorUSDLibor( int settlementDays ) : this( settlementDays, new Handle() ) + {} + public DailyTenorUSDLibor( int settlementDays, Handle h ) + : base( "USDLibor", settlementDays, new USDCurrency(), new UnitedStates( UnitedStates.Market.Settlement ), new Actual360(), h ) + {} + + } + + //! Overnight %USD %Libor index + public class USDLiborON : DailyTenorUSDLibor + { + public USDLiborON() : this( new Handle() ) + {} + + public USDLiborON( Handle h ) : base( 0, h ) + {} + + } } diff --git a/QLNet/Indexes/InflationIndex.cs b/QLNet/Indexes/InflationIndex.cs index e423b82e5..44a191f1e 100644 --- a/QLNet/Indexes/InflationIndex.cs +++ b/QLNet/Indexes/InflationIndex.cs @@ -1,489 +1,472 @@ -/* - Copyright (C) 2008, 2009 , 2010 Andrea Maggiulli (a.maggiulli@gmail.com) - * - This file is part of QLNet Project https://github.com/amaggiulli/qlnet - - QLNet is free software: you can redistribute it and/or modify it - under the terms of the QLNet license. You should have received a - copy of the license along with this program; if not, license is - available online at . - - QLNet is a based on QuantLib, a free-software/open-source library - for financial quantitative analysts and developers - http://quantlib.org/ - The QuantLib license is available online at http://quantlib.org/license.shtml. - - This program is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS - FOR A PARTICULAR PURPOSE. See the license for more details. -*/ - -using System; -using System.Collections.Generic; - -namespace QLNet -{ - //! Base class for inflation-rate indexes, - public class InflationIndex : Index,IObserver - { - /*! An inflation index may return interpolated - values. These are linearly interpolated - values with act/act convention within a period. - Note that stored "fixings" are always flat (constant) - within a period and interpolated as needed. This - is because interpolation adds an addional availability - lag (because you always need the next period to - give the previous period's value) - and enables storage of the most recent uninterpolated value. - */ - - public InflationIndex(string familyName, Region region, bool revised, bool interpolated, - Frequency frequency, Period availabilitiyLag, Currency currency) - { - familyName_ = familyName; - region_ = region; - revised_ = revised; - interpolated_ = interpolated; - frequency_ = frequency; - availabilityLag_ = availabilitiyLag; - currency_ = currency; - Settings.registerWith(update); - IndexManager.instance().notifier(name()).registerWith(update); - } - - - //! \name Index interface - //@{ - public override string name() { return region_.name() + " " + familyName_; } - - /*! Inflation indices do not have fixing calendars. An - inflation index value is valid for every day (including - weekends) of a calendar period. I.e. it uses the - NullCalendar as its fixing calendar. - */ - public override Calendar fixingCalendar() { return new NullCalendar(); } - - public override bool isValidFixingDate(Date fixingDate) { return true; } - - /*! Forecasting index values requires an inflation term - structure. The inflation term structure (ITS) defines the - usual lag (not the index). I.e. an ITS is always relatve - to a base date that is earlier than its asof date. This - must be so because indices are available only with a lag. - However, the index availability lag only sets a minimum - lag for the ITS. An ITS may be relative to an earlier - date, e.g. an index may have a 2-month delay in - publication but the inflation swaps may take as their base - the index 3 months before. - */ - public override double fixing(Date fixingDate) { return fixing(fixingDate, false); } - public override double fixing(Date fixingDate, bool forecastTodaysFixing) { return 0; } - - /*! this method creates all the "fixings" for the relevant - period of the index. E.g. for monthly indices it will put - the same value in every calendar day in the month. - */ - public override void addFixing(Date fixingDate, double fixing) { addFixing(fixingDate, fixing, false); } - public override void addFixing(Date fixingDate, double fixing, bool forceOverwrite) - { - KeyValuePair lim = Utils.inflationPeriod(fixingDate, frequency_); - int n = lim.Value - lim.Key + 1; - List dates = new List(n); - List rates = new List(n); - - for (int i=0; iavailable, not how it is used. Specifically the - fixing for, say, January, may only be available in April - but the index will always return the index value - applicable for January as its January fixing (independent - of the lag in availability). - */ - public Period availabilityLag() {return availabilityLag_;} - public Currency currency() { return currency_; } - //@} - - protected Date referenceDate_; - protected string familyName_; - protected Region region_; - protected bool revised_; - protected bool interpolated_; - protected Frequency frequency_; - protected Period availabilityLag_; - protected Currency currency_; - - } - - - //! Base class for zero inflation indices. - public class ZeroInflationIndex : InflationIndex - { - //! Always use the evaluation date as the reference date - public ZeroInflationIndex(string familyName, - Region region, - bool revised, - bool interpolated, - Frequency frequency, - Period availabilityLag, - Currency currency) - :this(familyName,region,revised,interpolated,frequency,availabilityLag, - currency,new Handle()){} - - public ZeroInflationIndex(string familyName, - Region region, - bool revised, - bool interpolated, - Frequency frequency, - Period availabilityLag, - Currency currency, - Handle ts) - : base(familyName, region, revised, interpolated, - frequency, availabilityLag, currency) - { - zeroInflation_ = ts; - zeroInflation_.registerWith (update); - } - - /*! \warning the forecastTodaysFixing parameter (required by - the Index interface) is currently ignored. - */ - public override double fixing(Date aFixingDate, bool forecastTodaysFixing) - { - if (!needsForecast(aFixingDate)) - { - KeyValuePair lim = Utils.inflationPeriod(aFixingDate, frequency_); - Utils.QL_REQUIRE( IndexManager.instance().getHistory( name() ).value().ContainsKey( lim.Key ), () => - "Missing " + name() + " fixing for " + lim.Key ); - - double pastFixing = IndexManager.instance().getHistory(name()).value()[lim.Key]; - double theFixing = pastFixing; - if (interpolated_) - { - // fixings stored on first day of every period - if (aFixingDate == lim.Key) - { - // we don't actually need the next fixing - theFixing = pastFixing; - } - else - { - Utils.QL_REQUIRE( IndexManager.instance().getHistory( name() ).value().ContainsKey( lim.Value+1 ),()=> - "Missing " + name() + " fixing for " + (lim.Value+1)); - double pastFixing2 = IndexManager.instance().getHistory(name()).value()[lim.Value+1]; - // now linearly interpolate - double daysInPeriod = lim.Value+1 - lim.Key; - theFixing = pastFixing + (pastFixing2-pastFixing)*(aFixingDate-lim.Key)/daysInPeriod; - } - } - return theFixing; - } - else - { - return forecastFixing(aFixingDate); - } - } - - bool needsForecast(Date fixingDate) - { - // Stored fixings are always non-interpolated. - // If an interpolated fixing is required then - // the availability lag + one inflation period - // must have passed to use historical fixings - // (because you need the next one to interpolate). - // The interpolation is calculated (linearly) on demand. - - Date today = Settings.evaluationDate(); - Date todayMinusLag = today - availabilityLag_; - - Date historicalFixingKnown = Utils.inflationPeriod(todayMinusLag, frequency_).Key - 1; - Date latestNeededDate = fixingDate; - - if (interpolated_) { // might need the next one too - KeyValuePair p = Utils.inflationPeriod(fixingDate, frequency_); - if (fixingDate > p.Key) - latestNeededDate = latestNeededDate + new Period(frequency_); - } - - if (latestNeededDate <= historicalFixingKnown) { - // the fixing date is well before the availability lag, so - // we know that fixings were provided. - return false; - } else if (latestNeededDate > today) { - // the fixing can't be available, no matter what's in the - // time series - return true; - } else { - // we're not sure, but the fixing might be there so we - // check. Todo: check which fixings are not possible, to - // avoid using fixings in the future - return IndexManager.instance().getHistory(name()).value().ContainsKey(latestNeededDate); - } - } - - - public Handle zeroInflationTermStructure() {return zeroInflation_;} - - public ZeroInflationIndex clone(Handle h) - { - - return new ZeroInflationIndex(familyName_, region_, revised_, - interpolated_, frequency_, - availabilityLag_, currency_, h); - } - - - private double forecastFixing(Date fixingDate) - { - // the term structure is relative to the fixing value at the base date. - Date baseDate = zeroInflation_.link.baseDate(); - Utils.QL_REQUIRE( !needsForecast( baseDate ), () => name() + " index fixing at base date is not available" ); - double baseFixing = fixing(baseDate, false); - Date effectiveFixingDate; - if (interpolated()) - { - effectiveFixingDate = fixingDate; - } - else - { - // start of period is the convention - // so it's easier to do linear interpolation on fixings - effectiveFixingDate = Utils.inflationPeriod(fixingDate, frequency()).Key; - } - - // no observation lag because it is the fixing for the date - // but if index is not interpolated then that fixing is constant - // for each period, hence the t uses the effectiveFixingDate - // However, it's slightly safe to get the zeroRate with the - // fixingDate to avoid potential problems at the edges of periods - double t = zeroInflation_.link.dayCounter().yearFraction(baseDate, effectiveFixingDate); - bool forceLinearInterpolation = false; - double zero = zeroInflation_.link.zeroRate(fixingDate, new Period(0,TimeUnit.Days), forceLinearInterpolation); - // Annual compounding is the convention for zero inflation rates (or quotes) - return baseFixing * Math.Pow(1.0 + zero, t); - } - - private Handle zeroInflation_; - }; - - //! Base class for year-on-year inflation indices. - /*! These may be genuine indices published on, say, Bloomberg, or - "fake" indices that are defined as the ratio of an index at - different time points. - */ - public class YoYInflationIndex : InflationIndex - { - - public YoYInflationIndex(string familyName, - Region region, - bool revised, - bool interpolated, - bool ratio, // is this one a genuine index or a ratio? - Frequency frequency, - Period availabilityLag, - Currency currency) - :this(familyName,region,revised,interpolated,ratio,frequency,availabilityLag,currency, - new Handle()) {} - - public YoYInflationIndex(string familyName, - Region region, - bool revised, - bool interpolated, - bool ratio, // is this one a genuine index or a ratio? - Frequency frequency, - Period availabilityLag, - Currency currency, - Handle yoyInflation) - : base(familyName, region, revised, interpolated,frequency, availabilityLag, currency) - { - ratio_ = ratio; - yoyInflation_ = yoyInflation; - yoyInflation_.registerWith(update); - } - - /*! \warning the forecastTodaysFixing parameter (required by - the Index interface) is currently ignored. - */ - public override double fixing(Date fixingDate) { return fixing(fixingDate,false); } - public override double fixing(Date fixingDate, bool forecastTodaysFixing) - { - Date today = Settings.evaluationDate(); - Date todayMinusLag = today - availabilityLag_; - KeyValuePair limm = Utils.inflationPeriod(todayMinusLag, frequency_); - Date lastFix = limm.Key-1; - - Date flatMustForecastOn = lastFix+1; - Date interpMustForecastOn = lastFix+1 - new Period(frequency_); - - - if (interpolated() && fixingDate >= interpMustForecastOn) { - return forecastFixing(fixingDate); - } - - if (!interpolated() && fixingDate >= flatMustForecastOn) { - return forecastFixing(fixingDate); - } - - // four cases with ratio() and interpolated() - if (ratio()) - { - if(interpolated()) - { - // IS ratio, IS interpolated - KeyValuePair lim = Utils.inflationPeriod(fixingDate, frequency_); - Date fixMinus1Y= new NullCalendar().advance(fixingDate, new Period(-1,TimeUnit.Years),BusinessDayConvention.ModifiedFollowing); - KeyValuePair limBef = Utils.inflationPeriod(fixMinus1Y, frequency_); - double dp= lim.Value + 1 - lim.Key; - double dpBef=limBef.Value + 1 - limBef.Key; - double dl = fixingDate-lim.Key; - // potentially does not work on 29th Feb - double dlBef = fixMinus1Y - limBef.Key; - // get the four relevant fixings - // recall that they are stored flat for every day - double? limFirstFix = - IndexManager.instance().getHistory(name()).value()[lim.Key]; - if( limFirstFix == null) - throw new ApplicationException("Missing " + name() + " fixing for " - + lim.Key ); - double? limSecondFix = - IndexManager.instance().getHistory(name()).value()[lim.Value+1]; - if ( limSecondFix == null ) - throw new ApplicationException("Missing " + name() + " fixing for " - + lim.Value+1 ); - double? limBefFirstFix = - IndexManager.instance().getHistory(name()).value()[limBef.Key]; - if ( limBefFirstFix == null ) - throw new ApplicationException("Missing " + name() + " fixing for " - + limBef.Key ); - double? limBefSecondFix = - IndexManager.instance().getHistory(name()).value()[limBef.Value+1]; - if ( limBefSecondFix == null ) - throw new ApplicationException("Missing " + name() + " fixing for " - + limBef.Value+1 ); - - double linearNow = limFirstFix.Value + (limSecondFix.Value-limFirstFix.Value)*dl/dp; - double linearBef = limBefFirstFix.Value + (limBefSecondFix.Value-limBefFirstFix.Value)*dlBef/dpBef; - double wasYES = linearNow / linearBef - 1.0; - - return wasYES; - - } - else - { - // IS ratio, NOT interpolated - double? pastFixing = - IndexManager.instance().getHistory(name()).value()[fixingDate]; - if ( pastFixing == null ) - throw new ApplicationException("Missing " + name() + " fixing for " - + fixingDate); - Date previousDate = fixingDate - new Period(1,TimeUnit.Years); - double? previousFixing = - IndexManager.instance().getHistory(name()).value()[previousDate]; - if( previousFixing == null ) - throw new ApplicationException("Missing " + name() + " fixing for " - + previousDate ); - - return pastFixing.Value/previousFixing.Value - 1.0; - } - } - else - { - // NOT ratio - if (interpolated()) - { - // NOT ratio, IS interpolated - KeyValuePair lim = Utils.inflationPeriod(fixingDate, frequency_); - double dp= lim.Value + 1 - lim.Key; - double dl = fixingDate-lim.Key; - double? limFirstFix = - IndexManager.instance().getHistory(name()).value()[lim.Key]; - if ( limFirstFix == null ) - throw new ApplicationException("Missing " + name() + " fixing for " - + lim.Key ); - double? limSecondFix = - IndexManager.instance().getHistory(name()).value()[lim.Value+1]; - if ( limSecondFix == null ) - throw new ApplicationException("Missing " + name() + " fixing for " - + lim.Value+1 ); - double linearNow = limFirstFix.Value + (limSecondFix.Value-limFirstFix.Value)*dl/dp; - - return linearNow; - - } - else - { - // NOT ratio, NOT interpolated - // so just flat - double? pastFixing = - IndexManager.instance().getHistory(name()).value()[fixingDate]; - if ( pastFixing == null ) - throw new ApplicationException("Missing " + name() + " fixing for " - + fixingDate); - return pastFixing.Value; - - } - } - - // QL_FAIL("YoYInflationIndex::fixing, should never get here"); - - } - - public bool ratio() { return ratio_; } - public Handle yoyInflationTermStructure() - { return yoyInflation_; } - - public YoYInflationIndex clone(Handle h) - { - return new YoYInflationIndex(familyName_, region_, revised_, - interpolated_, ratio_, frequency_, - availabilityLag_, currency_, h); - } - - - private double forecastFixing(Date fixingDate) - { - Date d; - if (interpolated()) - { - d = fixingDate; - } - else - { - // if the value is not interpolated use the starting value - // by internal convention this will be consistent - KeyValuePair lim = Utils.inflationPeriod(fixingDate, frequency_); - d = lim.Key; - } - return yoyInflation_.link.yoyRate(d,new Period(0,TimeUnit.Days)); - } - - private bool ratio_; - private Handle yoyInflation_; - } -} +/* + Copyright (C) 2008-2016 Andrea Maggiulli (a.maggiulli@gmail.com) + + This file is part of QLNet Project https://github.com/amaggiulli/qlnet + + QLNet is free software: you can redistribute it and/or modify it + under the terms of the QLNet license. You should have received a + copy of the license along with this program; if not, license is + available online at . + + QLNet is a based on QuantLib, a free-software/open-source library + for financial quantitative analysts and developers - http://quantlib.org/ + The QuantLib license is available online at http://quantlib.org/license.shtml. + + This program is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS + FOR A PARTICULAR PURPOSE. See the license for more details. +*/ + +using System; +using System.Collections.Generic; + +namespace QLNet +{ + //! Base class for inflation-rate indexes, + public class InflationIndex : Index, IObserver + { + /*! An inflation index may return interpolated + values. These are linearly interpolated + values with act/act convention within a period. + Note that stored "fixings" are always flat (constant) + within a period and interpolated as needed. This + is because interpolation adds an addional availability + lag (because you always need the next period to + give the previous period's value) + and enables storage of the most recent uninterpolated value. + */ + public InflationIndex( string familyName, + Region region, + bool revised, + bool interpolated, + Frequency frequency, + Period availabilitiyLag, + Currency currency ) + { + familyName_ = familyName; + region_ = region; + revised_ = revised; + interpolated_ = interpolated; + frequency_ = frequency; + availabilityLag_ = availabilitiyLag; + currency_ = currency; + name_ = region_.name() + " " + familyName_; + Settings.registerWith( update ); + IndexManager.instance().notifier( name() ).registerWith( update ); + } + + + // Index interface + public override string name() { return name_; } + + /*! Inflation indices do not have fixing calendars. An + inflation index value is valid for every day (including + weekends) of a calendar period. I.e. it uses the + NullCalendar as its fixing calendar. + */ + public override Calendar fixingCalendar() { return new NullCalendar(); } + + public override bool isValidFixingDate( Date fixingDate ) { return true; } + + /*! Forecasting index values requires an inflation term + structure. The inflation term structure (ITS) defines the + usual lag (not the index). I.e. an ITS is always relatve + to a base date that is earlier than its asof date. This + must be so because indices are available only with a lag. + However, the index availability lag only sets a minimum + lag for the ITS. An ITS may be relative to an earlier + date, e.g. an index may have a 2-month delay in + publication but the inflation swaps may take as their base + the index 3 months before. + */ + public override double fixing( Date fixingDate, bool forecastTodaysFixing = false ) { return 0; } + + /*! this method creates all the "fixings" for the relevant + period of the index. E.g. for monthly indices it will put + the same value in every calendar day in the month. + */ + public override void addFixing( Date fixingDate, double fixing, bool forceOverwrite = false ) + { + KeyValuePair lim = Utils.inflationPeriod( fixingDate, frequency_ ); + int n = lim.Value - lim.Key + 1; + List dates = new List( n ); + List rates = new List( n ); + + for ( int i = 0; i < n; ++i ) + { + dates.Add( lim.Key + i ); + rates.Add( fixing ); + } + + base.addFixings( dates, rates, forceOverwrite ); + + } + //@} + + //! \name Observer interface + //@{ + public void update() { notifyObservers(); } + //@} + + //! \name Inspectors + //@{ + public string familyName() { return familyName_; } + public Region region() { return region_; } + public bool revised() { return revised_; } + /*! Forecasting index values using an inflation term structure + uses the interpolation of the inflation term structure + unless interpolation is set to false. In this case the + extrapolated values are constant within each period taking + the mid-period extrapolated value. + */ + public bool interpolated() { return interpolated_; } + public Frequency frequency() { return frequency_; } + /*! The availability lag describes when the index is + available, not how it is used. Specifically the + fixing for, say, January, may only be available in April + but the index will always return the index value + applicable for January as its January fixing (independent + of the lag in availability). + */ + public Period availabilityLag() { return availabilityLag_; } + public Currency currency() { return currency_; } + //@} + + protected Date referenceDate_; + protected string familyName_; + protected Region region_; + protected bool revised_; + protected bool interpolated_; + protected Frequency frequency_; + protected Period availabilityLag_; + protected Currency currency_; + + private string name_; + + } + + + //! Base class for zero inflation indices. + public class ZeroInflationIndex : InflationIndex + { + //! Always use the evaluation date as the reference date + public ZeroInflationIndex( string familyName, + Region region, + bool revised, + bool interpolated, + Frequency frequency, + Period availabilityLag, + Currency currency, + Handle ts = null ) + : base( familyName, region, revised, interpolated, + frequency, availabilityLag, currency ) + { + zeroInflation_ = ts ?? new Handle(); + zeroInflation_.registerWith( update ); + } + + /*! \warning the forecastTodaysFixing parameter (required by + the Index interface) is currently ignored. + */ + public override double fixing( Date aFixingDate, bool forecastTodaysFixing = false ) + { + if ( !needsForecast( aFixingDate ) ) + { + KeyValuePair lim = Utils.inflationPeriod( aFixingDate, frequency_ ); + Utils.QL_REQUIRE( IndexManager.instance().getHistory( name() ).value().ContainsKey( lim.Key ), () => + "Missing " + name() + " fixing for " + lim.Key ); + + double pastFixing = IndexManager.instance().getHistory( name() ).value()[lim.Key]; + double theFixing = pastFixing; + if ( interpolated_ ) + { + // fixings stored on first day of every period + if ( aFixingDate == lim.Key ) + { + // we don't actually need the next fixing + theFixing = pastFixing; + } + else + { + Utils.QL_REQUIRE( IndexManager.instance().getHistory( name() ).value().ContainsKey( lim.Value + 1 ), () => + "Missing " + name() + " fixing for " + ( lim.Value + 1 ) ); + double pastFixing2 = IndexManager.instance().getHistory( name() ).value()[lim.Value + 1]; + // now linearly interpolate + double daysInPeriod = lim.Value + 1 - lim.Key; + theFixing = pastFixing + ( pastFixing2 - pastFixing ) * ( aFixingDate - lim.Key ) / daysInPeriod; + } + } + return theFixing; + } + else + { + return forecastFixing( aFixingDate ); + } + } + + // Other methods + public Handle zeroInflationTermStructure() { return zeroInflation_; } + public ZeroInflationIndex clone( Handle h ) + { + + return new ZeroInflationIndex( familyName_, region_, revised_, + interpolated_, frequency_, + availabilityLag_, currency_, h ); + } + + private bool needsForecast( Date fixingDate ) + { + // Stored fixings are always non-interpolated. + // If an interpolated fixing is required then + // the availability lag + one inflation period + // must have passed to use historical fixings + // (because you need the next one to interpolate). + // The interpolation is calculated (linearly) on demand. + + Date today = Settings.evaluationDate(); + Date todayMinusLag = today - availabilityLag_; + + Date historicalFixingKnown = Utils.inflationPeriod( todayMinusLag, frequency_ ).Key - 1; + Date latestNeededDate = fixingDate; + + if ( interpolated_ ) + { // might need the next one too + KeyValuePair p = Utils.inflationPeriod( fixingDate, frequency_ ); + if ( fixingDate > p.Key ) + latestNeededDate = latestNeededDate + new Period( frequency_ ); + } + + if ( latestNeededDate <= historicalFixingKnown ) + { + // the fixing date is well before the availability lag, so + // we know that fixings were provided. + return false; + } + else if ( latestNeededDate > today ) + { + // the fixing can't be available, no matter what's in the + // time series + return true; + } + else + { + // we're not sure, but the fixing might be there so we + // check. Todo: check which fixings are not possible, to + // avoid using fixings in the future + return IndexManager.instance().getHistory( name() ).value().ContainsKey( latestNeededDate ); + } + } + private double forecastFixing( Date fixingDate ) + { + // the term structure is relative to the fixing value at the base date. + Date baseDate = zeroInflation_.link.baseDate(); + Utils.QL_REQUIRE( !needsForecast( baseDate ), () => name() + " index fixing at base date is not available" ); + double baseFixing = fixing( baseDate, false ); + Date effectiveFixingDate; + if ( interpolated() ) + { + effectiveFixingDate = fixingDate; + } + else + { + // start of period is the convention + // so it's easier to do linear interpolation on fixings + effectiveFixingDate = Utils.inflationPeriod( fixingDate, frequency() ).Key; + } + + // no observation lag because it is the fixing for the date + // but if index is not interpolated then that fixing is constant + // for each period, hence the t uses the effectiveFixingDate + // However, it's slightly safe to get the zeroRate with the + // fixingDate to avoid potential problems at the edges of periods + double t = zeroInflation_.link.dayCounter().yearFraction( baseDate, effectiveFixingDate ); + bool forceLinearInterpolation = false; + double zero = zeroInflation_.link.zeroRate( fixingDate, new Period( 0, TimeUnit.Days ), forceLinearInterpolation ); + // Annual compounding is the convention for zero inflation rates (or quotes) + return baseFixing * Math.Pow( 1.0 + zero, t ); + } + private Handle zeroInflation_; + + } + + //! Base class for year-on-year inflation indices. + /*! These may be genuine indices published on, say, Bloomberg, or + "fake" indices that are defined as the ratio of an index at + different time points. + */ + public class YoYInflationIndex : InflationIndex + { + public YoYInflationIndex( string familyName, + Region region, + bool revised, + bool interpolated, + bool ratio, // is this one a genuine index or a ratio? + Frequency frequency, + Period availabilityLag, + Currency currency, + Handle yoyInflation = null ) + : base( familyName, region, revised, interpolated, frequency, availabilityLag, currency ) + { + ratio_ = ratio; + yoyInflation_ = yoyInflation ?? new Handle(); + yoyInflation_.registerWith( update ); + } + + // Index interface + // The forecastTodaysFixing parameter (required by the Index interface) is currently ignored. + public override double fixing( Date fixingDate, bool forecastTodaysFixing = false ) + { + Date today = Settings.evaluationDate(); + Date todayMinusLag = today - availabilityLag_; + KeyValuePair limm = Utils.inflationPeriod( todayMinusLag, frequency_ ); + Date lastFix = limm.Key - 1; + + Date flatMustForecastOn = lastFix + 1; + Date interpMustForecastOn = lastFix + 1 - new Period( frequency_ ); + + + if ( interpolated() && fixingDate >= interpMustForecastOn ) + { + return forecastFixing( fixingDate ); + } + + if ( !interpolated() && fixingDate >= flatMustForecastOn ) + { + return forecastFixing( fixingDate ); + } + + // four cases with ratio() and interpolated() + if ( ratio() ) + { + if ( interpolated() ) + { + // IS ratio, IS interpolated + KeyValuePair lim = Utils.inflationPeriod( fixingDate, frequency_ ); + Date fixMinus1Y = new NullCalendar().advance( fixingDate, new Period( -1, TimeUnit.Years ), BusinessDayConvention.ModifiedFollowing ); + KeyValuePair limBef = Utils.inflationPeriod( fixMinus1Y, frequency_ ); + double dp = lim.Value + 1 - lim.Key; + double dpBef = limBef.Value + 1 - limBef.Key; + double dl = fixingDate - lim.Key; + // potentially does not work on 29th Feb + double dlBef = fixMinus1Y - limBef.Key; + // get the four relevant fixings + // recall that they are stored flat for every day + double? limFirstFix = + IndexManager.instance().getHistory( name() ).value()[lim.Key]; + if ( limFirstFix == null ) + throw new Exception( "Missing " + name() + " fixing for " + + lim.Key ); + double? limSecondFix = + IndexManager.instance().getHistory( name() ).value()[lim.Value + 1]; + if ( limSecondFix == null ) + throw new Exception( "Missing " + name() + " fixing for " + + lim.Value + 1 ); + double? limBefFirstFix = + IndexManager.instance().getHistory( name() ).value()[limBef.Key]; + if ( limBefFirstFix == null ) + throw new Exception( "Missing " + name() + " fixing for " + + limBef.Key ); + double? limBefSecondFix = + IndexManager.instance().getHistory( name() ).value()[limBef.Value + 1]; + if ( limBefSecondFix == null ) + throw new Exception( "Missing " + name() + " fixing for " + + limBef.Value + 1 ); + + double linearNow = limFirstFix.Value + ( limSecondFix.Value - limFirstFix.Value ) * dl / dp; + double linearBef = limBefFirstFix.Value + ( limBefSecondFix.Value - limBefFirstFix.Value ) * dlBef / dpBef; + double wasYES = linearNow / linearBef - 1.0; + + return wasYES; + + } + else + { + // IS ratio, NOT interpolated + double? pastFixing = + IndexManager.instance().getHistory( name() ).value()[fixingDate]; + if ( pastFixing == null ) + throw new Exception( "Missing " + name() + " fixing for " + + fixingDate ); + Date previousDate = fixingDate - new Period( 1, TimeUnit.Years ); + double? previousFixing = + IndexManager.instance().getHistory( name() ).value()[previousDate]; + if ( previousFixing == null ) + throw new Exception( "Missing " + name() + " fixing for " + + previousDate ); + + return pastFixing.Value / previousFixing.Value - 1.0; + } + } + else + { + // NOT ratio + if ( interpolated() ) + { + // NOT ratio, IS interpolated + KeyValuePair lim = Utils.inflationPeriod( fixingDate, frequency_ ); + double dp = lim.Value + 1 - lim.Key; + double dl = fixingDate - lim.Key; + double? limFirstFix = + IndexManager.instance().getHistory( name() ).value()[lim.Key]; + if ( limFirstFix == null ) + throw new Exception( "Missing " + name() + " fixing for " + + lim.Key ); + double? limSecondFix = + IndexManager.instance().getHistory( name() ).value()[lim.Value + 1]; + if ( limSecondFix == null ) + throw new Exception( "Missing " + name() + " fixing for " + + lim.Value + 1 ); + double linearNow = limFirstFix.Value + ( limSecondFix.Value - limFirstFix.Value ) * dl / dp; + + return linearNow; + + } + else + { + // NOT ratio, NOT interpolated + // so just flat + double? pastFixing = + IndexManager.instance().getHistory( name() ).value()[fixingDate]; + if ( pastFixing == null ) + throw new Exception( "Missing " + name() + " fixing for " + + fixingDate ); + return pastFixing.Value; + + } + } + + // QL_FAIL("YoYInflationIndex::fixing, should never get here"); + + } + + // Other methods + public bool ratio() { return ratio_; } + public Handle yoyInflationTermStructure() { return yoyInflation_; } + public YoYInflationIndex clone( Handle h ) + { + return new YoYInflationIndex( familyName_, region_, revised_, + interpolated_, ratio_, frequency_, + availabilityLag_, currency_, h ); + } + + + private double forecastFixing( Date fixingDate ) + { + Date d; + if ( interpolated() ) + { + d = fixingDate; + } + else + { + // if the value is not interpolated use the starting value + // by internal convention this will be consistent + KeyValuePair lim = Utils.inflationPeriod( fixingDate, frequency_ ); + d = lim.Key; + } + return yoyInflation_.link.yoyRate( d, new Period( 0, TimeUnit.Days ) ); + } + private bool ratio_; + private Handle yoyInflation_; + } +} diff --git a/QLNet/Indexes/InterestRateIndex.cs b/QLNet/Indexes/InterestRateIndex.cs index 933f6b553..470c63b3b 100644 --- a/QLNet/Indexes/InterestRateIndex.cs +++ b/QLNet/Indexes/InterestRateIndex.cs @@ -1,6 +1,7 @@ /* Copyright (C) 2008 Siarhei Novik (snovik@gmail.com) Copyright (C) 2008 Toyin Akin (toyin_akin@hotmail.com) + Copyright (C) 2008-2016 Andrea Maggiulli (a.maggiulli@gmail.com) This file is part of QLNet Project https://github.com/amaggiulli/qlnet @@ -16,125 +17,144 @@ under the terms of the QLNet license. You should have received a This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the license for more details. -*/ -using System; - -namespace QLNet { - //! base class for interest rate indexes - /*! \todo add methods returning InterestRate */ - public abstract class InterestRateIndex : Index, IObserver { - - #region properties - protected string familyName_; - public string familyName() { return familyName_; } - - protected Period tenor_; - public Period tenor() { return tenor_; } - - protected int fixingDays_; - public int fixingDays() { return fixingDays_; } - - protected Calendar fixingCalendar_; - - protected Currency currency_; - public Currency currency() { return currency_; } - - protected DayCounter dayCounter_; - public DayCounter dayCounter() { return dayCounter_; } - #endregion - - // need by CashFlowVectors - public InterestRateIndex() { } - - public InterestRateIndex(string familyName, Period tenor, int fixingDays, Currency currency, - Calendar fixingCalendar, DayCounter dayCounter) { - familyName_ = familyName; - tenor_ = tenor; - fixingDays_ = fixingDays; - currency_ = currency; - fixingCalendar_ = fixingCalendar; - dayCounter_ = dayCounter; - - tenor_.normalize(); - - Settings.registerWith(update); - // recheck - IndexManager.instance().notifier(name()).registerWith(update); - } - - public void update() { notifyObservers(); } - - #region Index interface - public override string name() { - string res = familyName_; - if (tenor_ == new Period(1, TimeUnit.Days)) { - if (fixingDays_ == 0) - res += "ON"; - else if (fixingDays_ == 1) - res += "TN"; - else if (fixingDays_ == 2) - res += "SN"; - else - res += tenor_.ToShortString(); - } else - res += tenor_.ToShortString(); - res = res + " " + dayCounter_.name(); - return res; - } - - public override Calendar fixingCalendar() { return fixingCalendar_; } - public override bool isValidFixingDate(Date fixingDate) { return fixingCalendar_.isBusinessDay(fixingDate); } - - public override double fixing(Date fixingDate, bool forecastTodaysFixing) { - if (!isValidFixingDate(fixingDate)) - throw new ArgumentException("Fixing date " + fixingDate + " is not valid"); - - TimeSeries fixings = IndexManager.instance().getHistory(name()).value(); - if (fixings.ContainsKey(fixingDate)) { - return fixings[fixingDate]; - } else { - Date today = Settings.evaluationDate(); - if (fixingDate < today - || (fixingDate == today && !forecastTodaysFixing && Settings.enforcesTodaysHistoricFixings)) { - // must have been fixed - if (IndexManager.MissingPastFixingCallBack == null) { - throw new ArgumentException("Missing " + name() + " fixing for " + fixingDate); - } else { - // try to load missing fixing from external source - double fixing = IndexManager.MissingPastFixingCallBack(this, fixingDate); - // add to history - addFixing(fixingDate, fixing); - return fixing; - } - } - if ((fixingDate == today) && !forecastTodaysFixing) { - // might have been fixed but forecast since it does not exist - // so fall through and forecast - } - // forecast - return forecastFixing(fixingDate); - } - } - #endregion - - /*! \name Date calculations - These methods can be overridden to implement particular conventions (e.g. EurLibor) */ - public virtual Date valueDate(Date fixingDate) { - if (!isValidFixingDate(fixingDate)) - throw new ArgumentException("fixing date " + fixingDate + " is not valid"); - return fixingCalendar().advance(fixingDate, fixingDays_, TimeUnit.Days); - } - public abstract Date maturityDate(Date valueDate); - - public Date fixingDate(Date valueDate) { - Date fixingDate = fixingCalendar().advance(valueDate, -fixingDays_, TimeUnit.Days); - if (!isValidFixingDate(fixingDate)) - throw new ArgumentException("fixing date " + fixingDate + " is not valid"); - return fixingDate; - } - - // ////////////////////////////////////////////////////////// - protected abstract double forecastFixing(Date fixingDate); - //public abstract Handle termStructure(); - } +*/ +using System; + +namespace QLNet +{ + //! base class for interest rate indexes + /*! \todo add methods returning InterestRate */ + public abstract class InterestRateIndex : Index, IObserver + { + protected InterestRateIndex( string familyName, + Period tenor, + int fixingDays, + Currency currency, + Calendar fixingCalendar, + DayCounter dayCounter ) + { + familyName_ = familyName; + tenor_ = tenor; + fixingDays_ = fixingDays; + currency_ = currency; + dayCounter_ = dayCounter; + fixingCalendar_ = fixingCalendar; + + + tenor_.normalize(); + + string res = familyName_; + if ( tenor_ == new Period( 1, TimeUnit.Days ) ) + { + if ( fixingDays_ == 0 ) + res += "ON"; + else if ( fixingDays_ == 1 ) + res += "TN"; + else if ( fixingDays_ == 2 ) + res += "SN"; + else + res += tenor_.ToShortString(); + } + else + res += tenor_.ToShortString(); + res = res + " " + dayCounter_.name(); + name_= res; + + Settings.registerWith( update ); + // recheck + IndexManager.instance().notifier( name() ).registerWith( update ); + } + + // Index interface + public override string name() + { + return name_; + } + public override Calendar fixingCalendar() { return fixingCalendar_; } + public override bool isValidFixingDate( Date fixingDate ) { return fixingCalendar().isBusinessDay( fixingDate ); } + public override double fixing( Date fixingDate, bool forecastTodaysFixing = false ) + { + Utils.QL_REQUIRE( isValidFixingDate( fixingDate ),()=> "Fixing date " + fixingDate + " is not valid" ); + + Date today = Settings.evaluationDate(); + + if ( fixingDate > today || + ( fixingDate == today && forecastTodaysFixing ) ) + return forecastFixing( fixingDate ); + + if (fixingDate < today || Settings.enforcesTodaysHistoricFixings) + { + // must have been fixed + // do not catch exceptions + double? result = pastFixing(fixingDate); + Utils.QL_REQUIRE(result != null, () => "Missing " + name() + " fixing for " + fixingDate); + return result.Value; + } + + try + { + // might have been fixed + double? result = pastFixing(fixingDate); + if (result!=null) + return result.Value; + + } + catch (Exception) + { + + } + return forecastFixing(fixingDate); + } + + // Observer interface + public void update() { notifyObservers(); } + + // Inspectors + public string familyName() { return familyName_; } + public Period tenor() { return tenor_; } + public int fixingDays() { return fixingDays_; } + public Date fixingDate( Date valueDate ) + { + Date fixingDate = fixingCalendar().advance( valueDate, -fixingDays_, TimeUnit.Days ); + return fixingDate; + } + public Currency currency() { return currency_; } + public DayCounter dayCounter() { return dayCounter_; } + + // Date calculations + // These methods can be overridden to implement particular conventions (e.g. EurLibor) */ + public virtual Date valueDate( Date fixingDate ) + { + Utils.QL_REQUIRE( isValidFixingDate( fixingDate ),()=> fixingDate + " is not a valid fixing date" ); + return fixingCalendar().advance( fixingDate, fixingDays_, TimeUnit.Days ); + } + public abstract Date maturityDate( Date valueDate ); + + // Fixing calculations + //! It can be overridden to implement particular conventions + public abstract double forecastFixing( Date fixingDate ); + public virtual double? pastFixing(Date fixingDate) + { + Utils.QL_REQUIRE( isValidFixingDate( fixingDate ),()=> fixingDate + " is not a valid fixing date" ); + if (timeSeries().value().ContainsKey(fixingDate)) + return timeSeries().value()[fixingDate]; + else + return null; + } + + + protected string familyName_; + protected Period tenor_; + protected int fixingDays_; + protected Currency currency_; + protected DayCounter dayCounter_; + protected string name_; + + private Calendar fixingCalendar_; + + + // need by CashFlowVectors + public InterestRateIndex() { } + } + } diff --git a/QLNet/Indexes/Swapindex.cs b/QLNet/Indexes/Swapindex.cs index 00f381bd3..ba019902f 100644 --- a/QLNet/Indexes/Swapindex.cs +++ b/QLNet/Indexes/Swapindex.cs @@ -1,7 +1,8 @@ /* Copyright (C) 2008 Siarhei Novik (snovik@gmail.com) Copyright (C) 2008 Toyin Akin (toyin_akin@hotmail.com) - * + Copyright (C) 2008-2016 Andrea Maggiulli (a.maggiulli@gmail.com) + This file is part of QLNet Project https://github.com/amaggiulli/qlnet QLNet is free software: you can redistribute it and/or modify it @@ -16,207 +17,226 @@ under the terms of the QLNet license. You should have received a This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the license for more details. -*/ - -namespace QLNet -{ - - public class SwapIndex : InterestRateIndex - { - // need by CashFlowVectors - public SwapIndex() { } - - - public SwapIndex(string familyName, Period tenor, int settlementDays, Currency currency, - Calendar calendar, Period fixedLegTenor, BusinessDayConvention fixedLegConvention, - DayCounter fixedLegDayCounter, IborIndex iborIndex) : - base(familyName, tenor, settlementDays, currency, calendar, fixedLegDayCounter) - { - tenor_ = tenor; - iborIndex_ = iborIndex; - fixedLegTenor_ = fixedLegTenor; - fixedLegConvention_ = fixedLegConvention; - exogenousDiscount_ = false; - discount_ = new Handle(); - - iborIndex_.registerWith(update); - } - - public SwapIndex(string familyName, - Period tenor, - int settlementDays, - Currency currency, - Calendar calendar, - Period fixedLegTenor, - BusinessDayConvention fixedLegConvention, - DayCounter fixedLegDayCounter, - IborIndex iborIndex, - Handle discountingTermStructure) - { - tenor_ = tenor; - iborIndex_ = iborIndex; - fixedLegTenor_ = fixedLegTenor; - fixedLegConvention_ = fixedLegConvention; - exogenousDiscount_ = true; - discount_ = discountingTermStructure; - - iborIndex_.registerWith(update); - } - - //! \name InterestRateIndex interface - //@{ - public override Date maturityDate(Date valueDate) - { - Date fixDate = fixingDate(valueDate); - return underlyingSwap(fixDate).maturityDate(); - } - //@} - //! \name Inspectors - //@{ - public Period fixedLegTenor() { return fixedLegTenor_; } - public BusinessDayConvention fixedLegConvention() { return fixedLegConvention_; } - public IborIndex iborIndex() { return iborIndex_; } - public Handle forwardingTermStructure() { return iborIndex_.forwardingTermStructure();} - public Handle discountingTermStructure() { return discount_; } - public bool exogenousDiscount() { return exogenousDiscount_; } - // \warning Relinking the term structure underlying the index will not have effect on the returned swap. - // recheck - public VanillaSwap underlyingSwap(Date fixingDate) - { - double fixedRate = 0.0; - if (exogenousDiscount_) - return new MakeVanillaSwap(tenor_, iborIndex_, fixedRate) - .withEffectiveDate(valueDate(fixingDate)) - .withFixedLegCalendar(fixingCalendar()) - .withFixedLegDayCount(dayCounter_) - .withFixedLegTenor(fixedLegTenor_) - .withFixedLegConvention(fixedLegConvention_) - .withFixedLegTerminationDateConvention(fixedLegConvention_) - .withDiscountingTermStructure(discount_) - .value(); - else - return new MakeVanillaSwap(tenor_, iborIndex_, fixedRate) - .withEffectiveDate(valueDate(fixingDate)) - .withFixedLegCalendar(fixingCalendar()) - .withFixedLegDayCount(dayCounter_) - .withFixedLegTenor(fixedLegTenor_) - .withFixedLegConvention(fixedLegConvention_) - .withFixedLegTerminationDateConvention(fixedLegConvention_) - .value(); - - } - //@} - //! \name Other methods - //@{ - //! returns a copy of itself linked to a different forwarding curve - public virtual SwapIndex clone(Handle forwarding) - { - if (exogenousDiscount_) - return new SwapIndex(familyName(), - tenor(), - fixingDays(), - currency(), - fixingCalendar(), - fixedLegTenor(), - fixedLegConvention(), - dayCounter(), - iborIndex_.clone(forwarding), - discount_); - else - return new SwapIndex(familyName(), - tenor(), - fixingDays(), - currency(), - fixingCalendar(), - fixedLegTenor(), - fixedLegConvention(), - dayCounter(), - iborIndex_.clone(forwarding)); - } - //! returns a copy of itself linked to a different curves - public virtual SwapIndex clone( Handle forwarding, Handle discounting ) - { - return new SwapIndex( familyName(), - tenor(), - fixingDays(), - currency(), - fixingCalendar(), - fixedLegTenor(), - fixedLegConvention(), - dayCounter(), - iborIndex_.clone( forwarding ), - discounting ); - } - //! returns a copy of itself linked to a different tenor - public virtual SwapIndex clone( Period tenor ) - { - if ( exogenousDiscount_ ) - return new SwapIndex( familyName(), - tenor, - fixingDays(), - currency(), - fixingCalendar(), - fixedLegTenor(), - fixedLegConvention(), - dayCounter(), - iborIndex(), - discountingTermStructure() ); - else - return new SwapIndex( familyName(), - tenor, - fixingDays(), - currency(), - fixingCalendar(), - fixedLegTenor(), - fixedLegConvention(), - dayCounter(), - iborIndex() ); - } - // @} - protected override double forecastFixing(Date fixingDate) - { - return underlyingSwap(fixingDate).fairRate(); - } - protected new Period tenor_; - protected IborIndex iborIndex_; - protected Period fixedLegTenor_; - BusinessDayConvention fixedLegConvention_; - bool exogenousDiscount_; - Handle discount_; - } - - //! base class for overnight indexed swap indexes - public class OvernightIndexedSwapIndex : SwapIndex - { - public OvernightIndexedSwapIndex( - string familyName, - Period tenor, - int settlementDays, - Currency currency, - OvernightIndex overnightIndex) - :base(familyName, tenor, settlementDays, - currency, overnightIndex.fixingCalendar(), - new Period(1,TimeUnit.Years),BusinessDayConvention.ModifiedFollowing, - overnightIndex.dayCounter(),overnightIndex) - { - overnightIndex_ = overnightIndex; - } - //! \name Inspectors - //@{ - public OvernightIndex overnightIndex() { return overnightIndex_;} +*/ + +namespace QLNet +{ + //! base class for swap-rate indexes + public class SwapIndex : InterestRateIndex + { + // need by CashFlowVectors + public SwapIndex() { } + + + public SwapIndex( string familyName, + Period tenor, + int settlementDays, + Currency currency, + Calendar calendar, + Period fixedLegTenor, + BusinessDayConvention fixedLegConvention, + DayCounter fixedLegDayCounter, + IborIndex iborIndex ) : + base( familyName, tenor, settlementDays, currency, calendar, fixedLegDayCounter ) + { + tenor_ = tenor; + iborIndex_ = iborIndex; + fixedLegTenor_ = fixedLegTenor; + fixedLegConvention_ = fixedLegConvention; + exogenousDiscount_ = false; + discount_ = new Handle(); + + iborIndex_.registerWith( update ); + } + + public SwapIndex( string familyName, + Period tenor, + int settlementDays, + Currency currency, + Calendar calendar, + Period fixedLegTenor, + BusinessDayConvention fixedLegConvention, + DayCounter fixedLegDayCounter, + IborIndex iborIndex, + Handle discountingTermStructure ) + { + tenor_ = tenor; + iborIndex_ = iborIndex; + fixedLegTenor_ = fixedLegTenor; + fixedLegConvention_ = fixedLegConvention; + exogenousDiscount_ = true; + discount_ = discountingTermStructure; + + iborIndex_.registerWith( update ); + } + + // InterestRateIndex interface + public override Date maturityDate( Date valueDate ) + { + Date fixDate = fixingDate( valueDate ); + return underlyingSwap( fixDate ).maturityDate(); + } + // Inspectors + public Period fixedLegTenor() { return fixedLegTenor_; } + public BusinessDayConvention fixedLegConvention() { return fixedLegConvention_; } + public IborIndex iborIndex() { return iborIndex_; } + public Handle forwardingTermStructure() { return iborIndex_.forwardingTermStructure(); } + public Handle discountingTermStructure() { return discount_; } + public bool exogenousDiscount() { return exogenousDiscount_; } + // \warning Relinking the term structure underlying the index will not have effect on the returned swap. + // recheck + public VanillaSwap underlyingSwap( Date fixingDate ) + { + Utils.QL_REQUIRE( fixingDate != null,()=> "null fixing date" ); + // caching mechanism + if ( lastFixingDate_ != fixingDate ) + { + double fixedRate = 0.0; + if ( exogenousDiscount_ ) + lastSwap_ = new MakeVanillaSwap( tenor_, iborIndex_, fixedRate ) + .withEffectiveDate( valueDate( fixingDate ) ) + .withFixedLegCalendar( fixingCalendar() ) + .withFixedLegDayCount( dayCounter_ ) + .withFixedLegTenor( fixedLegTenor_ ) + .withFixedLegConvention( fixedLegConvention_ ) + .withFixedLegTerminationDateConvention( fixedLegConvention_ ) + .withDiscountingTermStructure( discount_ ) + .value(); + else + lastSwap_ = new MakeVanillaSwap( tenor_, iborIndex_, fixedRate ) + .withEffectiveDate( valueDate( fixingDate ) ) + .withFixedLegCalendar( fixingCalendar() ) + .withFixedLegDayCount( dayCounter_ ) + .withFixedLegTenor( fixedLegTenor_ ) + .withFixedLegConvention( fixedLegConvention_ ) + .withFixedLegTerminationDateConvention( fixedLegConvention_ ) + .value(); + lastFixingDate_ = fixingDate; + } + return lastSwap_; + } + // Other methods + // returns a copy of itself linked to a different forwarding curve + public virtual SwapIndex clone( Handle forwarding ) + { + if ( exogenousDiscount_ ) + return new SwapIndex( familyName(), + tenor(), + fixingDays(), + currency(), + fixingCalendar(), + fixedLegTenor(), + fixedLegConvention(), + dayCounter(), + iborIndex_.clone( forwarding ), + discount_ ); + else + return new SwapIndex( familyName(), + tenor(), + fixingDays(), + currency(), + fixingCalendar(), + fixedLegTenor(), + fixedLegConvention(), + dayCounter(), + iborIndex_.clone( forwarding ) ); + } + //! returns a copy of itself linked to a different curves + public virtual SwapIndex clone( Handle forwarding, Handle discounting ) + { + return new SwapIndex( familyName(), + tenor(), + fixingDays(), + currency(), + fixingCalendar(), + fixedLegTenor(), + fixedLegConvention(), + dayCounter(), + iborIndex_.clone( forwarding ), + discounting ); + } + //! returns a copy of itself linked to a different tenor + public virtual SwapIndex clone( Period tenor ) + { + if ( exogenousDiscount_ ) + return new SwapIndex( familyName(), + tenor, + fixingDays(), + currency(), + fixingCalendar(), + fixedLegTenor(), + fixedLegConvention(), + dayCounter(), + iborIndex(), + discountingTermStructure() ); + else + return new SwapIndex( familyName(), + tenor, + fixingDays(), + currency(), + fixingCalendar(), + fixedLegTenor(), + fixedLegConvention(), + dayCounter(), + iborIndex() ); + } + public override double forecastFixing( Date fixingDate ) + { + return underlyingSwap( fixingDate ).fairRate(); + } + + protected new Period tenor_; + protected IborIndex iborIndex_; + protected Period fixedLegTenor_; + protected BusinessDayConvention fixedLegConvention_; + protected bool exogenousDiscount_; + protected Handle discount_; + // cache data to avoid swap recreation when the same fixing date + // is used multiple time to forecast changing fixing + protected VanillaSwap lastSwap_; + protected Date lastFixingDate_; + } + + //! base class for overnight indexed swap indexes + public class OvernightIndexedSwapIndex : SwapIndex + { + public OvernightIndexedSwapIndex( string familyName, + Period tenor, + int settlementDays, + Currency currency, + OvernightIndex overnightIndex ) + : base( familyName, tenor, settlementDays, + currency, overnightIndex.fixingCalendar(), + new Period( 1, TimeUnit.Years ), BusinessDayConvention.ModifiedFollowing, + overnightIndex.dayCounter(), overnightIndex ) + { + overnightIndex_ = overnightIndex; + } + // Inspectors + public OvernightIndex overnightIndex() { return overnightIndex_; } /*! \warning Relinking the term structure underlying the index will not have effect on the returned swap. - */ - public new OvernightIndexedSwap underlyingSwap(Date fixingDate) - { - double fixedRate = 0.0; - return new MakeOIS(tenor_, overnightIndex_, fixedRate) - .withEffectiveDate(valueDate(fixingDate)) - .withFixedLegDayCount(dayCounter_); - } - //@} - protected OvernightIndex overnightIndex_; - }; - - + */ + public new OvernightIndexedSwap underlyingSwap( Date fixingDate ) + { + Utils.QL_REQUIRE( fixingDate != null,()=> "null fixing date" ); + if ( lastFixingDate_ != fixingDate ) + { + double fixedRate = 0.0; + lastSwap_ = new MakeOIS( tenor_, overnightIndex_, fixedRate ) + .withEffectiveDate( valueDate( fixingDate ) ) + .withFixedLegDayCount( dayCounter_ ); + lastFixingDate_ = fixingDate; + } + return lastSwap_; + } + + protected OvernightIndex overnightIndex_; + // cache data to avoid swap recreation when the same fixing date + // is used multiple time to forecast changing fixing + protected new OvernightIndexedSwap lastSwap_; + protected new Date lastFixingDate_; + }; + + } diff --git a/QLNet/Indexes/bmaindex.cs b/QLNet/Indexes/bmaindex.cs index bd30cfb89..f2490a7ef 100644 --- a/QLNet/Indexes/bmaindex.cs +++ b/QLNet/Indexes/bmaindex.cs @@ -1,6 +1,6 @@ /* Copyright (C) 2008 Siarhei Novik (snovik@gmail.com) - Copyright (C) 2008, 2009 , 2010 Andrea Maggiulli (a.maggiulli@gmail.com) + Copyright (C) 2008-2016 Andrea Maggiulli (a.maggiulli@gmail.com) This file is part of QLNet Project https://github.com/amaggiulli/qlnet @@ -16,83 +16,92 @@ under the terms of the QLNet license. You should have received a This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the license for more details. -*/ -using System; - -namespace QLNet { - //! Bond Market Association index - /*! The BMA index is the short-term tax-exempt reference index of - the Bond Market Association. It has tenor one week, is fixed - weekly on Wednesdays and is applied with a one-day's fixing - gap from Thursdays on for one week. It is the tax-exempt - correspondent of the 1M USD-Libor. - */ - public class BMAIndex : InterestRateIndex { - protected Handle termStructure_; - public Handle forwardingTermStructure() { return termStructure_; } - - public BMAIndex() : this(new Handle()) { } - public BMAIndex(Handle h) - : base("BMA", new Period(1, TimeUnit.Weeks), 1, new USDCurrency(), - new UnitedStates(UnitedStates.Market.NYSE), new ActualActual(ActualActual.Convention.ISDA)) { - termStructure_ = h; - h.registerWith(update); - } - - //! \name Index interface - public override string name() { return "BMA"; } - - public override bool isValidFixingDate(Date fixingDate) { - // either the fixing date is last Wednesday, or all days - // between last Wednesday included and the fixing date are - // holidays - for (Date d = Utils.previousWednesday(fixingDate); d < fixingDate; ++d) { - if (fixingCalendar_.isBusinessDay(d)) - return false; - } - // also, the fixing date itself must be a business day - return fixingCalendar_.isBusinessDay(fixingDate); - } - - //! \name InterestRateIndex interface - public override Date maturityDate(Date valueDate) { - Date fixingDate = fixingCalendar_.advance(valueDate, -1, TimeUnit.Days); - Date nextWednesday = Utils.previousWednesday(fixingDate + 7); - return fixingCalendar_.advance(nextWednesday,1,TimeUnit.Days); - } - - //! \name Date calculations - /*! This method returns a schedule of fixing dates between start and end. */ - public Schedule fixingSchedule(Date start, Date end) { - return new MakeSchedule().from(Utils.previousWednesday(start)) - .to(Utils.nextWednesday(end)) - .withFrequency(Frequency.Weekly) - .withCalendar(fixingCalendar_) - .withConvention(BusinessDayConvention.Following) - .forwards() - .value(); - } - - protected override double forecastFixing(Date fixingDate) { - if (termStructure_.empty()) - throw new ApplicationException("null term structure set to this instance of " + name()); - Date start = fixingCalendar_.advance(fixingDate,1,TimeUnit.Days); - Date end = maturityDate(start); - return termStructure_.link.forwardRate(start, end, dayCounter_, Compounding.Simple).rate(); - } - } - - public partial class Utils { - public static Date previousWednesday(Date date) { - int w = date.weekday(); - if (w >= 4) // roll back w-4 days - return date - new Period((w - 4), TimeUnit.Days); - else // roll forward 4-w days and back one week - return date + new Period((4 - w - 7), TimeUnit.Days); - } - - public static Date nextWednesday(Date date) { - return previousWednesday(date+7); - } - } +*/ +using System; + +namespace QLNet +{ + //! Bond Market Association index + /*! The BMA index is the short-term tax-exempt reference index of + the Bond Market Association. It has tenor one week, is fixed + weekly on Wednesdays and is applied with a one-day's fixing + gap from Thursdays on for one week. It is the tax-exempt + correspondent of the 1M USD-Libor. + */ + public class BMAIndex : InterestRateIndex + { + public BMAIndex( Handle h = null) + : base( "BMA", new Period( 1, TimeUnit.Weeks ), 1, new USDCurrency(), + new UnitedStates( UnitedStates.Market.NYSE ), new ActualActual( ActualActual.Convention.ISDA ) ) + { + termStructure_ = h ?? new Handle(); + termStructure_.registerWith( update ); + } + + // Index interface + // BMA is fixed weekly on Wednesdays. + public override string name() { return "BMA"; } + public override bool isValidFixingDate( Date fixingDate ) + { + Calendar cal = fixingCalendar(); + // either the fixing date is last Wednesday, or all days + // between last Wednesday included and the fixing date are + // holidays + for ( Date d = Utils.previousWednesday( fixingDate ); d < fixingDate; ++d ) + { + if ( cal.isBusinessDay( d ) ) + return false; + } + // also, the fixing date itself must be a business day + return cal.isBusinessDay( fixingDate ); + } + // Inspectors + public Handle forwardingTermStructure() { return termStructure_; } + // Date calculations + public override Date maturityDate( Date valueDate ) + { + Calendar cal = fixingCalendar(); + Date fixingDate = cal.advance( valueDate, -1, TimeUnit.Days ); + Date nextWednesday = Utils.previousWednesday( fixingDate + 7 ); + return cal.advance( nextWednesday, 1, TimeUnit.Days ); + } + // This method returns a schedule of fixing dates between start and end. + public Schedule fixingSchedule( Date start, Date end ) + { + return new MakeSchedule().from( Utils.previousWednesday( start ) ) + .to( Utils.nextWednesday( end ) ) + .withFrequency( Frequency.Weekly ) + .withCalendar( fixingCalendar() ) + .withConvention( BusinessDayConvention.Following ) + .forwards() + .value(); + } + + public override double forecastFixing( Date fixingDate ) + { + Utils.QL_REQUIRE( !termStructure_.empty(),()=> "null term structure set to this instance of " + name() ); + Date start = fixingCalendar().advance( fixingDate, 1, TimeUnit.Days ); + Date end = maturityDate( start ); + return termStructure_.link.forwardRate( start, end, dayCounter_, Compounding.Simple ).rate(); + } + + protected Handle termStructure_; + } + + public partial class Utils + { + public static Date previousWednesday( Date date ) + { + int w = date.weekday(); + if ( w >= 4 ) // roll back w-4 days + return date - new Period( ( w - 4 ), TimeUnit.Days ); + else // roll forward 4-w days and back one week + return date + new Period( ( 4 - w - 7 ), TimeUnit.Days ); + } + + public static Date nextWednesday( Date date ) + { + return previousWednesday( date + 7 ); + } + } } diff --git a/QLNet/Instruments/AsianOption.cs b/QLNet/Instruments/AsianOption.cs index 4316857c5..fb3ae3175 100644 --- a/QLNet/Instruments/AsianOption.cs +++ b/QLNet/Instruments/AsianOption.cs @@ -16,7 +16,7 @@ under the terms of the QLNet license. You should have received a This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the license for more details. -*/ +*/ using System; using System.Collections.Generic; @@ -40,7 +40,7 @@ public override void validate() base.validate(); if (averageType == Average.Type.NULL) - throw new ApplicationException("unspecified average type"); + throw new Exception("unspecified average type"); } public Average.Type averageType; } @@ -60,7 +60,7 @@ public override void setupArguments(IPricingEngineArguments args) ContinuousAveragingAsianOption.Arguments moreArgs = args as ContinuousAveragingAsianOption.Arguments; if (!(moreArgs != null)) - throw new ApplicationException("wrong argument type"); + throw new Exception("wrong argument type"); moreArgs.averageType = averageType_; } protected Average.Type averageType_; @@ -83,26 +83,26 @@ public override void validate() base.validate(); if (averageType == Average.Type.NULL) - throw new ApplicationException("unspecified average type"); + throw new Exception("unspecified average type"); if (!(pastFixings != null)) - throw new ApplicationException("null past-fixing number"); + throw new Exception("null past-fixing number"); if (!(runningAccumulator != null)) - throw new ApplicationException("null running product"); + throw new Exception("null running product"); switch (averageType) { case Average.Type.Arithmetic: if (!(runningAccumulator >= 0.0)) - throw new ApplicationException("non negative running sum required: " + runningAccumulator + " not allowed"); + throw new Exception("non negative running sum required: " + runningAccumulator + " not allowed"); break; case Average.Type.Geometric: if (!(runningAccumulator > 0.0)) - throw new ApplicationException("positive running product required: " + runningAccumulator + " not allowed"); + throw new Exception("positive running product required: " + runningAccumulator + " not allowed"); break; default: - throw new ApplicationException("invalid average type"); + throw new Exception("invalid average type"); } // check fixingTimes_ here @@ -136,7 +136,7 @@ public override void setupArguments(IPricingEngineArguments args) DiscreteAveragingAsianOption.Arguments moreArgs = args as DiscreteAveragingAsianOption.Arguments; if (!(moreArgs != null)) - throw new ApplicationException("wrong argument type"); + throw new Exception("wrong argument type"); moreArgs.averageType = averageType_; moreArgs.runningAccumulator = runningAccumulator_; diff --git a/QLNet/Instruments/BarrierOption.cs b/QLNet/Instruments/BarrierOption.cs index 8002e2839..b287be8a0 100644 --- a/QLNet/Instruments/BarrierOption.cs +++ b/QLNet/Instruments/BarrierOption.cs @@ -50,14 +50,14 @@ public override void validate() case Barrier.Type.UpOut: break; default: - throw new ApplicationException("unknown type"); + throw new Exception("unknown type"); } if (!(barrier != null)) - throw new ApplicationException("no barrier given"); + throw new Exception("no barrier given"); if (!(rebate != null)) - throw new ApplicationException("no rebate given"); + throw new Exception("no rebate given"); } } @@ -74,7 +74,7 @@ protected bool triggered(double underlying) case Barrier.Type.UpOut: return underlying > arguments_.barrier; default: - throw new ApplicationException("unknown type"); + throw new Exception("unknown type"); } } } @@ -92,7 +92,7 @@ public override void setupArguments(IPricingEngineArguments args) BarrierOption.Arguments moreArgs = args as BarrierOption.Arguments; if (!(moreArgs != null)) - throw new ApplicationException("wrong argument type"); + throw new Exception("wrong argument type"); moreArgs.barrierType = barrierType_; moreArgs.barrier = barrier_; @@ -101,9 +101,9 @@ public override void setupArguments(IPricingEngineArguments args) // ! \warning see VanillaOption for notes on implied-volatility // calculation. // - public double impliedVolatility( double targetValue, GeneralizedBlackScholesProcess process, double accuracy = 1.0e-4, + public double impliedVolatility( double targetValue, GeneralizedBlackScholesProcess process, double accuracy = 1.0e-4, int maxEvaluations = 100, double minVol = 1.0e-7, double maxVol = 4.0) - { + { Utils.QL_REQUIRE( !isExpired(), ()=> "option expired" ); SimpleQuote volQuote = new SimpleQuote(); @@ -119,9 +119,9 @@ public double impliedVolatility( double targetValue, GeneralizedBlackScholesProc break; case Exercise.Type.American: case Exercise.Type.Bermudan: - throw new ApplicationException("Engine not available for non-European barrier option"); + throw new Exception("Engine not available for non-European barrier option"); default: - throw new ApplicationException("unknown exercise type"); + throw new Exception("unknown exercise type"); } return ImpliedVolatilityHelper.calculate( this, engine, volQuote, targetValue, accuracy, maxEvaluations, minVol, maxVol); diff --git a/QLNet/Instruments/Bonds/AmortizingBond.cs b/QLNet/Instruments/Bonds/AmortizingBond.cs index 589a1ab29..9ad079310 100644 --- a/QLNet/Instruments/Bonds/AmortizingBond.cs +++ b/QLNet/Instruments/Bonds/AmortizingBond.cs @@ -100,19 +100,19 @@ void addEffectiveInterestRateAmortizing() InterestRate rate2 = new InterestRate(_couponRate, _dCounter, Compounding.Simple, Frequency.Annual); FixedRateCoupon r,r2; if (i > 1) - { - r = new FixedRateCoupon(currentNominal, actualDate, rate, prevDate, actualDate, prevDate, actualDate); - r2 = new FixedRateCoupon(currentNominal, actualDate, rate2, prevDate, actualDate, prevDate, actualDate, null,_originalPayment); + { + r = new FixedRateCoupon( actualDate, currentNominal, rate, prevDate, actualDate, prevDate, actualDate ); + r2 = new FixedRateCoupon( actualDate, currentNominal, rate2, prevDate, actualDate, prevDate, actualDate, null, _originalPayment ); } else { Calendar nullCalendar = new NullCalendar(); Period p1 = new Period(_payFrequency); - Date testDate = nullCalendar.advance(actualDate, -1 * p1); - - r = new FixedRateCoupon(currentNominal, actualDate, rate, testDate, actualDate, prevDate, actualDate); - r2 = new FixedRateCoupon(currentNominal, actualDate, rate2, testDate, actualDate, prevDate, actualDate, null,_originalPayment); + Date testDate = nullCalendar.advance(actualDate, -1 * p1); + + r = new FixedRateCoupon( actualDate, currentNominal, rate, testDate, actualDate, prevDate, actualDate ); + r2 = new FixedRateCoupon( actualDate, currentNominal, rate2, testDate, actualDate, prevDate, actualDate, null, _originalPayment ); } double amort = Math.Round(Math.Abs(_originalPayment - r.amount()),2); @@ -160,13 +160,13 @@ public double AmortizationValue(Date d) // lastDate < d let calculate last interest // Base Interest - InterestRate r1 = new InterestRate(_couponRate,_dCounter,Compounding.Simple,_payFrequency); - FixedRateCoupon c1 = new FixedRateCoupon(_faceValue,d,r1,lastDate,d); + InterestRate r1 = new InterestRate(_couponRate,_dCounter,Compounding.Simple,_payFrequency); + FixedRateCoupon c1 = new FixedRateCoupon( d, _faceValue,r1, lastDate, d ); double baseInterest = c1.amount(); // - InterestRate r2 = new InterestRate(_yield,_dCounter,Compounding.Simple,_payFrequency); - FixedRateCoupon c2 = new FixedRateCoupon(_marketValue,d,r2,lastDate,d); + InterestRate r2 = new InterestRate(_yield,_dCounter,Compounding.Simple,_payFrequency); + FixedRateCoupon c2 = new FixedRateCoupon( d, _marketValue,r2, lastDate, d ); double yieldInterest = c2.amount(); totAmortized += Math.Abs(baseInterest - yieldInterest); diff --git a/QLNet/Instruments/Bonds/AmortizingFixedRateBond.cs b/QLNet/Instruments/Bonds/AmortizingFixedRateBond.cs index 2c06702c5..acdd524ed 100644 --- a/QLNet/Instruments/Bonds/AmortizingFixedRateBond.cs +++ b/QLNet/Instruments/Bonds/AmortizingFixedRateBond.cs @@ -53,7 +53,7 @@ public AmortizingFixedRateBond( addRedemptionsToCashflows(); if ( cashflows().empty()) - throw new ApplicationException("bond with no cashflows!"); + throw new Exception("bond with no cashflows!"); } public AmortizingFixedRateBond( @@ -184,7 +184,7 @@ KeyValuePair daysMinMax(Period p) case TimeUnit.Years: return new KeyValuePair(365 * p.length(), 366 * p.length()); default: - throw new ApplicationException("unknown time unit (" + p.units() + ")"); + throw new Exception("unknown time unit (" + p.units() + ")"); } } } diff --git a/QLNet/Instruments/Bonds/CmsRateBond.cs b/QLNet/Instruments/Bonds/CmsRateBond.cs index ed3cb6a37..be53392bf 100644 --- a/QLNet/Instruments/Bonds/CmsRateBond.cs +++ b/QLNet/Instruments/Bonds/CmsRateBond.cs @@ -60,9 +60,9 @@ public CmsRateBond(int settlementDays, addRedemptionsToCashflows(new List() { redemption }); if (cashflows().Count == 0) - throw new ApplicationException("bond with no cashflows!"); + throw new Exception("bond with no cashflows!"); if (redemptions_.Count != 1) - throw new ApplicationException("multiple redemptions created"); + throw new Exception("multiple redemptions created"); index.registerWith(update); diff --git a/QLNet/Instruments/Bonds/Fixedratebond.cs b/QLNet/Instruments/Bonds/Fixedratebond.cs index 6dd4eb95c..591cb52ff 100644 --- a/QLNet/Instruments/Bonds/Fixedratebond.cs +++ b/QLNet/Instruments/Bonds/Fixedratebond.cs @@ -60,10 +60,10 @@ public FixedRateBond(int settlementDays, double faceAmount, Schedule schedule,Li addRedemptionsToCashflows(new List() { redemption }); if (cashflows().Count == 0) - throw new ApplicationException("bond with no cashflows!"); + throw new Exception("bond with no cashflows!"); if (redemptions_.Count != 1) - throw new ApplicationException("multiple redemptions created"); + throw new Exception("multiple redemptions created"); } /*! simple annual compounding coupon rates @@ -115,10 +115,10 @@ public FixedRateBond(int settlementDays, case DateGeneration.Rule.ThirdWednesday: case DateGeneration.Rule.Twentieth: case DateGeneration.Rule.TwentiethIMM: - throw new ApplicationException("stub date (" + stubDate + ") not allowed with " + rule + " DateGeneration::Rule"); + throw new Exception("stub date (" + stubDate + ") not allowed with " + rule + " DateGeneration::Rule"); default: - throw new ApplicationException("unknown DateGeneration::Rule (" + rule + ")"); + throw new Exception("unknown DateGeneration::Rule (" + rule + ")"); } @@ -142,10 +142,10 @@ public FixedRateBond(int settlementDays, if (cashflows().Count == 0) - throw new ApplicationException("bond with no cashflows!"); + throw new Exception("bond with no cashflows!"); if (redemptions_.Count != 1) - throw new ApplicationException("multiple redemptions created"); + throw new Exception("multiple redemptions created"); } public FixedRateBond(int settlementDays, @@ -183,10 +183,10 @@ public FixedRateBond(int settlementDays, if (cashflows().Count == 0) - throw new ApplicationException("bond with no cashflows!"); + throw new Exception("bond with no cashflows!"); if (redemptions_.Count != 1) - throw new ApplicationException("multiple redemptions created"); + throw new Exception("multiple redemptions created"); } Frequency frequency() { return frequency_; } diff --git a/QLNet/Instruments/Bonds/FloatingRateBond.cs b/QLNet/Instruments/Bonds/FloatingRateBond.cs index d30793440..2c9e6ee0e 100644 --- a/QLNet/Instruments/Bonds/FloatingRateBond.cs +++ b/QLNet/Instruments/Bonds/FloatingRateBond.cs @@ -52,9 +52,9 @@ public FloatingRateBond(int settlementDays, double faceAmount, Schedule schedule addRedemptionsToCashflows(new List() { redemption }); if (cashflows().Count == 0) - throw new ApplicationException("bond with no cashflows!"); + throw new Exception("bond with no cashflows!"); if (redemptions_.Count != 1) - throw new ApplicationException("multiple redemptions created"); + throw new Exception("multiple redemptions created"); index.registerWith(update); } @@ -98,9 +98,9 @@ public FloatingRateBond(int settlementDays, double faceAmount, Date startDate, D case DateGeneration.Rule.ThirdWednesday: case DateGeneration.Rule.Twentieth: case DateGeneration.Rule.TwentiethIMM: - throw new ApplicationException("stub date (" + stubDate + ") not allowed with " + rule + " DateGeneration::Rule"); + throw new Exception("stub date (" + stubDate + ") not allowed with " + rule + " DateGeneration::Rule"); default: - throw new ApplicationException("unknown DateGeneration::Rule (" + rule + ")"); + throw new Exception("unknown DateGeneration::Rule (" + rule + ")"); } Schedule schedule = new Schedule(startDate, maturityDate_, new Period(couponFrequency), calendar_, @@ -120,9 +120,9 @@ public FloatingRateBond(int settlementDays, double faceAmount, Date startDate, D addRedemptionsToCashflows(new List() { redemption }); if (cashflows().Count == 0) - throw new ApplicationException("bond with no cashflows!"); + throw new Exception("bond with no cashflows!"); if (redemptions_.Count != 1) - throw new ApplicationException("multiple redemptions created"); + throw new Exception("multiple redemptions created"); index.registerWith(update); } diff --git a/QLNet/Instruments/Bonds/MBSFixedRateBond.cs b/QLNet/Instruments/Bonds/MBSFixedRateBond.cs index 0ed28d20c..61667c16a 100644 --- a/QLNet/Instruments/Bonds/MBSFixedRateBond.cs +++ b/QLNet/Instruments/Bonds/MBSFixedRateBond.cs @@ -88,7 +88,7 @@ public List expectedCashflows() // ADD CashFlow c1 = new VoluntaryPrepay(prepay, schedule_[i + 1]); CashFlow c2 = new AmortizingPayment(actualamort, schedule_[i + 1]); - CashFlow c3 = new FixedRateCoupon(currentNotional, schedule_[i + 1], new InterestRate(PassThroughRate_, dCounter_, Compounding.Simple,Frequency.Annual), schedule_[i], schedule_[i + 1]); + CashFlow c3 = new FixedRateCoupon( schedule_[i + 1], currentNotional, new InterestRate(PassThroughRate_, dCounter_, Compounding.Simple,Frequency.Annual), schedule_[i], schedule_[i + 1]); expectedcashflows.Add(c1); expectedcashflows.Add(c2); expectedcashflows.Add(c3); diff --git a/QLNet/Instruments/DividendVanillaOption.cs b/QLNet/Instruments/DividendVanillaOption.cs index 399e5b8b5..6d1ec2cf5 100644 --- a/QLNet/Instruments/DividendVanillaOption.cs +++ b/QLNet/Instruments/DividendVanillaOption.cs @@ -40,7 +40,7 @@ public double impliedVolatility(double targetValue, GeneralizedBlackScholesProce double accuracy = 1.0e-4, int maxEvaluations = 100, double minVol = 1.0e-7, double maxVol = 4.0) { - if (isExpired()) throw new ApplicationException("option expired"); + if (isExpired()) throw new Exception("option expired"); SimpleQuote volQuote = new SimpleQuote(); @@ -57,7 +57,7 @@ public double impliedVolatility(double targetValue, GeneralizedBlackScholesProce engine = new FDDividendAmericanEngine(newProcess); break; case Exercise.Type.Bermudan: - throw new ApplicationException("engine not available for Bermudan option with dividends"); + throw new Exception("engine not available for Bermudan option with dividends"); default: throw new ArgumentException("unknown exercise type"); } @@ -71,7 +71,7 @@ public override void setupArguments(IPricingEngineArguments args) { base.setupArguments(args); Arguments arguments = args as Arguments; - if (arguments == null) throw new ApplicationException("wrong engine type"); + if (arguments == null) throw new Exception("wrong engine type"); arguments.cashFlow = cashFlow_; } @@ -88,7 +88,7 @@ public override void validate() { for (int i = 0; i < cashFlow.Count; i++) { if (!(cashFlow[i].date() <= exerciseDate)) - throw new ApplicationException((i+1) + " dividend date (" + cashFlow[i].date() + throw new Exception((i+1) + " dividend date (" + cashFlow[i].date() + ") is later than the exercise date (" + exerciseDate + ")"); } } diff --git a/QLNet/Instruments/ImpliedVolatility.cs b/QLNet/Instruments/ImpliedVolatility.cs index 0c47993fe..345bb9f96 100644 --- a/QLNet/Instruments/ImpliedVolatility.cs +++ b/QLNet/Instruments/ImpliedVolatility.cs @@ -64,7 +64,7 @@ public PriceError(IPricingEngine engine, SimpleQuote vol, double targetValue) { results_ = engine_.getResults() as Instrument.Results; if (results_ == null) - throw new ApplicationException("pricing engine does not supply needed results"); + throw new Exception("pricing engine does not supply needed results"); } public override double value(double x) { diff --git a/QLNet/Instruments/Instrument.cs b/QLNet/Instruments/Instrument.cs index 319d42341..39295de99 100644 --- a/QLNet/Instruments/Instrument.cs +++ b/QLNet/Instruments/Instrument.cs @@ -142,7 +142,7 @@ public object result(string tag) // This method must leave the instrument in a consistent state when the expiration condition is met. protected virtual void setupExpired() { - NPV_ = errorEstimate_ = CASH_ = null; + NPV_ = errorEstimate_ = CASH_ = 0.0; valuationDate_ = null; additionalResults_.Clear(); } diff --git a/QLNet/Instruments/Loan.cs b/QLNet/Instruments/Loan.cs index cd0ceeefe..26c0c2a7e 100644 --- a/QLNet/Instruments/Loan.cs +++ b/QLNet/Instruments/Loan.cs @@ -299,7 +299,7 @@ public CommercialPaper(Type type, double nominal, { FixedRateCoupon c = (FixedRateCoupon)fixedLeg[i]; n = i > 0 ? notionals_.Last() : c.nominal(); - notionals_.Add ( n /(1+(c.rate()* c.dayCounter().yearFraction(c.refPeriodStart, c.refPeriodEnd)))); + notionals_.Add ( n /(1+(c.rate()* c.dayCounter().yearFraction(c.referencePeriodStart, c.referencePeriodEnd)))); } // New Leg diff --git a/QLNet/Instruments/MultiAssetOption.cs b/QLNet/Instruments/MultiAssetOption.cs index 9b4dfd70d..2cc43e90a 100644 --- a/QLNet/Instruments/MultiAssetOption.cs +++ b/QLNet/Instruments/MultiAssetOption.cs @@ -44,7 +44,7 @@ public MultiAssetOption(Payoff payoff, Exercise exercise) : base(payoff, exercis public override bool isExpired() { - return exercise_.lastDate() < Settings.evaluationDate(); + return new simple_event(exercise_.lastDate()).hasOccurred(); } //@} //! \name greeks @@ -53,42 +53,42 @@ public double delta() { calculate(); if (delta_ == null) - throw new ApplicationException("delta not provided"); + throw new Exception("delta not provided"); return delta_.GetValueOrDefault(); } public double gamma() { calculate(); if (gamma_ == null) - throw new ApplicationException("gamma not provided"); + throw new Exception("gamma not provided"); return gamma_.GetValueOrDefault(); } public double theta() { calculate(); if (theta_ == null) - throw new ApplicationException("theta not provided"); + throw new Exception("theta not provided"); return theta_.GetValueOrDefault(); } public double vega() { calculate(); if (vega_ == null) - throw new ApplicationException("vega not provided"); + throw new Exception("vega not provided"); return vega_.GetValueOrDefault(); } public double rho() { calculate(); if (rho_ == null) - throw new ApplicationException("rho not provided"); + throw new Exception("rho not provided"); return rho_.GetValueOrDefault(); } public double dividendRho() { calculate(); if (dividendRho_ == null) - throw new ApplicationException("dividend rho not provided"); + throw new Exception("dividend rho not provided"); return dividendRho_.GetValueOrDefault(); } @@ -96,7 +96,7 @@ public override void setupArguments(IPricingEngineArguments args) { MultiAssetOption.Arguments arguments = args as MultiAssetOption.Arguments; if (arguments == null) - throw new ApplicationException("wrong argument type"); + throw new Exception("wrong argument type"); arguments.payoff = payoff_; arguments.exercise = exercise_; @@ -108,7 +108,7 @@ public override void fetchResults(IPricingEngineResults r) Results results = r as Results; if (results == null) - throw new ApplicationException("no greeks returned from pricing engine"); + throw new Exception("no greeks returned from pricing engine"); delta_ = results.delta; gamma_ = results.gamma; diff --git a/QLNet/Instruments/OneAssetOption.cs b/QLNet/Instruments/OneAssetOption.cs index 38de1c451..b34e4093c 100644 --- a/QLNet/Instruments/OneAssetOption.cs +++ b/QLNet/Instruments/OneAssetOption.cs @@ -28,71 +28,71 @@ public class OneAssetOption : Option { public OneAssetOption(Payoff payoff, Exercise exercise) : base(payoff, exercise) {} - public override bool isExpired() { return exercise_.lastDate() < Settings.evaluationDate(); } + public override bool isExpired() { return new simple_event(exercise_.lastDate()).hasOccurred(); } public double delta() { calculate(); - if (delta_ == null) throw new ApplicationException("delta not provided"); + if (delta_ == null) throw new Exception("delta not provided"); return delta_.GetValueOrDefault(); } public double deltaForward() { calculate(); - if (deltaForward_ == null) throw new ApplicationException("forward delta not provided"); + if (deltaForward_ == null) throw new Exception("forward delta not provided"); return deltaForward_.GetValueOrDefault(); } public double elasticity() { calculate(); - if (elasticity_ == null) throw new ApplicationException("elasticity not provided"); + if (elasticity_ == null) throw new Exception("elasticity not provided"); return elasticity_.GetValueOrDefault(); } public double gamma() { calculate(); - if (gamma_ == null) throw new ApplicationException("gamma not provided"); + if (gamma_ == null) throw new Exception("gamma not provided"); return gamma_.GetValueOrDefault(); } public double theta() { calculate(); - if (theta_ == null) throw new ApplicationException("theta not provided"); + if (theta_ == null) throw new Exception("theta not provided"); return theta_.GetValueOrDefault(); } public double thetaPerDay() { calculate(); - if (thetaPerDay_ == null) throw new ApplicationException("theta per-day not provided"); + if (thetaPerDay_ == null) throw new Exception("theta per-day not provided"); return thetaPerDay_.GetValueOrDefault(); } public double vega() { calculate(); - if (vega_ == null) throw new ApplicationException("vega not provided"); + if (vega_ == null) throw new Exception("vega not provided"); return vega_.GetValueOrDefault(); } public double rho() { calculate(); - if (rho_ == null) throw new ApplicationException("rho not provided"); + if (rho_ == null) throw new Exception("rho not provided"); return rho_.GetValueOrDefault(); } public double dividendRho() { calculate(); - if (dividendRho_ == null) throw new ApplicationException("dividend rho not provided"); + if (dividendRho_ == null) throw new Exception("dividend rho not provided"); return dividendRho_.GetValueOrDefault(); } public double strikeSensitivity() { calculate(); - if (strikeSensitivity_ == null) throw new ApplicationException("strike sensitivity not provided"); + if (strikeSensitivity_ == null) throw new Exception("strike sensitivity not provided"); return strikeSensitivity_.GetValueOrDefault(); } public double itmCashProbability() { calculate(); - if (itmCashProbability_ == null) throw new ApplicationException("in-the-money cash probability not provided"); + if (itmCashProbability_ == null) throw new Exception("in-the-money cash probability not provided"); return itmCashProbability_.GetValueOrDefault(); } @@ -107,7 +107,7 @@ public override void fetchResults(IPricingEngineResults r) { Results results = r as Results; if (results == null) - throw new ApplicationException("no greeks returned from pricing engine"); + throw new Exception("no greeks returned from pricing engine"); /* no check on null values - just copy. this allows: a) to decide in derived options what to do when null diff --git a/QLNet/Instruments/OvernightIndexedSwap.cs b/QLNet/Instruments/OvernightIndexedSwap.cs index ddb28e70c..22ca20fb4 100644 --- a/QLNet/Instruments/OvernightIndexedSwap.cs +++ b/QLNet/Instruments/OvernightIndexedSwap.cs @@ -81,7 +81,7 @@ public OvernightIndexedSwap(Type type, payer_[1] = -1.0; break; default: - throw new ApplicationException("Unknown overnight-swap type"); + throw new Exception("Unknown overnight-swap type"); } } @@ -116,7 +116,7 @@ public OvernightIndexedSwap(Type type, { calculate(); if (legBPS_[0] == null) - throw new ApplicationException("result not available"); + throw new Exception("result not available"); return legBPS_[0]; } @@ -124,7 +124,7 @@ public OvernightIndexedSwap(Type type, { calculate(); if (legBPS_[1] == null) - throw new ApplicationException("result not available"); + throw new Exception("result not available"); return legBPS_[1]; } @@ -132,7 +132,7 @@ public OvernightIndexedSwap(Type type, { calculate(); if (legNPV_[0] == null) - throw new ApplicationException("result not available"); + throw new Exception("result not available"); return legNPV_[0]; } @@ -140,7 +140,7 @@ public OvernightIndexedSwap(Type type, { calculate(); if (legNPV_[1] == null) - throw new ApplicationException("result not available"); + throw new Exception("result not available"); return legNPV_[1]; } } diff --git a/QLNet/Instruments/Stock.cs b/QLNet/Instruments/Stock.cs index dc8eb6623..24570cd1a 100644 --- a/QLNet/Instruments/Stock.cs +++ b/QLNet/Instruments/Stock.cs @@ -32,7 +32,7 @@ public Stock(Handle quote) { protected override void performCalculations() { if (quote_.empty()) - throw new ApplicationException("null quote set"); + throw new Exception("null quote set"); NPV_ = quote_.link.value(); } } diff --git a/QLNet/Instruments/Swaption.cs b/QLNet/Instruments/Swaption.cs index 19a3b606b..f1199753e 100644 --- a/QLNet/Instruments/Swaption.cs +++ b/QLNet/Instruments/Swaption.cs @@ -82,7 +82,7 @@ public Swaption(VanillaSwap swap,Exercise exercise,Settlement.Type delivery) //@{ public override bool isExpired() { - return exercise_.dates().Last() < Settings.evaluationDate(); + return new simple_event(exercise_.dates().Last()).hasOccurred(); } public override void setupArguments(IPricingEngineArguments args) diff --git a/QLNet/Instruments/VanillaSwap.cs b/QLNet/Instruments/VanillaSwap.cs index 6813a761d..35059158c 100644 --- a/QLNet/Instruments/VanillaSwap.cs +++ b/QLNet/Instruments/VanillaSwap.cs @@ -113,7 +113,7 @@ public VanillaSwap(Type type, double nominal, payer_[1] = -1.0; break; default: - throw new ApplicationException("Unknown vanilla-swap type"); + throw new Exception("Unknown vanilla-swap type"); } } @@ -323,5 +323,7 @@ public override void reset() fairRate = fairSpread = null; } } + + public abstract class Engine : GenericEngine { } } } diff --git a/QLNet/Instruments/YearOnYearInflationSwap.cs b/QLNet/Instruments/YearOnYearInflationSwap.cs index 1afe83447..b4f02ae39 100644 --- a/QLNet/Instruments/YearOnYearInflationSwap.cs +++ b/QLNet/Instruments/YearOnYearInflationSwap.cs @@ -81,7 +81,7 @@ public YearOnYearInflationSwap( .withNotionals( nominal_ ) .withPaymentAdjustment( paymentConvention_ ); - yoyLeg.ForEach( x => x.registerWith( update ) ); + yoyLeg.ForEach((i, x) => x.registerWith( update ) ); legs_[0] = fixedLeg; diff --git a/QLNet/Instruments/ZeroCouponInflationSwap.cs b/QLNet/Instruments/ZeroCouponInflationSwap.cs index 16ee4b0b0..c506e588d 100644 --- a/QLNet/Instruments/ZeroCouponInflationSwap.cs +++ b/QLNet/Instruments/ZeroCouponInflationSwap.cs @@ -142,7 +142,7 @@ public ZeroCouponInflationSwap(Type type, for (int j=0; j<2; ++j) { - legs_[j].ForEach(x => x.registerWith(update)); + legs_[j].ForEach((i, x) => x.registerWith(update)); } switch (type_) diff --git a/QLNet/Instruments/bmaswap.cs b/QLNet/Instruments/bmaswap.cs index cf5a1626d..d8ce4932d 100644 --- a/QLNet/Instruments/bmaswap.cs +++ b/QLNet/Instruments/bmaswap.cs @@ -78,7 +78,7 @@ public BMASwap(Type type, double nominal, payer_[1] = +1.0; break; default: - throw new ApplicationException("Unknown BMA-swap type"); + throw new Exception("Unknown BMA-swap type"); } } @@ -89,14 +89,14 @@ public BMASwap(Type type, double nominal, public double liborLegBPS() { calculate(); if (legBPS_[0] == null) - throw new ApplicationException("result not available"); + throw new Exception("result not available"); return legBPS_[0].GetValueOrDefault(); } public double liborLegNPV() { calculate(); if (legNPV_[0] == null) - throw new ApplicationException("result not available"); + throw new Exception("result not available"); return legNPV_[0].GetValueOrDefault(); } @@ -106,7 +106,7 @@ public double fairLiborFraction() { double spreadNPV = (liborSpread_/basisPoint)*liborLegBPS(); double pureLiborNPV = liborLegNPV() - spreadNPV; if (pureLiborNPV == 0.0) - throw new ApplicationException("result not available (null libor NPV)"); + throw new Exception("result not available (null libor NPV)"); return -liborFraction_ * (bmaLegNPV() + spreadNPV) / pureLiborNPV; } @@ -118,14 +118,14 @@ public double fairLiborSpread() { public double bmaLegBPS() { calculate(); if (legBPS_[1] == null) - throw new ApplicationException("result not available"); + throw new Exception("result not available"); return legBPS_[1].GetValueOrDefault(); } public double bmaLegNPV() { calculate(); if (legNPV_[1] == null) - throw new ApplicationException("result not available"); + throw new Exception("result not available"); return legNPV_[1].GetValueOrDefault(); } } diff --git a/QLNet/Instruments/forward.cs b/QLNet/Instruments/forward.cs index 4af4a0a52..c7f7bb9ee 100644 --- a/QLNet/Instruments/forward.cs +++ b/QLNet/Instruments/forward.cs @@ -86,11 +86,7 @@ public virtual Date settlementDate() { } public override bool isExpired() { - #if QL_TODAYS_PAYMENTS - return maturityDate_ < settlementDate(); - #else - return maturityDate_ <= settlementDate(); - #endif + return new simple_event(maturityDate_).hasOccurred(settlementDate()); } @@ -129,7 +125,7 @@ public InterestRate impliedYield(double underlyingSpotValue, double forwardValue protected override void performCalculations() { if (discountCurve_.empty()) - throw new ApplicationException("no discounting term structure set to Forward"); + throw new Exception("no discounting term structure set to Forward"); ForwardTypePayoff ftpayoff = payoff_ as ForwardTypePayoff; double fwdValue = forwardValue(); @@ -149,7 +145,7 @@ public ForwardTypePayoff(Position.Type type, double strike) { type_ = type; strike_ = strike; if (strike < 0.0) - throw new ApplicationException("negative strike given"); + throw new Exception("negative strike given"); } //! \name Payoff interface @@ -165,7 +161,7 @@ public override double value(double price) { case Position.Type.Short: return (strike_-price); default: - throw new ApplicationException("unknown/illegal position type"); + throw new Exception("unknown/illegal position type"); } } }; diff --git a/QLNet/Instruments/forwardrateagreement.cs b/QLNet/Instruments/forwardrateagreement.cs index 1e25128da..edf898b6e 100644 --- a/QLNet/Instruments/forwardrateagreement.cs +++ b/QLNet/Instruments/forwardrateagreement.cs @@ -85,7 +85,7 @@ public ForwardRateAgreement(Date valueDate, Date maturityDate, Position.Type typ index_ = index; if (notionalAmount <= 0.0) - throw new ApplicationException("notional Amount must be positive"); + throw new Exception("notional Amount must be positive"); // do I adjust this ? // valueDate_ = calendar_.adjust(valueDate_,businessDayConvention_); @@ -110,11 +110,7 @@ public override Date settlementDate() { /*! A FRA expires/settles on the valueDate */ public override bool isExpired() { - #if QL_TODAYS_PAYMENTS - return valueDate_ < settlementDate(); - #else - return valueDate_ <= settlementDate(); - #endif + return new simple_event(valueDate_).hasOccurred(settlementDate()); } /*! Income is zero for a FRA */ diff --git a/QLNet/Instruments/payoffs.cs b/QLNet/Instruments/payoffs.cs index bdbdeccdc..412ea8d03 100644 --- a/QLNet/Instruments/payoffs.cs +++ b/QLNet/Instruments/payoffs.cs @@ -194,9 +194,9 @@ public SuperFundPayoff(double strike, double secondStrike) : base(Option.Type.Ca secondStrike_ = secondStrike; if (!(strike>0.0)) - throw new ApplicationException("strike (" + strike + ") must be positive"); + throw new Exception("strike (" + strike + ") must be positive"); if (!(secondStrike>strike)) - throw new ApplicationException("second strike (" + secondStrike + + throw new Exception("second strike (" + secondStrike + ") must be higher than first strike (" + strike + ")"); } @@ -221,7 +221,7 @@ public SuperSharePayoff(double strike, double secondStrike, double cashPayoff) cashPayoff_ = cashPayoff; if (!(secondStrike>strike)) - throw new ApplicationException("second strike (" + secondStrike + + throw new Exception("second strike (" + secondStrike + ") must be higher than first strike (" + strike + ")"); } diff --git a/QLNet/InterestRate.cs b/QLNet/InterestRate.cs index 649134aec..ef6d02ac5 100644 --- a/QLNet/InterestRate.cs +++ b/QLNet/InterestRate.cs @@ -238,7 +238,7 @@ public override string ToString() { case Frequency.NoFrequency: case Frequency.Once: - throw new ApplicationException(frequency() + " frequency not allowed for this interest rate"); + throw new Exception(frequency() + " frequency not allowed for this interest rate"); default: result += frequency() + " compounding"; break; @@ -252,7 +252,7 @@ public override string ToString() { case Frequency.NoFrequency: case Frequency.Once: - throw new ApplicationException(frequency() + " frequency not allowed for this interest rate"); + throw new Exception(frequency() + " frequency not allowed for this interest rate"); default: result += "simple compounding up to " + (int)(12 / (int)frequency()) + " months, then " @@ -261,7 +261,7 @@ public override string ToString() } break; default: - throw new ApplicationException("unknown compounding convention (" + compounding() + ")"); + throw new Exception("unknown compounding convention (" + compounding() + ")"); } return result; } diff --git a/QLNet/Math/Distributions/GammaDistribution.cs b/QLNet/Math/Distributions/GammaDistribution.cs index 1cd960770..e0a55f4c2 100644 --- a/QLNet/Math/Distributions/GammaDistribution.cs +++ b/QLNet/Math/Distributions/GammaDistribution.cs @@ -24,7 +24,7 @@ public class GammaDistribution { public GammaDistribution(double a) { a_ = a; - if (!(a>0.0)) throw new ApplicationException("invalid parameter for gamma distribution"); + if (!(a>0.0)) throw new Exception("invalid parameter for gamma distribution"); } public double value(double x) { @@ -62,7 +62,7 @@ public double value(double x) { return h*Math.Exp(-x + a_*Math.Log(x) - gln); } } - throw new ApplicationException("too few iterations"); + throw new Exception("too few iterations"); } } @@ -90,7 +90,7 @@ public static class GammaFunction public static double logValue( double x ) { - if ( !( x > 0.0 ) ) throw new ApplicationException( "positive argument required" ); + if ( !( x > 0.0 ) ) throw new Exception( "positive argument required" ); double temp = x + 5.5; temp -= ( x + 0.5 ) * Math.Log( temp ); diff --git a/QLNet/Math/Distributions/NormalDistribution.cs b/QLNet/Math/Distributions/NormalDistribution.cs index 569acf024..6e1de2a15 100644 --- a/QLNet/Math/Distributions/NormalDistribution.cs +++ b/QLNet/Math/Distributions/NormalDistribution.cs @@ -38,7 +38,7 @@ public NormalDistribution(double average, double sigma) { sigma_ = sigma; if (!(sigma_>0.0)) - throw new ApplicationException("sigma must be greater than 0.0 (" + sigma_ + " not allowed)"); + throw new Exception("sigma must be greater than 0.0 (" + sigma_ + " not allowed)"); normalizationFactor_ = Const.M_SQRT_2*Const.M_1_SQRTPI/sigma_; derNormalizationFactor_ = sigma_*sigma_; @@ -79,7 +79,7 @@ public CumulativeNormalDistribution(double average, double sigma) { sigma_ = sigma; if (!(sigma_>0.0)) - throw new ApplicationException("sigma must be greater than 0.0 (" + sigma_ + " not allowed)"); + throw new Exception("sigma must be greater than 0.0 (" + sigma_ + " not allowed)"); } // function @@ -395,7 +395,7 @@ public InverseCumulativeNormal(double average, double sigma) { sigma_ = sigma; if (!(sigma_>0.0)) - throw new ApplicationException("sigma must be greater than 0.0 (" + sigma_ + " not allowed)"); + throw new Exception("sigma must be greater than 0.0 (" + sigma_ + " not allowed)"); } // function @@ -407,7 +407,7 @@ public double value(double x) { } else if (Math.Abs(x) < Const.QL_EPSILON) { x = 0.0; } else { - throw new ApplicationException("InverseCumulativeNormal(" + x + ") undefined: must be 0 < x < 1"); + throw new Exception("InverseCumulativeNormal(" + x + ") undefined: must be 0 < x < 1"); } } @@ -498,13 +498,13 @@ public MoroInverseCumulativeNormal(double average, double sigma) { sigma_ = sigma; if (!(sigma_>0.0)) - throw new ApplicationException("sigma must be greater than 0.0 (" + sigma_ + " not allowed)"); + throw new Exception("sigma must be greater than 0.0 (" + sigma_ + " not allowed)"); } // function public double value(double x) { if(!(x > 0.0 && x < 1.0)) - throw new ApplicationException("MoroInverseCumulativeNormal(" + x + ") undefined: must be 00)) throw new ApplicationException("negative p not allowed"); - if (!(p < 1.0)) throw new ApplicationException("p>1.0 not allowed"); + if (!(p>0)) throw new Exception("negative p not allowed"); + if (!(p < 1.0)) throw new Exception("p>1.0 not allowed"); logP_ = Math.Log(p); logOneMinusP_ = Math.Log(1.0 - p); @@ -72,8 +72,8 @@ public CumulativeBinomialDistribution(double p, int n) { n_ = n; p_ = p; - if (!(p >= 0)) throw new ApplicationException("negative p not allowed"); - if (!(p <= 1.0)) throw new ApplicationException("p>1.0 not allowed"); + if (!(p >= 0)) throw new Exception("negative p not allowed"); + if (!(p <= 1.0)) throw new Exception("p>1.0 not allowed"); } // function @@ -94,7 +94,7 @@ public static partial class Utils { */ public static double PeizerPrattMethod2Inversion(double z, int n) { - if (!(n%2==1)) throw new ApplicationException("n must be an odd number: " + n + " not allowed"); + if (!(n%2==1)) throw new Exception("n must be an odd number: " + n + " not allowed"); double result = (z/(n+1.0/3.0+0.1/(n+1.0))); result *= result; @@ -104,7 +104,7 @@ public static double PeizerPrattMethod2Inversion(double z, int n) { } public static double binomialCoefficientLn(int n, int k) { - if (!(n>=k)) throw new ApplicationException("n=k)) throw new Exception("n errmax) throw new ApplicationException("didn't converge"); + if (bound > errmax) throw new Exception("didn't converge"); return (ans); } } diff --git a/QLNet/Math/Distributions/poissondistribution.cs b/QLNet/Math/Distributions/poissondistribution.cs index 2827e52e6..a1c4ae890 100644 --- a/QLNet/Math/Distributions/poissondistribution.cs +++ b/QLNet/Math/Distributions/poissondistribution.cs @@ -29,12 +29,12 @@ public class InverseCumulativePoisson : IValue { public InverseCumulativePoisson() : this(1) { } public InverseCumulativePoisson(double lambda) { lambda_ = lambda; - if (!(lambda_ > 0.0)) throw new ApplicationException("lambda must be positive"); + if (!(lambda_ > 0.0)) throw new Exception("lambda must be positive"); } public double value(double x) { if (!(x >= 0.0 && x <= 1.0)) - throw new ApplicationException("Inverse cumulative Poisson distribution is only defined on the interval [0,1]"); + throw new Exception("Inverse cumulative Poisson distribution is only defined on the interval [0,1]"); if (x == 1.0) return double.MaxValue; diff --git a/QLNet/Math/Interpolation.cs b/QLNet/Math/Interpolation.cs index ea546740b..c2cbf12d4 100644 --- a/QLNet/Math/Interpolation.cs +++ b/QLNet/Math/Interpolation.cs @@ -1,142 +1,157 @@ -/* - Copyright (C) 2008 Siarhei Novik (snovik@gmail.com) - - This file is part of QLNet Project https://github.com/amaggiulli/qlnet - - QLNet is free software: you can redistribute it and/or modify it - under the terms of the QLNet license. You should have received a - copy of the license along with this program; if not, license is - available online at . - - QLNet is a based on QuantLib, a free-software/open-source library - for financial quantitative analysts and developers - http://quantlib.org/ - The QuantLib license is available online at http://quantlib.org/license.shtml. - - This program is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS - FOR A PARTICULAR PURPOSE. See the license for more details. -*/ -using System; -using System.Collections.Generic; -using System.Linq; - -namespace QLNet { - //! base class for 1-D interpolations. - /* Classes derived from this class will provide interpolated values from two sequences of equal length, - * representing discretized values of a variable and a function of the former, respectively. */ - - // Interpolation factory - public interface IInterpolationFactory { - Interpolation interpolate(List xBegin, int size, List yBegin); - bool global { get; } - int requiredPoints { get; } - } - - public abstract class Interpolation : Extrapolator, IValue { - protected Impl impl_; - - public bool empty() { return impl_ == null; } - - public double primitive(double x) { return primitive(x, false); } - public double primitive(double x, bool allowExtrapolation) { - checkRange(x,allowExtrapolation); - return impl_.primitive(x); - } - - public double derivative(double x) { return derivative(x, false); } - public double derivative(double x, bool allowExtrapolation) { - checkRange(x,allowExtrapolation); - return impl_.derivative(x); - } - - public double secondDerivative(double x) { return secondDerivative(x, false); } - public double secondDerivative(double x, bool allowExtrapolation) { - checkRange(x,allowExtrapolation); - return impl_.secondDerivative(x); - } - - public double xMin() { - return impl_.xMin(); - } - public double xMax() { - return impl_.xMax(); - } - bool isInRange(double x) { - return impl_.isInRange(x); - } - public override void update() { - impl_.update(); - } - - // main method to derive an interpolated point - public double value(double x) { return value(x, false); } - public double value(double x, bool allowExtrapolation) { - checkRange(x, allowExtrapolation); - return impl_.value(x); - } - - protected void checkRange(double x, bool extrapolate) { - if (!(extrapolate || allowsExtrapolation() || impl_.isInRange(x))) - throw new ArgumentException("interpolation range is [" + impl_.xMin() + ", " + impl_.xMax() - + "]: extrapolation at " + x + " not allowed"); - } - - - // abstract base class interface for interpolation implementations - protected interface Impl : IValue { - void update(); - double xMin(); - double xMax(); - List xValues(); - List yValues(); - bool isInRange(double d); - double primitive(double d); - double derivative(double d); - double secondDerivative(double d); - } - public abstract class templateImpl : Impl { - protected List xBegin_; - protected List yBegin_; - protected int size_; - - // this method should be used for initialisation - public templateImpl(List xBegin, int size, List yBegin) { - xBegin_ = xBegin; - yBegin_ = yBegin; - size_ = size; - if (size < 2) - throw new ArgumentException("not enough points to interpolate: at least 2 required, " - + size + " provided"); - } - - public double xMin() { return xBegin_.First(); } - public double xMax() { return xBegin_[size_-1]; } - public List xValues() { return xBegin_.GetRange(0, size_); } - public List yValues() { return yBegin_.GetRange(0, size_); } - - public bool isInRange(double x) { - double x1 = xMin(), x2 = xMax(); - return (x >= x1 && x <= x2) || Utils.close(x, x1) || Utils.close(x, x2); - } - - protected int locate(double x) { - int result = xBegin_.BinarySearch(x); - if (result < 0) - // The upper_bound() algorithm finds the last position in a sequence that value can occupy - // without violating the sequence's ordering - // if BinarySearch does not find value the value, the index of the next larger item is returned - result = ~result - 1; - - // impose limits. we need the one before last at max or the first at min - result = Math.Max(Math.Min(result, size_ - 2), 0); - return result; - } - - public abstract double value(double d); - public abstract void update(); - public abstract double primitive(double d); - public abstract double derivative(double d); - public abstract double secondDerivative(double d); - } - } -} +/* + Copyright (C) 2008 Siarhei Novik (snovik@gmail.com) + Copyright (C) 2008-2016 Andrea Maggiulli (a.maggiulli@gmail.com) + + This file is part of QLNet Project https://github.com/amaggiulli/qlnet + + QLNet is free software: you can redistribute it and/or modify it + under the terms of the QLNet license. You should have received a + copy of the license along with this program; if not, license is + available online at . + + QLNet is a based on QuantLib, a free-software/open-source library + for financial quantitative analysts and developers - http://quantlib.org/ + The QuantLib license is available online at http://quantlib.org/license.shtml. + + This program is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS + FOR A PARTICULAR PURPOSE. See the license for more details. +*/ +using System; +using System.Collections.Generic; +using System.Linq; + +namespace QLNet +{ + //! base class for 1-D interpolations. + /* Classes derived from this class will provide interpolated values from two sequences of equal length, + * representing discretized values of a variable and a function of the former, respectively. */ + + // Interpolation factory + public interface IInterpolationFactory + { + Interpolation interpolate( List xBegin, int size, List yBegin ); + bool global { get; } + int requiredPoints { get; } + } + + public abstract class Interpolation : Extrapolator, IValue + { + protected Impl impl_; + + public bool empty() { return impl_ == null; } + + public double primitive( double x, bool allowExtrapolation = false ) + { + checkRange( x, allowExtrapolation ); + return impl_.primitive( x ); + } + + public double derivative( double x, bool allowExtrapolation = false ) + { + checkRange( x, allowExtrapolation ); + return impl_.derivative( x ); + } + + public double secondDerivative( double x, bool allowExtrapolation = false ) + { + checkRange( x, allowExtrapolation ); + return impl_.secondDerivative( x ); + } + + public double xMin() + { + return impl_.xMin(); + } + public double xMax() + { + return impl_.xMax(); + } + bool isInRange( double x ) + { + return impl_.isInRange( x ); + } + public override void update() + { + impl_.update(); + } + + // main method to derive an interpolated point + public double value( double x ) { return value( x, false ); } + public double value( double x, bool allowExtrapolation ) + { + checkRange( x, allowExtrapolation ); + return impl_.value( x ); + } + + protected void checkRange( double x, bool extrap ) + { + if ( !( extrap || allowsExtrapolation() || isInRange( x ) ) ) + throw new ArgumentException( "interpolation range is [" + impl_.xMin() + ", " + impl_.xMax() + + "]: extrapolation at " + x + " not allowed" ); + } + + + // abstract base class interface for interpolation implementations + protected interface Impl : IValue + { + void update(); + double xMin(); + double xMax(); + List xValues(); + List yValues(); + bool isInRange( double d ); + double primitive( double d ); + double derivative( double d ); + double secondDerivative( double d ); + } + public abstract class templateImpl : Impl + { + protected List xBegin_; + protected List yBegin_; + protected int size_; + + // this method should be used for initialisation + public templateImpl( List xBegin, int size, List yBegin, int requiredPoints = 2 ) + { + xBegin_ = xBegin; + yBegin_ = yBegin; + size_ = size; + if ( size < requiredPoints ) + throw new ArgumentException( "not enough points to interpolate: at least 2 required, " + + size + " provided" ); + } + + public double xMin() { return xBegin_.First(); } + public double xMax() { return xBegin_[size_ - 1]; } + public List xValues() { return xBegin_.GetRange( 0, size_ ); } + public List yValues() { return yBegin_.GetRange( 0, size_ ); } + + public bool isInRange( double x ) + { + double x1 = xMin(), x2 = xMax(); + return ( x >= x1 && x <= x2 ) || Utils.close( x, x1 ) || Utils.close( x, x2 ); + } + + protected int locate( double x ) + { + int result = xBegin_.BinarySearch( x ); + if ( result < 0 ) + // The upper_bound() algorithm finds the last position in a sequence that value can occupy + // without violating the sequence's ordering + // if BinarySearch does not find value the value, the index of the next larger item is returned + result = ~result - 1; + + // impose limits. we need the one before last at max or the first at min + result = Math.Max( Math.Min( result, size_ - 2 ), 0 ); + return result; + } + + public abstract double value( double d ); + public abstract void update(); + public abstract double primitive( double d ); + public abstract double derivative( double d ); + public abstract double secondDerivative( double d ); + } + } +} diff --git a/QLNet/Math/Interpolations/Abcdinterpolation.cs b/QLNet/Math/Interpolations/Abcdinterpolation.cs new file mode 100644 index 000000000..416190667 --- /dev/null +++ b/QLNet/Math/Interpolations/Abcdinterpolation.cs @@ -0,0 +1,253 @@ +// Copyright (C) 2008-2016 Andrea Maggiulli (a.maggiulli@gmail.com) +// +// This file is part of QLNet Project https://github.com/amaggiulli/qlnet +// QLNet is free software: you can redistribute it and/or modify it +// under the terms of the QLNet license. You should have received a +// copy of the license along with this program; if not, license is +// available online at . +// +// QLNet is a based on QuantLib, a free-software/open-source library +// for financial quantitative analysts and developers - http://quantlib.org/ +// The QuantLib license is available online at http://quantlib.org/license.shtml. +// +// This program is distributed in the hope that it will be useful, but WITHOUT +// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +// FOR A PARTICULAR PURPOSE. See the license for more details. + +using System.Collections.Generic; + +namespace QLNet +{ + + public class AbcdCoeffHolder + { + public AbcdCoeffHolder(double? a, + double? b, + double? c, + double? d, + bool aIsFixed, + bool bIsFixed, + bool cIsFixed, + bool dIsFixed) + { + a_ = a; + b_ = b; + c_ = c; + d_ = d; + aIsFixed_ = false; + bIsFixed_ = false; + cIsFixed_ = false; + dIsFixed_ = false; + k_ = new List(); + error_ = null; + maxError_ = null; + abcdEndCriteria_ = EndCriteria.Type.None; + + if (a_ != null) + aIsFixed_ = aIsFixed; + else a_ = -0.06; + if (b_ != null) + bIsFixed_ = bIsFixed; + else b_ = 0.17; + if (c_ != null) + cIsFixed_ = cIsFixed; + else c_ = 0.54; + if (d_ != null) + dIsFixed_ = dIsFixed; + else d_ = 0.17; + + AbcdMathFunction.validate(a.Value, b.Value, c.Value, d.Value); + + } + + public double? a_, b_, c_, d_; + public bool aIsFixed_, bIsFixed_, cIsFixed_, dIsFixed_; + public List k_; + public double? error_, maxError_; + public EndCriteria.Type abcdEndCriteria_; + } + + public class AbcdInterpolationImpl : Interpolation.templateImpl + { + public AbcdInterpolationImpl( List xBegin, int size, List yBegin, + double a, double b, double c, double d, + bool aIsFixed, + bool bIsFixed, + bool cIsFixed, + bool dIsFixed, + bool vegaWeighted, + EndCriteria endCriteria, + OptimizationMethod optMethod) + : base(xBegin, size, yBegin) + { + abcdCoeffHolder_ = new AbcdCoeffHolder(a, b, c, d, aIsFixed, bIsFixed, cIsFixed, dIsFixed); + endCriteria_ = endCriteria; + optMethod_ = optMethod; + vegaWeighted_ = vegaWeighted; + } + + + public override void update() + { + List times = new List(), blackVols = new List(); + for ( int i = 0; i < xBegin_.Count; ++i) + { + times.Add(xBegin_[i]); + blackVols.Add(yBegin_[i]); + } + + abcdCalibrator_ = new AbcdCalibration(times, blackVols, + abcdCoeffHolder_.a_.Value, + abcdCoeffHolder_.b_.Value, + abcdCoeffHolder_.c_.Value, + abcdCoeffHolder_.d_.Value, + abcdCoeffHolder_.aIsFixed_, + abcdCoeffHolder_.bIsFixed_, + abcdCoeffHolder_.cIsFixed_, + abcdCoeffHolder_.dIsFixed_, + vegaWeighted_, + endCriteria_, + optMethod_); + + abcdCalibrator_.compute(); + abcdCoeffHolder_.a_ = abcdCalibrator_.a(); + abcdCoeffHolder_.b_ = abcdCalibrator_.b(); + abcdCoeffHolder_.c_ = abcdCalibrator_.c(); + abcdCoeffHolder_.d_ = abcdCalibrator_.d(); + abcdCoeffHolder_.k_ = abcdCalibrator_.k(times, blackVols); + abcdCoeffHolder_.error_ = abcdCalibrator_.error(); + abcdCoeffHolder_.maxError_ = abcdCalibrator_.maxError(); + abcdCoeffHolder_.abcdEndCriteria_ = abcdCalibrator_.endCriteria(); + } + + public override double value(double x) + { + Utils.QL_REQUIRE(x>=0.0,()=> "time must be non negative: " + x + " not allowed"); + return abcdCalibrator_.value(x); + } + + public override double primitive(double x) + { + Utils.QL_FAIL("Abcd primitive not implemented"); + return 0; + } + + public override double derivative(double x) + { + Utils.QL_FAIL("Abcd derivative not implemented"); + return 0; + } + + public override double secondDerivative(double x) + { + Utils.QL_FAIL("Abcd secondDerivative not implemented"); + return 0; + } + + public double k(double t) + { + LinearInterpolation li = new LinearInterpolation(this.xBegin_, this.size_, this.yBegin_); + return li.value(t); + } + + public AbcdCoeffHolder AbcdCoeffHolder() {return abcdCoeffHolder_;} + private EndCriteria endCriteria_; + private OptimizationMethod optMethod_; + private bool vegaWeighted_; + private AbcdCalibration abcdCalibrator_; + private AbcdCoeffHolder abcdCoeffHolder_; + + } + + //! %Abcd interpolation between discrete points. + /*! \ingroup interpolations */ + public class AbcdInterpolation : Interpolation + { + /*! Constructor */ + public AbcdInterpolation(List xBegin, int size, List yBegin, + double a = -0.06, + double b = 0.17, + double c = 0.54, + double d = 0.17, + bool aIsFixed = false, + bool bIsFixed = false, + bool cIsFixed = false, + bool dIsFixed = false, + bool vegaWeighted = false, + EndCriteria endCriteria = null, + OptimizationMethod optMethod = null) + { + impl_ = new AbcdInterpolationImpl(xBegin, size, yBegin, + a, b, c, d, + aIsFixed, bIsFixed, + cIsFixed, dIsFixed, + vegaWeighted, + endCriteria, + optMethod); + impl_.update(); + coeffs_ = ((AbcdInterpolationImpl)impl_).AbcdCoeffHolder(); + } + + //! \name Inspectors + //@{ + public double? a() { return coeffs_.a_; } + public double? b() { return coeffs_.b_; } + public double? c() { return coeffs_.c_; } + public double? d() { return coeffs_.d_; } + public List k() { return coeffs_.k_; } + public double? rmsError() { return coeffs_.error_; } + public double? maxError() { return coeffs_.maxError_; } + public EndCriteria.Type endCriteria(){ return coeffs_.abcdEndCriteria_; } + public double k(double t, List xBegin, int size) + { + LinearInterpolation li = new LinearInterpolation(xBegin, size, coeffs_.k_); + return li.value(t); + } + + private AbcdCoeffHolder coeffs_; + + } + + //! %Abcd interpolation factory and traits + /*! \ingroup interpolations */ + public class Abcd + { + public Abcd(double a, double b, double c, double d, + bool aIsFixed, bool bIsFixed, + bool cIsFixed, bool dIsFixed, + bool vegaWeighted = false, + EndCriteria endCriteria = null, + OptimizationMethod optMethod = null) + { + a_ = a; + b_ = b; + c_ = c; + d_ = d; + aIsFixed_ = aIsFixed; + bIsFixed_ = bIsFixed; + cIsFixed_ = cIsFixed; + dIsFixed_ = dIsFixed; + vegaWeighted_ = vegaWeighted; + endCriteria_ = endCriteria; + optMethod_ = optMethod; + } + + public Interpolation interpolate(List xBegin, int size,List yBegin) + { + return new AbcdInterpolation(xBegin, size, yBegin, + a_, b_, c_, d_, + aIsFixed_, bIsFixed_, + cIsFixed_, dIsFixed_, + vegaWeighted_, + endCriteria_, optMethod_); + } + + public bool global = true; + + private double a_, b_, c_, d_; + private bool aIsFixed_, bIsFixed_, cIsFixed_, dIsFixed_; + private bool vegaWeighted_; + private EndCriteria endCriteria_; + private OptimizationMethod optMethod_; + } +} diff --git a/QLNet/Math/Interpolations/BackwardflatLinearInterpolation.cs b/QLNet/Math/Interpolations/BackwardflatLinearInterpolation.cs new file mode 100644 index 000000000..311eef6f4 --- /dev/null +++ b/QLNet/Math/Interpolations/BackwardflatLinearInterpolation.cs @@ -0,0 +1,85 @@ +// Copyright (C) 2008-2016 Andrea Maggiulli (a.maggiulli@gmail.com) +// +// This file is part of QLNet Project https://github.com/amaggiulli/qlnet +// QLNet is free software: you can redistribute it and/or modify it +// under the terms of the QLNet license. You should have received a +// copy of the license along with this program; if not, license is +// available online at . +// +// QLNet is a based on QuantLib, a free-software/open-source library +// for financial quantitative analysts and developers - http://quantlib.org/ +// The QuantLib license is available online at http://quantlib.org/license.shtml. +// +// This program is distributed in the hope that it will be useful, but WITHOUT +// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +// FOR A PARTICULAR PURPOSE. See the license for more details. + +using System.Collections.Generic; + +namespace QLNet +{ + // backflat interpolation in first component, linear in second component + public class BackwardflatLinearInterpolationImpl : Interpolation2D.templateImpl + { + public BackwardflatLinearInterpolationImpl(List xBegin, int xEnd,List yBegin, int yEnd, + Matrix zData) + : base(xBegin,xEnd,yBegin,yEnd,zData) + { + calculate(); + } + + public override void calculate() {} + + public override double value(double x, double y) + { + int j = locateY(y); + double z1, z2; + if (x <= xBegin_[0]) + { + z1 = zData_[j,0]; + z2 = zData_[j + 1,0]; + } + else + { + int i = locateX(x); + if (x == xBegin_[i]) + { + z1 = zData_[j,i]; + z2 = zData_[j + 1,i]; + } + else + { + z1 = zData_[j,i + 1]; + z2 = zData_[j + 1,i + 1]; + } + } + + double u = (y - yBegin_[j])/ (yBegin_[j + 1] - yBegin_[j]); + + return (1.0 - u)*z1 + u*z2; + + } + + } + + public class BackwardflatLinearInterpolation : Interpolation2D + { + /*! \pre the \f$ x \f$ and \f$ y \f$ values must be sorted. */ + public BackwardflatLinearInterpolation(List xBegin, int xEnd,List yBegin, int yEnd,Matrix zData) + { + impl_ = new BackwardflatLinearInterpolationImpl(xBegin, xEnd,yBegin, yEnd,zData); + } + } + + public class BackwardflatLinear + { + public Interpolation2D interpolate(List xBegin, int xEnd,List yBegin, int yEnd,Matrix z) + { + return new BackwardflatLinearInterpolation(xBegin,xEnd,yBegin,yEnd,z); + } + } + + +} + + diff --git a/QLNet/Math/Interpolations/CubicInterpolation.cs b/QLNet/Math/Interpolations/CubicInterpolation.cs index 2e73b313f..a1482a268 100644 --- a/QLNet/Math/Interpolations/CubicInterpolation.cs +++ b/QLNet/Math/Interpolations/CubicInterpolation.cs @@ -1,17 +1,17 @@ /* Copyright (C) 2008 Siarhei Novik (snovik@gmail.com) - + This file is part of QLNet Project https://github.com/amaggiulli/qlnet QLNet is free software: you can redistribute it and/or modify it under the terms of the QLNet license. You should have received a - copy of the license along with this program; if not, license is + copy of the license along with this program; if not, license is available online at . - + QLNet is a based on QuantLib, a free-software/open-source library for financial quantitative analysts and developers - http://quantlib.org/ The QuantLib license is available online at http://quantlib.org/license.shtml. - + This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the license for more details. @@ -24,7 +24,7 @@ namespace QLNet { /*! Cubic interpolation is fully defined when the ${f_i}$ function values at points ${x_i}$ are supplemented with ${f_i}$ function derivative values. - + Different type of first derivative approximations are implemented, both local and non-local. Local schemes (Fourth-order, Parabolic, Modified Parabolic, Fritsch-Butland, Akima, Kruger) use only $f$ values @@ -39,17 +39,17 @@ monotoniticity of the input (three successive increasing or decreasing values) the interpolating cubic remains monotonic. If the interpolating cubic is already monotonic, the Hyman filter leaves it unchanged preserving all its original features. - + In the case of $C^2$ interpolants the Hyman filter ensures local monotonicity at the expense of the second derivative of the interpolant which will no longer be continuous in the points where the filter has - been applied. + been applied. While some non-linear schemes (Modified Parabolic, Fritsch-Butland, Kruger) are guaranteed to be locally monotone in their original approximation, all other schemes must be filtered according to the Hyman criteria at the expense of their linearity. - + See R. L. Dougherty, A. Edelman, and J. M. Hyman, "Nonnegativity-, Monotonicity-, or Convexity-Preserving CubicSpline and Quintic Hermite Interpolation" @@ -101,7 +101,7 @@ public enum BoundaryCondition { the first four data at the respective end */ Lagrange - }; + }; #endregion // private CoefficientHolder coeffs_; @@ -135,10 +135,10 @@ public class Cubic : IInterpolationFactory { private CubicInterpolation.BoundaryCondition leftType_, rightType_; private double leftValue_, rightValue_; - public Cubic() : this(CubicInterpolation.DerivativeApprox.Kruger, false, + public Cubic() : this(CubicInterpolation.DerivativeApprox.Kruger, false, CubicInterpolation.BoundaryCondition.SecondDerivative, 0.0, CubicInterpolation.BoundaryCondition.SecondDerivative, 0.0) { } - public Cubic(CubicInterpolation.DerivativeApprox da, bool monotonic, + public Cubic(CubicInterpolation.DerivativeApprox da, bool monotonic, CubicInterpolation.BoundaryCondition leftCondition, double leftConditionValue, CubicInterpolation.BoundaryCondition rightCondition, double rightConditionValue) { da_ = da; @@ -191,7 +191,14 @@ public CubicInterpolationImpl(List xBegin, int size, List yBegin a_ = new InitializedList(size - 1); b_ = new InitializedList(size - 1); c_ = new InitializedList(size - 1); - monotonicityAdjustments_ = new InitializedList(size); + monotonicityAdjustments_ = new InitializedList(size); + + if (leftType_ == CubicInterpolation.BoundaryCondition.Lagrange + || rightType_ == CubicInterpolation.BoundaryCondition.Lagrange) { + Utils.QL_REQUIRE(size >= 4, () => + "Lagrange boundary condition requires at least " + + "4 points (" + size.ToString() + " are given)"); + } } public override void update() { @@ -227,10 +234,18 @@ public override void update() { L.setFirstRow(2.0, 1.0); tmp[0] = 3.0*S[0] - leftValue_*dx[0]/2.0; break; - case CubicInterpolation.BoundaryCondition.Periodic: - case CubicInterpolation.BoundaryCondition.Lagrange: - // ignoring end condition value - throw new NotImplementedException("this end condition is not implemented yet"); + case CubicInterpolation.BoundaryCondition.Periodic: + // ignoring end condition value + throw new NotImplementedException("this end condition is not implemented yet"); + case CubicInterpolation.BoundaryCondition.Lagrange: + L.setFirstRow(1.0, 0.0); + tmp[0] = cubicInterpolatingPolynomialDerivative( + this.xBegin_[0], this.xBegin_[1], + this.xBegin_[2], this.xBegin_[3], + this.yBegin_[0], this.yBegin_[1], + this.yBegin_[2], this.yBegin_[3], + this.xBegin_[0]); + break; default: throw new ArgumentException("unknown end condition"); } @@ -252,10 +267,18 @@ public override void update() { L.setLastRow(1.0, 2.0); tmp[size_ - 1] = 3.0 * S[size_ - 2] + rightValue_ * dx[size_ - 2] / 2.0; break; - case CubicInterpolation.BoundaryCondition.Periodic: - case CubicInterpolation.BoundaryCondition.Lagrange: - // ignoring end condition value - throw new NotImplementedException("this end condition is not implemented yet"); + case CubicInterpolation.BoundaryCondition.Periodic: + // ignoring end condition value + throw new NotImplementedException("this end condition is not implemented yet"); + case CubicInterpolation.BoundaryCondition.Lagrange: + L.setLastRow(0.0,1.0); + tmp[size_ - 1] = cubicInterpolatingPolynomialDerivative( + this.xBegin_[size_ - 4], this.xBegin_[size_ - 3], + this.xBegin_[size_ - 2], this.xBegin_[size_ - 1], + this.yBegin_[size_ - 4], this.yBegin_[size_ - 3], + this.yBegin_[size_ - 2], this.yBegin_[size_ - 1], + this.xBegin_[size_ - 1]); + break; default: throw new ArgumentException("unknown end condition"); } @@ -415,8 +438,8 @@ public override void update() { (a_[i-1]/2.0 + dx[i-1] * (b_[i-1]/3.0 + dx[i-1] * c_[i-1]/4.0))); } - } - + } + public override double value(double x) { int j = locate(x); double dx = x-xBegin_[j]; @@ -441,6 +464,20 @@ public override double secondDerivative(double x) { int j = locate(x); double dx = x-xBegin_[j]; return 2.0*b_[j] + 6.0*c_[j]*dx; + } + + private double cubicInterpolatingPolynomialDerivative( + double a, double b, double c, double d, + double u, double v, double w, double z, double x) + { + return (-((((a - c) * (b - c) * (c - x) * z - (a - d) * (b - d) * (d - x) * w) * (a - x + b - x) + + ((a - c) * (b - c) * z - (a - d) * (b - d) * w) * (a - x) * (b - x)) * (a - b) + + ((a - c) * (a - d) * v - (b - c) * (b - d) * u) * (c - d) * (c - x) * (d - x) + + ((a - c) * (a - d) * (a - x) * v - (b - c) * (b - d) * (b - x) * u) + * (c - x + d - x) * (c - d))) / + ((a - b) * (a - c) * (a - d) * (b - c) * (b - d) * (c - d)); } + + } } diff --git a/QLNet/Math/Interpolations/CubicSplineInterpolation.cs b/QLNet/Math/Interpolations/CubicSplineInterpolation.cs deleted file mode 100644 index fcf46f0ce..000000000 --- a/QLNet/Math/Interpolations/CubicSplineInterpolation.cs +++ /dev/null @@ -1,341 +0,0 @@ -/* - Copyright (C) 2008 Andrea Maggiulli - - This file is part of QLNet Project http://www.qlnet.org - - QLNet is free software: you can redistribute it and/or modify it - under the terms of the QLNet license. You should have received a - copy of the license along with this program; if not, license is - available online at . - - QLNet is a based on QuantLib, a free-software/open-source library - for financial quantitative analysts and developers - http://quantlib.org/ - The QuantLib license is available online at http://quantlib.org/license.shtml. - - This program is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS - FOR A PARTICULAR PURPOSE. See the license for more details. -*/ - -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; - -namespace QLNet -{ - public class CoefficientHolder - { - public CoefficientHolder(int n) - { - n_ = n ; - primitiveConst_ = new Array(n - 1); - a_ = new Array(n - 1); - b_ = new Array(n - 1); - c_ = new Array(n - 1); - monotonicityAdjustments_ = new Array(n); - } - - public virtual void Dispose() {} - public int n_; - public Array primitiveConst_, a_, b_, c_; - public Array monotonicityAdjustments_; - }; - - public class CubicSplineInterpolationImpl : Interpolation.templateImpl - { - private bool constrained_; - private CubicSplineInterpolation.BoundaryCondition leftType_, rightType_; - private double leftValue_, rightValue_; - private CoefficientHolder cH_ ; - - public CoefficientHolder getCoefficientHolder() - { - return cH_; - } - - public CubicSplineInterpolationImpl(List xBegin, int size, List yBegin, - CubicSplineInterpolation.BoundaryCondition leftCondition, - double leftConditionValue, - CubicSplineInterpolation.BoundaryCondition rightCondition, - double rightConditionValue, - bool monotonicityConstraint) - : base(xBegin, size, yBegin) - { - cH_ = new CoefficientHolder(size - xBegin.Count); - constrained_ = monotonicityConstraint; - leftType_ = leftCondition; - rightType_ = rightCondition; - leftValue_ = leftConditionValue; - rightValue_ = rightConditionValue; - } - - - public override void update() - { - TridiagonalOperator L = new TridiagonalOperator(cH_.n_); - - Array tmp = new Array(cH_.n_); - var dx = new Array(cH_.n_ - 1); - var S = new Array(cH_.n_ - 1); - - int i=0; - dx[i] = this.xBegin_[i+1] - this.xBegin_[i]; - S[i] = (this.yBegin_[i+1] - this.yBegin_[i])/dx[i]; - for (i=1; i0.0) - { - correction = tmp[i]/Math.Abs(tmp[i]) * - Math.Min(Math.Abs(tmp[i]), - Math.Abs(3.0*S[0])); - } - else - { - correction = 0.0; - } - if (correction!=tmp[i]) - { - tmp[i] = correction; - cH_.monotonicityAdjustments_[i] = true; - } - } - else if (i==cH_.n_-1) - { - if (tmp[i]*S[cH_.n_-2]>0.0) - { - correction = tmp[i]/Math.Abs(tmp[i]) * - Math.Min(Math.Abs(tmp[i]), - Math.Abs(3.0*S[cH_.n_-2])); - } - else - { - correction = 0.0; - } - if (correction!=tmp[i]) - { - tmp[i] = correction; - cH_.monotonicityAdjustments_[i] = true; - } - } - else - { - pm=(S[i-1]*dx[i]+S[i]*dx[i-1])/ - (dx[i-1]+dx[i]); - M = 3.0 * Math.Min(Math.Min(Math.Abs(S[i-1]), - Math.Abs(S[i])), - Math.Abs(pm)); - if (i>1) - { - if ((S[i-1]-S[i-2])*(S[i]-S[i-1])>0.0) - { - pd=(S[i-1]*(2.0*dx[i-1]+dx[i-2]) - -S[i-2]*dx[i-1])/ - (dx[i-2]+dx[i-1]); - if (pm*pd>0.0 && pm*(S[i-1]-S[i-2])>0.0) - { - M = Math.Max(M, 1.5*Math.Min( - Math.Abs(pm),Math.Abs(pd))); - } - } - } - if (i0.0) - { - pu=(S[i]*(2.0*dx[i]+dx[i+1])-S[i+1]*dx[i])/ - (dx[i]+dx[i+1]); - if (pm*pu>0.0 && -pm*(S[i]-S[i-1])>0.0) - { - M = Math.Max(M, 1.5*Math.Min( - Math.Abs(pm),Math.Abs(pu))); - } - } - } - if (tmp[i]*pm>0.0) - { - correction = tmp[i]/Math.Abs(tmp[i]) * - Math.Min(Math.Abs(tmp[i]), M); - } - else - { - correction = 0.0; - } - if (correction!=tmp[i]) - { - tmp[i] = correction; - cH_.monotonicityAdjustments_[i] = true; - } - } - } - } - - for (i=0; i - /// Make second(-last) point an inactive knot - /// - NotAKnot, - /// - /// Match value of end-slope - /// - FirstDerivative, - /// - /// Match value of second derivative at end - /// - SecondDerivative, - /// - /// Match first and second derivative at either end - /// - Periodic, - /// - /// Match end-slope to the slope of the cubic that matches - /// the first four data at the respective end - /// - Lagrange - }; - - private CoefficientHolder coeffs_; - - public CubicSplineInterpolation(List xBegin, int size, List yBegin, - CubicSplineInterpolation.BoundaryCondition leftCondition, - double leftConditionValue, - CubicSplineInterpolation.BoundaryCondition rightCondition, - double rightConditionValue, - bool monotonicityConstraint) - { - impl_ = (Interpolation.Impl) new CubicSplineInterpolationImpl(xBegin, size, yBegin, - leftCondition, - leftConditionValue, - rightCondition, - rightConditionValue, - monotonicityConstraint); - impl_.update(); - //coeffs_ = boost::dynamic_pointer_cast(impl_); - } - - } -} diff --git a/QLNet/Math/Interpolations/FlatExtrapolator2D.cs b/QLNet/Math/Interpolations/FlatExtrapolator2D.cs new file mode 100644 index 000000000..5b5a04540 --- /dev/null +++ b/QLNet/Math/Interpolations/FlatExtrapolator2D.cs @@ -0,0 +1,75 @@ +// Copyright (C) 2008-2016 Andrea Maggiulli (a.maggiulli@gmail.com) +// +// This file is part of QLNet Project https://github.com/amaggiulli/qlnet +// QLNet is free software: you can redistribute it and/or modify it +// under the terms of the QLNet license. You should have received a +// copy of the license along with this program; if not, license is +// available online at . +// +// QLNet is a based on QuantLib, a free-software/open-source library +// for financial quantitative analysts and developers - http://quantlib.org/ +// The QuantLib license is available online at http://quantlib.org/license.shtml. +// +// This program is distributed in the hope that it will be useful, but WITHOUT +// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +// FOR A PARTICULAR PURPOSE. See the license for more details. + +using System.Collections.Generic; + +namespace QLNet +{ + + public class FlatExtrapolator2D : Interpolation2D + { + public FlatExtrapolator2D(Interpolation2D decoratedInterpolation) + { + impl_ = new FlatExtrapolator2DImpl(decoratedInterpolation); + } + + protected class FlatExtrapolator2DImpl: Interpolation2D.Impl + { + public FlatExtrapolator2DImpl(Interpolation2D decoratedInterpolation) + { + decoratedInterp_ = decoratedInterpolation; + calculate(); + } + public double xMin() { return decoratedInterp_.xMin();} + public double xMax() { return decoratedInterp_.xMax();} + public List xValues() {return decoratedInterp_.xValues();} + public int locateX(double x) {return decoratedInterp_.locateX(x);} + public double yMin() {return decoratedInterp_.yMin();} + public double yMax() {return decoratedInterp_.yMax();} + public List yValues() {return decoratedInterp_.yValues();} + public int locateY(double y) {return decoratedInterp_.locateY(y);} + public Matrix zData() {return decoratedInterp_.zData();} + public bool isInRange(double x, double y) {return decoratedInterp_.isInRange(x,y);} + public void update() {decoratedInterp_.update();} + public void calculate() {} + public double value(double x, double y) + { + x = bindX(x); + y = bindY(y); + return decoratedInterp_.value(x,y); + } + + private Interpolation2D decoratedInterp_; + + private double bindX(double x) + { + if(x < xMin()) + return xMin(); + if (x > xMax()) + return xMax(); + return x; + } + private double bindY(double y) + { + if(y < yMin()) + return yMin(); + if (y > yMax()) + return yMax(); + return y; + } + } + } +} diff --git a/QLNet/Math/Interpolations/MixedInterpolation.cs b/QLNet/Math/Interpolations/MixedInterpolation.cs new file mode 100644 index 000000000..0e714a94d --- /dev/null +++ b/QLNet/Math/Interpolations/MixedInterpolation.cs @@ -0,0 +1,256 @@ +// Copyright (C) 2008-2016 Andrea Maggiulli (a.maggiulli@gmail.com) +// +// This file is part of QLNet Project https://github.com/amaggiulli/qlnet +// QLNet is free software: you can redistribute it and/or modify it +// under the terms of the QLNet license. You should have received a +// copy of the license along with this program; if not, license is +// available online at . +// +// QLNet is a based on QuantLib, a free-software/open-source library +// for financial quantitative analysts and developers - http://quantlib.org/ +// The QuantLib license is available online at http://quantlib.org/license.shtml. +// +// This program is distributed in the hope that it will be useful, but WITHOUT +// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +// FOR A PARTICULAR PURPOSE. See the license for more details. +using System; +using System.Collections.Generic; +using System.Linq; + +namespace QLNet +{ + // mixed interpolation between discrete points + public enum Behavior + { + ShareRanges, /*!< Define both interpolations over the + whole range defined by the passed + iterators. This is the default + behavior. */ + SplitRanges /*!< Define the first interpolation over the + first part of the range, and the second + interpolation over the second part. */ + } + + public class MixedInterpolationImpl : Interpolation.templateImpl + where Interpolator1 : IInterpolationFactory,new() + where Interpolator2 : IInterpolationFactory,new() + { + public MixedInterpolationImpl(List xBegin, int xEnd, + List yBegin, int n, + Behavior behavior = Behavior.ShareRanges, + Interpolator1 factory1 = default(Interpolator1), + Interpolator2 factory2 = default(Interpolator2)) + : base(xBegin, xEnd, yBegin, + Math.Max(factory1 == null ? (factory1 = new Interpolator1()).requiredPoints : factory1.requiredPoints, + factory2 == null ? (factory2 = new Interpolator2()).requiredPoints : factory2.requiredPoints)) + + { + n_ = n; + + xBegin2_ = xBegin.GetRange( n_, xBegin.Count); + yBegin2_ = yBegin.GetRange( n_, yBegin.Count ); + + Utils.QL_REQUIRE( xBegin2_.Count < size_,()=> "too large n (" + n + ") for " + size_ + "-element x sequence"); + + switch (behavior) + { + case Behavior.ShareRanges: + interpolation1_ = factory1.interpolate(xBegin_,size_,yBegin_); + interpolation2_ = factory2.interpolate(xBegin_,size_,yBegin_); + break; + case Behavior.SplitRanges: + interpolation1_ = factory1.interpolate(xBegin_,xBegin2_.Count+1,yBegin_); + interpolation2_ = factory2.interpolate(xBegin2_,size_,yBegin2_); + break; + default: + Utils.QL_FAIL("unknown mixed-interpolation behavior: " + behavior); + break; + } + } + + + public override void update() + { + interpolation1_.update(); + interpolation2_.update(); + } + + public override double value(double x) + { + if (x<(xBegin2_.First())) + return interpolation1_.value(x, true); + return interpolation2_.value(x, true); + } + + public override double primitive(double x) + { + if (x<(xBegin2_.First())) + return interpolation1_.primitive(x, true); + return interpolation2_.primitive(x, true) - + interpolation2_.primitive(xBegin2_.First(), true) + + interpolation1_.primitive( xBegin2_.First(), true ); + } + + public override double derivative(double x) + { + if ( x < ( xBegin2_.First() ) ) + return interpolation1_.derivative(x, true); + return interpolation2_.derivative(x, true); + } + + public override double secondDerivative(double x) + { + if ( x < ( xBegin2_.First() ) ) + return interpolation1_.secondDerivative(x, true); + return interpolation2_.secondDerivative(x, true); + } + + public int switchIndex() { return n_; } + + private List xBegin2_; + private List yBegin2_; + private int n_; + private Interpolation interpolation1_, interpolation2_; + + } + + //! mixed linear/cubic interpolation between discrete points + public class MixedLinearCubicInterpolation : Interpolation + { + /*! \pre the \f$ x \f$ values must be sorted. */ + public MixedLinearCubicInterpolation(List xBegin, int xEnd, + List yBegin, int n, + Behavior behavior, + CubicInterpolation.DerivativeApprox da, + bool monotonic, + CubicInterpolation.BoundaryCondition leftC, + double leftConditionValue, + CubicInterpolation.BoundaryCondition rightC, + double rightConditionValue) + { + impl_ = new MixedInterpolationImpl(xBegin, xEnd, yBegin, n, behavior, + new Linear(), + new Cubic(da, monotonic,leftC, leftConditionValue,rightC, rightConditionValue)); + impl_.update(); + } + } + + //! mixed linear/cubic interpolation factory and traits + /*! \ingroup interpolations */ + public class MixedLinearCubic + { + public MixedLinearCubic(int n, + Behavior behavior, + CubicInterpolation.DerivativeApprox da, + bool monotonic = true, + CubicInterpolation.BoundaryCondition leftCondition = QLNet.CubicInterpolation.BoundaryCondition.SecondDerivative, + double leftConditionValue = 0.0, + CubicInterpolation.BoundaryCondition rightCondition = CubicInterpolation.BoundaryCondition.SecondDerivative, + double rightConditionValue = 0.0) + { + n_ = n; + behavior_ = behavior; + da_ = da; + monotonic_ = monotonic; + leftType_ = leftCondition; + rightType_ = rightCondition; + leftValue_ = leftConditionValue; + rightValue_ = rightConditionValue; + } + + Interpolation interpolate(List xBegin, int xEnd,List yBegin) + { + return new MixedLinearCubicInterpolation(xBegin, xEnd, + yBegin, n_, behavior_, + da_, monotonic_, + leftType_, leftValue_, + rightType_, rightValue_); + } + + // fix below + public bool global = true; + public int requiredPoints = 3; + + private int n_; + private Behavior behavior_; + private CubicInterpolation.DerivativeApprox da_; + private bool monotonic_; + private CubicInterpolation.BoundaryCondition leftType_, rightType_; + private double leftValue_, rightValue_; + } + + // convenience classes + + public class MixedLinearCubicNaturalSpline : MixedLinearCubicInterpolation + { + /*! \pre the \f$ x \f$ values must be sorted. */ + public MixedLinearCubicNaturalSpline(List xBegin, int xEnd,List yBegin, int n, + Behavior behavior = Behavior.ShareRanges) + : base(xBegin, xEnd, yBegin, n, behavior, + CubicInterpolation.DerivativeApprox.Spline, false, + CubicInterpolation.BoundaryCondition.SecondDerivative, 0.0, + CubicInterpolation.BoundaryCondition.SecondDerivative, 0.0) + {} + } + + public class MixedLinearMonotonicCubicNaturalSpline : MixedLinearCubicInterpolation + { + /*! \pre the \f$ x \f$ values must be sorted. */ + public MixedLinearMonotonicCubicNaturalSpline(List xBegin, int xEnd,List yBegin, int n, + Behavior behavior = Behavior.ShareRanges) + : base(xBegin, xEnd, yBegin, n, behavior, + CubicInterpolation.DerivativeApprox.Spline, true, + CubicInterpolation.BoundaryCondition.SecondDerivative, 0.0, + CubicInterpolation.BoundaryCondition.SecondDerivative, 0.0) + {} + } + + public class MixedLinearKrugerCubic : MixedLinearCubicInterpolation + { + /*! \pre the \f$ x \f$ values must be sorted. */ + public MixedLinearKrugerCubic(List xBegin, int xEnd,List yBegin, int n, + Behavior behavior = Behavior.ShareRanges) + : base(xBegin, xEnd, yBegin, n, behavior, + CubicInterpolation.DerivativeApprox.Kruger, false, + CubicInterpolation.BoundaryCondition.SecondDerivative, 0.0, + CubicInterpolation.BoundaryCondition.SecondDerivative, 0.0) + {} + } + + public class MixedLinearFritschButlandCubic : MixedLinearCubicInterpolation + { + /*! \pre the \f$ x \f$ values must be sorted. */ + public MixedLinearFritschButlandCubic(List xBegin, int xEnd,List yBegin, int n, + Behavior behavior = Behavior.ShareRanges ) + : base(xBegin, xEnd, yBegin, n, behavior, + CubicInterpolation.DerivativeApprox.FritschButland, false, + CubicInterpolation.BoundaryCondition.SecondDerivative, 0.0, + CubicInterpolation.BoundaryCondition.SecondDerivative, 0.0) + {} + } + + public class MixedLinearParabolic : MixedLinearCubicInterpolation + { + /*! \pre the \f$ x \f$ values must be sorted. */ + public MixedLinearParabolic(List xBegin, int xEnd,List yBegin, int n, + Behavior behavior = Behavior.ShareRanges) + : base(xBegin, xEnd, yBegin, n, behavior, + CubicInterpolation.DerivativeApprox.Parabolic, false, + CubicInterpolation.BoundaryCondition.SecondDerivative, 0.0, + CubicInterpolation.BoundaryCondition.SecondDerivative, 0.0) + {} + } + + public class MixedLinearMonotonicParabolic : MixedLinearCubicInterpolation + { + /*! \pre the \f$ x \f$ values must be sorted. */ + public MixedLinearMonotonicParabolic(List xBegin, int xEnd,List yBegin, int n, + Behavior behavior = Behavior.ShareRanges) + : base(xBegin, xEnd, yBegin, n, behavior, + CubicInterpolation.DerivativeApprox.Parabolic, true, + CubicInterpolation.BoundaryCondition.SecondDerivative, 0.0, + CubicInterpolation.BoundaryCondition.SecondDerivative, 0.0) + {} + } + +} diff --git a/QLNet/Math/Interpolations/convexmonotoneinterpolation.cs b/QLNet/Math/Interpolations/convexmonotoneinterpolation.cs index d807996b7..4fb82f000 100644 --- a/QLNet/Math/Interpolations/convexmonotoneinterpolation.cs +++ b/QLNet/Math/Interpolations/convexmonotoneinterpolation.cs @@ -40,7 +40,7 @@ public ComboHelper(ISectionHelper quadraticHelper, ISectionHelper convMonoHelper quadraticHelper_ = quadraticHelper; convMonoHelper_ = convMonoHelper; if (!(quadraticity < 1.0 && quadraticity > 0.0)) - throw new ApplicationException("Quadratic value must lie between 0 and 1"); + throw new Exception("Quadratic value must lie between 0 and 1"); } public double value(double x) { @@ -402,14 +402,14 @@ public ConvexMonotoneImpl(List xBegin, int size, List yBegin, monotonicity_ = monotonicity; if (!(monotonicity_ >= 0 && monotonicity_ <= 1)) - throw new ApplicationException("Monotonicity must lie between 0 and 1"); + throw new Exception("Monotonicity must lie between 0 and 1"); if(!(quadraticity_ >= 0 && quadraticity_ <= 1)) - throw new ApplicationException("Quadraticity must lie between 0 and 1"); + throw new Exception("Quadraticity must lie between 0 and 1"); if(!(size_ >= 2)) - throw new ApplicationException("Single point provided, not supported by convex " + + throw new Exception("Single point provided, not supported by convex " + "monotone method as first point is ignored"); if(!((size_ - preExistingHelpers.Count) > 1)) - throw new ApplicationException("Too many existing helpers have been supplied"); + throw new Exception("Too many existing helpers have been supplied"); } public override void update() { diff --git a/QLNet/Math/Matrix.cs b/QLNet/Math/Matrix.cs index fb52bd82c..d876e6036 100644 --- a/QLNet/Math/Matrix.cs +++ b/QLNet/Math/Matrix.cs @@ -16,7 +16,7 @@ under the terms of the QLNet license. You should have received a This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the license for more details. -*/ +*/ using System; using System.Linq; using System.Collections.Generic; @@ -98,7 +98,7 @@ public Matrix(Matrix from) { public static Matrix operator /(Matrix m1, double value) { return operValue(ref m1, value, (x, y) => x / y); } private static Matrix operMatrix(ref Matrix m1, ref Matrix m2, Func func) { if (!(m1.rows_ == m2.rows_ && m1.columns_ == m2.columns_)) - throw new ApplicationException("operation on matrices with different sizes (" + + throw new Exception("operation on matrices with different sizes (" + m2.rows_ + "x" + m2.columns_ + ", " + m1.rows_ + "x" + m1.columns_ + ")"); Matrix result = new Matrix(m1.rows_, m1.columns_); @@ -117,7 +117,7 @@ private static Matrix operValue(ref Matrix m1, double value, Func v1begin, List v2begin) { int size1 = v1begin.Count; - if (!(size1>0)) throw new ApplicationException("null first vector"); + if (!(size1>0)) throw new Exception("null first vector"); int size2 = v2begin.Count; - if(!(size2>0)) throw new ApplicationException("null second vector"); + if(!(size2>0)) throw new Exception("null second vector"); Matrix result = new Matrix(size1, size2); @@ -181,19 +181,19 @@ public void swap(int i1, int j1, int i2, int j2) { double t = this[i2, j2]; this[i2, j2] = this[i1, j1]; this[i1, j1] = t; - } - - public override string ToString() - { - String to = string.Empty; + } + + public override string ToString() + { + String to = string.Empty; for (int i=0; i. - - QLNet is a based on QuantLib, a free-software/open-source library - for financial quantitative analysts and developers - http://quantlib.org/ - The QuantLib license is available online at http://quantlib.org/license.shtml. - - This program is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS - FOR A PARTICULAR PURPOSE. See the license for more details. +/* + Copyright (C) 2008 Siarhei Novik (snovik@gmail.com) + Copyright (C) 2008 Toyin Akin (toyin_akin@hotmail.com) + Copyright (C) 2008-2016 Andrea Maggiulli (a.maggiulli@gmail.com) + + This file is part of QLNet Project https://github.com/amaggiulli/qlnet + + QLNet is free software: you can redistribute it and/or modify it + under the terms of the QLNet license. You should have received a + copy of the license along with this program; if not, license is + available online at . + + QLNet is a based on QuantLib, a free-software/open-source library + for financial quantitative analysts and developers - http://quantlib.org/ + The QuantLib license is available online at http://quantlib.org/license.shtml. + + This program is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS + FOR A PARTICULAR PURPOSE. See the license for more details. */ using System; @@ -50,7 +50,7 @@ public double update( ref Vector p, Vector direction, double beta ) while ( !valid ) { if ( icount > 200 ) - throw new ApplicationException( "can't update parameter vector" ); + throw new Exception( "can't update parameter vector" ); diff *= 0.5; icount++; newParams = p + diff * direction; @@ -62,17 +62,17 @@ public double update( ref Vector p, Vector direction, double beta ) //! Tests if params satisfy the constraint public virtual bool test( Vector p ) { return impl_.test( p ); } - - //! Returns upper bound for given parameters - public virtual Vector upperBound(Vector parameters) + + //! Returns upper bound for given parameters + public virtual Vector upperBound(Vector parameters) { - return impl_.upperBound( parameters ); // new Vector( parameters.size(), Double.MaxValue ); - } - - //! Returns lower bound for given parameters - public virtual Vector lowerBound(Vector parameters) + return impl_.upperBound( parameters ); // new Vector( parameters.size(), Double.MaxValue ); + } + + //! Returns lower bound for given parameters + public virtual Vector lowerBound(Vector parameters) { - return impl_.lowerBound( parameters ); // + return impl_.lowerBound( parameters ); // } } @@ -81,16 +81,16 @@ public class NoConstraint : Constraint { private class Impl : IConstraint { - public bool test( Vector v ) { return true; } - public Vector upperBound(Vector parameters) + public bool test( Vector v ) { return true; } + public Vector upperBound(Vector parameters) { - return new Vector( parameters.size(), Double.MaxValue ); - } - - public Vector lowerBound(Vector parameters) + return new Vector( parameters.size(), Double.MaxValue ); + } + + public Vector lowerBound(Vector parameters) { - return new Vector( parameters.size(), Double.MinValue ); - } + return new Vector( parameters.size(), Double.MinValue ); + } } public NoConstraint() : base( new Impl() ) { } }; @@ -113,17 +113,17 @@ public bool test( Vector v ) return false; } return true; - } - - public Vector upperBound(Vector parameters) + } + + public Vector upperBound(Vector parameters) { - return new Vector( parameters.size(), Double.MaxValue ); - } - - public Vector lowerBound(Vector parameters) + return new Vector( parameters.size(), Double.MaxValue ); + } + + public Vector lowerBound(Vector parameters) { - return new Vector( parameters.size(), 0.0 ); - } + return new Vector( parameters.size(), 0.0 ); + } } } @@ -153,17 +153,17 @@ public bool test( Vector v ) return false; } return true; - } - - public Vector upperBound(Vector parameters) - { - return new Vector(parameters.size(), high_); - } - - public Vector lowerBound(Vector parameters) - { - return new Vector(parameters.size(), low_); - } + } + + public Vector upperBound(Vector parameters) + { + return new Vector(parameters.size(), high_); + } + + public Vector lowerBound(Vector parameters) + { + return new Vector(parameters.size(), low_); + } } } @@ -185,80 +185,80 @@ public Impl( Constraint c1, Constraint c2 ) public bool test( Vector p ) { return c1_.test( p ) && c2_.test( p ); - } - - public Vector upperBound(Vector parameters) - { - Vector c1ub = c1_.upperBound(parameters); - Vector c2ub = c2_.upperBound(parameters); - Vector rtrnArray = new Vector(c1ub.size(), 0.0); - - for (int iter = 0; iter < c1ub.size(); iter++) - { - rtrnArray[iter] = Math.Min(c1ub[iter], c2ub[iter]); - } - - return rtrnArray; - } - - public Vector lowerBound(Vector parameters) - { - Vector c1lb = c1_.lowerBound(parameters); - Vector c2lb = c2_.lowerBound(parameters); - Vector rtrnArray = new Vector(c1lb.size(), 0.0); - - for (int iter = 0; iter < c1lb.size(); iter++) - { - rtrnArray[iter] = Math.Max(c1lb[iter], c2lb[iter]); - - } - - return rtrnArray; - } + } + + public Vector upperBound(Vector parameters) + { + Vector c1ub = c1_.upperBound(parameters); + Vector c2ub = c2_.upperBound(parameters); + Vector rtrnArray = new Vector(c1ub.size(), 0.0); + + for (int iter = 0; iter < c1ub.size(); iter++) + { + rtrnArray[iter] = Math.Min(c1ub[iter], c2ub[iter]); + } + + return rtrnArray; + } + + public Vector lowerBound(Vector parameters) + { + Vector c1lb = c1_.lowerBound(parameters); + Vector c2lb = c2_.lowerBound(parameters); + Vector rtrnArray = new Vector(c1lb.size(), 0.0); + + for (int iter = 0; iter < c1lb.size(); iter++) + { + rtrnArray[iter] = Math.Max(c1lb[iter], c2lb[iter]); + + } + + return rtrnArray; + } + } + } + + //! %Constraint imposing i-th argument to be in [low_i,high_i] for all i + public class NonhomogeneousBoundaryConstraint: Constraint + { + private class Impl: IConstraint + { + public Impl(Vector low, Vector high) + { + low_ = low; + high_ = high; + Utils.QL_REQUIRE(low_.Count==high_.Count,()=> "Upper and lower boundaries sizes are inconsistent."); + } + + public bool test(Vector parameters) + { + Utils.QL_REQUIRE(parameters.size() == low_.Count, () => + "Number of parameters and boundaries sizes are inconsistent."); + + for (int i = 0; i < parameters.size(); i++) + { + if ((parameters[i] < low_[i]) || (parameters[i] > high_[i])) + return false; + } + return true; + } + + public Vector upperBound(Vector v) + { + return high_; + } + + public Vector lowerBound(Vector v) + { + return low_; + } + + private Vector low_, high_; } + + public NonhomogeneousBoundaryConstraint(Vector low, Vector high) + : base( new Impl(low, high)) + {} } - - //! %Constraint imposing i-th argument to be in [low_i,high_i] for all i - public class NonhomogeneousBoundaryConstraint: Constraint - { - private class Impl: IConstraint - { - public Impl(Vector low, Vector high) - { - low_ = low; - high_ = high; - Utils.QL_REQUIRE(low_.Count==high_.Count,()=> "Upper and lower boundaries sizes are inconsistent."); - } - - public bool test(Vector parameters) - { - Utils.QL_REQUIRE(parameters.size() == low_.Count, () => - "Number of parameters and boundaries sizes are inconsistent."); - - for (int i = 0; i < parameters.size(); i++) - { - if ((parameters[i] < low_[i]) || (parameters[i] > high_[i])) - return false; - } - return true; - } - - public Vector upperBound(Vector v) - { - return high_; - } - - public Vector lowerBound(Vector v) - { - return low_; - } - - private Vector low_, high_; - } - - public NonhomogeneousBoundaryConstraint(Vector low, Vector high) - : base( new Impl(low, high)) - {} - } -} +} diff --git a/QLNet/Math/Optimization/EndCriteria.cs b/QLNet/Math/Optimization/EndCriteria.cs index abb95d2c9..1e4fc37aa 100644 --- a/QLNet/Math/Optimization/EndCriteria.cs +++ b/QLNet/Math/Optimization/EndCriteria.cs @@ -54,10 +54,10 @@ public EndCriteria(int maxIterations, int? maxStationaryStateIterations, double maxStationaryStateIterations_ = Math.Min((int)(maxIterations/2), (int)(100)); if (!(maxStationaryStateIterations_ > 1)) - throw new ApplicationException("maxStationaryStateIterations_ (" + maxStationaryStateIterations_ + ") must be greater than one"); + throw new Exception("maxStationaryStateIterations_ (" + maxStationaryStateIterations_ + ") must be greater than one"); if (!(maxStationaryStateIterations_ < maxIterations_)) - throw new ApplicationException("maxStationaryStateIterations_ (" + maxStationaryStateIterations_ + ") must be less than maxIterations_ (" + maxIterations_ + ")"); + throw new Exception("maxStationaryStateIterations_ (" + maxStationaryStateIterations_ + ") must be less than maxIterations_ (" + maxIterations_ + ")"); if (gradientNormEpsilon_ == null) gradientNormEpsilon_ = functionEpsilon_; diff --git a/QLNet/Math/Optimization/LineSearch.cs b/QLNet/Math/Optimization/LineSearch.cs index 7b544c879..cde9b3371 100644 --- a/QLNet/Math/Optimization/LineSearch.cs +++ b/QLNet/Math/Optimization/LineSearch.cs @@ -63,7 +63,7 @@ public double update(ref Vector data, Vector direction, double beta, Constraint int icount = 0; while (!valid) { if (icount > 200) - throw new ApplicationException("can't update linesearch"); + throw new Exception("can't update linesearch"); diff *= 0.5; icount++; newParams = data + diff * direction; diff --git a/QLNet/Math/Optimization/ProjectedCostFunction.cs b/QLNet/Math/Optimization/ProjectedCostFunction.cs index 3277554cf..56df3e129 100644 --- a/QLNet/Math/Optimization/ProjectedCostFunction.cs +++ b/QLNet/Math/Optimization/ProjectedCostFunction.cs @@ -43,14 +43,14 @@ public ProjectedCostFunction(CostFunction costFunction, Vector parametersValues, costFunction_ = costFunction; if (!(fixedParameters_.Count==parametersFreedoms_.Count)) - throw new ApplicationException("fixedParameters_.Count!=parametersFreedoms_.Count"); + throw new Exception("fixedParameters_.Count!=parametersFreedoms_.Count"); for (int i =0; i0)) - throw new ApplicationException("numberOfFreeParameters==0"); + throw new Exception("numberOfFreeParameters==0"); } //! \name CostFunction interface @@ -72,7 +72,7 @@ public override Vector values(Vector freeParameters) public Vector project (Vector parameters) { if (!(parameters.Count==parametersFreedoms_.Count)) - throw new ApplicationException("parameters.Count!=parametersFreedoms_.Count"); + throw new Exception("parameters.Count!=parametersFreedoms_.Count"); Vector projectedParameters = new Vector(numberOfFreeParameters_); int i = 0; @@ -87,7 +87,7 @@ public Vector project (Vector parameters) public Vector include(Vector projectedParameters) { if (!(projectedParameters.Count==numberOfFreeParameters_)) - throw new ApplicationException("projectedParameters.Count!=numberOfFreeParameters"); + throw new Exception("projectedParameters.Count!=numberOfFreeParameters"); Vector y = new Vector(fixedParameters_); int i = 0; @@ -100,7 +100,7 @@ public Vector include(Vector projectedParameters) private void mapFreeParameters (Vector parametersValues) { if (!(parametersValues.Count==numberOfFreeParameters_)) - throw new ApplicationException("parametersValues.Count!=numberOfFreeParameters"); + throw new Exception("parametersValues.Count!=numberOfFreeParameters"); int i = 0; for (int j =0; j. - - QLNet is a based on QuantLib, a free-software/open-source library - for financial quantitative analysts and developers - http://quantlib.org/ - The QuantLib license is available online at http://quantlib.org/license.shtml. - - This program is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS - FOR A PARTICULAR PURPOSE. See the license for more details. -*/ -using System; - -namespace QLNet -{ - public static partial class Utils { - // Computes the size of the simplex - public static double computeSimplexSize(InitializedList vertices) - { - Vector center = new Vector(vertices[0].Count, 0); - for (int i = 0; i < vertices.Count; ++i) - center += vertices[i]; - center *= 1 / (double)(vertices.Count); - double result = 0; - for (int i = 0; i < vertices.Count; ++i) - { - Vector temp = vertices[i] - center; - result += Math.Sqrt(Vector.DotProduct(temp, temp)); - } - return result / (double)(vertices.Count); - } - - } - - //! Multi-dimensional simplex class - public class Simplex : OptimizationMethod - { - //! Constructor taking as input the characteristic length - public Simplex(double lambda) - { - lambda_ = lambda; +/* + Copyright (C) 2008 Toyin Akin (toyin_akin@hotmail.com) + * + This file is part of QLNet Project https://github.com/amaggiulli/qlnet + + QLNet is free software: you can redistribute it and/or modify it + under the terms of the QLNet license. You should have received a + copy of the license along with this program; if not, license is + available online at . + + QLNet is a based on QuantLib, a free-software/open-source library + for financial quantitative analysts and developers - http://quantlib.org/ + The QuantLib license is available online at http://quantlib.org/license.shtml. + + This program is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS + FOR A PARTICULAR PURPOSE. See the license for more details. +*/ +using System; + +namespace QLNet +{ + public static partial class Utils { + // Computes the size of the simplex + public static double computeSimplexSize(InitializedList vertices) + { + Vector center = new Vector(vertices[0].Count, 0); + for (int i = 0; i < vertices.Count; ++i) + center += vertices[i]; + center *= 1 / (double)(vertices.Count); + double result = 0; + for (int i = 0; i < vertices.Count; ++i) + { + Vector temp = vertices[i] - center; + result += Math.Sqrt(Vector.DotProduct(temp, temp)); + } + return result / (double)(vertices.Count); + } + + } + + //! Multi-dimensional simplex class + public class Simplex : OptimizationMethod + { + //! Constructor taking as input the characteristic length + public Simplex(double lambda) + { + lambda_ = lambda; } public override EndCriteria.Type minimize( Problem P, EndCriteria endCriteria ) { @@ -153,8 +153,8 @@ public override EndCriteria.Type minimize( Problem P, EndCriteria endCriteria ) { if ( i != iLowest ) { -#if QL_ARRAY_EXPRESSIONS - vertices_[i] = 0.5 * (vertices_[i] + vertices_[iLowest]); +#if QL_ARRAY_EXPRESSIONS + vertices_[i] = 0.5 * (vertices_[i] + vertices_[iLowest]); #else vertices_[i] += vertices_[iLowest]; vertices_[i] *= 0.5; @@ -175,49 +175,49 @@ public override EndCriteria.Type minimize( Problem P, EndCriteria endCriteria ) return EndCriteria.Type.StationaryFunctionValue; } } while ( end == false ); - throw new ApplicationException( "optimization failed: unexpected behaviour" ); + throw new Exception( "optimization failed: unexpected behaviour" ); + } + + private double extrapolate(ref Problem P, int iHighest, ref double factor) + { + + Vector pTry; + do + { + int dimensions = values_.Count - 1; + double factor1 = (1.0 - factor) / dimensions; + double factor2 = factor1 - factor; + // #if QL_ARRAY_EXPRESSIONS + pTry = sum_ * factor1 - vertices_[iHighest] * factor2; + //#else + // // composite expressions fail to compile with gcc 3.4 on windows + // pTry = sum_ * factor1; + // pTry -= vertices_[iHighest] * factor2; + //#endif + factor *= 0.5; + } while (!P.constraint().test(pTry) && Math.Abs(factor) > Const.QL_EPSILON); + if (Math.Abs(factor) <= Const.QL_EPSILON) { + return values_[iHighest]; + } + factor *= 2.0; + double vTry = P.value(pTry); + if (vTry < values_[iHighest]) + { + values_[iHighest] = vTry; + //#if QL_ARRAY_EXPRESSIONS + sum_ += pTry - vertices_[iHighest]; + //#else + // sum_ += pTry; + // sum_ -= vertices_[iHighest]; + //#endif + vertices_[iHighest] = pTry; + } + return vTry; + } - - private double extrapolate(ref Problem P, int iHighest, ref double factor) - { - - Vector pTry; - do - { - int dimensions = values_.Count - 1; - double factor1 = (1.0 - factor) / dimensions; - double factor2 = factor1 - factor; - // #if QL_ARRAY_EXPRESSIONS - pTry = sum_ * factor1 - vertices_[iHighest] * factor2; - //#else - // // composite expressions fail to compile with gcc 3.4 on windows - // pTry = sum_ * factor1; - // pTry -= vertices_[iHighest] * factor2; - //#endif - factor *= 0.5; - } while (!P.constraint().test(pTry) && Math.Abs(factor) > Const.QL_EPSILON); - if (Math.Abs(factor) <= Const.QL_EPSILON) { - return values_[iHighest]; - } - factor *= 2.0; - double vTry = P.value(pTry); - if (vTry < values_[iHighest]) - { - values_[iHighest] = vTry; - //#if QL_ARRAY_EXPRESSIONS - sum_ += pTry - vertices_[iHighest]; - //#else - // sum_ += pTry; - // sum_ -= vertices_[iHighest]; - //#endif - vertices_[iHighest] = pTry; - } - return vTry; - - } - private double lambda_; - private InitializedList vertices_; - private Vector values_; - private Vector sum_; - } + private double lambda_; + private InitializedList vertices_; + private Vector values_; + private Vector sum_; + } } \ No newline at end of file diff --git a/QLNet/Math/Optimization/levenbergmarquardt.cs b/QLNet/Math/Optimization/levenbergmarquardt.cs index 13d192b73..0177f725f 100644 --- a/QLNet/Math/Optimization/levenbergmarquardt.cs +++ b/QLNet/Math/Optimization/levenbergmarquardt.cs @@ -109,17 +109,17 @@ public override EndCriteria.Type minimize( Problem P, EndCriteria endCriteria ) fcn, j); info_ = info; // check requirements & endCriteria evaluation - if ( info == 0 ) throw new ApplicationException( "MINPACK: improper input parameters" ); - //if(info == 6) throw new ApplicationException("MINPACK: ftol is too small. no further " + + if ( info == 0 ) throw new Exception( "MINPACK: improper input parameters" ); + //if(info == 6) throw new Exception("MINPACK: ftol is too small. no further " + // "reduction in the sum of squares is possible."); if ( info != 6 ) ecType = EndCriteria.Type.StationaryFunctionValue; //QL_REQUIRE(info != 5, "MINPACK: number of calls to fcn has reached or exceeded maxfev."); endCriteria.checkMaxIterations( nfev, ref ecType ); - if ( info == 7 ) throw new ApplicationException( "MINPACK: xtol is too small. no further " + + if ( info == 7 ) throw new Exception( "MINPACK: xtol is too small. no further " + "improvement in the approximate " + "solution x is possible." ); - if ( info == 8 ) throw new ApplicationException( "MINPACK: gtol is too small. fvec is " + + if ( info == 8 ) throw new Exception( "MINPACK: gtol is too small. fvec is " + "orthogonal to the columns of the " + "jacobian to machine precision." ); // set problem diff --git a/QLNet/Math/SampledCurve.cs b/QLNet/Math/SampledCurve.cs index ea42a8d33..83efb3e12 100644 --- a/QLNet/Math/SampledCurve.cs +++ b/QLNet/Math/SampledCurve.cs @@ -62,7 +62,7 @@ public void sample(Func f) { /*! \todo replace or complement with a more general function valueAt(spot) */ public double valueAtCenter() { if(empty()) - throw new ApplicationException("empty sampled curve"); + throw new Exception("empty sampled curve"); int jmid = size() / 2; if (size() % 2 == 1) @@ -74,7 +74,7 @@ public double valueAtCenter() { /*! \todo replace or complement with a more general function firstDerivativeAt(spot) */ public double firstDerivativeAtCenter() { if (!(size() >= 3)) - throw new ApplicationException("the size of the curve must be at least 3"); + throw new Exception("the size of the curve must be at least 3"); int jmid = size() / 2; if (size() % 2 == 1) { @@ -87,7 +87,7 @@ public double firstDerivativeAtCenter() { /*! \todo replace or complement with a more general function secondDerivativeAt(spot) */ public double secondDerivativeAtCenter() { if (!(size() >= 4)) - throw new ApplicationException("the size of the curve must be at least 4"); + throw new Exception("the size of the curve must be at least 4"); int jmid = size() / 2; if (size() % 2 == 1) { double deltaPlus = (values_[jmid + 1] - values_[jmid]) / (grid_[jmid + 1] - grid_[jmid]); diff --git a/QLNet/Math/Solvers1d/Newton.cs b/QLNet/Math/Solvers1d/Newton.cs index 15ca607a3..a89489882 100644 --- a/QLNet/Math/Solvers1d/Newton.cs +++ b/QLNet/Math/Solvers1d/Newton.cs @@ -54,7 +54,7 @@ protected override double solveImpl(ISolver1d f, double xAccuracy) { evaluationNumber_++; } - throw new ApplicationException("maximum number of function evaluations (" + maxEvaluations_ + ") exceeded"); + throw new Exception("maximum number of function evaluations (" + maxEvaluations_ + ") exceeded"); } } } diff --git a/QLNet/Math/Solvers1d/Newtonsafe.cs b/QLNet/Math/Solvers1d/Newtonsafe.cs index bbf5137e9..758549604 100644 --- a/QLNet/Math/Solvers1d/Newtonsafe.cs +++ b/QLNet/Math/Solvers1d/Newtonsafe.cs @@ -81,7 +81,7 @@ protected override double solveImpl(ISolver1d f, double xAccuracy) { xh=root_; } - throw new ApplicationException("maximum number of function evaluations (" + maxEvaluations_ + ") exceeded"); + throw new Exception("maximum number of function evaluations (" + maxEvaluations_ + ") exceeded"); } } } diff --git a/QLNet/Math/Vector.cs b/QLNet/Math/Vector.cs index ef2477c4c..c21d70a11 100644 --- a/QLNet/Math/Vector.cs +++ b/QLNet/Math/Vector.cs @@ -103,7 +103,7 @@ public Vector(List from) : this(from.Count) { internal static Vector operVector(Vector v1, Vector v2, Func func) { if (v1.Count != v2.Count) - throw new ApplicationException("operation on vectors with different sizes (" + v1.Count + ", " + v2.Count); + throw new Exception("operation on vectors with different sizes (" + v1.Count + ", " + v2.Count); Vector temp = new Vector(v1.Count); for (int i = 0; i < v1.Count; i++) @@ -119,7 +119,7 @@ private static Vector operValue(Vector v1, double value, Func result[i] = Math.Sqrt(v[i])); return result; - } - - public static Vector Abs( Vector v ) - { - Vector result = new Vector( v.size() ); - result.ForEach( ( i, x ) => result[i] = Math.Abs( v[i] ) ); - return result; + } + + public static Vector Abs( Vector v ) + { + Vector result = new Vector( v.size() ); + result.ForEach( ( i, x ) => result[i] = Math.Abs( v[i] ) ); + return result; } public void swap(int i1, int i2) { diff --git a/QLNet/Math/beta.cs b/QLNet/Math/beta.cs index 87af464cf..3d5b27116 100644 --- a/QLNet/Math/beta.cs +++ b/QLNet/Math/beta.cs @@ -62,7 +62,7 @@ public static double betaContinuedFraction(double a, double b, double x, double if (Math.Abs(del-1.0) < accuracy) return result; } - throw new ApplicationException("a or b too big, or maxIteration too small in betacf"); + throw new Exception("a or b too big, or maxIteration too small in betacf"); } /*! Incomplete Beta function @@ -76,8 +76,8 @@ public static double incompleteBetaFunction(double a, double b, double x) { } public static double incompleteBetaFunction(double a, double b, double x, double accuracy, int maxIteration) { - if (!(a > 0.0)) throw new ApplicationException("a must be greater than zero"); - if (!(b > 0.0)) throw new ApplicationException("b must be greater than zero"); + if (!(a > 0.0)) throw new Exception("a must be greater than zero"); + if (!(b > 0.0)) throw new Exception("b must be greater than zero"); if (x == 0.0) @@ -85,7 +85,7 @@ public static double incompleteBetaFunction(double a, double b, double x, double else if (x == 1.0) return 1.0; else - if (!(x>0.0 && x<1.0)) throw new ApplicationException("x must be in [0,1]"); + if (!(x>0.0 && x<1.0)) throw new Exception("x must be in [0,1]"); double result = Math.Exp(GammaFunction.logValue(a+b) - GammaFunction.logValue(a) - GammaFunction.logValue(b) + diff --git a/QLNet/Math/integrals/Integral.cs b/QLNet/Math/integrals/Integral.cs index 5c63b6dba..2a6aaf4ab 100644 --- a/QLNet/Math/integrals/Integral.cs +++ b/QLNet/Math/integrals/Integral.cs @@ -32,7 +32,7 @@ public Integrator(double? absoluteAccuracy, int maxEvaluations) { maxEvaluations_ = maxEvaluations; if ( absoluteAccuracy != null) if (!(absoluteAccuracy > ((Double.Epsilon)))) - throw new ApplicationException("required tolerance (" + absoluteAccuracy + ") not allowed. It must be > " + Double.Epsilon); + throw new Exception("required tolerance (" + absoluteAccuracy + ") not allowed. It must be > " + Double.Epsilon); } public double value(Func f, double a, double b) { diff --git a/QLNet/Math/integrals/Segmentintegral.cs b/QLNet/Math/integrals/Segmentintegral.cs index 0d0a94355..163cb8ee9 100644 --- a/QLNet/Math/integrals/Segmentintegral.cs +++ b/QLNet/Math/integrals/Segmentintegral.cs @@ -45,7 +45,7 @@ public SegmentIntegral(int intervals) intervals_ = intervals; if (!(intervals > 0)) - throw new ApplicationException("at least 1 interval needed, 0 given"); + throw new Exception("at least 1 interval needed, 0 given"); } // inline and template definitions diff --git a/QLNet/Math/integrals/gaussianorthogonalpolynomial.cs b/QLNet/Math/integrals/gaussianorthogonalpolynomial.cs index 34ca4372f..befb52aae 100644 --- a/QLNet/Math/integrals/gaussianorthogonalpolynomial.cs +++ b/QLNet/Math/integrals/gaussianorthogonalpolynomial.cs @@ -68,7 +68,7 @@ public GaussLaguerrePolynomial() : this(0.0) { } public GaussLaguerrePolynomial(double s) { s_ = s; if (!(s > -1.0)) - throw new ApplicationException("s must be bigger than -1"); + throw new Exception("s must be bigger than -1"); } public override double mu_0() { return Math.Exp(GammaFunction.logValue(s_+1)); } @@ -85,7 +85,7 @@ public GaussHermitePolynomial() : this(0.0) { } public GaussHermitePolynomial(double mu) { mu_ = mu; if (!(mu > -0.5)) - throw new ApplicationException("mu must be bigger than -0.5"); + throw new Exception("mu must be bigger than -0.5"); } public override double mu_0() { return Math.Exp(GammaFunction.logValue(mu_+0.5)); } @@ -104,11 +104,11 @@ public GaussJacobiPolynomial(double alpha, double beta) { beta_ = beta; if (!(alpha_+beta_ > -2.0)) - throw new ApplicationException("alpha+beta must be bigger than -2"); + throw new Exception("alpha+beta must be bigger than -2"); if (!(alpha_ > -1.0)) - throw new ApplicationException("alpha must be bigger than -1"); + throw new Exception("alpha must be bigger than -1"); if (!(beta_ > -1.0)) - throw new ApplicationException("beta must be bigger than -1"); + throw new Exception("beta must be bigger than -1"); } public override double mu_0() { @@ -123,7 +123,7 @@ public override double alpha(int i) { if (denom == 0) { if (num != 0) { - throw new ApplicationException("can't compute a_k for jacobi integration\n"); + throw new Exception("can't compute a_k for jacobi integration\n"); } else { // l'Hospital @@ -131,7 +131,7 @@ public override double alpha(int i) { denom= 2*(2.0*i+alpha_+beta_+1); if(denom == 0) - throw new ApplicationException("can't compute a_k for jacobi integration\n"); + throw new Exception("can't compute a_k for jacobi integration\n"); } } @@ -144,14 +144,14 @@ public override double beta(int i) { if (denom == 0) { if (num != 0) { - throw new ApplicationException("can't compute b_k for jacobi integration\n"); + throw new Exception("can't compute b_k for jacobi integration\n"); } else { // l'Hospital num = 4.0*i*(i+beta_)* (2.0*i+2*alpha_+beta_); denom= 2.0*(2.0*i+alpha_+beta_); denom*=denom-1; if(denom == 0) - throw new ApplicationException("can't compute b_k for jacobi integration\n"); + throw new Exception("can't compute b_k for jacobi integration\n"); } } return num / denom; diff --git a/QLNet/Math/integrals/simpsonintegral.cs b/QLNet/Math/integrals/simpsonintegral.cs index 38ac2413f..38ad57f0d 100644 --- a/QLNet/Math/integrals/simpsonintegral.cs +++ b/QLNet/Math/integrals/simpsonintegral.cs @@ -48,7 +48,7 @@ protected override double integrate (Func f, double a, double b) adjI = newAdjI; i++; } while (i < maxEvaluations()); - throw new ApplicationException("max number of iterations reached"); + throw new Exception("max number of iterations reached"); } } } diff --git a/QLNet/Math/integrals/trapezoidintegral.cs b/QLNet/Math/integrals/trapezoidintegral.cs index 9ce281836..ec8c393b7 100644 --- a/QLNet/Math/integrals/trapezoidintegral.cs +++ b/QLNet/Math/integrals/trapezoidintegral.cs @@ -58,7 +58,7 @@ protected override double integrate (Func f, double a, double b) I = newI; i++; } while (i < maxEvaluations()); - throw new ApplicationException("max number of iterations reached"); + throw new Exception("max number of iterations reached"); } } diff --git a/QLNet/Math/linearleastsquaresregression.cs b/QLNet/Math/linearleastsquaresregression.cs index b0a2c1414..f9f1f35de 100644 --- a/QLNet/Math/linearleastsquaresregression.cs +++ b/QLNet/Math/linearleastsquaresregression.cs @@ -53,8 +53,8 @@ public LinearLeastSquaresRegression(List x, List y, List= v.Count)) throw new ApplicationException("sample set is too small"); + if (x.Count != y.Count) throw new Exception("sample set need to be of the same size"); + if (!(x.Count >= v.Count)) throw new Exception("sample set is too small"); int i; int n = x.Count; diff --git a/QLNet/Math/matrixutilities/choleskydecomposition.cs b/QLNet/Math/matrixutilities/choleskydecomposition.cs index 275b310dc..ea8254a7e 100644 --- a/QLNet/Math/matrixutilities/choleskydecomposition.cs +++ b/QLNet/Math/matrixutilities/choleskydecomposition.cs @@ -24,7 +24,7 @@ public static Matrix CholeskyDecomposition(Matrix S, bool flexible) { int i, j, size = S.rows(); if(size != S.columns()) - throw new ApplicationException("input matrix is not a square matrix"); + throw new Exception("input matrix is not a square matrix"); #if QL_EXTRA_SAFETY_CHECKS for (i=0; i 0.0)) - throw new ApplicationException("input matrix is not positive definite"); + throw new Exception("input matrix is not positive definite"); // To handle positive semi-definite matrices take the // square root of sum if positive, else zero. result[i,i] = Math.Sqrt(Math.Max(sum, 0.0)); diff --git a/QLNet/Math/matrixutilities/pseudosqrt.cs b/QLNet/Math/matrixutilities/pseudosqrt.cs index fd4724981..ff0b07671 100644 --- a/QLNet/Math/matrixutilities/pseudosqrt.cs +++ b/QLNet/Math/matrixutilities/pseudosqrt.cs @@ -28,7 +28,7 @@ public enum SalvagingAlgorithm { public static void normalizePseudoRoot(Matrix matrix, Matrix pseudo) { int size = matrix.rows(); if (size != pseudo.rows()) - throw new ApplicationException("matrix/pseudo mismatch: matrix rows are " + size + + throw new Exception("matrix/pseudo mismatch: matrix rows are " + size + " while pseudo rows are " + pseudo.columns()); int pseudoCols = pseudo.columns(); @@ -65,7 +65,7 @@ public HypersphereCostFunction(Matrix targetMatrix, Vector targetVariance, bool } public override Vector values(Vector a) { - throw new ApplicationException("values method not implemented"); + throw new Exception("values method not implemented"); } public override double value(Vector x) { @@ -254,7 +254,7 @@ private static double normInf(Matrix M) { private static Matrix projectToUnitDiagonalMatrix(Matrix M) { int size = M.rows(); if (size != M.columns()) - throw new ApplicationException("matrix not square"); + throw new Exception("matrix not square"); Matrix result = new Matrix(M); for (int i=0; i=-1e-16)) - throw new ApplicationException("negative eigenvalue(s) (" + jd.eigenvalues()[size-1] + ")"); + throw new Exception("negative eigenvalue(s) (" + jd.eigenvalues()[size-1] + ")"); result = MatrixUtilities.CholeskyDecomposition(matrix, true); break; @@ -415,7 +415,7 @@ public static Matrix pseudoSqrt(Matrix matrix, SalvagingAlgorithm sa) { break; default: - throw new ApplicationException("unknown salvaging algorithm"); + throw new Exception("unknown salvaging algorithm"); } return result; @@ -432,17 +432,17 @@ public static Matrix rankReducedSqrt(Matrix matrix, checkSymmetry(matrix); #else if (size != matrix.columns()) - throw new ApplicationException("non square matrix: " + size + " rows, " + matrix.columns() + " columns"); + throw new Exception("non square matrix: " + size + " rows, " + matrix.columns() + " columns"); #endif if (!(componentRetainedPercentage > 0.0)) - throw new ApplicationException("no eigenvalues retained"); + throw new Exception("no eigenvalues retained"); if (!(componentRetainedPercentage <= 1.0)) - throw new ApplicationException("percentage to be retained > 100%"); + throw new Exception("percentage to be retained > 100%"); if (!(maxRank >= 1)) - throw new ApplicationException("max rank required < 1"); + throw new Exception("max rank required < 1"); // spectral (a.k.a Principal Component) analysis SymmetricSchurDecomposition jd = new SymmetricSchurDecomposition(matrix); @@ -454,7 +454,7 @@ public static Matrix rankReducedSqrt(Matrix matrix, case SalvagingAlgorithm.None: // eigenvalues are sorted in decreasing order if (!(eigenValues[size - 1] >= -1e-16)) - throw new ApplicationException("negative eigenvalue(s) (" + eigenValues[size - 1] + ")"); + throw new Exception("negative eigenvalue(s) (" + eigenValues[size - 1] + ")"); break; case SalvagingAlgorithm.Spectral: // negative eigenvalues set to zero @@ -471,7 +471,7 @@ public static Matrix rankReducedSqrt(Matrix matrix, } break; default: - throw new ApplicationException("unknown or invalid salvaging algorithm"); + throw new Exception("unknown or invalid salvaging algorithm"); } diff --git a/QLNet/Math/matrixutilities/symmetricschurdecomposition.cs b/QLNet/Math/matrixutilities/symmetricschurdecomposition.cs index 185d2562d..ca456c23f 100644 --- a/QLNet/Math/matrixutilities/symmetricschurdecomposition.cs +++ b/QLNet/Math/matrixutilities/symmetricschurdecomposition.cs @@ -48,9 +48,9 @@ public SymmetricSchurDecomposition(Matrix s) { eigenVectors_ = new Matrix(s.rows(), s.columns(), 0.0); if (!(s.rows() > 0 && s.columns() > 0)) - throw new ApplicationException( "null matrix given"); + throw new Exception( "null matrix given"); if (s.rows()!=s.columns()) - throw new ApplicationException( "input matrix must be square"); + throw new Exception( "input matrix must be square"); int size = s.rows(); for (int q=0; q>(ls, 1.0); int32Sequence_ = new InitializedList(dimensionality); - if (!(dimensionality>0)) throw new ApplicationException("dimensionality must be greater than 0"); + if (!(dimensionality>0)) throw new Exception("dimensionality must be greater than 0"); } //public RandomSequenceGenerator(int dimensionality, long seed = 0) { diff --git a/QLNet/Math/randomnumbers/sobolrsg.cs b/QLNet/Math/randomnumbers/sobolrsg.cs index 926ee6449..da1bca237 100644 --- a/QLNet/Math/randomnumbers/sobolrsg.cs +++ b/QLNet/Math/randomnumbers/sobolrsg.cs @@ -1,21 +1,21 @@ -/* - Copyright (C) 2008 Siarhei Novik (snovik@gmail.com) - Copyright (C) 2008-2016 Andrea Maggiulli (a.maggiulli@gmail.com) - - This file is part of QLNet Project https://github.com/amaggiulli/qlnet - - QLNet is free software: you can redistribute it and/or modify it - under the terms of the QLNet license. You should have received a - copy of the license along with this program; if not, license is - available online at . - - QLNet is a based on QuantLib, a free-software/open-source library - for financial quantitative analysts and developers - http://quantlib.org/ - The QuantLib license is available online at http://quantlib.org/license.shtml. - - This program is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS - FOR A PARTICULAR PURPOSE. See the license for more details. +/* + Copyright (C) 2008 Siarhei Novik (snovik@gmail.com) + Copyright (C) 2008-2016 Andrea Maggiulli (a.maggiulli@gmail.com) + + This file is part of QLNet Project https://github.com/amaggiulli/qlnet + + QLNet is free software: you can redistribute it and/or modify it + under the terms of the QLNet license. You should have received a + copy of the license along with this program; if not, license is + available online at . + + QLNet is a based on QuantLib, a free-software/open-source library + for financial quantitative analysts and developers - http://quantlib.org/ + The QuantLib license is available online at http://quantlib.org/license.shtml. + + This program is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS + FOR A PARTICULAR PURPOSE. See the license for more details. */ using System; using System.Collections.Generic; @@ -23,76 +23,76 @@ under the terms of the QLNet license. You should have received a namespace QLNet { //! Sobol low-discrepancy sequence generator - /*! A Gray code counter and bitwise operations are used for very - fast sequence generation. - - The implementation relies on primitive polynomials modulo two - from the book "Monte Carlo Methods in Finance" by Peter - Jдckel. - - 21 200 primitive polynomials modulo two are provided in QuantLib. - Jдckel has calculated 8 129 334 polynomials: if you need that many - dimensions you can replace the primitivepolynomials.c file included - in QuantLib with the one provided in the CD of the "Monte Carlo - Methods in Finance" book. - - The choice of initialization numbers (also know as free direction - integers) is crucial for the homogeneity properties of the sequence. - Sobol defines two homogeneity properties: Property A and Property A'. - - The unit initialization numbers suggested in "Numerical - Recipes in C", 2nd edition, by Press, Teukolsky, Vetterling, - and Flannery (section 7.7) fail the test for Property A even - for low dimensions. - - Bratley and Fox published coefficients of the free direction - integers up to dimension 40, crediting unpublished work of - Sobol' and Levitan. See Bratley, P., Fox, B.L. (1988) - "Algorithm 659: Implementing Sobol's quasirandom sequence - generator," ACM Transactions on Mathematical Software - 14:88-100. These values satisfy Property A for d<=20 and d = - 23, 31, 33, 34, 37; Property A' holds for d<=6. - - Jдckel provides in his book (section 8.3) initialization - numbers up to dimension 32. Coefficients for d<=8 are the same - as in Bradley-Fox, so Property A' holds for d<=6 but Property - A holds for d<=32. - - The implementation of Lemieux, Cieslak, and Luttmer includes - coefficients of the free direction integers up to dimension - 360. Coefficients for d<=40 are the same as in Bradley-Fox. - For dimension 40( bits_ ); - if ( !( dimensionality > 0 ) ) throw new ApplicationException( "dimensionality must be greater than 0" ); + if ( !( dimensionality > 0 ) ) throw new Exception( "dimensionality must be greater than 0" ); if ( !( dimensionality <= PPMT_MAX_DIM ) ) - throw new ApplicationException( "dimensionality " + dimensionality + " exceeds the number of available " + throw new Exception( "dimensionality " + dimensionality + " exceeds the number of available " + "primitive polynomials modulo two (" + PPMT_MAX_DIM + ")" ); // initializes coefficient array of the k-th primitive polynomial @@ -421,20 +421,20 @@ public SobolRsg( int dimensionality, ulong seed, DirectionIntegers directionInte } // in case one needs to check the directionIntegers used - /* bool printDirectionIntegers = false; - if (printDirectionIntegers) { - std::ofstream outStream("directionIntegers.txt"); - for (k=0; k nextInt32Sequence() // increment the counter sequenceCounter_++; // did we overflow? - if ( sequenceCounter_ == 0 ) throw new ApplicationException( "period exceeded" ); + if ( sequenceCounter_ == 0 ) throw new Exception( "period exceeded" ); // instead of using the counter n as new unique generating integer // for the n-th draw use the Gray code G(n) as proposed @@ -515,4 +515,4 @@ public IRNG factory( int dimensionality, ulong seed ) } #endregion } -} +} diff --git a/QLNet/Math/statistics/gaussianstatistics.cs b/QLNet/Math/statistics/gaussianstatistics.cs index 6941434f7..d4d484ac1 100644 --- a/QLNet/Math/statistics/gaussianstatistics.cs +++ b/QLNet/Math/statistics/gaussianstatistics.cs @@ -99,7 +99,7 @@ public double gaussianRegret(double target) { /*! \pre percentile must be in range (0%-100%) extremes excluded */ public double gaussianPercentile(double percentile) { if (!(percentile > 0.0 && percentile < 1.0)) - throw new ApplicationException("percentile (" + percentile + ") must be in (0.0, 1.0)"); + throw new Exception("percentile (" + percentile + ") must be in (0.0, 1.0)"); InverseCumulativeNormal gInverse = new InverseCumulativeNormal(mean(), standardDeviation()); return gInverse.value(percentile); @@ -109,7 +109,7 @@ public double gaussianPercentile(double percentile) { //! gaussian-assumption Potential-Upside at a given percentile public double gaussianPotentialUpside(double percentile) { if (!(percentile<1.0 && percentile>=0.9)) - throw new ApplicationException("percentile (" + percentile + ") out of range [0.9, 1)"); + throw new Exception("percentile (" + percentile + ") out of range [0.9, 1)"); double result = gaussianPercentile(percentile); // potential upside must be a gain, i.e., floored at 0.0 @@ -119,7 +119,7 @@ public double gaussianPotentialUpside(double percentile) { //! gaussian-assumption Value-At-Risk at a given percentile public double gaussianValueAtRisk(double percentile) { if (!(percentile<1.0 && percentile>=0.9)) - throw new ApplicationException("percentile (" + percentile + ") out of range [0.9, 1)"); + throw new Exception("percentile (" + percentile + ") out of range [0.9, 1)"); double result = gaussianPercentile(1.0-percentile); // VAR must be a loss @@ -144,7 +144,7 @@ Also know as conditional value-at-risk. */ public double gaussianExpectedShortfall(double percentile) { if (!(percentile<1.0 && percentile>=0.9)) - throw new ApplicationException("percentile (" + percentile + ") out of range [0.9, 1)"); + throw new Exception("percentile (" + percentile + ") out of range [0.9, 1)"); double m = this.mean(); double std = this.standardDeviation(); diff --git a/QLNet/Math/statistics/generalstatistics.cs b/QLNet/Math/statistics/generalstatistics.cs index 61b108197..ad49e864d 100644 --- a/QLNet/Math/statistics/generalstatistics.cs +++ b/QLNet/Math/statistics/generalstatistics.cs @@ -72,13 +72,13 @@ public class GeneralStatistics : IGeneralStatistics { /*! returns the minimum sample value */ public double min() { - if (!(samples() > 0)) throw new ApplicationException("empty sample set"); + if (!(samples() > 0)) throw new Exception("empty sample set"); return samples_.Min>(x => x.Key); } /*! returns the maximum sample value */ public double max() { - if (!(samples() > 0)) throw new ApplicationException("empty sample set"); + if (!(samples() > 0)) throw new Exception("empty sample set"); return samples_.Max>(x => x.Key); } @@ -86,7 +86,7 @@ public double max() { //! adds a datum to the set, possibly with a weight public void add(double value) { add(value, 1); } public void add(double value, double weight) { - if (!(weight>=0.0)) throw new ApplicationException("negative weight not allowed"); + if (!(weight>=0.0)) throw new Exception("negative weight not allowed"); samples_.Add(new KeyValuePair(value,weight)); sorted_ = false; @@ -122,7 +122,7 @@ public double weightSum() { public double mean() { if (mean_ == null) { int N = samples(); - if (!(samples() > 0)) throw new ApplicationException("empty sample set"); + if (!(samples() > 0)) throw new Exception("empty sample set"); // eat our own dog food mean_ = expectationValue(x => x.Key * x.Value, x => true).Key; } @@ -139,7 +139,7 @@ square root of the variance. */ public double variance() { if (variance_ == null) { int N = samples(); - if (!(N > 1)) throw new ApplicationException("sample number <=1, unsufficient"); + if (!(N > 1)) throw new Exception("sample number <=1, unsufficient"); // Subtract the mean and square. Repeat on the whole range. // Hopefully, the whole thing will be inlined in a single loop. double s2 = expectationValue(x => Math.Pow(x.Key * x.Value - mean(), 2), x => true).Key; @@ -158,7 +158,7 @@ public double variance() { public double skewness() { if (skewness_ == null) { int N = samples(); - if (!(N > 2)) throw new ApplicationException("sample number <=2, unsufficient"); + if (!(N > 2)) throw new Exception("sample number <=2, unsufficient"); double x = expectationValue(y => Math.Pow(y.Key * y.Value - mean(), 3), y => true).Key; double sigma = standardDeviation(); @@ -177,7 +177,7 @@ public double skewness() { public double kurtosis() { if (kurtosis_ == null) { int N = samples(); - if (!(N > 3)) throw new ApplicationException("sample number <=3, unsufficient"); + if (!(N > 3)) throw new Exception("sample number <=3, unsufficient"); double x = expectationValue(y => Math.Pow(y.Key * y.Value - mean(), 4), y => true).Key; double sigma2 = variance(); @@ -224,10 +224,10 @@ such that public double percentile(double percent) { if (!(percent > 0.0 && percent <= 1.0)) - throw new ApplicationException("percentile (" + percent + ") must be in (0.0, 1.0]"); + throw new Exception("percentile (" + percent + ") must be in (0.0, 1.0]"); double sampleWeight = weightSum(); - if (!(sampleWeight > 0)) throw new ApplicationException("empty sample set"); + if (!(sampleWeight > 0)) throw new Exception("empty sample set"); sort(); @@ -245,10 +245,10 @@ public double percentile(double percent) { */ public double topPercentile(double percent) { if (!(percent > 0.0 && percent <= 1.0)) - throw new ApplicationException("percentile (" + percent + ") must be in (0.0, 1.0]"); + throw new Exception("percentile (" + percent + ") must be in (0.0, 1.0]"); double sampleWeight = weightSum(); - if (!(sampleWeight > 0)) throw new ApplicationException("empty sample set"); + if (!(sampleWeight > 0)) throw new Exception("empty sample set"); sort(); diff --git a/QLNet/Math/statistics/incrementalstatistics.cs b/QLNet/Math/statistics/incrementalstatistics.cs index b4429faf1..2b77d5746 100644 --- a/QLNet/Math/statistics/incrementalstatistics.cs +++ b/QLNet/Math/statistics/incrementalstatistics.cs @@ -53,7 +53,7 @@ public KeyValuePair expectationValue(Func0.0)) throw new ApplicationException("sampleWeight_=0, insufficient"); + if (!(sampleWeight_>0.0)) throw new Exception("sampleWeight_=0, insufficient"); return sum_/sampleWeight_; } @@ -62,15 +62,15 @@ public double mean() { x-\langle x \rangle \right)^2 \right\rangle. \f] */ public double variance() { - if (!(sampleWeight_>0.0)) throw new ApplicationException("sampleWeight_=0, insufficient"); - if (!(sampleNumber_>1)) throw new ApplicationException("sample number <=1, insufficient"); + if (!(sampleWeight_>0.0)) throw new Exception("sampleWeight_=0, insufficient"); + if (!(sampleNumber_>1)) throw new Exception("sample number <=1, insufficient"); double m = mean(); double v = quadraticSum_/sampleWeight_; v -= m*m; v *= sampleNumber_/(sampleNumber_-1.0); - if (!(v >= 0.0)) throw new ApplicationException("negative variance (" + v + ")"); + if (!(v >= 0.0)) throw new Exception("negative variance (" + v + ")"); return v; } @@ -85,11 +85,11 @@ public double variance() { */ public double downsideVariance() { if (downsideSampleWeight_==0.0) { - if (!(sampleWeight_>0.0)) throw new ApplicationException("sampleWeight_=0, insufficient"); + if (!(sampleWeight_>0.0)) throw new Exception("sampleWeight_=0, insufficient"); return 0.0; } - if (!(downsideSampleNumber_>1)) throw new ApplicationException("sample number below zero <=1, insufficient"); + if (!(downsideSampleNumber_>1)) throw new Exception("sample number below zero <=1, insufficient"); return (downsideSampleNumber_/(downsideSampleNumber_-1.0))* (downsideQuadraticSum_ /downsideSampleWeight_); } @@ -99,7 +99,7 @@ public double downsideVariance() { * square root of the ratio of the variance to the number of samples. */ public double errorEstimate() { double var = variance(); - if (!(samples() > 0)) throw new ApplicationException("empty sample set"); + if (!(samples() > 0)) throw new Exception("empty sample set"); return Math.Sqrt(var/samples()); } @@ -109,7 +109,7 @@ public double errorEstimate() { The above evaluates to 0 for a Gaussian distribution. */ public double skewness() { - if (!(sampleNumber_>2)) throw new ApplicationException("sample number <=2, insufficient"); + if (!(sampleNumber_>2)) throw new Exception("sample number <=2, insufficient"); double s = standardDeviation(); if (s==0.0) return 0.0; @@ -131,7 +131,7 @@ public double skewness() { The above evaluates to 0 for a Gaussian distribution. */ public double kurtosis() { - if (!(sampleNumber_>3)) throw new ApplicationException("sample number <=3, insufficient"); + if (!(sampleNumber_>3)) throw new Exception("sample number <=3, insufficient"); double m = mean(); double v = variance(); @@ -156,13 +156,13 @@ public double kurtosis() { /*! returns the minimum sample value */ public double min() { - if (!(samples() > 0)) throw new ApplicationException("empty sample set"); + if (!(samples() > 0)) throw new Exception("empty sample set"); return min_; } /*! returns the maximum sample value */ public double max() { - if (!(samples() > 0)) throw new ApplicationException("empty sample set"); + if (!(samples() > 0)) throw new Exception("empty sample set"); return max_; } @@ -176,11 +176,11 @@ public double max() { /*! \pre weight must be positive or null */ public void add(double value) { add(value, 1); } public void add(double value, double weight) { - if (!(weight>=0.0)) throw new ApplicationException("negative weight (" + weight + ") not allowed"); + if (!(weight>=0.0)) throw new Exception("negative weight (" + weight + ") not allowed"); int oldSamples = sampleNumber_; sampleNumber_++; - if (!(sampleNumber_ > oldSamples)) throw new ApplicationException("maximum number of samples reached"); + if (!(sampleNumber_ > oldSamples)) throw new Exception("maximum number of samples reached"); sampleWeight_ += weight; diff --git a/QLNet/Math/statistics/riskstatistics.cs b/QLNet/Math/statistics/riskstatistics.cs index 152353b4f..6523f7368 100644 --- a/QLNet/Math/statistics/riskstatistics.cs +++ b/QLNet/Math/statistics/riskstatistics.cs @@ -91,14 +91,14 @@ public double regret(double target) { z => z.Key < target); double x = result.Key; int N = result.Value; - if (!(N > 1)) throw new ApplicationException("samples under target <= 1, unsufficient"); + if (!(N > 1)) throw new Exception("samples under target <= 1, unsufficient"); return (N/(N-1.0))*x; } //! potential upside (the reciprocal of VAR) at a given percentile public double potentialUpside(double centile) { if (!(centile < 1.0 && centile >= 0.9)) - throw new ApplicationException("percentile (" + centile + ") out of range [0.9, 1)"); + throw new Exception("percentile (" + centile + ") out of range [0.9, 1)"); // potential upside must be a gain, i.e., floored at 0.0 return Math.Max(percentile(centile), 0.0); @@ -107,7 +107,7 @@ public double potentialUpside(double centile) { //! value-at-risk at a given percentile public double valueAtRisk(double centile) { if (!(centile < 1.0 && centile >= 0.9)) - throw new ApplicationException("percentile (" + centile + ") out of range [0.9, 1)"); + throw new Exception("percentile (" + centile + ") out of range [0.9, 1)"); // must be a loss, i.e., capped at 0.0 and negated return -Math.Min(percentile(1.0 - centile), 0.0); @@ -128,15 +128,15 @@ Also know as conditional value-at-risk. */ public double expectedShortfall(double centile) { if (!(centile < 1.0 && centile >= 0.9)) - throw new ApplicationException("percentile (" + centile + ") out of range [0.9, 1)"); + throw new Exception("percentile (" + centile + ") out of range [0.9, 1)"); - if (samples() == 0) throw new ApplicationException("empty sample set"); + if (samples() == 0) throw new Exception("empty sample set"); double target = -valueAtRisk(centile); KeyValuePair result = expectationValue(z => z.Key, z => z.Key < target); double x = result.Key; int N = result.Value; - if (N == 0) throw new ApplicationException("no data below the target"); + if (N == 0) throw new Exception("no data below the target"); // must be a loss, i.e., capped at 0.0 and negated return -Math.Min(x, 0.0); } @@ -152,7 +152,7 @@ public double expectedShortfall(double centile) { \right. \f] */ public double shortfall(double target) { - if (samples() == 0) throw new ApplicationException("empty sample set"); + if (samples() == 0) throw new Exception("empty sample set"); return expectationValue(x => x.Key < target ? 1 : 0, x => true).Key; } @@ -164,7 +164,7 @@ public double averageShortfall(double target) { KeyValuePair result = expectationValue(z => target - z.Key, z => z.Key < target); double x = result.Key; int N = result.Value; - if (N == 0) throw new ApplicationException("no data below the target"); + if (N == 0) throw new Exception("no data below the target"); return x; } } diff --git a/QLNet/Math/statistics/sequencestatistics.cs b/QLNet/Math/statistics/sequencestatistics.cs index 5db2799b9..b5546711f 100644 --- a/QLNet/Math/statistics/sequencestatistics.cs +++ b/QLNet/Math/statistics/sequencestatistics.cs @@ -54,10 +54,10 @@ public GenericSequenceStatistics(int dimension) { //! returns the covariance Matrix public Matrix covariance() { double sampleWeight = weightSum(); - if (!(sampleWeight > 0.0)) throw new ApplicationException("sampleWeight=0, unsufficient"); + if (!(sampleWeight > 0.0)) throw new Exception("sampleWeight=0, unsufficient"); double sampleNumber = samples(); - if (!(sampleNumber > 1.0)) throw new ApplicationException("sample number <=1, unsufficient"); + if (!(sampleNumber > 1.0)) throw new Exception("sample number <=1, unsufficient"); List m = mean(); double inv = 1.0/sampleWeight; @@ -103,8 +103,8 @@ public Matrix correlation() { // no argument list private List noArg(string method) { // do not check for null - in this case we throw anyways - for (int i = 0; i < dimension_; i++) { - MethodInfo methodInfo = stats_[i].GetType().GetMethod(method); + for (int i = 0; i < dimension_; i++) { + MethodInfo methodInfo = Utils.GetMethodInfo( stats_[i], method ); results_[i] = (double)methodInfo.Invoke(stats_[i], new object[] { }); } return results_; @@ -112,8 +112,8 @@ private List noArg(string method) { // single argument list private List singleArg(double x, string method) { // do not check for null - in this case we throw anyways - for (int i = 0; i < dimension_; i++) { - MethodInfo methodInfo = stats_[i].GetType().GetMethod(method); + for (int i = 0; i < dimension_; i++) { + MethodInfo methodInfo = Utils.GetMethodInfo( stats_[i], method ); results_[i] = (double)methodInfo.Invoke(stats_[i], new object[] { x }); } return results_; @@ -200,12 +200,12 @@ public virtual void add(List begin, double weight) { if (dimension_ == 0) { // stat wasn't initialized yet int dimension = begin.Count; - if(!(dimension>0)) throw new ApplicationException("sample error: end<=begin"); + if(!(dimension>0)) throw new Exception("sample error: end<=begin"); reset(dimension); } if (begin.Count != dimension_) - throw new ApplicationException("sample size mismatch: " + dimension_ + + throw new Exception("sample size mismatch: " + dimension_ + " required, " + begin.Count + " provided"); quadraticSum_ += weight * Matrix.outerProduct(begin, begin); diff --git a/QLNet/Methods/Finitedifferences/TridiagonalOperator.cs b/QLNet/Methods/Finitedifferences/TridiagonalOperator.cs index 9d82ddbf5..3b84e0e0c 100644 --- a/QLNet/Methods/Finitedifferences/TridiagonalOperator.cs +++ b/QLNet/Methods/Finitedifferences/TridiagonalOperator.cs @@ -73,9 +73,9 @@ public TridiagonalOperator(Vector low, Vector mid, Vector high) { upperDiagonal_ = (Vector)high.Clone(); if (!(low.Count == mid.Count - 1)) - throw new ApplicationException("wrong size for lower diagonal vector"); + throw new Exception("wrong size for lower diagonal vector"); if (!(high.Count == mid.Count - 1)) - throw new ApplicationException("wrong size for upper diagonal vector"); + throw new Exception("wrong size for upper diagonal vector"); } // TridiagonalOperator(const Disposable&); @@ -117,7 +117,7 @@ public IOperator subtract(IOperator A, IOperator B) { //! apply operator to a given array public Vector applyTo(Vector v) { if (!(v.Count == size())) - throw new ApplicationException("vector of the wrong size (" + v.Count + "instead of " + size() + ")"); + throw new Exception("vector of the wrong size (" + v.Count + "instead of " + size() + ")"); Vector result = new Vector(size()); @@ -136,18 +136,18 @@ public Vector applyTo(Vector v) { //! solve linear system for a given right-hand side public Vector solveFor(Vector rhs) { - if (rhs.Count != size()) throw new ApplicationException("rhs has the wrong size"); + if (rhs.Count != size()) throw new Exception("rhs has the wrong size"); Vector result = new Vector(size()), tmp = new Vector(size()); double bet = diagonal_[0]; - if (bet == 0.0) throw new ApplicationException("division by zero"); + if (bet == 0.0) throw new Exception("division by zero"); result[0] = rhs[0] / bet; for (int j = 1; j < size(); j++) { tmp[j] = upperDiagonal_[j - 1] / bet; bet = diagonal_[j] - lowerDiagonal_[j - 1] * tmp[j]; - if (bet == 0.0) throw new ApplicationException("division by zero"); + if (bet == 0.0) throw new Exception("division by zero"); result[j] = (rhs[j] - lowerDiagonal_[j - 1] * result[j - 1]) / bet; } // cannot be j>=0 with Size j @@ -159,7 +159,7 @@ public Vector solveFor(Vector rhs) { //! solve linear system with SOR approach public Vector SOR(Vector rhs, double tol) { - if (rhs.Count != size()) throw new ApplicationException("rhs has the wrong size"); + if (rhs.Count != size()) throw new Exception("rhs has the wrong size"); // initial guess Vector result = (Vector)rhs.Clone(); @@ -171,7 +171,7 @@ public Vector SOR(Vector rhs, double tol) { int i; for (int sorIteration = 0; err > tol; sorIteration++) { if (!(sorIteration < 100000)) - throw new ApplicationException("tolerance (" + tol + ") not reached in " + sorIteration + " iterations. " + throw new Exception("tolerance (" + tol + ") not reached in " + sorIteration + " iterations. " + "The error still is " + err); temp = omega * (rhs[0] - @@ -212,7 +212,7 @@ public void setFirstRow(double valB, double valC) { } public void setMidRow(int i, double valA, double valB, double valC) { if (!(i >= 1 && i <= size() - 2)) - throw new ApplicationException("out of range in TridiagonalSystem::setMidRow"); + throw new Exception("out of range in TridiagonalSystem::setMidRow"); lowerDiagonal_[i - 1] = valA; diagonal_[i] = valB; upperDiagonal_[i] = valC; diff --git a/QLNet/Methods/Finitedifferences/finitedifferencemodel.cs b/QLNet/Methods/Finitedifferences/finitedifferencemodel.cs index 3cf50328b..57cd8ee7f 100644 --- a/QLNet/Methods/Finitedifferences/finitedifferencemodel.cs +++ b/QLNet/Methods/Finitedifferences/finitedifferencemodel.cs @@ -55,7 +55,7 @@ public void rollback(ref object a, double from, double to, int steps, IStepCondi private void rollbackImpl(ref object o, double from, double to, int steps, IStepCondition condition) { - if (!(from >= to)) throw new ApplicationException("trying to roll back from " + from + " to " + to); + if (!(from >= to)) throw new Exception("trying to roll back from " + from + " to " + to); double dt = (from - to) / steps, t = from; evolver_.setStep(dt); diff --git a/QLNet/Methods/lattices/binominaltree.cs b/QLNet/Methods/lattices/binominaltree.cs index bf6f431d8..56b8633bb 100644 --- a/QLNet/Methods/lattices/binominaltree.cs +++ b/QLNet/Methods/lattices/binominaltree.cs @@ -121,8 +121,8 @@ public CoxRossRubinstein(StochasticProcess1D process, double end, int steps, dou pu_ = 0.5 + 0.5*driftPerStep_/dx_; pd_ = 1.0 - pu_; - if (!(pu_<=1.0)) throw new ApplicationException("negative probability"); - if (!(pu_ >= 0.0)) throw new ApplicationException("negative probability"); + if (!(pu_<=1.0)) throw new Exception("negative probability"); + if (!(pu_ >= 0.0)) throw new Exception("negative probability"); } public CoxRossRubinstein factory(StochasticProcess1D process, double end, int steps, double strike) { @@ -157,8 +157,8 @@ public Trigeorgis(StochasticProcess1D process, double end, int steps, double str pu_ = 0.5 + 0.5*driftPerStep_/dx_; pd_ = 1.0 - pu_; - if (!(pu_<=1.0)) throw new ApplicationException("negative probability"); - if (!(pu_ >= 0.0)) throw new ApplicationException("negative probability"); + if (!(pu_<=1.0)) throw new Exception("negative probability"); + if (!(pu_ >= 0.0)) throw new Exception("negative probability"); } public Trigeorgis factory(StochasticProcess1D process, double end, int steps, double strike) { @@ -189,8 +189,8 @@ public Tian(StochasticProcess1D process, double end, int steps, double strike) // treeCentering_ = (up_+down_)/2.0; // up_ = up_-treeCentering_; - if (!(pu_<=1.0)) throw new ApplicationException("negative probability"); - if (!(pu_ >= 0.0)) throw new ApplicationException("negative probability"); + if (!(pu_<=1.0)) throw new Exception("negative probability"); + if (!(pu_ >= 0.0)) throw new Exception("negative probability"); } public override double underlying(int i, int index) { @@ -213,7 +213,7 @@ public LeisenReimer() { } public LeisenReimer(StochasticProcess1D process, double end, int steps, double strike) : base(process, end, (steps%2 != 0 ? steps : steps+1)) { - if (!(strike>0.0)) throw new ApplicationException("strike must be positive"); + if (!(strike>0.0)) throw new Exception("strike must be positive"); int oddSteps = (steps%2 != 0 ? steps : steps+1); double variance = process.variance(0.0, x0_, end); double ermqdt = Math.Exp(driftPerStep_ + 0.5*variance/oddSteps); @@ -246,7 +246,7 @@ public Joshi4() { } public Joshi4(StochasticProcess1D process, double end, int steps, double strike) : base(process, end, (steps%2 != 0 ? steps : steps+1)) { - if (!(strike>0.0)) throw new ApplicationException("strike must be positive"); + if (!(strike>0.0)) throw new Exception("strike must be positive"); int oddSteps = (steps%2 != 0 ? steps : steps+1); double variance = process.variance(0.0, x0_, end); diff --git a/QLNet/Methods/lattices/lattice.cs b/QLNet/Methods/lattices/lattice.cs index 518bbbe51..7d25d6182 100644 --- a/QLNet/Methods/lattices/lattice.cs +++ b/QLNet/Methods/lattices/lattice.cs @@ -65,7 +65,7 @@ public class TreeLattice : Lattice where T : IGenericLattice{ public TreeLattice(TimeGrid timeGrid, int n) : base(timeGrid) { n_ = n; - if (!(n>0)) throw new ApplicationException("there is no zeronomial lattice!"); + if (!(n>0)) throw new Exception("there is no zeronomial lattice!"); statePrices_ = new InitializedList(1, new Vector(1, 1.0)); statePricesLimit_ = 0; } @@ -88,7 +88,7 @@ public override void partialRollback(DiscretizedAsset asset, double to) { if (Utils.close(from,to)) return; - if (!(from > to)) throw new ApplicationException("cannot roll the asset back to" + to + if (!(from > to)) throw new Exception("cannot roll the asset back to" + to + " (it is already at t = " + from + ")"); int iFrom = t_.index(from); diff --git a/QLNet/Methods/montecarlo/brownianbridge.cs b/QLNet/Methods/montecarlo/brownianbridge.cs index 646a9d1a8..fc81bce79 100644 --- a/QLNet/Methods/montecarlo/brownianbridge.cs +++ b/QLNet/Methods/montecarlo/brownianbridge.cs @@ -151,8 +151,8 @@ private void initialize() { //! \name Brownian-bridge constructor public void transform(List begin, List output) { - if (begin.Count == 0) throw new ApplicationException("invalid sequence"); - if (begin.Count != size_) throw new ApplicationException("incompatible sequence size"); + if (begin.Count == 0) throw new Exception("invalid sequence"); + if (begin.Count != size_) throw new Exception("incompatible sequence size"); // We use output to store the path... output[size_-1] = stdDev_[0] * begin[0]; for (int i=1; i> pathBasisSystem(int order, PolynomType ret.Add((x) => new GaussChebyshev2ndPolynomial().weightedValue(i, x)); break; default: - throw new ApplicationException("unknown regression type"); + throw new Exception("unknown regression type"); } } return ret; diff --git a/QLNet/Methods/montecarlo/multipath.cs b/QLNet/Methods/montecarlo/multipath.cs index 2c3008d89..18014d3e8 100644 --- a/QLNet/Methods/montecarlo/multipath.cs +++ b/QLNet/Methods/montecarlo/multipath.cs @@ -34,7 +34,7 @@ public MultiPath(int nAsset, TimeGrid timeGrid) { multiPath_ = new List(nAsset); for (int i = 0; i < nAsset; i++) multiPath_.Add(new Path(timeGrid)); - if (!(nAsset > 0)) throw new ApplicationException("number of asset must be positive"); + if (!(nAsset > 0)) throw new Exception("number of asset must be positive"); } public MultiPath(List multiPath) { diff --git a/QLNet/Methods/montecarlo/multipathgenerator.cs b/QLNet/Methods/montecarlo/multipathgenerator.cs index 2d7c8f160..e8415c856 100644 --- a/QLNet/Methods/montecarlo/multipathgenerator.cs +++ b/QLNet/Methods/montecarlo/multipathgenerator.cs @@ -48,20 +48,20 @@ public MultiPathGenerator(StochasticProcess process, TimeGrid times, GSG generat next_ = new Sample(new MultiPath(process.size(), times), 1.0); if (generator_.dimension() != process.factors()*(times.size()-1)) - throw new ApplicationException("dimension (" + generator_.dimension() + throw new Exception("dimension (" + generator_.dimension() + ") is not equal to (" + process.factors() + " * " + (times.size()-1) + ") the number of factors " + "times the number of time steps"); if (!(times.size() > 1)) - throw new ApplicationException("no times given"); + throw new Exception("no times given"); } public Sample next() { return next(false); } public Sample antithetic() { return next(true); } private Sample next(bool antithetic) { if (brownianBridge_) { - throw new ApplicationException("Brownian bridge not supported"); + throw new Exception("Brownian bridge not supported"); } else { // typedef typename GSG::sample_type sequence_type; Sample> sequence_ = diff --git a/QLNet/Methods/montecarlo/path.cs b/QLNet/Methods/montecarlo/path.cs index 31210684a..0576d8974 100644 --- a/QLNet/Methods/montecarlo/path.cs +++ b/QLNet/Methods/montecarlo/path.cs @@ -24,17 +24,17 @@ namespace QLNet { /*! \ingroup mcarlo \note the path includes the initial asset value as its first point. - */ - - public interface IPath : ICloneable - { - int length(); - } - - public interface IPathGenerator - { - Sample next(); - Sample antithetic(); + */ + + public interface IPath : ICloneable + { + int length(); + } + + public interface IPathGenerator + { + Sample next(); + Sample antithetic(); } public class Path : ICloneable, IPath { @@ -52,7 +52,7 @@ public Path(TimeGrid timeGrid, Vector values) { values_ = new Vector(timeGrid_.size()); if (values_.size() != timeGrid_.size()) - throw new ApplicationException("different number of times and asset values"); + throw new Exception("different number of times and asset values"); } //! \name inspectors diff --git a/QLNet/Methods/montecarlo/pathgenerator.cs b/QLNet/Methods/montecarlo/pathgenerator.cs index d3ef2c95b..a01abe08e 100644 --- a/QLNet/Methods/montecarlo/pathgenerator.cs +++ b/QLNet/Methods/montecarlo/pathgenerator.cs @@ -51,7 +51,7 @@ public PathGenerator(StochasticProcess process, double length, int timeSteps, GS temp_ = new InitializedList(dimension_); bb_ = new BrownianBridge(timeGrid_); if (dimension_ != timeSteps) - throw new ApplicationException("sequence generator dimensionality (" + dimension_ + throw new Exception("sequence generator dimensionality (" + dimension_ + ") != timeSteps (" + timeSteps + ")"); } @@ -66,7 +66,7 @@ public PathGenerator(StochasticProcess process, TimeGrid timeGrid, GSG generator bb_ = new BrownianBridge(timeGrid_); if (dimension_ != timeGrid_.size() - 1) - throw new ApplicationException("sequence generator dimensionality (" + dimension_ + throw new Exception("sequence generator dimensionality (" + dimension_ + ") != timeSteps (" + (timeGrid_.size() - 1) + ")"); } diff --git a/QLNet/Models/Parameter.cs b/QLNet/Models/Parameter.cs index c54b4591c..6b204eb1e 100644 --- a/QLNet/Models/Parameter.cs +++ b/QLNet/Models/Parameter.cs @@ -1,22 +1,22 @@ -/* - Copyright (C) 2008 Siarhei Novik (snovik@gmail.com) - Copyright (C) 2008 Toyin Akin (toyin_akin@hotmail.com) - Copyright (C) 2008-2016 Andrea Maggiulli (a.maggiulli@gmail.com) - - This file is part of QLNet Project https://github.com/amaggiulli/qlnet - - QLNet is free software: you can redistribute it and/or modify it - under the terms of the QLNet license. You should have received a - copy of the license along with this program; if not, license is - available online at . - - QLNet is a based on QuantLib, a free-software/open-source library - for financial quantitative analysts and developers - http://quantlib.org/ - The QuantLib license is available online at http://quantlib.org/license.shtml. - - This program is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS - FOR A PARTICULAR PURPOSE. See the license for more details. +/* + Copyright (C) 2008 Siarhei Novik (snovik@gmail.com) + Copyright (C) 2008 Toyin Akin (toyin_akin@hotmail.com) + Copyright (C) 2008-2016 Andrea Maggiulli (a.maggiulli@gmail.com) + + This file is part of QLNet Project https://github.com/amaggiulli/qlnet + + QLNet is free software: you can redistribute it and/or modify it + under the terms of the QLNet license. You should have received a + copy of the license along with this program; if not, license is + available online at . + + QLNet is a based on QuantLib, a free-software/open-source library + for financial quantitative analysts and developers - http://quantlib.org/ + The QuantLib license is available online at http://quantlib.org/license.shtml. + + This program is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS + FOR A PARTICULAR PURPOSE. See the license for more details. */ using System; using System.Collections.Generic; @@ -81,7 +81,7 @@ public ConstantParameter( double value, Constraint constraint ) params_[0] = value; if ( !( testParams( params_ ) ) ) - throw new ApplicationException( ": invalid value" ); + throw new Exception( ": invalid value" ); } } @@ -179,7 +179,7 @@ public override double value( Vector UnnamedParameter1, double t ) //int nIndex = times_.FindIndex( delegate(double val) { return val == locVal; }); int nIndex = times_.FindIndex( val => val == t ); if ( nIndex == -1 ) - throw new ApplicationException( "fitting parameter not set!" ); + throw new Exception( "fitting parameter not set!" ); return values_[nIndex]; } @@ -198,4 +198,4 @@ public TermStructureFittingParameter( Handle term ) } } -} +} diff --git a/QLNet/Models/Shortrate/Onefactormodels/coxingersollross.cs b/QLNet/Models/Shortrate/Onefactormodels/coxingersollross.cs index d5c2ab699..c388f8c57 100644 --- a/QLNet/Models/Shortrate/Onefactormodels/coxingersollross.cs +++ b/QLNet/Models/Shortrate/Onefactormodels/coxingersollross.cs @@ -64,7 +64,7 @@ public override double discountBondOption(Option.Type type, double bondMaturity) { if (!(strike > 0.0)) - throw new ApplicationException("strike must be positive"); + throw new Exception("strike must be positive"); double discountT = discountBond(0.0, maturity, x0()); double discountS = discountBond(0.0, bondMaturity, x0()); @@ -76,7 +76,7 @@ public override double discountBondOption(Option.Type type, case Option.Type.Put: return Math.Max(strike - discountS, 0.0); default: - throw new ApplicationException("unsupported option type"); + throw new Exception("unsupported option type"); } } double sigma2 = sigma()*sigma(); diff --git a/QLNet/Models/Shortrate/Onefactormodels/hullwhite.cs b/QLNet/Models/Shortrate/Onefactormodels/hullwhite.cs index d29088e96..942d2bbd9 100644 --- a/QLNet/Models/Shortrate/Onefactormodels/hullwhite.cs +++ b/QLNet/Models/Shortrate/Onefactormodels/hullwhite.cs @@ -126,15 +126,15 @@ public static double convexityBias(double futuresPrice, double sigma, double a){ if(!(futuresPrice>=0.0)) - throw new ApplicationException("negative futures price (" + futuresPrice + ") not allowed"); + throw new Exception("negative futures price (" + futuresPrice + ") not allowed"); if(!(t>=0.0)) - throw new ApplicationException("negative t (" + t + ") not allowed"); + throw new Exception("negative t (" + t + ") not allowed"); if(!(T>=t)) - throw new ApplicationException("T (" + T + ") must not be less than t (" + t + ")"); + throw new Exception("T (" + T + ") must not be less than t (" + t + ")"); if(!(sigma>=0.0)) - throw new ApplicationException("negative sigma (" + sigma + ") not allowed"); + throw new Exception("negative sigma (" + sigma + ") not allowed"); if(!(a>=0.0)) - throw new ApplicationException("negative a (" + a + ") not allowed"); + throw new Exception("negative a (" + a + ") not allowed"); double deltaT = (T-t); double tempDeltaT = (1.0-Math.Exp(-a*deltaT)) / a; diff --git a/QLNet/Models/Shortrate/Twofactorsmodels/g2.cs b/QLNet/Models/Shortrate/Twofactorsmodels/g2.cs index 048d4548d..05f069be4 100644 --- a/QLNet/Models/Shortrate/Twofactorsmodels/g2.cs +++ b/QLNet/Models/Shortrate/Twofactorsmodels/g2.cs @@ -136,7 +136,7 @@ public virtual double discountBond(double now, Vector factors) { if (!(factors.size() > 1)) - throw new ApplicationException("g2 model needs two factors to compute discount bond"); + throw new Exception("g2 model needs two factors to compute discount bond"); return discountBond(now, maturity, factors[0], factors[1]); } diff --git a/QLNet/Models/model.cs b/QLNet/Models/model.cs index 5afadd43c..a8b98985f 100644 --- a/QLNet/Models/model.cs +++ b/QLNet/Models/model.cs @@ -193,12 +193,12 @@ public virtual void setParams(Vector parameters) { int p = 0; for (int i = 0; i < arguments_.Count; ++i) { for (int j=0; j 0.0)) - throw new ApplicationException("positive spot value required"); + throw new Exception("positive spot value required"); if (!(discount_ > 0.0)) - throw new ApplicationException("positive discount required"); + throw new Exception("positive discount required"); if (!(dividendDiscount_ > 0.0)) - throw new ApplicationException("positive dividend discount required"); + throw new Exception("positive dividend discount required"); if (!(variance_ >= 0.0)) - throw new ApplicationException("negative variance not allowed"); + throw new Exception("negative variance not allowed"); stdDev_ = Math.Sqrt(variance_); @@ -87,7 +87,7 @@ public AmericanPayoffAtHit(double spot, double discount, double dividendDiscount mu_ = -0.5; lambda_ = 0.5; } else if (discount_ == 0.0) { - throw new ApplicationException("null discount not handled yet"); + throw new Exception("null discount not handled yet"); } else { mu_ = Math.Log(dividendDiscount_ / discount_) / variance_ - 0.5; lambda_ = Math.Sqrt(mu_ * mu_ - 2.0 * Math.Log(discount_) / variance_); @@ -147,7 +147,7 @@ public AmericanPayoffAtHit(double spot, double discount, double dividendDiscount } break; default: - throw new ApplicationException("invalid option type"); + throw new Exception("invalid option type"); } @@ -239,7 +239,7 @@ public double gamma() { public double rho(double maturity) { if (!(maturity >= 0.0)) - throw new ApplicationException("negative maturity not allowed"); + throw new Exception("negative maturity not allowed"); // actually D.Dr / T double DalphaDr = -DalphaDd1_ / (lambda_ * stdDev_) * (1.0 + mu_); diff --git a/QLNet/Pricingengines/BlackCalculator.cs b/QLNet/Pricingengines/BlackCalculator.cs index 8e7b7f66a..fcceface4 100644 --- a/QLNet/Pricingengines/BlackCalculator.cs +++ b/QLNet/Pricingengines/BlackCalculator.cs @@ -40,13 +40,13 @@ public BlackCalculator(StrikedTypePayoff payoff, double forward, double stdDev, variance_ = stdDev*stdDev; if (!(forward>0.0)) - throw new ApplicationException("positive forward value required: " + forward + " not allowed"); + throw new Exception("positive forward value required: " + forward + " not allowed"); if (!(stdDev>=0.0)) - throw new ApplicationException("non-negative standard deviation required: " + stdDev + " not allowed"); + throw new Exception("non-negative standard deviation required: " + stdDev + " not allowed"); if (!(discount>0.0)) - throw new ApplicationException("positive discount required: " + discount + " not allowed"); + throw new Exception("positive discount required: " + discount + " not allowed"); if (stdDev_>=Const.QL_EPSILON) { if (strike_==0.0) { @@ -128,7 +128,7 @@ public double deltaForward() { /*! Sensitivity to change in the underlying spot price. */ public virtual double delta(double spot) { if (!(spot > 0.0)) - throw new ApplicationException("positive spot value required: " + spot + " not allowed"); + throw new Exception("positive spot value required: " + spot + " not allowed"); double DforwardDs = forward_ / spot; @@ -193,7 +193,7 @@ underlying spot price. */ public virtual double gamma(double spot) { if (!(spot > 0.0)) - throw new ApplicationException("positive spot value required: " + spot + " not allowed"); + throw new Exception("positive spot value required: " + spot + " not allowed"); double DforwardDs = forward_ / spot; @@ -215,7 +215,7 @@ public virtual double theta(double spot, double maturity) { if (maturity==0.0) return 0.0; if (!(maturity>0.0)) - throw new ApplicationException("non negative maturity required: " + maturity + " not allowed"); + throw new Exception("non negative maturity required: " + maturity + " not allowed"); //vol = stdDev_ / std::sqrt(maturity); //rate = -std::log(discount_)/maturity; //dividendRate = -std::log(forward_ / spot * discount_)/maturity; @@ -235,7 +235,7 @@ public virtual double thetaPerDay(double spot, double maturity) { /*! Sensitivity to volatility. */ public double vega(double maturity) { if (!(maturity>=0.0)) - throw new ApplicationException("negative maturity not allowed"); + throw new Exception("negative maturity not allowed"); double temp = Math.Log(strike_/forward_)/variance_; // actually DalphaDsigma / SQRT(T) @@ -251,7 +251,7 @@ public double vega(double maturity) { /*! Sensitivity to discounting rate. */ public double rho(double maturity) { if (!(maturity >= 0.0)) - throw new ApplicationException("negative maturity not allowed"); + throw new Exception("negative maturity not allowed"); // actually DalphaDr / T double DalphaDr = DalphaDd1_ / stdDev_; @@ -264,7 +264,7 @@ public double rho(double maturity) { /*! Sensitivity to dividend/growth rate. */ public double dividendRho(double maturity) { if (!(maturity >= 0.0)) - throw new ApplicationException("negative maturity not allowed"); + throw new Exception("negative maturity not allowed"); // actually DalphaDq / T double DalphaDq = -DalphaDd1_ / stdDev_; @@ -319,8 +319,8 @@ public Calculator(BlackCalculator black) { } public void visit(object o) { - Type[] types = new Type[] { o.GetType() }; - MethodInfo methodInfo = this.GetType().GetMethod("visit", types); + Type[] types = new Type[] { o.GetType() }; + MethodInfo methodInfo = Utils.GetMethodInfo( this, "visit", types ); if (methodInfo != null) { methodInfo.Invoke(this, new object[] { o }); } diff --git a/QLNet/Pricingengines/Blackscholescalculator.cs b/QLNet/Pricingengines/Blackscholescalculator.cs index cfafe30e2..2703af4d5 100644 --- a/QLNet/Pricingengines/Blackscholescalculator.cs +++ b/QLNet/Pricingengines/Blackscholescalculator.cs @@ -33,10 +33,10 @@ public BlackScholesCalculator(StrikedTypePayoff payoff, double spot, double grow growth_ = growth; if (!(spot_ >= 0.0)) - throw new ApplicationException("positive spot value required: " + spot_ + " not allowed"); + throw new Exception("positive spot value required: " + spot_ + " not allowed"); if (!(growth_ >= 0.0)) - throw new ApplicationException("positive growth value required: " + growth_ + " not allowed"); + throw new Exception("positive growth value required: " + growth_ + " not allowed"); } //! Sensitivity to change in the underlying spot price. diff --git a/QLNet/Pricingengines/Swap/CounterpartyAdjSwapEngine.cs b/QLNet/Pricingengines/Swap/CounterpartyAdjSwapEngine.cs new file mode 100644 index 000000000..7ba548ba3 --- /dev/null +++ b/QLNet/Pricingengines/Swap/CounterpartyAdjSwapEngine.cs @@ -0,0 +1,232 @@ +// Copyright (C) 2008-2016 Andrea Maggiulli (a.maggiulli@gmail.com) +// +// This file is part of QLNet Project https://github.com/amaggiulli/qlnet +// QLNet is free software: you can redistribute it and/or modify it +// under the terms of the QLNet license. You should have received a +// copy of the license along with this program; if not, license is +// available online at . +// +// QLNet is a based on QuantLib, a free-software/open-source library +// for financial quantitative analysts and developers - http://quantlib.org/ +// The QuantLib license is available online at http://quantlib.org/license.shtml. +// +// This program is distributed in the hope that it will be useful, but WITHOUT +// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +// FOR A PARTICULAR PURPOSE. See the license for more details. +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +namespace QLNet +{ + /*! Bilateral (CVA and DVA) default adjusted vanilla swap pricing + engine. Collateral is not considered. No wrong way risk is + considered (rates and counterparty default are uncorrelated). + Based on: + Sorensen, E.H. and Bollier, T.F., Pricing swap default + risk. Financial Analysts Journal, 1994, 50, 23–33 + Also see sect. II-5 in: Risk Neutral Pricing of Counterparty Risk + D. Brigo, M. Masetti, 2004 + or in sections 3 and 4 of "A Formula for Interest Rate Swaps + Valuation under Counterparty Risk in presence of Netting Agreements" + D. Brigo and M. Masetti; May 4, 2005 + + to do: Compute fair rate through iteration instead of the + current approximation . + to do: write Issuer based constructors (event type) + to do: Check consistency between option engine discount and the one given + */ + public class CounterpartyAdjSwapEngine : VanillaSwap.Engine + { + //! \name Constructors + //@{ + //! + /*! Creates the engine from an arbitrary swaption engine. + If the investor default model is not given a default + free one is assumed. + @param discountCurve Used in pricing. + @param swaptionEngine Determines the volatility and thus the + exposure model. + @param ctptyDTS Counterparty default curve. + @param ctptyRecoveryRate Counterparty recovey rate. + @param invstDTS Investor (swap holder) default curve. + @param invstRecoveryRate Investor recovery rate. + */ + public CounterpartyAdjSwapEngine(Handle discountCurve, + Handle swaptionEngine,Handle ctptyDTS,double ctptyRecoveryRate, + Handle invstDTS=null,double invstRecoveryRate = 0.999) + { + baseSwapEngine_ = new Handle(new DiscountingSwapEngine(discountCurve)); + swaptionletEngine_ = swaptionEngine; + discountCurve_ = discountCurve; + defaultTS_ = ctptyDTS; + ctptyRecoveryRate_ = ctptyRecoveryRate; + invstDTS_ = invstDTS ?? new Handle( + new FlatHazardRate(0, ctptyDTS.link.calendar(), 1.0E-12, ctptyDTS.link.dayCounter())); + invstRecoveryRate_ = invstRecoveryRate; + + discountCurve.registerWith(update) ; + ctptyDTS.registerWith( update ) ; + invstDTS_.registerWith( update ) ; + swaptionEngine.registerWith( update ) ; + } + + /*! Creates an engine with a black volatility model for the + exposure. + If the investor default model is not given a default + free one is assumed. + @param discountCurve Used in pricing. + @param blackVol Black volatility used in the exposure model. + @param ctptyDTS Counterparty default curve. + @param ctptyRecoveryRate Counterparty recovey rate. + @param invstDTS Investor (swap holder) default curve. + @param invstRecoveryRate Investor recovery rate. + */ + public CounterpartyAdjSwapEngine(Handle discountCurve,double blackVol, + Handle ctptyDTS,double ctptyRecoveryRate, + Handle invstDTS=null,double invstRecoveryRate = 0.999) + { + baseSwapEngine_ = new Handle(new DiscountingSwapEngine(discountCurve)); + swaptionletEngine_ = new Handle(new BlackSwaptionEngine(discountCurve, blackVol)); + discountCurve_ = discountCurve; + defaultTS_ = ctptyDTS; + ctptyRecoveryRate_ = ctptyRecoveryRate; + invstDTS_ = invstDTS ?? new Handle( + new FlatHazardRate(0, ctptyDTS.link.calendar(), 1.0e-12, ctptyDTS.link.dayCounter())); + invstRecoveryRate_ = invstRecoveryRate; + + discountCurve.registerWith(update) ; + ctptyDTS.registerWith(update) ; + invstDTS_.registerWith(update) ; + } + + /*! Creates an engine with a black volatility model for the + exposure. The volatility is given as a quote. + If the investor default model is not given a default + free one is assumed. + @param discountCurve Used in pricing. + @param blackVol Black volatility used in the exposure model. + @param ctptyDTS Counterparty default curve. + @param ctptyRecoveryRate Counterparty recovey rate. + @param invstDTS Investor (swap holder) default curve. + @param invstRecoveryRate Investor recovery rate. + */ + public CounterpartyAdjSwapEngine(Handle discountCurve,Handle blackVol, + Handle ctptyDTS,double ctptyRecoveryRate, + Handle invstDTS=null,double invstRecoveryRate = 0.999) + { + baseSwapEngine_ = new Handle(new DiscountingSwapEngine(discountCurve)); + swaptionletEngine_ = new Handle(new BlackSwaptionEngine(discountCurve, blackVol)); + discountCurve_ = discountCurve; + defaultTS_ = ctptyDTS; + ctptyRecoveryRate_ = ctptyRecoveryRate; + invstDTS_ = invstDTS ?? new Handle( + new FlatHazardRate(0, ctptyDTS.link.calendar(), 1.0e-12, ctptyDTS.link.dayCounter())); + invstRecoveryRate_ = invstRecoveryRate; + + discountCurve.registerWith(update) ; + ctptyDTS.registerWith(update) ; + invstDTS_.registerWith(update) ; + blackVol.registerWith(update) ; + } + //@} + public override void calculate() + { + /* both DTS, YTS ref dates and pricing date consistency + checks? settlement... */ + Utils.QL_REQUIRE(!discountCurve_.empty(),()=> "no discount term structure set"); + Utils.QL_REQUIRE(!defaultTS_.empty(),()=> "no ctpty default term structure set"); + Utils.QL_REQUIRE(!swaptionletEngine_.empty(),()=> "no swap option engine set"); + + Date priceDate = defaultTS_.link.referenceDate(); + + double cumOptVal = 0.0,cumPutVal = 0.0; + // Vanilla swap so 0 leg is floater + + int index = 0; + Date nextFD = arguments_.fixedPayDates[index]; + Date swapletStart = priceDate; + while (nextFD < priceDate) + { + index++; + nextFD = arguments_.fixedPayDates[index]; + } + + + // Compute fair spread for strike value: + // copy args into the non risky engine + Swap.Arguments noCVAArgs = baseSwapEngine_.link.getArguments() as Swap.Arguments; + + noCVAArgs.legs = this.arguments_.legs; + noCVAArgs.payer = this.arguments_.payer; + + baseSwapEngine_.link.calculate(); + + double baseSwapRate = ((FixedRateCoupon)arguments_.legs[0][0]).rate(); + + Swap.Results vSResults = baseSwapEngine_.link.getResults() as Swap.Results; + + double? baseSwapFairRate = -baseSwapRate*vSResults.legNPV[1]/ vSResults.legNPV[0]; + double? baseSwapNPV = vSResults.value; + + VanillaSwap.Type reversedType = arguments_.type == VanillaSwap.Type.Payer + ? VanillaSwap.Type.Receiver + : VanillaSwap.Type.Payer; + + // Swaplet options summatory: + while (nextFD != arguments_.fixedPayDates.Last()) + { + // iFD coupon not fixed, create swaptionlet: + IborIndex swapIndex = ((FloatingRateCoupon)arguments_.legs[1][0]).index() as IborIndex; + + // Alternatively one could cap this period to, say, 1M + // Period swapPeriod = boost::dynamic_pointer_cast( + // arguments_.legs[1][0])->index()->tenor(); + + Period baseSwapsTenor = new Period(arguments_.fixedPayDates.Last().serialNumber() + - swapletStart.serialNumber(),TimeUnit.Days); + VanillaSwap swaplet = new MakeVanillaSwap(baseSwapsTenor, swapIndex, baseSwapFairRate) + .withType(arguments_.type) + .withNominal(arguments_.nominal) + .withEffectiveDate(swapletStart) + .withTerminationDate(arguments_.fixedPayDates.Last()).value(); + + VanillaSwap revSwaplet = new MakeVanillaSwap(baseSwapsTenor,swapIndex,baseSwapFairRate) + .withType(reversedType) + .withNominal(arguments_.nominal) + .withEffectiveDate(swapletStart) + .withTerminationDate(arguments_.fixedPayDates.Last()).value(); + + Swaption swaptionlet = new Swaption(swaplet,new EuropeanExercise(swapletStart)); + Swaption putSwaplet = new Swaption(revSwaplet,new EuropeanExercise (swapletStart)); + swaptionlet.setPricingEngine(swaptionletEngine_.currentLink()); + putSwaplet.setPricingEngine(swaptionletEngine_.currentLink()); + + // atm underlying swap means that the value of put = value + // call so this double pricing is not needed + cumOptVal += swaptionlet.NPV()*defaultTS_.link.defaultProbability( + swapletStart, nextFD); + cumPutVal += putSwaplet.NPV()*invstDTS_.link.defaultProbability(swapletStart, nextFD); + + swapletStart = nextFD; + index++; + nextFD = arguments_.fixedPayDates[index]; + } + + results_.value = baseSwapNPV - (1.0-ctptyRecoveryRate_)*cumOptVal+ (1.0-invstRecoveryRate_)*cumPutVal; + results_.fairRate = -baseSwapRate*(vSResults.legNPV[1] - (1.0 - ctptyRecoveryRate_)*cumOptVal + + (1.0-invstRecoveryRate_)*cumPutVal )/vSResults.legNPV[0]; + + } + + private Handle baseSwapEngine_; + private Handle swaptionletEngine_; + private Handle discountCurve_; + private Handle defaultTS_; + private double ctptyRecoveryRate_; + private Handle invstDTS_; + private double invstRecoveryRate_; + + } +} diff --git a/QLNet/Pricingengines/Swap/Discountingswapengine.cs b/QLNet/Pricingengines/Swap/Discountingswapengine.cs index 4e8895c35..f6624097d 100644 --- a/QLNet/Pricingengines/Swap/Discountingswapengine.cs +++ b/QLNet/Pricingengines/Swap/Discountingswapengine.cs @@ -99,19 +99,27 @@ public override void calculate() out npv, out bps); results_.legNPV[i] = npv *arguments_.payer[i]; - results_.legBPS[i] = bps *arguments_.payer[i]; - - Date d1 = CashFlows.startDate(arguments_.legs[i]); - if (d1>=refDate) - results_.startDiscounts[i] = discountCurve_.link.discount(d1); - else - results_.startDiscounts[i] = null; - - Date d2 = CashFlows.maturityDate(arguments_.legs[i]); - if (d2>=refDate) - results_.endDiscounts[i] = discountCurve_.link.discount(d2); - else - results_.endDiscounts[i] = null; + results_.legBPS[i] = bps *arguments_.payer[i]; + + if ( !arguments_.legs[i].empty() ) + { + Date d1 = CashFlows.startDate( arguments_.legs[i] ); + if ( d1 >= refDate ) + results_.startDiscounts[i] = discountCurve_.link.discount( d1 ); + else + results_.startDiscounts[i] = null; + + Date d2 = CashFlows.maturityDate( arguments_.legs[i] ); + if ( d2 >= refDate ) + results_.endDiscounts[i] = discountCurve_.link.discount( d2 ); + else + results_.endDiscounts[i] = null; + } + else + { + results_.startDiscounts[i] = null; + results_.endDiscounts[i] = null; + } } catch (Exception e) diff --git a/QLNet/Pricingengines/asian/mc_discr_arith_av_price.cs b/QLNet/Pricingengines/asian/mc_discr_arith_av_price.cs index e7ac75e16..17e706624 100644 --- a/QLNet/Pricingengines/asian/mc_discr_arith_av_price.cs +++ b/QLNet/Pricingengines/asian/mc_discr_arith_av_price.cs @@ -59,11 +59,11 @@ protected override PathPricer pathPricer() { PlainVanillaPayoff payoff = (PlainVanillaPayoff)(this.arguments_.payoff); if (payoff == null) - throw new ApplicationException("non-plain payoff given"); + throw new Exception("non-plain payoff given"); EuropeanExercise exercise = (EuropeanExercise)this.arguments_.exercise; if (exercise == null) - throw new ApplicationException("wrong exercise given"); + throw new Exception("wrong exercise given"); return (PathPricer)new ArithmeticAPOPathPricer( payoff.optionType(), @@ -77,11 +77,11 @@ protected override PathPricer controlPathPricer() { PlainVanillaPayoff payoff = (PlainVanillaPayoff)this.arguments_.payoff; if (payoff == null) - throw new ApplicationException("non-plain payoff given"); + throw new Exception("non-plain payoff given"); EuropeanExercise exercise = (EuropeanExercise)this.arguments_.exercise; if (exercise == null) - throw new ApplicationException("wrong exercise given"); + throw new Exception("wrong exercise given"); // for seasoned option the geometric strike might be rescaled // to obtain an equivalent arithmetic strike. @@ -116,7 +116,7 @@ public ArithmeticAPOPathPricer(Option.Type type, runningSum_ = runningSum; pastFixings_ = pastFixings; if(!(strike>=0.0)) - throw new ApplicationException("strike less than zero not allowed"); + throw new Exception("strike less than zero not allowed"); } public ArithmeticAPOPathPricer(Option.Type type, @@ -135,7 +135,7 @@ public double value(Path path) { int n = path.length(); if(!(n>1)) - throw new ApplicationException("the path cannot be empty"); + throw new Exception("the path cannot be empty"); double sum = runningSum_; int fixings; @@ -158,7 +158,7 @@ public double value(Path path) /*public double value(IPath path){ if (!(path.length() > 0)) - throw new ApplicationException("the path cannot be empty"); + throw new Exception("the path cannot be empty"); return payoff_.value((path as Path).back()) * discount_; }*/ } @@ -205,7 +205,7 @@ public MakeMCDiscreteArithmeticAPEngine withTolerance(double tolerance) { Utils.QL_REQUIRE( samples_ == null, () => "number of samples already set" ); if ((new RNG().allowsErrorEstimate == 0)) - throw new ApplicationException("chosen random generator policy " + + throw new Exception("chosen random generator policy " + "does not allow an error estimate"); tolerance_ = tolerance; return this; @@ -244,7 +244,7 @@ public MakeMCDiscreteArithmeticAPEngine withControlVariate(){ public IPricingEngine value() { if (steps_ == null) - throw new ApplicationException("max number of steps per year not given"); + throw new Exception("max number of steps per year not given"); return (IPricingEngine)new MCDiscreteArithmeticAPEngine(process_, steps_.Value, brownianBridge_, diff --git a/QLNet/Pricingengines/asian/mc_discr_arith_av_strike.cs b/QLNet/Pricingengines/asian/mc_discr_arith_av_strike.cs index 45dd1d694..3bade8945 100644 --- a/QLNet/Pricingengines/asian/mc_discr_arith_av_strike.cs +++ b/QLNet/Pricingengines/asian/mc_discr_arith_av_strike.cs @@ -48,11 +48,11 @@ public MCDiscreteArithmeticASEngine( protected override PathPricer pathPricer(){ PlainVanillaPayoff payoff = (PlainVanillaPayoff)(this.arguments_.payoff); if (payoff == null) - throw new ApplicationException("non-plain payoff given"); + throw new Exception("non-plain payoff given"); EuropeanExercise exercise = (EuropeanExercise)this.arguments_.exercise; if (exercise == null) - throw new ApplicationException("wrong exercise given"); + throw new Exception("wrong exercise given"); return (PathPricer)new ArithmeticASOPathPricer( payoff.optionType(), @@ -92,7 +92,7 @@ public ArithmeticASOPathPricer(Option.Type type, public double value(Path path){ int n = path.length(); if(!(n > 1)) - throw new ApplicationException("the path cannot be empty"); + throw new Exception("the path cannot be empty"); double averageStrike=runningSum_; if (path.timeGrid().mandatoryTimes()[0]==0.0) { //averageStrike = @@ -149,7 +149,7 @@ public MakeMCDiscreteArithmeticASEngine withTolerance(double tolerance) Utils.QL_REQUIRE( samples_ == null, () => "number of samples already set" ); if ((new RNG().allowsErrorEstimate == 0)) - throw new ApplicationException("chosen random generator policy " + + throw new Exception("chosen random generator policy " + "does not allow an error estimate"); tolerance_ = tolerance; return this; diff --git a/QLNet/Pricingengines/asian/mc_discr_geom_av_price.cs b/QLNet/Pricingengines/asian/mc_discr_geom_av_price.cs index c73e83f2c..066f71245 100644 --- a/QLNet/Pricingengines/asian/mc_discr_geom_av_price.cs +++ b/QLNet/Pricingengines/asian/mc_discr_geom_av_price.cs @@ -63,11 +63,11 @@ public MCDiscreteGeometricAPEngine( protected override PathPricer pathPricer() { PlainVanillaPayoff payoff = (PlainVanillaPayoff)(this.arguments_.payoff); if (payoff == null) - throw new ApplicationException("non-plain payoff given"); + throw new Exception("non-plain payoff given"); EuropeanExercise exercise = (EuropeanExercise)this.arguments_.exercise; if (exercise == null) - throw new ApplicationException("wrong exercise given"); + throw new Exception("wrong exercise given"); return (PathPricer)new GeometricAPOPathPricer( payoff.optionType(), @@ -96,7 +96,7 @@ public GeometricAPOPathPricer(Option.Type type, runningProduct_ = runningProduct; pastFixings_ = pastFixings; if(!(strike>=0.0)) - throw new ApplicationException("negative strike given"); + throw new Exception("negative strike given"); } public GeometricAPOPathPricer(Option.Type type, double strike, @@ -112,7 +112,7 @@ public GeometricAPOPathPricer(Option.Type type, public double value(Path path){ int n = path.length() - 1; if(!(n>0)) - throw new ApplicationException("the path cannot be empty"); + throw new Exception("the path cannot be empty"); double averagePrice; double product = runningProduct_; @@ -182,7 +182,7 @@ public MakeMCDiscreteGeometricAPEngine withSamples(int samples){ public MakeMCDiscreteGeometricAPEngine withTolerance(double tolerance){ Utils.QL_REQUIRE( samples_ == null, () => "number of samples already set" ); if ((new RNG().allowsErrorEstimate == 0)) - throw new ApplicationException("chosen random generator policy " + + throw new Exception("chosen random generator policy " + "does not allow an error estimate"); tolerance_ = tolerance; return this; @@ -220,7 +220,7 @@ public MakeMCDiscreteGeometricAPEngine withControlVariate(){ // conversion to pricing engine public IPricingEngine value(){ if (steps_ == null) - throw new ApplicationException("max number of steps per year not given"); + throw new Exception("max number of steps per year not given"); return (IPricingEngine)new MCDiscreteGeometricAPEngine(process_, steps_.Value, brownianBridge_, diff --git a/QLNet/Pricingengines/asian/mcdiscreteasianengine.cs b/QLNet/Pricingengines/asian/mcdiscreteasianengine.cs index 21db1bdf4..5f38c61c9 100644 --- a/QLNet/Pricingengines/asian/mcdiscreteasianengine.cs +++ b/QLNet/Pricingengines/asian/mcdiscreteasianengine.cs @@ -109,7 +109,7 @@ protected override IPathGenerator pathGenerator() { protected override double controlVariateValue() { IPricingEngine controlPE = this.controlPricingEngine(); if(controlPE==null) - throw new ApplicationException( "engine does not provide " + + throw new Exception( "engine does not provide " + "control variation pricing engine"); DiscreteAveragingAsianOption.Arguments controlArguments = diff --git a/QLNet/Pricingengines/barrier/AnalyticBarrierEngine.cs b/QLNet/Pricingengines/barrier/AnalyticBarrierEngine.cs index 729c59084..cfb4f7aa5 100644 --- a/QLNet/Pricingengines/barrier/AnalyticBarrierEngine.cs +++ b/QLNet/Pricingengines/barrier/AnalyticBarrierEngine.cs @@ -43,17 +43,17 @@ public override void calculate() PlainVanillaPayoff payoff = arguments_.payoff as PlainVanillaPayoff; if (payoff == null) - throw new ApplicationException("non-plain payoff given"); + throw new Exception("non-plain payoff given"); if (!(payoff.strike()>0.0)) - throw new ApplicationException("strike must be positive"); + throw new Exception("strike must be positive"); double strike = payoff.strike(); double spot = process_.x0(); if (!(spot >= 0.0)) - throw new ApplicationException("negative or null underlying given"); + throw new Exception("negative or null underlying given"); if (triggered(spot)) - throw new ApplicationException("barrier touched"); + throw new Exception("barrier touched"); Barrier.Type barrierType = arguments_.barrierType; @@ -118,7 +118,7 @@ public override void calculate() } break; default: - throw new ApplicationException("unknown type"); + throw new Exception("unknown type"); } } private GeneralizedBlackScholesProcess process_; @@ -133,7 +133,7 @@ private double strike() { PlainVanillaPayoff payoff = arguments_.payoff as PlainVanillaPayoff; if (payoff == null) - throw new ApplicationException("non-plain payoff given"); + throw new Exception("non-plain payoff given"); return payoff.strike(); } private double residualTime() diff --git a/QLNet/Pricingengines/mclongstaffschwartzengine.cs b/QLNet/Pricingengines/mclongstaffschwartzengine.cs index 6fb59fea9..3219918ab 100644 --- a/QLNet/Pricingengines/mclongstaffschwartzengine.cs +++ b/QLNet/Pricingengines/mclongstaffschwartzengine.cs @@ -1,167 +1,201 @@ -/* - Copyright (C) 2008 Siarhei Novik (snovik@gmail.com) - - This file is part of QLNet Project https://github.com/amaggiulli/qlnet - - QLNet is free software: you can redistribute it and/or modify it - under the terms of the QLNet license. You should have received a - copy of the license along with this program; if not, license is - available online at . - - QLNet is a based on QuantLib, a free-software/open-source library - for financial quantitative analysts and developers - http://quantlib.org/ - The QuantLib license is available online at http://quantlib.org/license.shtml. - - This program is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS - FOR A PARTICULAR PURPOSE. See the license for more details. -*/ -using System; - -namespace QLNet { - //! Longstaff-Schwarz Monte Carlo engine for early exercise options - /*! References: - - Francis Longstaff, Eduardo Schwartz, 2001. Valuing American Options - by Simulation: A Simple Least-Squares Approach, The Review of - Financial Studies, Volume 14, No. 1, 113-147 - - \test the correctness of the returned value is tested by - reproducing results available in web/literature - */ - public abstract class MCLongstaffSchwartzEngine - : MCLongstaffSchwartzEngine - where GenericEngine : IPricingEngine, new() - where RNG : IRSG, new() { - protected MCLongstaffSchwartzEngine(StochasticProcess process, int timeSteps, int timeStepsPerYear, - bool brownianBridge, bool antitheticVariate, bool controlVariate, - int requiredSamples, double requiredTolerance, int maxSamples, - ulong seed, int nCalibrationSamples) : - base(process, timeSteps, timeStepsPerYear, brownianBridge, antitheticVariate, controlVariate, - requiredSamples, requiredTolerance, maxSamples, seed, nCalibrationSamples) { } - } - public abstract class MCLongstaffSchwartzEngine : McSimulation, IPricingEngine - where GenericEngine : IPricingEngine, new() - where RNG : IRSG, new() - where S : IGeneralStatistics, new() { - - //typedef typename MC::path_type path_type; - //typedef typename McSimulation::stats_type stats_type; - //typedef typename McSimulation::path_pricer_type path_pricer_type; - //typedef typename McSimulation::path_generator_type path_generator_type; - - protected StochasticProcess process_; - protected int timeSteps_; - protected int timeStepsPerYear_; - protected bool brownianBridge_; - protected int requiredSamples_; - protected double requiredTolerance_; - protected int maxSamples_; - protected ulong seed_; - protected int nCalibrationSamples_; - - protected LongstaffSchwartzPathPricer pathPricer_; - - - protected MCLongstaffSchwartzEngine(StochasticProcess process, int timeSteps, int timeStepsPerYear, - bool brownianBridge, bool antitheticVariate, bool controlVariate, - int requiredSamples, double requiredTolerance, int maxSamples, - ulong seed, int nCalibrationSamples) - : base(antitheticVariate, controlVariate) { - process_ = process; - timeSteps_ = timeSteps; - timeStepsPerYear_ = timeStepsPerYear; - brownianBridge_ = brownianBridge; - requiredSamples_ = requiredSamples; - requiredTolerance_ = requiredTolerance; - maxSamples_ = maxSamples; - seed_ = seed; - nCalibrationSamples_ = nCalibrationSamples == 0 ? 2048 : nCalibrationSamples; - - if (!(timeSteps != 0 || timeStepsPerYear != 0)) - throw new ApplicationException("no time steps provided"); - if (!(timeSteps == 0 || timeStepsPerYear == 0)) - throw new ApplicationException("both time steps and time steps per year were provided"); - if (!(timeSteps != 0)) - throw new ApplicationException("timeSteps must be positive, " + timeSteps + " not allowed"); - //if (!(timeStepsPerYear != 0)) - // throw new ApplicationException("timeStepsPerYear must be positive, " + timeStepsPerYear + " not allowed"); - - process_.registerWith(update); - } - - public virtual void calculate() { - pathPricer_ = lsmPathPricer(); - mcModel_ = new MonteCarloModel(pathGenerator(), pathPricer_, new S(), antitheticVariate_); - - mcModel_.addSamples(nCalibrationSamples_); - pathPricer_.calibrate(); - - base.calculate(requiredTolerance_, requiredSamples_, maxSamples_); - results_.value = mcModel_.sampleAccumulator().mean(); - if (new RNG().allowsErrorEstimate != 0) { - results_.errorEstimate = mcModel_.sampleAccumulator().errorEstimate(); - } - } - - protected override TimeGrid timeGrid() { - Date lastExerciseDate = arguments_.exercise.lastDate(); - double t = process_.time(lastExerciseDate); - if (timeSteps_ != 0) { - return new TimeGrid(t, timeSteps_); - } else if (timeStepsPerYear_ != 0) { - int steps = (int)(timeStepsPerYear_*t); - return new TimeGrid(t, Math.Max(steps, 1)); - } else { - throw new ApplicationException("time steps not specified"); - } - } - - protected override PathPricer pathPricer() { - if (pathPricer_ == null) - throw new ApplicationException("path pricer unknown"); - return pathPricer_; - } - - protected override IPathGenerator pathGenerator() { - int dimensions = process_.factors(); - TimeGrid grid = timeGrid(); - IRNG generator = (IRNG)new RNG().make_sequence_generator(dimensions*(grid.size()-1),seed_); - if ( typeof( MC ) == typeof( SingleVariate ) ) - return new PathGenerator(process_, grid, generator, brownianBridge_); - else - return new MultiPathGenerator( process_, grid, generator, brownianBridge_ ); - - } - - protected abstract LongstaffSchwartzPathPricer lsmPathPricer(); - - #region PricingEngine - protected OneAssetOption.Arguments arguments_ = new OneAssetOption.Arguments(); - protected OneAssetOption.Results results_ = new OneAssetOption.Results(); - - public IPricingEngineArguments getArguments() { return arguments_; } - public IPricingEngineResults getResults() { return results_; } - public void reset() { results_.reset(); } - - #region Observer & Observable - // observable interface - private readonly WeakEventSource eventSource = new WeakEventSource(); - public event Callback notifyObserversEvent - { - add { eventSource.Subscribe(value); } - remove { eventSource.Unsubscribe(value); } - } - - public void registerWith(Callback handler) { notifyObserversEvent += handler; } - public void unregisterWith(Callback handler) { notifyObserversEvent -= handler; } - protected void notifyObservers() - { - eventSource.Raise(); - } - - public void update() { notifyObservers(); } - #endregion - #endregion - } -} +/* + Copyright (C) 2008 Siarhei Novik (snovik@gmail.com) + Copyright (C) 2008-2016 Andrea Maggiulli (a.maggiulli@gmail.com) + + This file is part of QLNet Project https://github.com/amaggiulli/qlnet + + QLNet is free software: you can redistribute it and/or modify it + under the terms of the QLNet license. You should have received a + copy of the license along with this program; if not, license is + available online at . + + QLNet is a based on QuantLib, a free-software/open-source library + for financial quantitative analysts and developers - http://quantlib.org/ + The QuantLib license is available online at http://quantlib.org/license.shtml. + + This program is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS + FOR A PARTICULAR PURPOSE. See the license for more details. +*/ +using System; + +namespace QLNet +{ + //! Longstaff-Schwarz Monte Carlo engine for early exercise options + /*! References: + + Francis Longstaff, Eduardo Schwartz, 2001. Valuing American Options + by Simulation: A Simple Least-Squares Approach, The Review of + Financial Studies, Volume 14, No. 1, 113-147 + + \test the correctness of the returned value is tested by + reproducing results available in web/literature + */ + public abstract class MCLongstaffSchwartzEngine + : MCLongstaffSchwartzEngine + where GenericEngine : IPricingEngine, new() + where RNG : IRSG, new() + { + protected MCLongstaffSchwartzEngine( StochasticProcess process, + int? timeSteps, + int? timeStepsPerYear, + bool brownianBridge, + bool antitheticVariate, + bool controlVariate, + int? requiredSamples, + double? requiredTolerance, + int? maxSamples, + ulong seed, + int nCalibrationSamples ) : + base( process, timeSteps, timeStepsPerYear, brownianBridge, antitheticVariate, controlVariate, + requiredSamples, requiredTolerance, maxSamples, seed, nCalibrationSamples ) + {} + } + + public abstract class MCLongstaffSchwartzEngine : McSimulation, IPricingEngine + where GenericEngine : IPricingEngine, new() + where RNG : IRSG, new() + where S : IGeneralStatistics, new() + { + + //typedef typename MC::path_type path_type; + //typedef typename McSimulation::stats_type stats_type; + //typedef typename McSimulation::path_pricer_type path_pricer_type; + //typedef typename McSimulation::path_generator_type path_generator_type; + + protected StochasticProcess process_; + protected int? timeSteps_; + protected int? timeStepsPerYear_; + protected bool brownianBridge_; + protected int? requiredSamples_; + protected double? requiredTolerance_; + protected int? maxSamples_; + protected ulong seed_; + protected int nCalibrationSamples_; + protected bool brownianBridgeCalibration_; + protected bool antitheticVariateCalibration_; + protected ulong seedCalibration_; + + protected LongstaffSchwartzPathPricer pathPricer_; + + + protected MCLongstaffSchwartzEngine( StochasticProcess process, + int? timeSteps, + int? timeStepsPerYear, + bool brownianBridge, + bool antitheticVariate, + bool controlVariate, + int? requiredSamples, + double? requiredTolerance, + int? maxSamples, + ulong seed, + int? nCalibrationSamples ) + : base( antitheticVariate, controlVariate ) + { + process_ = process; + timeSteps_ = timeSteps; + timeStepsPerYear_ = timeStepsPerYear; + brownianBridge_ = brownianBridge; + requiredSamples_ = requiredSamples; + requiredTolerance_ = requiredTolerance; + maxSamples_ = maxSamples; + seed_ = seed; + nCalibrationSamples_ = nCalibrationSamples ?? 2048; + + + Utils.QL_REQUIRE( timeSteps != null || + timeStepsPerYear != null,()=> "no time steps provided" ); + Utils.QL_REQUIRE( timeSteps == null || + timeStepsPerYear == null,()=> "both time steps and time steps per year were provided" ); + Utils.QL_REQUIRE( timeSteps != 0,()=> + "timeSteps must be positive, " + timeSteps + " not allowed" ); + Utils.QL_REQUIRE( timeStepsPerYear != 0,()=> + "timeStepsPerYear must be positive, " + timeStepsPerYear + " not allowed" ); + + process_.registerWith( update ); + } + + public virtual void calculate() + { + pathPricer_ = lsmPathPricer(); + mcModel_ = new MonteCarloModel( pathGenerator(), pathPricer_, new S(), antitheticVariate_ ); + + mcModel_.addSamples( nCalibrationSamples_ ); + pathPricer_.calibrate(); + + base.calculate( requiredTolerance_, requiredSamples_, maxSamples_ ); + results_.value = mcModel_.sampleAccumulator().mean(); + if ( new RNG().allowsErrorEstimate != 0 ) + { + results_.errorEstimate = mcModel_.sampleAccumulator().errorEstimate(); + } + } + + protected override TimeGrid timeGrid() + { + Date lastExerciseDate = arguments_.exercise.lastDate(); + double t = process_.time( lastExerciseDate ); + if ( timeSteps_ != null ) + { + return new TimeGrid( t, timeSteps_.Value ); + } + else if ( timeStepsPerYear_ != null ) + { + int steps = (int)( timeStepsPerYear_.Value * t ); + return new TimeGrid( t, Math.Max( steps, 1 ) ); + } + else + { + throw new Exception( "time steps not specified" ); + } + } + + protected override PathPricer pathPricer() + { + Utils.QL_REQUIRE( pathPricer_!=null,()=> "path pricer unknown" ); + return pathPricer_; + } + + protected override IPathGenerator pathGenerator() + { + int dimensions = process_.factors(); + TimeGrid grid = timeGrid(); + IRNG generator = (IRNG)new RNG().make_sequence_generator( dimensions * ( grid.size() - 1 ), seed_ ); + if ( typeof( MC ) == typeof( SingleVariate ) ) + return new PathGenerator( process_, grid, generator, brownianBridge_ ); + else + return new MultiPathGenerator( process_, grid, generator, brownianBridge_ ); + + } + + protected abstract LongstaffSchwartzPathPricer lsmPathPricer(); + + #region PricingEngine + protected OneAssetOption.Arguments arguments_ = new OneAssetOption.Arguments(); + protected OneAssetOption.Results results_ = new OneAssetOption.Results(); + + public IPricingEngineArguments getArguments() { return arguments_; } + public IPricingEngineResults getResults() { return results_; } + public void reset() { results_.reset(); } + + #region Observer & Observable + // observable interface + private readonly WeakEventSource eventSource = new WeakEventSource(); + public event Callback notifyObserversEvent + { + add { eventSource.Subscribe( value ); } + remove { eventSource.Unsubscribe( value ); } + } + + public void registerWith( Callback handler ) { notifyObserversEvent += handler; } + public void unregisterWith( Callback handler ) { notifyObserversEvent -= handler; } + protected void notifyObservers() + { + eventSource.Raise(); + } + + public void update() { notifyObservers(); } + #endregion + #endregion + } +} diff --git a/QLNet/Pricingengines/mcsimulation.cs b/QLNet/Pricingengines/mcsimulation.cs index db7212c8d..200ef835d 100644 --- a/QLNet/Pricingengines/mcsimulation.cs +++ b/QLNet/Pricingengines/mcsimulation.cs @@ -38,11 +38,8 @@ protected McSimulation( bool antitheticVariate, bool controlVariate ) controlVariate_ = controlVariate; } - //! add samples until the required absolute tolerance is reached - public double value( double tolerance ) { return value( tolerance, int.MaxValue, 1023 ); } - public double value( double tolerance, int maxSamples ) { return value( tolerance, maxSamples, 1023 ); } - public double value( double tolerance, int maxSamples, int minSamples ) + public double value( double tolerance, int maxSamples = int.MaxValue, int minSamples = 1023) { int sampleNumber = mcModel_.sampleAccumulator().samples(); if ( sampleNumber < minSamples ) @@ -56,10 +53,10 @@ public double value( double tolerance, int maxSamples, int minSamples ) double error = mcModel_.sampleAccumulator().errorEstimate(); while ( maxError( error ) > tolerance ) { - if ( !( sampleNumber < maxSamples ) ) - throw new ApplicationException( "max number of samples (" + maxSamples - + ") reached, while error (" + error - + ") is still above tolerance (" + tolerance + ")" ); + Utils.QL_REQUIRE( sampleNumber < maxSamples,()=> + "max number of samples (" + maxSamples + + ") reached, while error (" + error + + ") is still above tolerance (" + tolerance + ")" ); // conservative estimate of how many samples are needed order = maxError( error * error ) / tolerance / tolerance; @@ -81,9 +78,9 @@ public double valueWithSamples( int samples ) int sampleNumber = mcModel_.sampleAccumulator().samples(); - if ( !( samples >= sampleNumber ) ) - throw new ApplicationException( "number of already simulated samples (" + sampleNumber - + ") greater than requested samples (" + samples + ")" ); + Utils.QL_REQUIRE( samples >= sampleNumber,()=> + "number of already simulated samples (" + sampleNumber + + ") greater than requested samples (" + samples + ")" ); mcModel_.addSamples( samples - sampleNumber ); @@ -97,44 +94,41 @@ public double valueWithSamples( int samples ) public S sampleAccumulator() { return mcModel_.sampleAccumulator(); } //! basic calculate method provided to inherited pricing engines - public void calculate( double requiredTolerance, int requiredSamples, int maxSamples ) + public void calculate( double? requiredTolerance, int? requiredSamples, int? maxSamples ) { - - if ( !( requiredTolerance != 0 || requiredSamples != 0 ) ) - throw new ApplicationException( "neither tolerance nor number of samples set" ); + Utils.QL_REQUIRE( requiredTolerance != null || + requiredSamples != null,()=> "neither tolerance nor number of samples set" ); //! Initialize the one-factor Monte Carlo if ( this.controlVariate_ ) { - double controlVariateValue = this.controlVariateValue(); - if ( controlVariateValue == 0 ) - throw new ApplicationException( "engine does not provide control-variation price" ); + double? controlVariateValue = this.controlVariateValue(); + Utils.QL_REQUIRE(controlVariateValue != null,()=> "engine does not provide control-variation price"); PathPricer controlPP = this.controlPathPricer(); - if ( controlPP == null ) - throw new ApplicationException( "engine does not provide control-variation path pricer" ); + Utils.QL_REQUIRE(controlPP != null ,()=> "engine does not provide control-variation path pricer"); IPathGenerator controlPG = this.controlPathGenerator(); this.mcModel_ = new MonteCarloModel( pathGenerator(), pathPricer(), new S(), antitheticVariate_, - controlPP, controlVariateValue, controlPG ); + controlPP, controlVariateValue.Value, controlPG ); } else { this.mcModel_ = new MonteCarloModel( pathGenerator(), pathPricer(), new S(), antitheticVariate_ ); } - if ( requiredTolerance != 0 ) + if ( requiredTolerance != null ) { - if ( maxSamples != 0 ) - value( requiredTolerance, maxSamples ); + if ( maxSamples != null ) + value( requiredTolerance.Value, maxSamples.Value ); else - value( requiredTolerance ); + value( requiredTolerance.Value ); } else { - valueWithSamples( requiredSamples ); + valueWithSamples( requiredSamples.Value ); } } diff --git a/QLNet/Pricingengines/swaption/blackswaptionengine.cs b/QLNet/Pricingengines/swaption/blackswaptionengine.cs index 9447854aa..8633a5976 100644 --- a/QLNet/Pricingengines/swaption/blackswaptionengine.cs +++ b/QLNet/Pricingengines/swaption/blackswaptionengine.cs @@ -110,7 +110,7 @@ public override void calculate() break; } default: - throw new ApplicationException("unknown settlement type"); + throw new Exception("unknown settlement type"); } results_.additionalResults["annuity"] = annuity; diff --git a/QLNet/Pricingengines/swaption/g2swaptionengine.cs b/QLNet/Pricingengines/swaption/g2swaptionengine.cs index 78d61dad5..c32f2fb40 100644 --- a/QLNet/Pricingengines/swaption/g2swaptionengine.cs +++ b/QLNet/Pricingengines/swaption/g2swaptionengine.cs @@ -51,7 +51,7 @@ public G2SwaptionEngine(G2 model, public override void calculate() { if(!(arguments_.settlementType == Settlement.Type.Physical)) - throw new ApplicationException("cash-settled swaptions not priced with G2 engine"); + throw new Exception("cash-settled swaptions not priced with G2 engine"); // adjust the fixed rate of the swap for the spread on the // floating leg (which is not taken into account by the diff --git a/QLNet/Pricingengines/vanilla/AnalyticEuropeanEngine.cs b/QLNet/Pricingengines/vanilla/AnalyticEuropeanEngine.cs index f771cd44f..6446a6b34 100644 --- a/QLNet/Pricingengines/vanilla/AnalyticEuropeanEngine.cs +++ b/QLNet/Pricingengines/vanilla/AnalyticEuropeanEngine.cs @@ -58,18 +58,18 @@ public AnalyticEuropeanEngine(GeneralizedBlackScholesProcess process) { public override void calculate() { if(arguments_.exercise.type() != Exercise.Type.European) - throw new ApplicationException("not an European option"); + throw new Exception("not an European option"); StrikedTypePayoff payoff = arguments_.payoff as StrikedTypePayoff; if (payoff == null) - throw new ApplicationException("non-striked payoff given"); + throw new Exception("non-striked payoff given"); double variance = process_.blackVolatility().link.blackVariance(arguments_.exercise.lastDate(), payoff.strike()); double dividendDiscount = process_.dividendYield().link.discount(arguments_.exercise.lastDate()); double riskFreeDiscount = process_.riskFreeRate().link.discount(arguments_.exercise.lastDate()); double spot = process_.stateVariable().link.value(); if (!(spot > 0.0)) - throw new ApplicationException("negative or null underlying given"); + throw new Exception("negative or null underlying given"); double forwardPrice = spot * dividendDiscount / riskFreeDiscount; BlackCalculator black = new BlackCalculator(payoff, forwardPrice, Math.Sqrt(variance), riskFreeDiscount); diff --git a/QLNet/Pricingengines/vanilla/FDDividendEngine.cs b/QLNet/Pricingengines/vanilla/FDDividendEngine.cs index e8f657c8f..207ff59f8 100644 --- a/QLNet/Pricingengines/vanilla/FDDividendEngine.cs +++ b/QLNet/Pricingengines/vanilla/FDDividendEngine.cs @@ -45,7 +45,7 @@ public abstract FDVanillaEngine factory2(GeneralizedBlackScholesProcess process, public override void setupArguments(IPricingEngineArguments a) { DividendVanillaOption.Arguments args = a as DividendVanillaOption.Arguments; - if (args == null) throw new ApplicationException("incorrect argument type"); + if (args == null) throw new Exception("incorrect argument type"); List events = new List(); foreach (Event e in args.cashFlow) events.Add(e); diff --git a/QLNet/Pricingengines/vanilla/FDMultiPeriodEngine.cs b/QLNet/Pricingengines/vanilla/FDMultiPeriodEngine.cs index fc6916b69..9bdafae02 100644 --- a/QLNet/Pricingengines/vanilla/FDMultiPeriodEngine.cs +++ b/QLNet/Pricingengines/vanilla/FDMultiPeriodEngine.cs @@ -66,7 +66,7 @@ protected virtual void setupArguments(IPricingEngineArguments args, List public override void setupArguments(IPricingEngineArguments a) { base.setupArguments(a); OneAssetOption.Arguments args = a as OneAssetOption.Arguments; - if (args == null) throw new ApplicationException("incorrect argument type"); + if (args == null) throw new Exception("incorrect argument type"); events_.Clear(); int n = args.exercise.dates().Count; @@ -77,7 +77,7 @@ public override void setupArguments(IPricingEngineArguments a) { public override void calculate(IPricingEngineResults r) { OneAssetOption.Results results = r as OneAssetOption.Results; - if (results == null) throw new ApplicationException("incorrect results type"); + if (results == null) throw new Exception("incorrect results type"); double beginDate, endDate; int dateNumber = stoppingTimes_.Count; @@ -92,7 +92,7 @@ public override void calculate(IPricingEngineResults r) { if (dateNumber > 0) { if (!(getDividendTime(0) >= 0)) - throw new ApplicationException("first date (" + getDividendTime(0) + ") cannot be negative"); + throw new Exception("first date (" + getDividendTime(0) + ") cannot be negative"); if (getDividendTime(0) < getResidualTime() * dateTolerance) { firstDateIsZero = true; firstIndex = 0; @@ -111,7 +111,7 @@ public override void calculate(IPricingEngineResults r) { if (dateNumber >= 2) { for (j = 1; j < dateNumber; j++) if (!(getDividendTime(j - 1) < getDividendTime(j))) - throw new ApplicationException("dates must be in increasing order: " + throw new Exception("dates must be in increasing order: " + getDividendTime(j - 1) + " is not strictly smaller than " + getDividendTime(j)); } } diff --git a/QLNet/Pricingengines/vanilla/FDStepConditionEngine.cs b/QLNet/Pricingengines/vanilla/FDStepConditionEngine.cs index 0b47953ec..899c0766c 100644 --- a/QLNet/Pricingengines/vanilla/FDStepConditionEngine.cs +++ b/QLNet/Pricingengines/vanilla/FDStepConditionEngine.cs @@ -87,7 +87,7 @@ public override void calculate(IPricingEngineResults r) { StrikedTypePayoff striked_payoff = payoff_ as StrikedTypePayoff; if (striked_payoff == null) - throw new ApplicationException("non-striked payoff given"); + throw new Exception("non-striked payoff given"); double variance = process_.blackVolatility().link.blackVariance(exerciseDate_, striked_payoff.strike()); double dividendDiscount = process_.dividendYield().link.discount(exerciseDate_); diff --git a/QLNet/Pricingengines/vanilla/FDVanillaEngine.cs b/QLNet/Pricingengines/vanilla/FDVanillaEngine.cs index cf3dd5f3e..bfbae522d 100644 --- a/QLNet/Pricingengines/vanilla/FDVanillaEngine.cs +++ b/QLNet/Pricingengines/vanilla/FDVanillaEngine.cs @@ -73,7 +73,7 @@ protected virtual void setGridLimits() { } protected void setGridLimits(double center, double t) { - if (!(center > 0.0)) throw new ApplicationException("negative or null underlying given"); + if (!(center > 0.0)) throw new Exception("negative or null underlying given"); Utils.QL_REQUIRE( t > 0.0,()=> "negative or zero residual time" ); center_ = center; int newGridPoints = safeGridPoints(gridPoints_, t); @@ -142,7 +142,7 @@ private int safeGridPoints(int gridPoints, double residualTime) { public virtual void setupArguments(IPricingEngineArguments a) { OneAssetOption.Arguments args = a as OneAssetOption.Arguments; - if (args == null) throw new ApplicationException("incorrect argument type"); + if (args == null) throw new Exception("incorrect argument type"); exerciseDate_ = args.exercise.lastDate(); payoff_ = args.payoff; diff --git a/QLNet/Pricingengines/vanilla/Integralengine.cs b/QLNet/Pricingengines/vanilla/Integralengine.cs index 1c644d493..9d4c228dd 100644 --- a/QLNet/Pricingengines/vanilla/Integralengine.cs +++ b/QLNet/Pricingengines/vanilla/Integralengine.cs @@ -62,12 +62,12 @@ public IntegralEngine(GeneralizedBlackScholesProcess process) public override void calculate() { if (!(arguments_.exercise.type() == Exercise.Type.European)) - throw new ApplicationException("not an European Option"); + throw new Exception("not an European Option"); StrikedTypePayoff payoff = arguments_.payoff as StrikedTypePayoff; if (payoff == null) - throw new ApplicationException("not an European Option"); + throw new Exception("not an European Option"); double variance = process_.blackVolatility().link.blackVariance(arguments_.exercise.lastDate(), payoff.strike()); diff --git a/QLNet/Pricingengines/vanilla/Juquadraticengine.cs b/QLNet/Pricingengines/vanilla/Juquadraticengine.cs index 0cad38d41..e8639c816 100644 --- a/QLNet/Pricingengines/vanilla/Juquadraticengine.cs +++ b/QLNet/Pricingengines/vanilla/Juquadraticengine.cs @@ -59,19 +59,19 @@ public JuQuadraticApproximationEngine(GeneralizedBlackScholesProcess process) public override void calculate() { if (!(arguments_.exercise.type() == Exercise.Type.American)) - throw new ApplicationException("not an American Option"); + throw new Exception("not an American Option"); AmericanExercise ex = arguments_.exercise as AmericanExercise; if (ex == null) - throw new ApplicationException("non-American exercise given"); + throw new Exception("non-American exercise given"); if (ex.payoffAtExpiry()) - throw new ApplicationException("payoff at expiry not handled"); + throw new Exception("payoff at expiry not handled"); StrikedTypePayoff payoff = arguments_.payoff as StrikedTypePayoff; if (payoff == null) - throw new ApplicationException("non-striked payoff given"); + throw new Exception("non-striked payoff given"); double variance = process_.blackVolatility().link.blackVariance(ex.lastDate(), payoff.strike()); double dividendDiscount = process_.dividendYield().link.discount(ex.lastDate()); @@ -79,7 +79,7 @@ public override void calculate() double spot = process_.stateVariable().link.value(); if (!(spot > 0.0)) - throw new ApplicationException("negative or null underlying given"); + throw new Exception("negative or null underlying given"); double forwardPrice = spot * dividendDiscount / riskFreeDiscount; BlackCalculator black = new BlackCalculator(payoff, forwardPrice, Math.Sqrt(variance), riskFreeDiscount); diff --git a/QLNet/Pricingengines/vanilla/MCEuropeanHestonEngine.cs b/QLNet/Pricingengines/vanilla/MCEuropeanHestonEngine.cs index b2726a60a..05cecb15c 100644 --- a/QLNet/Pricingengines/vanilla/MCEuropeanHestonEngine.cs +++ b/QLNet/Pricingengines/vanilla/MCEuropeanHestonEngine.cs @@ -32,9 +32,9 @@ public MCEuropeanHestonEngine( HestonProcess process, int? timeSteps, int? timeStepsPerYear, bool antitheticVariate, - int requiredSamples, - double requiredTolerance, - int maxSamples, + int? requiredSamples, + double? requiredTolerance, + int? maxSamples, ulong seed) :base( process, timeSteps, timeStepsPerYear,false, antitheticVariate, false,requiredSamples, requiredTolerance, maxSamples, seed ) @@ -129,8 +129,8 @@ public IPricingEngine getAsPricingEngine() steps_, stepsPerYear_, antithetic_, - samples_.GetValueOrDefault(), tolerance_.GetValueOrDefault(), - maxSamples_.GetValueOrDefault(), + samples_, tolerance_, + maxSamples_, seed_); } diff --git a/QLNet/Pricingengines/vanilla/MCHestonHullWhiteEngine.cs b/QLNet/Pricingengines/vanilla/MCHestonHullWhiteEngine.cs index 8829461bd..4188fbe4d 100644 --- a/QLNet/Pricingengines/vanilla/MCHestonHullWhiteEngine.cs +++ b/QLNet/Pricingengines/vanilla/MCHestonHullWhiteEngine.cs @@ -26,9 +26,9 @@ public MCHestonHullWhiteEngine( HybridHestonHullWhiteProcess process, int? timeStepsPerYear, bool antitheticVariate, bool controlVariate, - int requiredSamples, - double requiredTolerance, - int maxSamples, + int? requiredSamples, + double? requiredTolerance, + int? maxSamples, ulong seed) :base(process, timeSteps, timeStepsPerYear,false, antitheticVariate,controlVariate, requiredSamples, requiredTolerance, maxSamples, seed) @@ -182,9 +182,9 @@ public IPricingEngine getAsPricingEngine() stepsPerYear_, antithetic_, controlVariate_, - samples_.GetValueOrDefault(), - tolerance_.GetValueOrDefault(), - maxSamples_.GetValueOrDefault(), + samples_, + tolerance_, + maxSamples_, seed_); } diff --git a/QLNet/Pricingengines/vanilla/baroneadesiwhaleyengine.cs b/QLNet/Pricingengines/vanilla/baroneadesiwhaleyengine.cs index 595c1bda1..5ad77d346 100644 --- a/QLNet/Pricingengines/vanilla/baroneadesiwhaleyengine.cs +++ b/QLNet/Pricingengines/vanilla/baroneadesiwhaleyengine.cs @@ -134,21 +134,21 @@ public static double criticalPrice(StrikedTypePayoff payoff, double riskFreeDisc public override void calculate() { if (!(arguments_.exercise.type() == Exercise.Type.American)) - throw new ApplicationException("not an American Option"); + throw new Exception("not an American Option"); AmericanExercise ex = arguments_.exercise as AmericanExercise; - if (ex == null) throw new ApplicationException("non-American exercise given"); + if (ex == null) throw new Exception("non-American exercise given"); - if(ex.payoffAtExpiry()) throw new ApplicationException("payoff at expiry not handled"); + if(ex.payoffAtExpiry()) throw new Exception("payoff at expiry not handled"); StrikedTypePayoff payoff = arguments_.payoff as StrikedTypePayoff; - if (payoff == null) throw new ApplicationException("non-striked payoff given"); + if (payoff == null) throw new Exception("non-striked payoff given"); double variance = process_.blackVolatility().link.blackVariance(ex.lastDate(), payoff.strike()); double dividendDiscount = process_.dividendYield().link.discount(ex.lastDate()); double riskFreeDiscount = process_.riskFreeRate().link.discount(ex.lastDate()); double spot = process_.stateVariable().link.value(); - if (!(spot > 0.0)) throw new ApplicationException("negative or null underlying given"); + if (!(spot > 0.0)) throw new Exception("negative or null underlying given"); double forwardPrice = spot * dividendDiscount / riskFreeDiscount; BlackCalculator black = new BlackCalculator(payoff, forwardPrice, Math.Sqrt(variance), riskFreeDiscount); @@ -214,7 +214,7 @@ public override void calculate() { } break; default: - throw new ApplicationException("unknown option type"); + throw new Exception("unknown option type"); } } // end of "early exercise can be optimal" } diff --git a/QLNet/Pricingengines/vanilla/binomialengine.cs b/QLNet/Pricingengines/vanilla/binomialengine.cs index f945a0a99..269366e6c 100644 --- a/QLNet/Pricingengines/vanilla/binomialengine.cs +++ b/QLNet/Pricingengines/vanilla/binomialengine.cs @@ -39,7 +39,7 @@ public BinomialVanillaEngine(GeneralizedBlackScholesProcess process, int timeSte process_ = process; timeSteps_ = timeSteps; - if (!(timeSteps>0)) throw new ApplicationException("timeSteps must be positive, " + timeSteps + " not allowed"); + if (!(timeSteps>0)) throw new Exception("timeSteps must be positive, " + timeSteps + " not allowed"); process_.registerWith(update); } @@ -52,7 +52,7 @@ public override void calculate() { Calendar volcal = process_.blackVolatility().link.calendar(); double s0 = process_.stateVariable().link.value(); - if (!(s0 > 0.0)) throw new ApplicationException("negative or null underlying given"); + if (!(s0 > 0.0)) throw new Exception("negative or null underlying given"); double v = process_.blackVolatility().link.blackVol(arguments_.exercise.lastDate(), s0); Date maturityDate = arguments_.exercise.lastDate(); double r = process_.riskFreeRate().link.zeroRate(maturityDate, rfdc, Compounding.Continuous, Frequency.NoFrequency).rate(); @@ -65,7 +65,7 @@ public override void calculate() { var flatVol = new Handle(new BlackConstantVol(referenceDate, volcal, v, voldc)); PlainVanillaPayoff payoff = arguments_.payoff as PlainVanillaPayoff; - if (payoff== null) throw new ApplicationException("non-plain payoff given"); + if (payoff== null) throw new Exception("non-plain payoff given"); double maturity = rfdc.yearFraction(referenceDate, maturityDate); @@ -89,7 +89,7 @@ public override void calculate() { // option values (p2) at this point option.rollback(grid[2]); Vector va2 = new Vector(option.values()); - if (!(va2.size() == 3)) throw new ApplicationException("Expect 3 nodes in grid at second step"); + if (!(va2.size() == 3)) throw new Exception("Expect 3 nodes in grid at second step"); double p2h = va2[2]; // high-price double s2 = lattice.underlying(2, 2); // high price @@ -97,7 +97,7 @@ public override void calculate() { // this point option.rollback(grid[1]); Vector va = new Vector(option.values()); - if (!(va.size() == 2)) throw new ApplicationException("Expect 2 nodes in grid at first step"); + if (!(va.size() == 2)) throw new Exception("Expect 2 nodes in grid at first step"); double p1 = va[1]; // Finally, rollback to t=0 diff --git a/QLNet/Pricingengines/vanilla/bjerksundstenslandengine.cs b/QLNet/Pricingengines/vanilla/bjerksundstenslandengine.cs index dc088c129..c61fb1ac2 100644 --- a/QLNet/Pricingengines/vanilla/bjerksundstenslandengine.cs +++ b/QLNet/Pricingengines/vanilla/bjerksundstenslandengine.cs @@ -37,22 +37,22 @@ public BjerksundStenslandApproximationEngine(GeneralizedBlackScholesProcess proc public override void calculate() { if (!(arguments_.exercise.type() == Exercise.Type.American)) - throw new ApplicationException("not an American Option"); + throw new Exception("not an American Option"); AmericanExercise ex = arguments_.exercise as AmericanExercise; - if(ex == null) throw new ApplicationException("non-American exercise given"); + if(ex == null) throw new Exception("non-American exercise given"); - if(ex.payoffAtExpiry()) throw new ApplicationException("payoff at expiry not handled"); + if(ex.payoffAtExpiry()) throw new Exception("payoff at expiry not handled"); PlainVanillaPayoff payoff = arguments_.payoff as PlainVanillaPayoff; - if(payoff == null) throw new ApplicationException("non-plain payoff given"); + if(payoff == null) throw new Exception("non-plain payoff given"); double variance = process_.blackVolatility().link.blackVariance(ex.lastDate(), payoff.strike()); double dividendDiscount = process_.dividendYield().link.discount(ex.lastDate()); double riskFreeDiscount = process_.riskFreeRate().link.discount(ex.lastDate()); double spot = process_.stateVariable().link.value(); - if (!(spot > 0.0)) throw new ApplicationException("negative or null underlying given"); + if (!(spot > 0.0)) throw new Exception("negative or null underlying given"); double strike = payoff.strike(); @@ -125,7 +125,7 @@ double americanCallApproximation(double S, double X, double rfD, double dD, doub // investigate what happen to I for dD->0.0 double I = B0 + (BInfinity - B0) * (1 - Math.Exp(ht)); if (!(I >= X)) - throw new ApplicationException("Bjerksund-Stensland approximation not applicable to this set of parameters"); + throw new Exception("Bjerksund-Stensland approximation not applicable to this set of parameters"); if (S >= I) { return S - X; } else { diff --git a/QLNet/Pricingengines/vanilla/discretizedvanillaoption.cs b/QLNet/Pricingengines/vanilla/discretizedvanillaoption.cs index 93c62c4c1..da52b4dd3 100644 --- a/QLNet/Pricingengines/vanilla/discretizedvanillaoption.cs +++ b/QLNet/Pricingengines/vanilla/discretizedvanillaoption.cs @@ -64,7 +64,7 @@ protected override void postAdjustValuesImpl() { } break; default: - throw new ApplicationException("invalid option type"); + throw new Exception("invalid option type"); } } diff --git a/QLNet/Pricingengines/vanilla/mcamericanengine.cs b/QLNet/Pricingengines/vanilla/mcamericanengine.cs index 9463bb815..51d905ca6 100644 --- a/QLNet/Pricingengines/vanilla/mcamericanengine.cs +++ b/QLNet/Pricingengines/vanilla/mcamericanengine.cs @@ -1,250 +1,283 @@ -/* - Copyright (C) 2008 Siarhei Novik (snovik@gmail.com) - - This file is part of QLNet Project https://github.com/amaggiulli/qlnet - - QLNet is free software: you can redistribute it and/or modify it - under the terms of the QLNet license. You should have received a - copy of the license along with this program; if not, license is - available online at . - - QLNet is a based on QuantLib, a free-software/open-source library - for financial quantitative analysts and developers - http://quantlib.org/ - The QuantLib license is available online at http://quantlib.org/license.shtml. - - This program is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS - FOR A PARTICULAR PURPOSE. See the license for more details. -*/ -using System; -using System.Collections.Generic; - -namespace QLNet { - //! American Monte Carlo engine - /*! References: - - \ingroup vanillaengines - - \test the correctness of the returned value is tested by - reproducing results available in web/literature - */ - public class MCAmericanEngine : MCLongstaffSchwartzEngine - where RNG : IRSG, new() - where S : IGeneralStatistics, new() { - - private int polynomOrder_; - private LsmBasisSystem.PolynomType polynomType_; - - // int nCalibrationSamples = Null()) - public MCAmericanEngine(GeneralizedBlackScholesProcess process, int timeSteps, int timeStepsPerYear, - bool antitheticVariate, bool controlVariate, int requiredSamples, double requiredTolerance, - int maxSamples, ulong seed, int polynomOrder, LsmBasisSystem.PolynomType polynomType, - int nCalibrationSamples) - : base(process, timeSteps, timeStepsPerYear, false, antitheticVariate, controlVariate, requiredSamples, - requiredTolerance, maxSamples, seed, nCalibrationSamples) { - polynomOrder_ = polynomOrder; - polynomType_ = polynomType; - } - - - public override void calculate() { - base.calculate(); - if (controlVariate_) { - // control variate might lead to small negative - // option values for deep OTM options - this.results_.value = Math.Max(0.0, this.results_.value.Value); - } - } - - protected override LongstaffSchwartzPathPricer lsmPathPricer() { - GeneralizedBlackScholesProcess process = process_ as GeneralizedBlackScholesProcess; - if (process == null) - throw new ApplicationException("generalized Black-Scholes process required"); - - EarlyExercise exercise = arguments_.exercise as EarlyExercise; - if (exercise == null) - throw new ApplicationException("wrong exercise given"); - if(exercise.payoffAtExpiry()) - throw new ApplicationException("payoff at expiry not handled"); - - AmericanPathPricer earlyExercisePathPricer = new AmericanPathPricer(arguments_.payoff, polynomOrder_, polynomType_); - - return new LongstaffSchwartzPathPricer(timeGrid(), earlyExercisePathPricer, process.riskFreeRate()); - } - - protected override double controlVariateValue() { - IPricingEngine controlPE = controlPricingEngine(); - - if (controlPE == null) - throw new ApplicationException("engine does not provide control variation pricing engine"); - - VanillaOption.Arguments controlArguments = controlPE.getArguments() as VanillaOption.Arguments; - controlArguments = arguments_; - controlArguments.exercise = new EuropeanExercise(arguments_.exercise.lastDate()); - - controlPE.calculate(); - - VanillaOption.Results controlResults = controlPE.getResults() as VanillaOption.Results; - - return controlResults.value.GetValueOrDefault(); - } - - protected override IPricingEngine controlPricingEngine() { - GeneralizedBlackScholesProcess process = process_ as GeneralizedBlackScholesProcess; - if (process == null) - throw new ApplicationException("generalized Black-Scholes process required"); - - return new AnalyticEuropeanEngine(process); - } - - protected override PathPricer controlPathPricer() { - StrikedTypePayoff payoff = arguments_.payoff as StrikedTypePayoff; - if(payoff == null) - throw new ApplicationException("StrikedTypePayoff needed for control variate"); - - GeneralizedBlackScholesProcess process = process_ as GeneralizedBlackScholesProcess; - if (process == null) - throw new ApplicationException("generalized Black-Scholes process required"); - - return new EuropeanPathPricer(payoff.optionType(), payoff.strike(), - process.riskFreeRate().link.discount(timeGrid().Last())); - } - } - - - public class AmericanPathPricer : IEarlyExercisePathPricer { - protected double scalingValue_; - protected Payoff payoff_; - protected List> v_ = new List>(); - - public AmericanPathPricer(Payoff payoff, int polynomOrder, LsmBasisSystem.PolynomType polynomType) { - scalingValue_ = 1; - payoff_ = payoff; - v_ = LsmBasisSystem.pathBasisSystem(polynomOrder, polynomType); - - if (!(polynomType == LsmBasisSystem.PolynomType.Monomial - || polynomType == LsmBasisSystem.PolynomType.Laguerre - || polynomType == LsmBasisSystem.PolynomType.Hermite - || polynomType == LsmBasisSystem.PolynomType.Hyperbolic - || polynomType == LsmBasisSystem.PolynomType.Chebyshev2th)) - throw new ApplicationException("insufficient polynom type"); - - // the payoff gives an additional value - v_.Add(this.payoff); - - StrikedTypePayoff strikePayoff = payoff_ as StrikedTypePayoff; - - if (strikePayoff != null) { - scalingValue_/=strikePayoff.strike(); - } - } - - // scale values of the underlying to increase numerical stability - public double state(IPath path, int t) { return (path as Path)[t]*scalingValue_; } - public double value(IPath path, int t) { return payoff(state(path, t)); } - public List> basisSystem() { return v_; } - protected double payoff(double state) { return payoff_.value(state / scalingValue_); } - } - - - //! Monte Carlo American engine factory - //template - public class MakeMCAmericanEngine : MakeMCAmericanEngine - where RNG : IRSG, new() { - public MakeMCAmericanEngine(GeneralizedBlackScholesProcess process) : base(process) { } - } - - public class MakeMCAmericanEngine - where RNG : IRSG, new() - where S : IGeneralStatistics, new() { - - private GeneralizedBlackScholesProcess process_; - private bool antithetic_, controlVariate_; - private int steps_, stepsPerYear_; - private int samples_, maxSamples_, calibrationSamples_; - private double tolerance_; - private ulong seed_; - private int polynomOrder_; - private LsmBasisSystem.PolynomType polynomType_; - - public MakeMCAmericanEngine(GeneralizedBlackScholesProcess process) { - process_ = process; - antithetic_ = false; - controlVariate_ = false; - steps_ = 0; - stepsPerYear_ = 0; - samples_ = 0; - maxSamples_ = 0; - calibrationSamples_ = 2048; - tolerance_ = 0; - seed_ = 0; - polynomOrder_ = 2; - polynomType_ = LsmBasisSystem.PolynomType.Monomial; - } - - // named parameters - public MakeMCAmericanEngine withSteps(int steps) { - steps_ = steps; - return this; - } - public MakeMCAmericanEngine withStepsPerYear(int steps) { - stepsPerYear_ = steps; - return this; - } - public MakeMCAmericanEngine withSamples(int samples) { - if (tolerance_ != 0) - throw new ApplicationException("tolerance already set"); - samples_ = samples; - return this; - } - public MakeMCAmericanEngine withAbsoluteTolerance(double tolerance) { - if (samples_ != 0) - throw new ApplicationException("number of samples already set"); - - if (new RNG().allowsErrorEstimate == 0) - throw new ApplicationException("chosen random generator policy does not allow an error estimate"); - tolerance_ = tolerance; - return this; - } - public MakeMCAmericanEngine withMaxSamples(int samples) { - maxSamples_ = samples; - return this; - } - public MakeMCAmericanEngine withSeed(ulong seed) { - seed_ = seed; - return this; - } - public MakeMCAmericanEngine withAntitheticVariate() { return withAntitheticVariate(true); } - public MakeMCAmericanEngine withAntitheticVariate(bool b) { - antithetic_ = b; - return this; - } - //public MakeMCAmericanEngine withControlVariate(bool b = true); - public MakeMCAmericanEngine withControlVariate(bool b) { - controlVariate_ = b; - return this; - } - public MakeMCAmericanEngine withPolynomOrder(int polynomOrder) { - polynomOrder_ = polynomOrder; - return this; - } - public MakeMCAmericanEngine withBasisSystem(LsmBasisSystem.PolynomType polynomType) { - polynomType_ = polynomType; - return this; - } - public MakeMCAmericanEngine withCalibrationSamples(int samples) { - calibrationSamples_ = samples; - return this; - } - - // conversion to pricing engine - public IPricingEngine value() { - if (!(steps_ != 0 || stepsPerYear_ != 0)) - throw new ApplicationException("number of steps not given"); - if (!(steps_ == 0 || stepsPerYear_ == 0)) - throw new ApplicationException("number of steps overspecified"); - return new MCAmericanEngine(process_, steps_, stepsPerYear_, antithetic_, controlVariate_, samples_, tolerance_, - maxSamples_, seed_, polynomOrder_, polynomType_, calibrationSamples_); - } - } -} +/* + Copyright (C) 2008 Siarhei Novik (snovik@gmail.com) + Copyright (C) 2008-2016 Andrea Maggiulli (a.maggiulli@gmail.com) + + This file is part of QLNet Project https://github.com/amaggiulli/qlnet + + QLNet is free software: you can redistribute it and/or modify it + under the terms of the QLNet license. You should have received a + copy of the license along with this program; if not, license is + available online at . + + QLNet is a based on QuantLib, a free-software/open-source library + for financial quantitative analysts and developers - http://quantlib.org/ + The QuantLib license is available online at http://quantlib.org/license.shtml. + + This program is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS + FOR A PARTICULAR PURPOSE. See the license for more details. +*/ +using System; +using System.Collections.Generic; + +namespace QLNet +{ + //! American Monte Carlo engine + /*! References: + + \ingroup vanillaengines + + \test the correctness of the returned value is tested by + reproducing results available in web/literature + */ + public class MCAmericanEngine : MCLongstaffSchwartzEngine + where RNG : IRSG, new() + where S : IGeneralStatistics, new() + { + + private int polynomOrder_; + private LsmBasisSystem.PolynomType polynomType_; + + // int nCalibrationSamples = Null()) + public MCAmericanEngine( GeneralizedBlackScholesProcess process, + int? timeSteps, + int? timeStepsPerYear, + bool antitheticVariate, + bool controlVariate, + int? requiredSamples, + double? requiredTolerance, + int? maxSamples, + ulong seed, + int polynomOrder, + LsmBasisSystem.PolynomType polynomType, + int nCalibrationSamples ) + : base( process, timeSteps, timeStepsPerYear, false, antitheticVariate, controlVariate, requiredSamples, + requiredTolerance, maxSamples, seed, nCalibrationSamples ) + { + polynomOrder_ = polynomOrder; + polynomType_ = polynomType; + } + + + public override void calculate() + { + base.calculate(); + if ( controlVariate_ ) + { + // control variate might lead to small negative + // option values for deep OTM options + this.results_.value = Math.Max( 0.0, this.results_.value.Value ); + } + } + + protected override LongstaffSchwartzPathPricer lsmPathPricer() + { + GeneralizedBlackScholesProcess process = process_ as GeneralizedBlackScholesProcess; + if ( process == null ) + throw new Exception( "generalized Black-Scholes process required" ); + + EarlyExercise exercise = arguments_.exercise as EarlyExercise; + if ( exercise == null ) + throw new Exception( "wrong exercise given" ); + if ( exercise.payoffAtExpiry() ) + throw new Exception( "payoff at expiry not handled" ); + + AmericanPathPricer earlyExercisePathPricer = new AmericanPathPricer( arguments_.payoff, polynomOrder_, polynomType_ ); + + return new LongstaffSchwartzPathPricer( timeGrid(), earlyExercisePathPricer, process.riskFreeRate() ); + } + + protected override double controlVariateValue() + { + IPricingEngine controlPE = controlPricingEngine(); + + if ( controlPE == null ) + throw new Exception( "engine does not provide control variation pricing engine" ); + + VanillaOption.Arguments controlArguments = controlPE.getArguments() as VanillaOption.Arguments; + controlArguments = arguments_; + controlArguments.exercise = new EuropeanExercise( arguments_.exercise.lastDate() ); + + controlPE.calculate(); + + VanillaOption.Results controlResults = controlPE.getResults() as VanillaOption.Results; + + return controlResults.value.GetValueOrDefault(); + } + + protected override IPricingEngine controlPricingEngine() + { + GeneralizedBlackScholesProcess process = process_ as GeneralizedBlackScholesProcess; + if ( process == null ) + throw new Exception( "generalized Black-Scholes process required" ); + + return new AnalyticEuropeanEngine( process ); + } + + protected override PathPricer controlPathPricer() + { + StrikedTypePayoff payoff = arguments_.payoff as StrikedTypePayoff; + if ( payoff == null ) + throw new Exception( "StrikedTypePayoff needed for control variate" ); + + GeneralizedBlackScholesProcess process = process_ as GeneralizedBlackScholesProcess; + if ( process == null ) + throw new Exception( "generalized Black-Scholes process required" ); + + return new EuropeanPathPricer( payoff.optionType(), payoff.strike(), + process.riskFreeRate().link.discount( timeGrid().Last() ) ); + } + } + + + public class AmericanPathPricer : IEarlyExercisePathPricer + { + protected double scalingValue_; + protected Payoff payoff_; + protected List> v_ = new List>(); + + public AmericanPathPricer( Payoff payoff, int polynomOrder, LsmBasisSystem.PolynomType polynomType ) + { + scalingValue_ = 1; + payoff_ = payoff; + v_ = LsmBasisSystem.pathBasisSystem( polynomOrder, polynomType ); + + if ( !( polynomType == LsmBasisSystem.PolynomType.Monomial + || polynomType == LsmBasisSystem.PolynomType.Laguerre + || polynomType == LsmBasisSystem.PolynomType.Hermite + || polynomType == LsmBasisSystem.PolynomType.Hyperbolic + || polynomType == LsmBasisSystem.PolynomType.Chebyshev2th ) ) + throw new Exception( "insufficient polynom type" ); + + // the payoff gives an additional value + v_.Add( this.payoff ); + + StrikedTypePayoff strikePayoff = payoff_ as StrikedTypePayoff; + + if ( strikePayoff != null ) + { + scalingValue_ /= strikePayoff.strike(); + } + } + + // scale values of the underlying to increase numerical stability + public double state( IPath path, int t ) { return ( path as Path )[t] * scalingValue_; } + public double value( IPath path, int t ) { return payoff( state( path, t ) ); } + public List> basisSystem() { return v_; } + protected double payoff( double state ) { return payoff_.value( state / scalingValue_ ); } + } + + + //! Monte Carlo American engine factory + //template + public class MakeMCAmericanEngine : MakeMCAmericanEngine + where RNG : IRSG, new() + { + public MakeMCAmericanEngine( GeneralizedBlackScholesProcess process ) : base( process ) { } + } + + public class MakeMCAmericanEngine + where RNG : IRSG, new() + where S : IGeneralStatistics, new() + { + + private GeneralizedBlackScholesProcess process_; + private bool antithetic_, controlVariate_; + private int? steps_, stepsPerYear_; + private int? samples_, maxSamples_; + private int calibrationSamples_; + private double? tolerance_; + private ulong seed_; + private int polynomOrder_; + private LsmBasisSystem.PolynomType polynomType_; + + public MakeMCAmericanEngine( GeneralizedBlackScholesProcess process ) + { + process_ = process; + antithetic_ = false; + controlVariate_ = false; + steps_ = null; + stepsPerYear_ = null; + samples_ = null; + maxSamples_ = null; + calibrationSamples_ = 2048; + tolerance_ = null; + seed_ = 0; + polynomOrder_ = 2; + polynomType_ = LsmBasisSystem.PolynomType.Monomial; + } + + // named parameters + public MakeMCAmericanEngine withSteps( int steps ) + { + steps_ = steps; + return this; + } + public MakeMCAmericanEngine withStepsPerYear( int steps ) + { + stepsPerYear_ = steps; + return this; + } + public MakeMCAmericanEngine withSamples( int samples ) + { + Utils.QL_REQUIRE( tolerance_ == null,()=> "tolerance already set" ); + samples_ = samples; + return this; + } + public MakeMCAmericanEngine withAbsoluteTolerance( double tolerance ) + { + Utils.QL_REQUIRE(samples_ == null,()=> "number of samples already set"); + Utils.QL_REQUIRE( new RNG().allowsErrorEstimate != 0, () => "chosen random generator policy does not allow an error estimate" ); + + tolerance_ = tolerance; + return this; + } + public MakeMCAmericanEngine withMaxSamples( int samples ) + { + maxSamples_ = samples; + return this; + } + public MakeMCAmericanEngine withSeed( ulong seed ) + { + seed_ = seed; + return this; + } + public MakeMCAmericanEngine withAntitheticVariate() { return withAntitheticVariate( true ); } + public MakeMCAmericanEngine withAntitheticVariate( bool b ) + { + antithetic_ = b; + return this; + } + //public MakeMCAmericanEngine withControlVariate(bool b = true); + public MakeMCAmericanEngine withControlVariate( bool b ) + { + controlVariate_ = b; + return this; + } + public MakeMCAmericanEngine withPolynomOrder( int polynomOrder ) + { + polynomOrder_ = polynomOrder; + return this; + } + public MakeMCAmericanEngine withBasisSystem( LsmBasisSystem.PolynomType polynomType ) + { + polynomType_ = polynomType; + return this; + } + public MakeMCAmericanEngine withCalibrationSamples( int samples ) + { + calibrationSamples_ = samples; + return this; + } + + // conversion to pricing engine + public IPricingEngine value() + { + Utils.QL_REQUIRE( steps_ != null || stepsPerYear_ != null,() => "number of steps not given" ); + Utils.QL_REQUIRE( steps_ == null || stepsPerYear_ == null,()=> "number of steps overspecified" ); + + return new MCAmericanEngine( process_, steps_, stepsPerYear_, antithetic_, controlVariate_, samples_, tolerance_, + maxSamples_, seed_, polynomOrder_, polynomType_, calibrationSamples_ ); + } + } +} diff --git a/QLNet/Pricingengines/vanilla/mceuropeanengine.cs b/QLNet/Pricingengines/vanilla/mceuropeanengine.cs index 240f64ae5..7782f5417 100644 --- a/QLNet/Pricingengines/vanilla/mceuropeanengine.cs +++ b/QLNet/Pricingengines/vanilla/mceuropeanengine.cs @@ -1,143 +1,169 @@ -/* - Copyright (C) 2008 Siarhei Novik (snovik@gmail.com) - - This file is part of QLNet Project https://github.com/amaggiulli/qlnet - - QLNet is free software: you can redistribute it and/or modify it - under the terms of the QLNet license. You should have received a - copy of the license along with this program; if not, license is - available online at . - - QLNet is a based on QuantLib, a free-software/open-source library - for financial quantitative analysts and developers - http://quantlib.org/ - The QuantLib license is available online at http://quantlib.org/license.shtml. - - This program is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS - FOR A PARTICULAR PURPOSE. See the license for more details. -*/ -using System; - -namespace QLNet { - //! European option pricing engine using Monte Carlo simulation - /*! \ingroup vanillaengines - - \test the correctness of the returned value is tested by - checking it against analytic results. - */ - public class MCEuropeanEngine : MCVanillaEngine - where RNG : IRSG, new() - where S : IGeneralStatistics, new() { - - // constructor - public MCEuropeanEngine(GeneralizedBlackScholesProcess process, int timeSteps, int timeStepsPerYear, - bool brownianBridge, bool antitheticVariate, - int requiredSamples, double requiredTolerance, int maxSamples, ulong seed) - : base(process, timeSteps, timeStepsPerYear, brownianBridge, antitheticVariate, false, - requiredSamples, requiredTolerance, maxSamples, seed) { } - - protected override PathPricer pathPricer() { - PlainVanillaPayoff payoff = arguments_.payoff as PlainVanillaPayoff; - if (payoff == null) - throw new ApplicationException("non-plain payoff given"); - - GeneralizedBlackScholesProcess process = process_ as GeneralizedBlackScholesProcess; - if (process == null) - throw new ApplicationException("Black-Scholes process required"); - - return new EuropeanPathPricer(payoff.optionType(), payoff.strike(), - process.riskFreeRate().link.discount(timeGrid().Last())); - } - } - - - //! Monte Carlo European engine factory - // template - public class MakeMCEuropeanEngine : MakeMCEuropeanEngine where RNG : IRSG, new() { - public MakeMCEuropeanEngine(GeneralizedBlackScholesProcess process) : base(process) { } - } - - public class MakeMCEuropeanEngine where RNG : IRSG, new() where S : IGeneralStatistics, new() { - private GeneralizedBlackScholesProcess process_; - private bool antithetic_; - private int steps_, stepsPerYear_, samples_, maxSamples_; - private double tolerance_; - private bool brownianBridge_; - private ulong seed_; - - public MakeMCEuropeanEngine(GeneralizedBlackScholesProcess process) { - process_ = process; - } - - // named parameters - public MakeMCEuropeanEngine withSteps(int steps) { - steps_ = steps; - return this; - } - public MakeMCEuropeanEngine withStepsPerYear(int steps) { - stepsPerYear_ = steps; - return this; - } - //public MakeMCEuropeanEngine withBrownianBridge(bool b = true); - public MakeMCEuropeanEngine withBrownianBridge(bool brownianBridge) { - brownianBridge_ = brownianBridge; - return this; - } - public MakeMCEuropeanEngine withSamples(int samples) { - if(tolerance_ != 0) - throw new ApplicationException("tolerance already set"); - samples_ = samples; - return this; - } - public MakeMCEuropeanEngine withAbsoluteTolerance(double tolerance) { - if(samples_ != 0) - throw new ApplicationException("number of samples already set"); - if (new RNG().allowsErrorEstimate == 0) - throw new ApplicationException("chosen random generator policy does not allow an error estimate"); - tolerance_ = tolerance; - return this; - } - public MakeMCEuropeanEngine withMaxSamples(int samples) { - maxSamples_ = samples; - return this; - } - public MakeMCEuropeanEngine withSeed(ulong seed) { - seed_ = seed; - return this; - } - //public MakeMCEuropeanEngine withAntitheticVariate(bool b = true) - public MakeMCEuropeanEngine withAntitheticVariate(bool b) { - antithetic_ = b; - return this; - } - - // conversion to pricing engine - public IPricingEngine value() { - if (steps_ == 0 && stepsPerYear_ == 0) - throw new ApplicationException("number of steps not given"); - if (!(steps_ == 0 || stepsPerYear_ == 0)) - throw new ApplicationException("number of steps overspecified"); - return new MCEuropeanEngine(process_, steps_, stepsPerYear_, brownianBridge_, antithetic_, - samples_, tolerance_, maxSamples_, seed_); - } - } - - - public class EuropeanPathPricer : PathPricer { - private PlainVanillaPayoff payoff_; - private double discount_; - - public EuropeanPathPricer(Option.Type type, double strike, double discount) { - payoff_ = new PlainVanillaPayoff(type, strike); - discount_ = discount; - if (!(strike>=0.0)) - throw new ApplicationException("strike less than zero not allowed"); - } - - public double value(IPath path) { - if (!(path.length() > 0)) - throw new ApplicationException("the path cannot be empty"); - return payoff_.value((path as Path).back()) * discount_; - } - } -} +/* + Copyright (C) 2008 Siarhei Novik (snovik@gmail.com) + Copyright (C) 2008-2016 Andrea Maggiulli (a.maggiulli@gmail.com) + + This file is part of QLNet Project https://github.com/amaggiulli/qlnet + + QLNet is free software: you can redistribute it and/or modify it + under the terms of the QLNet license. You should have received a + copy of the license along with this program; if not, license is + available online at . + + QLNet is a based on QuantLib, a free-software/open-source library + for financial quantitative analysts and developers - http://quantlib.org/ + The QuantLib license is available online at http://quantlib.org/license.shtml. + + This program is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS + FOR A PARTICULAR PURPOSE. See the license for more details. +*/ +using System; + +namespace QLNet +{ + //! European option pricing engine using Monte Carlo simulation + /*! \ingroup vanillaengines + + \test the correctness of the returned value is tested by + checking it against analytic results. + */ + public class MCEuropeanEngine : MCVanillaEngine + where RNG : IRSG, new() + where S : IGeneralStatistics, new() + { + // constructor + public MCEuropeanEngine( GeneralizedBlackScholesProcess process, + int? timeSteps, + int? timeStepsPerYear, + bool brownianBridge, + bool antitheticVariate, + int? requiredSamples, + double? requiredTolerance, + int? maxSamples, + ulong seed ) + : base( process, timeSteps, timeStepsPerYear, brownianBridge, antitheticVariate, false, + requiredSamples, requiredTolerance, maxSamples, seed ) { } + + protected override PathPricer pathPricer() + { + PlainVanillaPayoff payoff = arguments_.payoff as PlainVanillaPayoff; + Utils.QL_REQUIRE( payoff != null,()=> "non-plain payoff given" ); + + GeneralizedBlackScholesProcess process = process_ as GeneralizedBlackScholesProcess; + Utils.QL_REQUIRE( process!= null,()=> "Black-Scholes process required" ); + + return new EuropeanPathPricer( payoff.optionType(), payoff.strike(), + process.riskFreeRate().link.discount( timeGrid().Last() ) ); + } + } + + + //! Monte Carlo European engine factory + // template + public class MakeMCEuropeanEngine : MakeMCEuropeanEngine where RNG : IRSG, new() + { + public MakeMCEuropeanEngine( GeneralizedBlackScholesProcess process ) : base( process ) { } + } + + public class MakeMCEuropeanEngine + where RNG : IRSG, new() + where S : IGeneralStatistics, new() + { + + public MakeMCEuropeanEngine( GeneralizedBlackScholesProcess process ) + { + process_ = process; + antithetic_ = false; + steps_ = null; + stepsPerYear_ = null; + samples_ = null; + maxSamples_ = null; + tolerance_ = null; + brownianBridge_ = false; + seed_ = 0; + } + + // named parameters + public MakeMCEuropeanEngine withSteps( int steps ) + { + steps_ = steps; + return this; + } + public MakeMCEuropeanEngine withStepsPerYear( int steps ) + { + stepsPerYear_ = steps; + return this; + } + public MakeMCEuropeanEngine withSamples( int samples ) + { + Utils.QL_REQUIRE( tolerance_ == null,()=> "tolerance already set" ); + samples_ = samples; + return this; + } + public MakeMCEuropeanEngine withAbsoluteTolerance( double tolerance ) + { + Utils.QL_REQUIRE( samples_ == null, () => "number of samples already set" ); + Utils.QL_REQUIRE( new RNG().allowsErrorEstimate != 0, () => + "chosen random generator policy does not allow an error estimate" ); + tolerance_ = tolerance; + return this; + } + public MakeMCEuropeanEngine withMaxSamples( int samples ) + { + maxSamples_ = samples; + return this; + } + public MakeMCEuropeanEngine withSeed( ulong seed ) + { + seed_ = seed; + return this; + } + public MakeMCEuropeanEngine withBrownianBridge( bool brownianBridge = true) + { + brownianBridge_ = brownianBridge; + return this; + } + public MakeMCEuropeanEngine withAntitheticVariate( bool b = true) + { + antithetic_ = b; + return this; + } + + // conversion to pricing engine + public IPricingEngine value() + { + Utils.QL_REQUIRE( steps_ != null || stepsPerYear_ != null,()=>"number of steps not given" ); + Utils.QL_REQUIRE( steps_ == null || stepsPerYear_ == null,()=>"number of steps overspecified" ); + return new MCEuropeanEngine( process_, steps_, stepsPerYear_, brownianBridge_, antithetic_, + samples_, tolerance_, maxSamples_, seed_ ); + } + + private GeneralizedBlackScholesProcess process_; + private bool antithetic_; + private int? steps_, stepsPerYear_, samples_, maxSamples_; + private double? tolerance_; + private bool brownianBridge_; + private ulong seed_; + + } + + + public class EuropeanPathPricer : PathPricer + { + public EuropeanPathPricer( Option.Type type, double strike, double discount ) + { + payoff_ = new PlainVanillaPayoff( type, strike ); + discount_ = discount; + Utils.QL_REQUIRE( strike >= 0.0,()=> "strike less than zero not allowed" ); + } + + public double value( IPath path ) + { + Utils.QL_REQUIRE( path.length() > 0,()=> "the path cannot be empty" ); + return payoff_.value( ( path as Path ).back() ) * discount_; + } + + private PlainVanillaPayoff payoff_; + private double discount_; + } +} diff --git a/QLNet/Pricingengines/vanilla/mcvanillaengine.cs b/QLNet/Pricingengines/vanilla/mcvanillaengine.cs index d596ded0e..be0f4b31a 100644 --- a/QLNet/Pricingengines/vanilla/mcvanillaengine.cs +++ b/QLNet/Pricingengines/vanilla/mcvanillaengine.cs @@ -1,21 +1,21 @@ -/* - Copyright (C) 2008 Siarhei Novik (snovik@gmail.com) - Copyright (C) 2008-2016 Andrea Maggiulli (a.maggiulli@gmail.com) - - This file is part of QLNet Project https://github.com/amaggiulli/qlnet - - QLNet is free software: you can redistribute it and/or modify it - under the terms of the QLNet license. You should have received a - copy of the license along with this program; if not, license is - available online at . - - QLNet is a based on QuantLib, a free-software/open-source library - for financial quantitative analysts and developers - http://quantlib.org/ - The QuantLib license is available online at http://quantlib.org/license.shtml. - - This program is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS - FOR A PARTICULAR PURPOSE. See the license for more details. +/* + Copyright (C) 2008 Siarhei Novik (snovik@gmail.com) + Copyright (C) 2008-2016 Andrea Maggiulli (a.maggiulli@gmail.com) + + This file is part of QLNet Project https://github.com/amaggiulli/qlnet + + QLNet is free software: you can redistribute it and/or modify it + under the terms of the QLNet license. You should have received a + copy of the license along with this program; if not, license is + available online at . + + QLNet is a based on QuantLib, a free-software/open-source library + for financial quantitative analysts and developers - http://quantlib.org/ + The QuantLib license is available online at http://quantlib.org/license.shtml. + + This program is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS + FOR A PARTICULAR PURPOSE. See the license for more details. */ using System; @@ -27,9 +27,16 @@ public abstract class MCVanillaEngine : MCVanillaEngine : McSimulationfull false bin\Debug\ - TRACE;DEBUG;QL_NEGATIVE_RATES + TRACE;DEBUG;QL_NEGATIVE_RATES,QL_DOTNET_FRAMEWORK prompt 4 false @@ -49,7 +49,7 @@ pdbonly true bin\Release\ - TRACE + TRACE;QL_NEGATIVE_RATES,QL_DOTNET_FRAMEWORK prompt 4 AllRules.ruleset @@ -66,7 +66,7 @@ - + @@ -90,6 +90,7 @@ + @@ -110,8 +111,8 @@ - - + + @@ -233,6 +234,10 @@ + + + + @@ -437,6 +442,7 @@ + diff --git a/QLNet/QLNet.xproj b/QLNet/QLNet.xproj new file mode 100644 index 000000000..995ce713c --- /dev/null +++ b/QLNet/QLNet.xproj @@ -0,0 +1,19 @@ + + + + 14.0 + $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion) + + + + 57246126-d94b-48ec-a3e3-4167bceff7c5 + QLNet + .\obj + .\bin\ + v4.5.2 + + + 2.0 + + + \ No newline at end of file diff --git a/QLNet/Termstructures/Credit/HazardRateStructure.cs b/QLNet/Termstructures/Credit/HazardRateStructure.cs index ca0dff2e8..042423712 100644 --- a/QLNet/Termstructures/Credit/HazardRateStructure.cs +++ b/QLNet/Termstructures/Credit/HazardRateStructure.cs @@ -1,5 +1,5 @@ /* - Copyright (C) 2008-2013 Andrea Maggiulli (a.maggiulli@gmail.com) + Copyright (C) 2008-2016 Andrea Maggiulli (a.maggiulli@gmail.com) This file is part of QLNet Project https://github.com/amaggiulli/qlnet @@ -34,7 +34,7 @@ Hazard rates are defined with annual frequency and continuous \ingroup defaultprobabilitytermstructures */ - public class HazardRateStructure : DefaultProbabilityTermStructure + public abstract class HazardRateStructure : DefaultProbabilityTermStructure { #region Constructors @@ -59,8 +59,7 @@ public HazardRateStructure(int settlementDays,Calendar cal,DayCounter dc = null, // must assume that extrapolation is required. //! hazard rate calculation - protected virtual double hazardRateImpl(double t) - {throw new NotImplementedException("HazardRateStructure.hazardRateImpl");} + protected abstract double hazardRateImpl(double t); #endregion diff --git a/QLNet/Termstructures/DefaultProbabilityTermStructure.cs b/QLNet/Termstructures/DefaultProbabilityTermStructure.cs index 7fa949272..ce1338ebc 100644 --- a/QLNet/Termstructures/DefaultProbabilityTermStructure.cs +++ b/QLNet/Termstructures/DefaultProbabilityTermStructure.cs @@ -1,5 +1,6 @@ /* Copyright (C) 2008 Toyin Akin (toyin_akin@hotmail.com) + Copyright (C) 2008-2016 Andrea Maggiulli (a.maggiulli@gmail.com) This file is part of QLNet Project https://github.com/amaggiulli/qlnet @@ -27,7 +28,7 @@ credit structures which will be derived from this one. \ingroup defaultprobabilitytermstructures */ - public class DefaultProbabilityTermStructure : TermStructure + public abstract class DefaultProbabilityTermStructure : TermStructure { #region Constructors @@ -233,12 +234,10 @@ public override void update() // must assume that extrapolation is required. //! survival probability calculation - protected virtual double survivalProbabilityImpl(double t) - {throw new NotImplementedException("DefaultProbabilityTermStructure.survivalProbabilityImpl");} + protected abstract double survivalProbabilityImpl(double t); //! default density calculation - protected virtual double defaultDensityImpl(double t) - {throw new NotImplementedException("DefaultProbabilityTermStructure.defaultDensityImpl");} + protected abstract double defaultDensityImpl(double t); #endregion diff --git a/QLNet/Termstructures/Inflation/InflationHelpers.cs b/QLNet/Termstructures/Inflation/InflationHelpers.cs index 4f567bf27..8337040bb 100644 --- a/QLNet/Termstructures/Inflation/InflationHelpers.cs +++ b/QLNet/Termstructures/Inflation/InflationHelpers.cs @@ -68,7 +68,7 @@ public ZeroCouponInflationSwapHelper( { Period pShift = new Period(zii_.frequency()); if ( (swapObsLag_ - pShift) <= zii_.availabilityLag()) - throw new ApplicationException( + throw new Exception( "inconsistency between swap observation of index " + swapObsLag_ + " index availability " + zii_.availabilityLag() + diff --git a/QLNet/Termstructures/Inflation/PiecewiseYoYInflationCurve.cs b/QLNet/Termstructures/Inflation/PiecewiseYoYInflationCurve.cs index f219f277f..6c0785018 100644 --- a/QLNet/Termstructures/Inflation/PiecewiseYoYInflationCurve.cs +++ b/QLNet/Termstructures/Inflation/PiecewiseYoYInflationCurve.cs @@ -156,7 +156,7 @@ public List> instruments_ { //todo edem List> instruments = new List>(); - _instruments_.ForEach( x => instruments.Add( x ) ); + _instruments_.ForEach((i, x) => instruments.Add( x ) ); return instruments; } } diff --git a/QLNet/Termstructures/Inflation/PiecewiseZeroInflationCurve.cs b/QLNet/Termstructures/Inflation/PiecewiseZeroInflationCurve.cs index 540ec1269..670e05b37 100644 --- a/QLNet/Termstructures/Inflation/PiecewiseZeroInflationCurve.cs +++ b/QLNet/Termstructures/Inflation/PiecewiseZeroInflationCurve.cs @@ -157,7 +157,7 @@ public List> instruments_ { //todo edem List> instruments = new List>(); - _instruments_.ForEach( x => instruments.Add( x ) ); + _instruments_.ForEach((i, x) => instruments.Add( x ) ); return instruments; } } diff --git a/QLNet/Termstructures/Inflation/Seasonality.cs b/QLNet/Termstructures/Inflation/Seasonality.cs index 9506d089a..f45cf7b6f 100644 --- a/QLNet/Termstructures/Inflation/Seasonality.cs +++ b/QLNet/Termstructures/Inflation/Seasonality.cs @@ -192,12 +192,12 @@ public virtual double seasonalityFactor(Date to) } else if (factorPeriod.units() == TimeUnit.Years) { - throw new ApplicationException( + throw new Exception( "seasonality period time unit is not allowed to be : " + factorPeriod.units()); } else { - throw new ApplicationException("Unknown time unit: " + factorPeriod.units()); + throw new Exception("Unknown time unit: " + factorPeriod.units()); } // now adjust to the available number of factors, direction dependent @@ -253,7 +253,7 @@ public override bool isConsistent(InflationTermStructure iTS) { double factorAt = this.seasonalityFactor(curveBaseDate+new Period(i,TimeUnit.Years)); if (Math.Abs(factorAt-factorBase)>=eps) - throw new ApplicationException("seasonality is inconsistent with inflation " + + throw new Exception("seasonality is inconsistent with inflation " + "term structure, factors " + factorBase + " and later factor " + factorAt + ", " + i + " years later from inflation curve " + " with base date at " + curveBaseDate); @@ -276,13 +276,13 @@ protected virtual void validate() case Frequency.Weekly: case Frequency.Daily: if ((this.seasonalityFactors().Count % (int)this.frequency()) != 0) - throw new ApplicationException( + throw new Exception( "For frequency " + this.frequency() + " require multiple of " + ((int)this.frequency()) + " factors " + this.seasonalityFactors().Count + " were given."); break; default: - throw new ApplicationException("bad frequency specified: " + this.frequency() + throw new Exception("bad frequency specified: " + this.frequency() + ", only semi-annual through daily permitted."); } diff --git a/QLNet/Termstructures/InflationTermStructure.cs b/QLNet/Termstructures/InflationTermStructure.cs index 4f36dd045..a92485bfa 100644 --- a/QLNet/Termstructures/InflationTermStructure.cs +++ b/QLNet/Termstructures/InflationTermStructure.cs @@ -1,7 +1,7 @@ /* Copyright (C) 2008 Toyin Akin (toyin_akin@hotmail.com) Copyright (C) 2008 Siarhei Novik (snovik@gmail.com) - Copyright (C) 2008, 2009 , 2010 Andrea Maggiulli (a.maggiulli@gmail.com) + Copyright (C) 2008-2016 Andrea Maggiulli (a.maggiulli@gmail.com) This file is part of QLNet Project https://github.com/amaggiulli/qlnet @@ -47,7 +47,7 @@ public static KeyValuePair inflationPeriod(Date d, Frequency frequen startMonth = endMonth = month; break; default: - throw new ApplicationException("Frequency not handled: " + frequency); + throw new Exception("Frequency not handled: " + frequency); } Date startDate = new Date(1, startMonth, year); @@ -83,7 +83,7 @@ public static double inflationYearFraction(Frequency f, bool indexIsInterpolated //! Interface for inflation term structures. //! \ingroup inflationtermstructures - public class InflationTermStructure : TermStructure + public abstract class InflationTermStructure : TermStructure { public InflationTermStructure() { } @@ -170,7 +170,7 @@ interpolated it is the beginning of the relevant period a not-interpolated curve because interpolation, usually, of fixings is forward looking). */ - public virtual Date baseDate() { return null; } + public abstract Date baseDate(); //@} //! Functions to set and get seasonality. @@ -184,7 +184,7 @@ public void setSeasonality(Seasonality seasonality = null) if (seasonality_ != null) { if (!seasonality_.isConsistent(this)) - throw new ApplicationException("Seasonality inconsistent with " + + throw new Exception("Seasonality inconsistent with " + "inflation term structure"); } notifyObservers(); @@ -211,10 +211,10 @@ public void setSeasonality(Seasonality seasonality = null) protected override void checkRange(Date d,bool extrapolate) { if (d < baseDate()) - throw new ApplicationException("date (" + d + ") is before base date"); + throw new Exception("date (" + d + ") is before base date"); if (!extrapolate && allowsExtrapolation() && d > maxDate()) - throw new ApplicationException("date (" + d + ") is past max curve date (" + throw new Exception("date (" + d + ") is past max curve date (" + maxDate() + ")"); } @@ -225,8 +225,8 @@ protected override void checkRange(Date d,bool extrapolate) //! Interface for zero inflation term structures. // Child classes use templates but do not want that exposed to // general users. - public class ZeroInflationTermStructure : InflationTermStructure - { + public abstract class ZeroInflationTermStructure : InflationTermStructure + { public ZeroInflationTermStructure() { } //! \name Constructors @@ -348,15 +348,15 @@ public double zeroRate(Date d, Period instObsLag, //@} //! to be defined in derived classes - protected virtual double zeroRateImpl(double t) {return 0;} - - } + protected abstract double zeroRateImpl(double t); + + } //! Base class for year-on-year inflation term structures. - public class YoYInflationTermStructure : InflationTermStructure - { + public abstract class YoYInflationTermStructure : InflationTermStructure + { public YoYInflationTermStructure() { } //! \name Constructors //@{ @@ -465,8 +465,7 @@ public double yoyRate(Date d, Period instObsLag, bool forceLinearInterpolation, //@} //! to be defined in derived classes - protected virtual double yoyRateImpl(double time) { return 0; } - + protected abstract double yoyRateImpl(double time); } diff --git a/QLNet/Termstructures/Iterativebootstrap.cs b/QLNet/Termstructures/Iterativebootstrap.cs index 8e0221dde..17b7b63fa 100644 --- a/QLNet/Termstructures/Iterativebootstrap.cs +++ b/QLNet/Termstructures/Iterativebootstrap.cs @@ -152,7 +152,7 @@ public void setup(T ts) throw new ArgumentException("not enough instruments: " + n_ + " provided, " + (ts_.interpolator_.requiredPoints-1) + " required"); - ts_.instruments_.ForEach(x => ts_.registerWith(x)); + ts_.instruments_.ForEach((i, x) => ts_.registerWith(x)); loopRequired_ = ts_.interpolator_.global; } @@ -191,7 +191,7 @@ public void calculate() for (int iteration = 0; ; ++iteration) { - previousData_ = ts_.data_; + previousData_ = new List(ts_.data_); for (int i = 1; i <= alive_; ++i) { diff --git a/QLNet/Termstructures/TermStructure.cs b/QLNet/Termstructures/TermStructure.cs index b556a465e..286dbdb10 100644 --- a/QLNet/Termstructures/TermStructure.cs +++ b/QLNet/Termstructures/TermStructure.cs @@ -1,5 +1,6 @@ /* Copyright (C) 2008 Siarhei Novik (snovik@gmail.com) + Copyright (C) 2008-2016 Andrea Maggiulli (a.maggiulli@gmail.com) This file is part of QLNet Project https://github.com/amaggiulli/qlnet @@ -16,12 +17,11 @@ under the terms of the QLNet license. You should have received a ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the license for more details. */ -using System; namespace QLNet { //! Basic term-structure functionality - public class TermStructure : Extrapolator, IObserver, IObservable + public abstract class TermStructure : Extrapolator, IObserver, IObservable { #region Constructors @@ -92,7 +92,7 @@ public TermStructure(int settlementDays, Calendar cal, DayCounter dc = null) //! date/time conversion public double timeFromReference( Date date) { return dayCounter().yearFraction(referenceDate(), date);} //! the latest date for which the curve can return values - public virtual Date maxDate() { throw new NotSupportedException(); } + public abstract Date maxDate(); //! the latest time for which the curve can return values public virtual double maxTime() {return timeFromReference(maxDate());} //! the date at which discount = 1.0 and/or variance = 0.0 @@ -159,9 +159,9 @@ protected void checkRange(double t, bool extrapolate) protected bool moving_; protected bool updated_; + protected Calendar calendar_; + - - private Calendar calendar_; private Date referenceDate_; private int? settlementDays_; private DayCounter dayCounter_; diff --git a/QLNet/Termstructures/Volatility/Bond/CallableBondVolatilityStructure.cs b/QLNet/Termstructures/Volatility/Bond/CallableBondVolatilityStructure.cs index ea2661a4a..939c6dc71 100644 --- a/QLNet/Termstructures/Volatility/Bond/CallableBondVolatilityStructure.cs +++ b/QLNet/Termstructures/Volatility/Bond/CallableBondVolatilityStructure.cs @@ -1,5 +1,5 @@ /* - Copyright (C) 2008, 2009 , 2010, 2011, 2012 Andrea Maggiulli (a.maggiulli@gmail.com) + Copyright (C) 2008-2016 Andrea Maggiulli (a.maggiulli@gmail.com) This file is part of QLNet Project https://github.com/amaggiulli/qlnet @@ -27,7 +27,7 @@ namespace QLNet concrete callable-bond volatility structures which will be derived from this one. */ - public class CallableBondVolatilityStructure : TermStructure + public abstract class CallableBondVolatilityStructure : TermStructure { /*! \name Constructors See the TermStructure documentation for issues regarding @@ -122,16 +122,16 @@ public SmileSection smileSection(Period optionTenor, Period bondTenor) //! \name Limits //@{ //! the largest length for which the term structure can return vols - public virtual Period maxBondTenor() {throw new ApplicationException("maxBondTenor need implementation");} + public abstract Period maxBondTenor(); //! the largest bondLength for which the term structure can return vols public virtual double maxBondLength() { return timeFromReference(referenceDate() + maxBondTenor()); } //! the minimum strike for which the term structure can return vols - public virtual double minStrike() { throw new ApplicationException("minStrike need implementation"); } + public abstract double minStrike(); //! the maximum strike for which the term structure can return vols - public virtual double maxStrike() { throw new ApplicationException("maxStrike need implementation"); } + public abstract double maxStrike(); //@} //! implements the conversion between dates and times public virtual KeyValuePair convertDates(Date optionDate, Period bondTenor) @@ -154,12 +154,10 @@ public Date optionDateFromTenor(Period optionTenor) } //! return smile section - protected virtual SmileSection smileSectionImpl( double optionTime, double bondLength) - { throw new ApplicationException("smileSectionImpl need implementation"); } + protected abstract SmileSection smileSectionImpl(double optionTime, double bondLength); //! implements the actual volatility calculation in derived classes - protected virtual double volatilityImpl(double optionTime, double bondLength, double strike) - { throw new ApplicationException("volatilityImpl need implementation"); } + protected abstract double volatilityImpl(double optionTime, double bondLength, double strike); protected virtual double volatilityImpl(Date optionDate, Period bondTenor, double strike) { KeyValuePair p = convertDates(optionDate, bondTenor); diff --git a/QLNet/Termstructures/Volatility/CapFloor/CapFloorTermVolatilityStructure.cs b/QLNet/Termstructures/Volatility/CapFloor/CapFloorTermVolatilityStructure.cs index c0409d28d..9101a8fd8 100644 --- a/QLNet/Termstructures/Volatility/CapFloor/CapFloorTermVolatilityStructure.cs +++ b/QLNet/Termstructures/Volatility/CapFloor/CapFloorTermVolatilityStructure.cs @@ -1,5 +1,5 @@ /* - Copyright (C) 2008 Andrea Maggiulli + Copyright (C) 2008-2016 Andrea Maggiulli (a.maggiulli@gmail.com) This file is part of QLNet Project https://github.com/amaggiulli/qlnet @@ -25,7 +25,7 @@ namespace QLNet /*! This class is purely abstract and defines the interface of concrete structures which will be derived from this one. */ - public class CapFloorTermVolatilityStructure : VolatilityTermStructure + public abstract class CapFloorTermVolatilityStructure : VolatilityTermStructure { #region Constructors /*! \warning term structures initialized by means of this @@ -72,6 +72,6 @@ public double volatility(double t, double strike, bool extrapolate = false) #endregion //! implements the actual volatility calculation in derived classes - protected virtual double volatilityImpl(double length, double strike) { throw new NotSupportedException(); } - } + protected abstract double volatilityImpl(double length, double strike); + } } diff --git a/QLNet/Termstructures/Volatility/Inflation/CPIVolatilitySurface.cs b/QLNet/Termstructures/Volatility/Inflation/CPIVolatilitySurface.cs index e7ac2c54f..dbd897749 100644 --- a/QLNet/Termstructures/Volatility/Inflation/CPIVolatilitySurface.cs +++ b/QLNet/Termstructures/Volatility/Inflation/CPIVolatilitySurface.cs @@ -1,5 +1,5 @@ /* - Copyright (C) 2008, 2009 , 2010, 2011 Andrea Maggiulli (a.maggiulli@gmail.com) + Copyright (C) 2008-2016 Andrea Maggiulli (a.maggiulli@gmail.com) This file is part of QLNet Project https://github.com/amaggiulli/qlnet @@ -27,7 +27,7 @@ namespace QLNet some base date. Also deal with lagged observations of an index with a (usually different) availability lag. */ - public class CPIVolatilitySurface : VolatilityTermStructure + public abstract class CPIVolatilitySurface : VolatilityTermStructure { //public CPIVolatilitySurface() // : base(BusinessDayConvention.Following, null) { } @@ -193,7 +193,7 @@ public virtual double timeFromBase(Date maturityDate, Period obsLag = null) public virtual double? baseLevel() { if(baseLevel_ == null ) - throw new ApplicationException("Base volatility, for baseDate(), not set."); + throw new Exception("Base volatility, for baseDate(), not set."); return baseLevel_; } //@} @@ -201,9 +201,9 @@ public virtual double timeFromBase(Date maturityDate, Period obsLag = null) //! \name Limits //@{ //! the minimum strike for which the term structure can return vols - public override double minStrike() { throw new NotSupportedException(); } + //public abstract double minStrike(); //! the maximum strike for which the term structure can return vols - public override double maxStrike() { throw new NotSupportedException(); } + //public abstract double maxStrike(); //@} protected virtual void checkRange(Date d, double strike, bool extrapolate) @@ -236,7 +236,7 @@ protected virtual void checkRange(double t, double strike, bool extrapolate) derived classes e.g. bilinear interpolation. N.B. does not derive the surface. */ - protected virtual double volatilityImpl(double length, double strike) { throw new NotSupportedException(); } + protected abstract double volatilityImpl(double length, double strike); protected double? baseLevel_; // so you do not need an index diff --git a/QLNet/Termstructures/Volatility/Inflation/yoyinflationoptionletvolatilitystructure.cs b/QLNet/Termstructures/Volatility/Inflation/yoyinflationoptionletvolatilitystructure.cs index ec15e2d9f..ac1c85cda 100644 --- a/QLNet/Termstructures/Volatility/Inflation/yoyinflationoptionletvolatilitystructure.cs +++ b/QLNet/Termstructures/Volatility/Inflation/yoyinflationoptionletvolatilitystructure.cs @@ -1,5 +1,5 @@ /* - Copyright (C) 2008, 2009 , 2010 Andrea Maggiulli (a.maggiulli@gmail.com) + Copyright (C) 2008-2016 Andrea Maggiulli (a.maggiulli@gmail.com) This file is part of QLNet Project https://github.com/amaggiulli/qlnet @@ -30,7 +30,7 @@ totalVariance. Also deal with lagged observations of an index with a (usually different) availability lag. */ - public class YoYOptionletVolatilitySurface : VolatilityTermStructure + public abstract class YoYOptionletVolatilitySurface : VolatilityTermStructure { //public YoYOptionletVolatilitySurface() //: base (BusinessDayConvention.Following,null) {} @@ -211,19 +211,12 @@ public virtual double timeFromBase(Date maturityDate,Period obsLag) } //@} - //! \name Limits - //@{ - //! the minimum strike for which the term structure can return vols - public override double minStrike() { return 0 ;} - //! the maximum strike for which the term structure can return vols - public override double maxStrike() { return 0; } - //@} // acts as zero time value for boostrapping public virtual double baseLevel() { if (baseLevel_ == null) - throw new ApplicationException("Base volatility, for baseDate(), not set."); + throw new Exception("Base volatility, for baseDate(), not set."); return baseLevel_.Value; } @@ -232,31 +225,31 @@ protected virtual void checkRange(Date d, double strike,bool extrapolate) { if ( d < baseDate() ) - throw new ApplicationException ("date (" + d + ") is before base date"); + throw new Exception ("date (" + d + ") is before base date"); if ( !extrapolate && !allowsExtrapolation() && d > maxDate()) - throw new ApplicationException ("date (" + d + ") is past max curve date (" + throw new Exception ("date (" + d + ") is past max curve date (" + maxDate() + ")"); if ( !extrapolate && !allowsExtrapolation() && ( strike < minStrike() || strike > maxStrike())) - throw new ApplicationException ("strike (" + strike + ") is outside the curve domain [" + throw new Exception ("strike (" + strike + ") is outside the curve domain [" + minStrike() + "," + maxStrike()+ "]] at date = " + d); } protected virtual void checkRange(double t, double strike,bool extrapolate) { if ( t < timeFromReference(baseDate()) ) - throw new ApplicationException("time (" + t + ") is before base date"); + throw new Exception("time (" + t + ") is before base date"); if ( !extrapolate && !allowsExtrapolation() && t > maxTime() ) - throw new ApplicationException("time (" + t + ") is past max curve time (" + throw new Exception("time (" + t + ") is past max curve time (" + maxTime() + ")"); if ( !extrapolate && !allowsExtrapolation() && (strike < minStrike() || strike > maxStrike())) - throw new ApplicationException("strike (" + strike + ") is outside the curve domain [" + throw new Exception("strike (" + strike + ") is outside the curve domain [" + minStrike() + "," + maxStrike()+ "] at time = " + t); } @@ -265,7 +258,7 @@ protected virtual void checkRange(double t, double strike,bool extrapolate) //! Implements the actual volatility surface calculation in //! derived classes e.g. bilinear interpolation. N.B. does //! not derive the surface. - protected virtual double volatilityImpl(double length, double strike) { return 0; } + protected abstract double volatilityImpl(double length, double strike); // acts as zero time value for boostrapping diff --git a/QLNet/Termstructures/Volatility/Optionlet/OptionletVolatilityStructure.cs b/QLNet/Termstructures/Volatility/Optionlet/OptionletVolatilityStructure.cs index 38d61f647..5600bde74 100644 --- a/QLNet/Termstructures/Volatility/Optionlet/OptionletVolatilityStructure.cs +++ b/QLNet/Termstructures/Volatility/Optionlet/OptionletVolatilityStructure.cs @@ -1,5 +1,6 @@ /* Copyright (C) 2008 Siarhei Novik (snovik@gmail.com) + Copyright (C) 2008-2016 Andrea Maggiulli (a.maggiulli@gmail.com) This file is part of QLNet Project https://github.com/amaggiulli/qlnet @@ -24,7 +25,7 @@ namespace QLNet /*! This class is purely abstract and defines the interface of concrete structures which will be derived from this one. */ - public class OptionletVolatilityStructure : VolatilityTermStructure + public abstract class OptionletVolatilityStructure : VolatilityTermStructure { #region Constructors //! default constructor @@ -119,13 +120,16 @@ public SmileSection smileSection(double optionTime, bool extr = false) #endregion + public virtual double displacement() {return 0.0;} + public virtual VolatilityType volatilityType() {return VolatilityType.ShiftedLognormal;} + protected virtual SmileSection smileSectionImpl(Date optionDate) { return smileSectionImpl(timeFromReference(optionDate)); } //! implements the actual smile calculation in derived classes - protected virtual SmileSection smileSectionImpl(double optionTime) { throw new NotImplementedException(); } + protected abstract SmileSection smileSectionImpl(double optionTime); protected double volatilityImpl(Date optionDate, double strike) { @@ -133,8 +137,9 @@ protected double volatilityImpl(Date optionDate, double strike) } //! implements the actual volatility calculation in derived classes - protected virtual double volatilityImpl(double optionTime, double strike) { throw new NotImplementedException(); } - + protected abstract double volatilityImpl(double optionTime, double strike); + + } } diff --git a/QLNet/Termstructures/Volatility/Sabr.cs b/QLNet/Termstructures/Volatility/Sabr.cs index 250d25371..f35464c13 100644 --- a/QLNet/Termstructures/Volatility/Sabr.cs +++ b/QLNet/Termstructures/Volatility/Sabr.cs @@ -61,23 +61,23 @@ public static double unsafeSabrVolatility(double strike, double forward, double public static void validateSabrParameters(double alpha, double beta, double nu, double rho) { if (!(alpha > 0.0)) - throw new ApplicationException("alpha must be positive: " + alpha + " not allowed"); + throw new Exception("alpha must be positive: " + alpha + " not allowed"); if (!(beta >= 0.0 && beta <= 1.0)) - throw new ApplicationException("beta must be in (0.0, 1.0): " + beta + " not allowed"); + throw new Exception("beta must be in (0.0, 1.0): " + beta + " not allowed"); if (!(nu >= 0.0)) - throw new ApplicationException("nu must be non negative: " + nu + " not allowed"); + throw new Exception("nu must be non negative: " + nu + " not allowed"); if (!(rho * rho < 1.0)) - throw new ApplicationException("rho square must be less than one: " + rho + " not allowed"); + throw new Exception("rho square must be less than one: " + rho + " not allowed"); } public static double sabrVolatility(double strike, double forward, double expiryTime, double alpha, double beta, double nu, double rho) { if (!(strike>0.0)) - throw new ApplicationException("strike must be positive: " + strike + " not allowed"); + throw new Exception("strike must be positive: " + strike + " not allowed"); if (!(forward>0.0)) - throw new ApplicationException("at the money forward rate must be: " + forward + " not allowed"); + throw new Exception("at the money forward rate must be: " + forward + " not allowed"); if (!(expiryTime>=0.0)) - throw new ApplicationException("expiry time must be non-negative: " + expiryTime + " not allowed"); + throw new Exception("expiry time must be non-negative: " + expiryTime + " not allowed"); validateSabrParameters(alpha, beta, nu, rho); return unsafeSabrVolatility(strike, forward, expiryTime, alpha, beta, nu, rho); } diff --git a/QLNet/Termstructures/Volatility/SmileSection.cs b/QLNet/Termstructures/Volatility/SmileSection.cs index a55715d60..33813fc3c 100644 --- a/QLNet/Termstructures/Volatility/SmileSection.cs +++ b/QLNet/Termstructures/Volatility/SmileSection.cs @@ -208,7 +208,7 @@ public SabrSmileSection(double timeToExpiry, double forward, List sabrPa rho_ = sabrParams[3]; if (!(forward_>0.0)) - throw new ApplicationException("at the money forward rate must be: " + forward_ + " not allowed"); + throw new Exception("at the money forward rate must be: " + forward_ + " not allowed"); Utils.validateSabrParameters(alpha_, beta_, nu_, rho_); } @@ -222,7 +222,7 @@ public SabrSmileSection( Date d, double forward, List sabrParams, DayCou rho_ = sabrParams[3]; if (!(forward_>0.0)) - throw new ApplicationException("at the money forward rate must be: " + forward_ + " not allowed"); + throw new Exception("at the money forward rate must be: " + forward_ + " not allowed"); Utils.validateSabrParameters(alpha_, beta_, nu_, rho_); } diff --git a/QLNet/Termstructures/Volatility/equityfx/BlackVarianceCurve.cs b/QLNet/Termstructures/Volatility/equityfx/BlackVarianceCurve.cs index dbb33ea26..969cadd7f 100644 --- a/QLNet/Termstructures/Volatility/equityfx/BlackVarianceCurve.cs +++ b/QLNet/Termstructures/Volatility/equityfx/BlackVarianceCurve.cs @@ -57,13 +57,13 @@ public BlackVarianceCurve(Date referenceDate, List dates, List bla maxDate_ = dates.Last(); if (!(dates.Count == blackVolCurve.Count)) - throw new ApplicationException("mismatch between date vector and black vol vector"); + throw new Exception("mismatch between date vector and black vol vector"); // cannot have dates[0]==referenceDate, since the // value of the vol at dates[0] would be lost // (variance at referenceDate must be zero) if (!(dates[0]>referenceDate)) - throw new ApplicationException("cannot have dates[0] <= referenceDate"); + throw new Exception("cannot have dates[0] <= referenceDate"); variances_ = new InitializedList(dates.Count+1); times_ = new InitializedList(dates.Count + 1); @@ -73,10 +73,10 @@ public BlackVarianceCurve(Date referenceDate, List dates, List bla times_[j] = timeFromReference(dates[j-1]); if (!(times_[j]>times_[j-1])) - throw new ApplicationException("dates must be sorted unique!"); + throw new Exception("dates must be sorted unique!"); variances_[j] = times_[j] * blackVolCurve[j-1]*blackVolCurve[j-1]; if (!(variances_[j]>=variances_[j-1] || !forceMonotoneVariance)) - throw new ApplicationException("variance must be non-decreasing"); + throw new Exception("variance must be non-decreasing"); } // default: linear interpolation diff --git a/QLNet/Termstructures/Volatility/equityfx/BlackVolTermStructure.cs b/QLNet/Termstructures/Volatility/equityfx/BlackVolTermStructure.cs index 5f698a1b0..47acfb3b5 100644 --- a/QLNet/Termstructures/Volatility/equityfx/BlackVolTermStructure.cs +++ b/QLNet/Termstructures/Volatility/equityfx/BlackVolTermStructure.cs @@ -1,5 +1,6 @@ /* Copyright (C) 2008 Siarhei Novik (snovik@gmail.com) + Copyright (C) 2008-2016 Andrea Maggiulli (a.maggiulli@gmail.com) This file is part of QLNet Project https://github.com/amaggiulli/qlnet @@ -27,7 +28,7 @@ this one. Volatilities are assumed to be expressed on an annual basis. */ - public class BlackVolTermStructure : VolatilityTermStructure + public abstract class BlackVolTermStructure : VolatilityTermStructure { private const double dT = 1.0/365.0; @@ -189,14 +190,14 @@ public double blackForwardVariance(double time1, double time2, double strike, b // assume that extrapolation is required. //! Black variance calculation - protected virtual double blackVarianceImpl(double t, double strike) { throw new NotSupportedException(); } + protected abstract double blackVarianceImpl(double t, double strike); //! Black volatility calculation - protected virtual double blackVolImpl(double t, double strike) { throw new NotSupportedException(); } - + protected abstract double blackVolImpl(double t, double strike); + #endregion - } + } //! Black-volatility term structure /*! This abstract class acts as an adapter to BlackVolTermStructure @@ -206,7 +207,7 @@ allowing the programmer to implement only the Volatility are assumed to be expressed on an annual basis. */ - public class BlackVolatilityTermStructure : BlackVolTermStructure + public abstract class BlackVolatilityTermStructure : BlackVolTermStructure { #region Constructors @@ -260,7 +261,7 @@ the programmer to implement only the Volatility are assumed to be expressed on an annual basis. */ - public class BlackVarianceTermStructure : BlackVolTermStructure + public abstract class BlackVarianceTermStructure : BlackVolTermStructure { #region Constructors //! default constructor diff --git a/QLNet/Termstructures/Volatility/equityfx/LocalVolSurface.cs b/QLNet/Termstructures/Volatility/equityfx/LocalVolSurface.cs index ad8f159b3..47603de31 100644 --- a/QLNet/Termstructures/Volatility/equityfx/LocalVolSurface.cs +++ b/QLNet/Termstructures/Volatility/equityfx/LocalVolSurface.cs @@ -99,7 +99,7 @@ protected override double localVolImpl(double t, double underlyingLevel) { wpt = blackTS_.link.blackVariance(t+dt, strike, true); if (!(wpt>=w)) - throw new ApplicationException("decreasing variance at strike " + strike + throw new Exception("decreasing variance at strike " + strike + " between time " + t + " and time " + (t+dt)); dwdt = (wpt-w)/dt; } else { @@ -107,10 +107,10 @@ protected override double localVolImpl(double t, double underlyingLevel) { wpt = blackTS_.link.blackVariance(t+dt, strike, true); wmt = blackTS_.link.blackVariance(t-dt, strike, true); if (!(wpt>=w)) - throw new ApplicationException("decreasing variance at strike " + strike + throw new Exception("decreasing variance at strike " + strike + " between time " + t + " and time " + (t+dt)); if (!(w>=wmt)) - throw new ApplicationException("decreasing variance at strike " + strike + throw new Exception("decreasing variance at strike " + strike + " between time " + (t-dt) + " and time " + t); dwdt = (wpt-wmt)/(2.0*dt); } @@ -124,7 +124,7 @@ protected override double localVolImpl(double t, double underlyingLevel) { double den = den1+den2+den3; double result = dwdt / den; if (!(result>=0.0)) - throw new ApplicationException("negative local vol^2 at strike " + strike + throw new Exception("negative local vol^2 at strike " + strike + " and time " + t + "; the black vol surface is not smooth enough"); return Math.Sqrt(result); // return std::sqrt(dwdt / (1.0 - y/w*dwdy + diff --git a/QLNet/Termstructures/Volatility/equityfx/LocalVolTermStructure.cs b/QLNet/Termstructures/Volatility/equityfx/LocalVolTermStructure.cs index 6d9f91caf..0b87657d9 100644 --- a/QLNet/Termstructures/Volatility/equityfx/LocalVolTermStructure.cs +++ b/QLNet/Termstructures/Volatility/equityfx/LocalVolTermStructure.cs @@ -1,5 +1,6 @@ /* Copyright (C) 2008 Siarhei Novik (snovik@gmail.com) + Copyright (C) 2008-2016 Andrea Maggiulli (a.maggiulli@gmail.com) This file is part of QLNet Project https://github.com/amaggiulli/qlnet @@ -26,7 +27,7 @@ namespace QLNet Volatilities are assumed to be expressed on an annual basis. */ - public class LocalVolTermStructure : VolatilityTermStructure + public abstract class LocalVolTermStructure : VolatilityTermStructure { #region Constructors //! default constructor @@ -78,9 +79,9 @@ assume that extrapolation is required. */ //! local vol calculation - protected virtual double localVolImpl(double t, double strike) { throw new NotSupportedException(); } + protected abstract double localVolImpl(double t, double strike); #endregion - } + } } diff --git a/QLNet/Termstructures/Volatility/swaption/SwaptionVolatilityStructure.cs b/QLNet/Termstructures/Volatility/swaption/SwaptionVolatilityStructure.cs index 99b47f61a..368e553b9 100644 --- a/QLNet/Termstructures/Volatility/swaption/SwaptionVolatilityStructure.cs +++ b/QLNet/Termstructures/Volatility/swaption/SwaptionVolatilityStructure.cs @@ -1,5 +1,6 @@ /* Copyright (C) 2008 Toyin Akin (toyin_akin@hotmail.com) + Copyright (C) 2008-2016 Andrea Maggiulli (a.maggiulli@gmail.com) This file is part of QLNet Project https://github.com/amaggiulli/qlnet @@ -24,7 +25,7 @@ namespace QLNet /*! This abstract class defines the interface of concrete swaption volatility structures which will be derived from this one. */ - public class SwaptionVolatilityStructure : VolatilityTermStructure + public abstract class SwaptionVolatilityStructure : VolatilityTermStructure { #region Constructors /*! \warning term structures initialized by means of this @@ -184,7 +185,7 @@ public SmileSection smileSection(double optionTime, double swapLength, bool extr #region Limits //! the largest length for which the term structure can return vols - public virtual Period maxSwapTenor() { throw new NotSupportedException(); } + public abstract Period maxSwapTenor(); //! the largest swapLength for which the term structure can return vols public double maxSwapLength() { return swapLength(maxSwapTenor()); } @@ -222,14 +223,14 @@ protected virtual SmileSection smileSectionImpl(Date optionDate, Period swapTeno return smileSectionImpl(timeFromReference(optionDate), swapLength(swapTenor)); } - protected virtual SmileSection smileSectionImpl(double optionTime, double swapLength) { throw new NotSupportedException(); } + protected abstract SmileSection smileSectionImpl(double optionTime, double swapLength); protected virtual double volatilityImpl(Date optionDate, Period swapTenor, double strike) { return volatilityImpl(timeFromReference(optionDate), swapLength(swapTenor), strike); } - protected virtual double volatilityImpl(double optionTime, double swapLength, double strike) { throw new NotSupportedException(); } + protected abstract double volatilityImpl(double optionTime, double swapLength, double strike); protected void checkSwapTenor(Period swapTenor, bool extrapolate) { diff --git a/QLNet/Termstructures/Volatility/swaption/swaptionvoldiscrete.cs b/QLNet/Termstructures/Volatility/swaption/swaptionvoldiscrete.cs index 73d63fece..0af328ae6 100644 --- a/QLNet/Termstructures/Volatility/swaption/swaptionvoldiscrete.cs +++ b/QLNet/Termstructures/Volatility/swaption/swaptionvoldiscrete.cs @@ -1,5 +1,6 @@ /* Copyright (C) 2009 Philippe Real (ph_real@hotmail.com) + Copyright (C) 2008-2016 Andrea Maggiulli (a.maggiulli@gmail.com) This file is part of QLNet Project https://github.com/amaggiulli/qlnet @@ -21,7 +22,7 @@ under the terms of the QLNet license. You should have received a namespace QLNet { - public class SwaptionVolatilityDiscrete : SwaptionVolatilityStructure//, IObservable, IObserver + public abstract class SwaptionVolatilityDiscrete : SwaptionVolatilityStructure//, IObservable, IObserver { protected int nOptionTenors_; protected List optionTenors_; diff --git a/QLNet/Termstructures/Yield/PiecewiseYieldCurve.cs b/QLNet/Termstructures/Yield/PiecewiseYieldCurve.cs index b7df9ab75..a115b2d75 100644 --- a/QLNet/Termstructures/Yield/PiecewiseYieldCurve.cs +++ b/QLNet/Termstructures/Yield/PiecewiseYieldCurve.cs @@ -142,7 +142,7 @@ public List> instruments_ { //todo edem List> instruments = new List>(); - _instruments_.ForEach( x => instruments.Add( x ) ); + _instruments_.ForEach((i, x) => instruments.Add( x ) ); return instruments; } } diff --git a/QLNet/Termstructures/Yield/Ratehelpers.cs b/QLNet/Termstructures/Yield/Ratehelpers.cs index 0bdc3e839..60df14f49 100644 --- a/QLNet/Termstructures/Yield/Ratehelpers.cs +++ b/QLNet/Termstructures/Yield/Ratehelpers.cs @@ -35,6 +35,8 @@ public FuturesRateHelper( Handle price, Futures.Type type= Futures.Type.IMM) : base( price ) { + convAdj_ = convAdj ?? new Handle(); + switch (type) { case QLNet.Futures.Type.IMM: diff --git a/QLNet/Termstructures/Yield/Zeroyieldstructure.cs b/QLNet/Termstructures/Yield/Zeroyieldstructure.cs index c5ef1f207..f4979d0a0 100644 --- a/QLNet/Termstructures/Yield/Zeroyieldstructure.cs +++ b/QLNet/Termstructures/Yield/Zeroyieldstructure.cs @@ -1,5 +1,6 @@ /* Copyright (C) 2008, 2009 Siarhei Novik (snovik@gmail.com) + Copyright (C) 2008-2016 Andrea Maggiulli (a.maggiulli@gmail.com) This file is part of QLNet Project https://github.com/amaggiulli/qlnet @@ -32,7 +33,7 @@ Zero rates are assumed to be annual continuous compounding. \ingroup yieldtermstructures */ - public class ZeroYieldStructure : YieldTermStructure + public abstract class ZeroYieldStructure : YieldTermStructure { #region Constructors @@ -57,7 +58,7 @@ public ZeroYieldStructure(int settlementDays,Calendar calendar, DayCounter dc = // must assume that extrapolation is required. //! zero-yield calculation - protected virtual double zeroYieldImpl(double t) { throw new NotSupportedException(); } + protected abstract double zeroYieldImpl(double t); #endregion diff --git a/QLNet/Termstructures/YieldTermStructure.cs b/QLNet/Termstructures/YieldTermStructure.cs index ea6ec393a..e02d825b2 100644 --- a/QLNet/Termstructures/YieldTermStructure.cs +++ b/QLNet/Termstructures/YieldTermStructure.cs @@ -1,6 +1,6 @@ /* Copyright (C) 2008 Siarhei Novik (snovik@gmail.com) - Copyright (C) 2008 Andrea Maggiulli + Copyright (C) 2008-2016 Andrea Maggiulli (a.maggiulli@gmail.com) This file is part of QLNet Project https://github.com/amaggiulli/qlnet @@ -30,7 +30,7 @@ interest rate structures which will be derived from this one. \test observability against evaluation date changes is checked. */ - public class YieldTermStructure : TermStructure + public abstract class YieldTermStructure : TermStructure { private const double dt = 0.0001; @@ -272,7 +272,7 @@ public override void update() // must assume that extrapolation is required. //! discount factor calculation - protected virtual double discountImpl(double d) { throw new NotSupportedException(); } + protected abstract double discountImpl(double d); #endregion diff --git a/QLNet/Termstructures/localbootstrap.cs b/QLNet/Termstructures/localbootstrap.cs index 59ec71032..9098129cd 100644 --- a/QLNet/Termstructures/localbootstrap.cs +++ b/QLNet/Termstructures/localbootstrap.cs @@ -117,10 +117,10 @@ public void setup(T ts) { (ts_.interpolator_.requiredPoints) + " required"); if (!(n > localisation_)) - throw new ApplicationException("not enough instruments: " + n + " provided, " + localisation_ + " required."); + throw new Exception("not enough instruments: " + n + " provided, " + localisation_ + " required."); //ts_.instruments_.ForEach(i => i.registerWith(ts_.update)); - ts_.instruments_.ForEach( x => ts_.registerWith( x ) ); + ts_.instruments_.ForEach((i, x) => ts_.registerWith( x ) ); } public void calculate() { @@ -144,7 +144,7 @@ public void calculate() { ") has an invalid quote"); // setup instruments and register with them - ts_.instruments_.ForEach( j => ts_.setTermStructure( j ) ); + ts_.instruments_.ForEach((x, j) => ts_.setTermStructure( j ) ); // set initial guess only if the current curve cannot be used as guess if (validCurve_) { @@ -208,7 +208,7 @@ public void calculate() { // check the end criteria if (!(endType == EndCriteria.Type.StationaryFunctionAccuracy || endType == EndCriteria.Type.StationaryFunctionValue)) - throw new ApplicationException("Unable to strip yieldcurve to required accuracy "); + throw new Exception("Unable to strip yieldcurve to required accuracy "); ++iInst; } while (iInst < nInsts); diff --git a/QLNet/Termstructures/voltermstructure.cs b/QLNet/Termstructures/voltermstructure.cs index 3e34174f0..a25a27fef 100644 --- a/QLNet/Termstructures/voltermstructure.cs +++ b/QLNet/Termstructures/voltermstructure.cs @@ -1,5 +1,6 @@ /* Copyright (C) 2008 Siarhei Novik (snovik@gmail.com) + Copyright (C) 2008-2016 Andrea Maggiulli (a.maggiulli@gmail.com) This file is part of QLNet Project https://github.com/amaggiulli/qlnet @@ -25,7 +26,7 @@ namespace QLNet volatility structures which will be derived from this one. */ - public class VolatilityTermStructure : TermStructure + public abstract class VolatilityTermStructure : TermStructure { #region Constructors @@ -64,10 +65,10 @@ public Date optionDateFromTenor(Period p) } //! the minimum strike for which the term structure can return vols - public virtual double minStrike() { throw new NotSupportedException(); } + public abstract double minStrike(); //! the maximum strike for which the term structure can return vols - public virtual double maxStrike() { throw new NotSupportedException(); } + public abstract double maxStrike(); //! strike-range check protected void checkStrike(double k, bool extrapolate) diff --git a/QLNet/Time/Calendars/JointCalendar.cs b/QLNet/Time/Calendars/JointCalendar.cs index d54eb4cc8..a1fa36cf0 100644 --- a/QLNet/Time/Calendars/JointCalendar.cs +++ b/QLNet/Time/Calendars/JointCalendar.cs @@ -63,7 +63,7 @@ public override string name() { result += "JoinBusinessDays("; break; default: - throw new ApplicationException("unknown joint calendar rule"); + throw new Exception("unknown joint calendar rule"); } result += calendars_.First().name(); for(int i = 1; i < calendars_.Count; i++) @@ -83,7 +83,7 @@ public override bool isWeekend(DayOfWeek w) { if (c.isWeekend(w)) return false; return true; default: - throw new ApplicationException("unknown joint calendar rule"); + throw new Exception("unknown joint calendar rule"); } } @@ -100,7 +100,7 @@ public override bool isBusinessDay(Date date) { return true; return false; default: - throw new ApplicationException("unknown joint calendar rule"); + throw new Exception("unknown joint calendar rule"); } } } diff --git a/QLNet/Time/Calendars/Ukraine.cs b/QLNet/Time/Calendars/Ukraine.cs index 41e3a92cc..e412cfa2b 100644 --- a/QLNet/Time/Calendars/Ukraine.cs +++ b/QLNet/Time/Calendars/Ukraine.cs @@ -35,6 +35,7 @@ namespace QLNet
  • Victory Day, May 9th
  • Constitution Day, June 28th
  • Independence Day, August 24th
  • +
  • Defender's Day, October 14th (since 2015)
  • Holidays falling on a Saturday or Sunday are moved to the following Monday. @@ -52,7 +53,7 @@ public Ukraine(Market m = Market.USE ) calendar_ = Impl.Singleton; break; default: - throw new ApplicationException( "unknown market" ); + throw new Exception( "unknown market" ); } } @@ -75,26 +76,28 @@ public override bool isBusinessDay( Date date ) if ( isWeekend( w ) // New Year's Day (possibly moved to Monday) - || ( ( d == 1 || ( ( d == 2 || d == 3 ) && w == DayOfWeek.Monday ) ) - && m == Month.January ) + || ( ( d == 1 || ( ( d == 2 || d == 3 ) && w == DayOfWeek.Monday ) ) + && m == Month.January ) // Orthodox Christmas - || ( ( d == 7 || ( ( d == 8 || d == 9 ) && w == DayOfWeek.Monday ) ) - && m == Month.January ) + || ( ( d == 7 || ( ( d == 8 || d == 9 ) && w == DayOfWeek.Monday ) ) + && m == Month.January ) // Women's Day - || ( ( d == 8 || ( ( d == 9 || d == 10 ) && w == DayOfWeek.Monday ) ) - && m == Month.March ) + || ( ( d == 8 || ( ( d == 9 || d == 10 ) && w == DayOfWeek.Monday ) ) + && m == Month.March ) // Orthodox Easter Monday - || ( dd == em ) + || ( dd == em ) // Holy Trinity Day - || ( dd == em + 49 ) + || ( dd == em + 49 ) // Workers' Solidarity Days - || ( ( d == 1 || d == 2 || ( d == 3 && w == DayOfWeek.Monday ) ) && m == Month.May ) + || ( ( d == 1 || d == 2 || ( d == 3 && w == DayOfWeek.Monday ) ) && m == Month.May ) // Victory Day - || ( ( d == 9 || ( ( d == 10 || d == 11 ) && w == DayOfWeek.Monday ) ) && m == Month.May ) + || ( ( d == 9 || ( ( d == 10 || d == 11 ) && w == DayOfWeek.Monday ) ) && m == Month.May ) // Constitution Day - || ( d == 28 && m == Month.June ) + || ( d == 28 && m == Month.June ) // Independence Day - || ( d == 24 && m == Month.August ) ) + || ( d == 24 && m == Month.August ) + // Defender's Day (since 2015) + || ( d == 14 && m == Month.October && y >= 2015 ) ) return false; return true; } diff --git a/QLNet/Time/Calendars/brazil.cs b/QLNet/Time/Calendars/brazil.cs index 3c84152f2..dba45aa95 100644 --- a/QLNet/Time/Calendars/brazil.cs +++ b/QLNet/Time/Calendars/brazil.cs @@ -19,7 +19,7 @@ under the terms of the QLNet license. You should have received a using System; namespace QLNet { - //! Brazilian calendar + //! Brazilian calendar /*! Banking holidays:
    • Saturdays
    • @@ -63,7 +63,7 @@ namespace QLNet { \test the correctness of the returned results is tested against a list of known holidays. - */ + */ public class Brazil : Calendar { //! Brazilian calendars public enum Market { Settlement, //!< generic settlement calendar @@ -81,7 +81,7 @@ public Brazil(Market market) { calendar_ = ExchangeImpl.Singleton; break; default: - throw new ApplicationException("unknown market"); + throw new Exception("unknown market"); } } @@ -161,8 +161,8 @@ public override bool isBusinessDay(Date date) { // Republic Day || (d == 15 && m == Month.November) // Black Consciousness Day - || (d == 20 && m == Month.November && y >= 2007) - // Christmas Eve + || (d == 20 && m == Month.November && y >= 2007) + // Christmas Eve || ( d == 24 && m == Month.December ) // Christmas || (d == 25 && m == Month.December) diff --git a/QLNet/Time/Date.cs b/QLNet/Time/Date.cs index 601bd249d..15fe8a1ba 100644 --- a/QLNet/Time/Date.cs +++ b/QLNet/Time/Date.cs @@ -67,8 +67,7 @@ public Date(DateTime d) { //! System DateTime constructor public static bool isEndOfMonth(Date d) { return (d.Day == DaysInMonth(d.Year, d.Month)); } public static double daysBetween(Date d1, Date d2) { - double days = d2 - d1; - return days + d2.fractionOfDay() - d1.fractionOfDay(); + return ( d2.date - d1.date ).TotalDays; } //! next given weekday following or equal to the given date public static Date nextWeekday(Date d, DayOfWeek dayOfWeek) { @@ -108,7 +107,7 @@ public static Date advance(Date d, int n, TimeUnit u) { // operator overloads - public static int operator -(Date d1, Date d2) { return (d1.date - d2.date).Days; } + public static int operator -(Date d1, Date d2) { return (d1.date.Date - d2.date.Date).Days; } public static Date operator +(Date d, int days) { DateTime t = d.date; return new Date(t.AddDays(days)); } public static Date operator -(Date d, int days) { DateTime t = d.date; return new Date(t.AddDays(-days)); } public static Date operator +(Date d, TimeUnit u) { return advance(d, 1, u); } @@ -135,8 +134,8 @@ public static Date advance(Date d, int n, TimeUnit u) { public static bool operator >(Date d1, Date d2) { return (d1.date > d2.date); } public static bool operator >=(Date d1, Date d2) { return (d1.date >= d2.date); } - public string ToLongDateString() { return date.ToLongDateString(); } - public string ToShortDateString() { return date.ToShortDateString(); } + public string ToLongDateString() { return date.ToString("D"); } + public string ToShortDateString() { return date.ToString("d"); } public override string ToString() { return this.ToShortDateString(); } public string ToString(IFormatProvider provider) { return date.ToString(provider); } public string ToString(string format) { return date.ToString(format); } diff --git a/QLNet/Time/Imm.cs b/QLNet/Time/Imm.cs index 61fb43459..9a9d0a9db 100644 --- a/QLNet/Time/Imm.cs +++ b/QLNet/Time/Imm.cs @@ -58,12 +58,12 @@ public static bool isIMMcode(string s, bool mainCycle) { return false; string str1 = "0123456789"; - if (!str1.Contains(s[1])) + if (!str1.Contains(s[1].ToString())) return false; if (mainCycle) str1 = "hmzuHMZU"; else str1 = "fghjkmnquvxzFGHJKMNQUVXZ"; - if (!str1.Contains(s[0])) + if (!str1.Contains(s[0].ToString())) return false; return true; diff --git a/QLNet/Time/Period.cs b/QLNet/Time/Period.cs index 300499842..1ec5a5b6d 100644 --- a/QLNet/Time/Period.cs +++ b/QLNet/Time/Period.cs @@ -178,12 +178,12 @@ public void normalize() { case TimeUnit.Weeks: case TimeUnit.Days: if ( p1.length() != 0 ) - throw new ApplicationException( + throw new Exception( "impossible addition between " + p1 + " and " + p2); break; default: - throw new ApplicationException("unknown time unit (" + throw new Exception("unknown time unit (" + p2.units() + ")"); } break; @@ -197,12 +197,12 @@ public void normalize() { case TimeUnit.Weeks: case TimeUnit.Days: if (p1.length() != 0) - throw new ApplicationException( + throw new Exception( "impossible addition between " + p1 + " and " + p2); break; default: - throw new ApplicationException("unknown time unit (" + throw new Exception("unknown time unit (" + p2.units() + ")"); } break; @@ -217,12 +217,12 @@ public void normalize() { case TimeUnit.Years: case TimeUnit.Months: if (p1.length() != 0) - throw new ApplicationException( + throw new Exception( "impossible addition between " + p1 + " and " + p2); break; default: - throw new ApplicationException("unknown time unit (" + throw new Exception("unknown time unit (" + p2.units() + ")"); } break; @@ -236,18 +236,18 @@ public void normalize() { case TimeUnit.Years: case TimeUnit.Months: if (p1.length() != 0) - throw new ApplicationException( + throw new Exception( "impossible addition between " + p1 + " and " + p2); break; default: - throw new ApplicationException("unknown time unit (" + throw new Exception("unknown time unit (" + p2.units() + ")"); } break; default: - throw new ApplicationException("unknown time unit (" + units_ + ")"); + throw new Exception("unknown time unit (" + units_ + ")"); } } return new Period(length_,units_); @@ -348,7 +348,7 @@ public string ToShortString() { case TimeUnit.Years: return result + n + "Y"; default: - throw new ApplicationException("unknown time unit (" + units() + ")"); + throw new Exception("unknown time unit (" + units() + ")"); } } } diff --git a/QLNet/Time/Schedule.cs b/QLNet/Time/Schedule.cs index cb01cbba4..4d58a51f3 100644 --- a/QLNet/Time/Schedule.cs +++ b/QLNet/Time/Schedule.cs @@ -57,7 +57,7 @@ public Schedule(List dates, Calendar calendar = null, BusinessDayConventio tenor_ = tenor; convention_ = convention; terminationDateConvention_ = terminationDateConvention; - rule_ = rule; + rule_ = rule; endOfMonth_ = (tenor != null && tenor < new Period(1, TimeUnit.Months)) ? false : endOfMonth; dates_ = dates; @@ -119,11 +119,11 @@ public Schedule(Date effectiveDate, Date terminationDate, Period tenor, Calendar } } else - Utils.QL_REQUIRE( effectiveDate != null, () => "null effective date" ); - - Utils.QL_REQUIRE(effectiveDate < terminationDate, () => - "effective date (" + effectiveDate + - ") later than or equal to termination date (" + + Utils.QL_REQUIRE( effectiveDate != null, () => "null effective date" ); + + Utils.QL_REQUIRE(effectiveDate < terminationDate, () => + "effective date (" + effectiveDate + + ") later than or equal to termination date (" + terminationDate + ")" ); @@ -377,19 +377,19 @@ public Schedule(Date effectiveDate, Date terminationDate, Period tenor, Calendar for (int i = 1; i < dates_.Count-1; ++i) dates_[i] = calendar_.endOfMonth(dates_[i]); } - if (terminationDateConvention_ != BusinessDayConvention.Unadjusted) - { + if (terminationDateConvention_ != BusinessDayConvention.Unadjusted) + { dates_[0] = calendar_.endOfMonth(dates_.First()); - dates_[dates_.Count - 1] = calendar_.endOfMonth(dates_.Last()); + dates_[dates_.Count - 1] = calendar_.endOfMonth(dates_.Last()); } - else - { - // the termination date is the first if going backwards, - // the last otherwise. - if (rule_ == DateGeneration.Rule.Backward) - dates_[dates_.Count - 1] = Date.endOfMonth(dates_.Last()); - else - dates_[0] = Date.endOfMonth(dates_.First()); + else + { + // the termination date is the first if going backwards, + // the last otherwise. + if (rule_ == DateGeneration.Rule.Backward) + dates_[dates_.Count - 1] = Date.endOfMonth(dates_.Last()); + else + dates_[0] = Date.endOfMonth(dates_.First()); } } else @@ -410,34 +410,36 @@ public Schedule(Date effectiveDate, Date terminationDate, Period tenor, Calendar dates_[dates_.Count - 1] = calendar_.adjust(dates_.Last(), terminationDateConvention_.Value); } - // final safety checks to remove duplicated last dates, if any - // it can happen if EOM is applied to two near dates + // Final safety checks to remove extra next-to-last date, if + // necessary. It can happen to be equal or later than the end + // date due to EOM adjustments (see the Schedule test suite + // for an example). if (dates_.Count >= 2 && dates_[dates_.Count - 2] >= dates_.Last()) { - isRegular_[dates_.Count - 2] = (dates_[dates_.Count - 2] == dates_.Last()); + isRegular_[isRegular_.Count - 2] = (dates_[dates_.Count - 2] == dates_.Last()); dates_[dates_.Count - 2] = dates_.Last(); dates_.RemoveAt(dates_.Count - 1); isRegular_.RemoveAt(isRegular_.Count - 1); - } - - if (dates_.Count >= 2 && dates_[1] <= dates_.First()) - { - isRegular_[1] = (dates_[1] == dates_.First()); - dates_[1] = dates_.First(); - dates_.RemoveAt(0); - isRegular_.RemoveAt(0); - } - - Utils.QL_REQUIRE(dates_.Count > 1, - () => "degenerate single date (" + dates_[0] + ") schedule" + - "\n seed date: " + seed + - "\n exit date: " + exitDate + - "\n effective date: " + effectiveDate + - "\n first date: " + firstDate + - "\n next to last date: " + nextToLastDate + - "\n termination date: " + terminationDate + - "\n generation rule: " + rule_.Value + + } + + if (dates_.Count >= 2 && dates_[1] <= dates_.First()) + { + isRegular_[1] = (dates_[1] == dates_.First()); + dates_[1] = dates_.First(); + dates_.RemoveAt(0); + isRegular_.RemoveAt(0); + } + + Utils.QL_REQUIRE(dates_.Count > 1, + () => "degenerate single date (" + dates_[0] + ") schedule" + + "\n seed date: " + seed + + "\n exit date: " + exitDate + + "\n effective date: " + effectiveDate + + "\n first date: " + firstDate + + "\n next to last date: " + nextToLastDate + + "\n termination date: " + terminationDate + + "\n generation rule: " + rule_.Value + "\n end of month: " + endOfMonth_.Value); } #endregion @@ -706,11 +708,11 @@ public Schedule value() // check for mandatory arguments if (effectiveDate_ == null) - throw new ApplicationException("effective date not provided"); + throw new Exception("effective date not provided"); if (terminationDate_ == null) - throw new ApplicationException("termination date not provided"); + throw new Exception("termination date not provided"); if ((object)tenor_ == null) - throw new ApplicationException("tenor/frequency not provided"); + throw new Exception("tenor/frequency not provided"); // if no calendar was set... if (calendar_ == null) diff --git a/QLNet/Utils.cs b/QLNet/Utils.cs index bc8a1da85..171637680 100644 --- a/QLNet/Utils.cs +++ b/QLNet/Utils.cs @@ -19,6 +19,7 @@ under the terms of the QLNet license. You should have received a using System; using System.Collections.Generic; using System.Linq; +using System.Reflection; namespace QLNet { @@ -77,11 +78,11 @@ public static double Pow(double x, int y) { public static void QL_REQUIRE( bool condition, Func message ) { if ( !condition ) - throw new ApplicationException( message.Invoke() ); + throw new Exception( message.Invoke() ); } public static void QL_FAIL(string message) { - throw new ApplicationException(message); + throw new Exception(message); } public static bool is_QL_NEGATIVE_RATES() @@ -91,7 +92,20 @@ public static bool is_QL_NEGATIVE_RATES() #else return false; #endif - } + } + + public static MethodInfo GetMethodInfo(Object t, String function , Type[] types = null ) + { + MethodInfo methodInfo; + if (types == null) types = new Type[0]; + #if QL_DOTNET_FRAMEWORK + methodInfo = t.GetType().GetMethod(function, types); + #else + methodInfo = t.GetType().GetRuntimeMethod( function, types ); + #endif + + return methodInfo; + } } // this is a redefined collection class to emulate array-type behaviour at initialisation @@ -112,5 +126,12 @@ public void Erase() { for (int i = 0; i < this.Count; i++) this[i] = default(T); // do we need to use "new T()" instead of default(T) when T is class? } - } + } + + #if ! QL_DOTNET_FRAMEWORK + public interface ICloneable + { + object Clone(); + } + #endif } diff --git a/QLNet/discretizedasset.cs b/QLNet/discretizedasset.cs index e8757d4ae..a472eaf8e 100644 --- a/QLNet/discretizedasset.cs +++ b/QLNet/discretizedasset.cs @@ -174,7 +174,7 @@ public DiscretizedOption(DiscretizedAsset underlying, Exercise.Type exerciseType public override void reset(int size) { if (method() != underlying_.method()) - throw new ApplicationException("option and underlying were initialized on different methods"); + throw new Exception("option and underlying were initialized on different methods"); values_ = new Vector(size, 0.0); adjustValues(); } @@ -209,7 +209,7 @@ must be exercised before performing the adjustment. } break; default: - throw new ApplicationException("invalid exercise type"); + throw new Exception("invalid exercise type"); } underlying_.postAdjustValues(); } diff --git a/QLNet/legacy/libormarketmodels/lfmcovarproxy.cs b/QLNet/legacy/libormarketmodels/lfmcovarproxy.cs index 518092d56..7c34a1ad0 100644 --- a/QLNet/legacy/libormarketmodels/lfmcovarproxy.cs +++ b/QLNet/legacy/libormarketmodels/lfmcovarproxy.cs @@ -100,7 +100,7 @@ public double integratedCovariance(int i, int j, double t,Vector x) { //QL_REQUIRE(x.empty(), "can not handle given x here"); try { if (x.empty() == false) - throw new ApplicationException("can not handle given x here"); + throw new Exception("can not handle given x here"); } catch { //OK x empty } diff --git a/QLNet/legacy/libormarketmodels/lfmhullwhiteparam.cs b/QLNet/legacy/libormarketmodels/lfmhullwhiteparam.cs index 920d9f7bc..a34991a83 100644 --- a/QLNet/legacy/libormarketmodels/lfmhullwhiteparam.cs +++ b/QLNet/legacy/libormarketmodels/lfmhullwhiteparam.cs @@ -39,15 +39,15 @@ public LfmHullWhiteParameterization( Matrix sqrtCorr = new Matrix(size_ - 1, factors_, 1.0); if (correlation.empty()) { if(!(factors_ == 1)) - throw new ApplicationException("correlation matrix must be given for "+ + throw new Exception("correlation matrix must be given for "+ "multi factor models"); } else { if(!(correlation.rows() == size_-1 && correlation.rows() == correlation.columns())) - throw new ApplicationException("wrong dimesion of the correlation matrix"); + throw new Exception("wrong dimesion of the correlation matrix"); if(!(factors_ <= size_-1)) - throw new ApplicationException("too many factors for given LFM process"); + throw new Exception("too many factors for given LFM process"); Matrix tmpSqrtCorr =MatrixUtilitites.pseudoSqrt(correlation, MatrixUtilitites.SalvagingAlgorithm.Spectral); diff --git a/QLNet/legacy/libormarketmodels/lfmswaptionengine.cs b/QLNet/legacy/libormarketmodels/lfmswaptionengine.cs index c04c5258a..179755090 100644 --- a/QLNet/legacy/libormarketmodels/lfmswaptionengine.cs +++ b/QLNet/legacy/libormarketmodels/lfmswaptionengine.cs @@ -39,7 +39,7 @@ public LfmSwaptionEngine(LiborForwardModel model, public override void calculate() { if(!(arguments_.settlementType == Settlement.Type.Physical)) - throw new ApplicationException( "cash-settled swaptions not priced with Lfm engine"); + throw new Exception( "cash-settled swaptions not priced with Lfm engine"); double basisPoint = 1.0e-4; diff --git a/QLNet/legacy/libormarketmodels/liborforwardmodel.cs b/QLNet/legacy/libormarketmodels/liborforwardmodel.cs index 88ca0d610..ab1ecc645 100644 --- a/QLNet/legacy/libormarketmodels/liborforwardmodel.cs +++ b/QLNet/legacy/libormarketmodels/liborforwardmodel.cs @@ -83,7 +83,7 @@ List accrualEndTimes = process_.accrualEndTimes(); if (!(accrualStartTimes.First() <= maturity && accrualStartTimes.Last() >= maturity)) - throw new ApplicationException("capet maturity does not fit to the process"); + throw new Exception("capet maturity does not fit to the process"); int i = accrualStartTimes.BinarySearch(maturity); if (i < 0) @@ -98,7 +98,7 @@ List accrualEndTimes if (!(i 1)) - throw new ApplicationException("too few dates"); + throw new Exception("too few dates"); if (!(volatilities_.size() == startTimes_.Count)) - throw new ApplicationException("volatility array and fixing time array have to have the same size"); + throw new Exception("volatility array and fixing time array have to have the same size"); for (int i = 1; i < startTimes_.Count; i++) { if (!(startTimes_[i] > startTimes_[i-1])) - throw new ApplicationException( "invalid time ("+startTimes_[i]+", vs "+startTimes_[i-1]+")"); + throw new Exception( "invalid time ("+startTimes_[i]+", vs "+startTimes_[i-1]+")"); } } @@ -53,7 +53,7 @@ public override Vector volatility(double t){ public override Vector volatility(double t, Vector x) { if (!(t >= startTimes_.First() && t <= startTimes_.Last())) - throw new ApplicationException("invalid time given for volatility model"); + throw new Exception("invalid time given for volatility model"); int ti = startTimes_.GetRange(0,startTimes_.Count -1).BinarySearch(t); if (ti < 0) @@ -79,7 +79,7 @@ public override Vector volatility(double t, Vector x) public override double volatility(int i, double t, Vector x) { if (!(t >= startTimes_.First() && t <= startTimes_.Last())) - throw new ApplicationException("invalid time given for volatility model"); + throw new Exception("invalid time given for volatility model"); int ti = startTimes_.GetRange(0, startTimes_.Count - 1).BinarySearch(t); if (ti < 0) diff --git a/QLNet/payoff.cs b/QLNet/payoff.cs index 98fcff116..550774ebf 100644 --- a/QLNet/payoff.cs +++ b/QLNet/payoff.cs @@ -35,7 +35,7 @@ public virtual void accept(IAcyclicVisitor v) { if (v != null) v.visit(this); else - throw new ApplicationException("not an event visitor"); + throw new Exception("not an event visitor"); } } } diff --git a/QLNet/processes/Ornsteinuhlenbeckprocess.cs b/QLNet/processes/Ornsteinuhlenbeckprocess.cs index 51bfaa870..e0e19daf0 100644 --- a/QLNet/processes/Ornsteinuhlenbeckprocess.cs +++ b/QLNet/processes/Ornsteinuhlenbeckprocess.cs @@ -1,32 +1,32 @@ -/* - Copyright (C) 2008 Toyin Akin (toyin_akin@hotmail.com) - - This file is part of QLNet Project https://github.com/amaggiulli/qlnet - - QLNet is free software: you can redistribute it and/or modify it - under the terms of the QLNet license. You should have received a - copy of the license along with this program; if not, license is - available online at . - - QLNet is a based on QuantLib, a free-software/open-source library - for financial quantitative analysts and developers - http://quantlib.org/ - The QuantLib license is available online at http://quantlib.org/license.shtml. - - This program is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS - FOR A PARTICULAR PURPOSE. See the license for more details. +/* + Copyright (C) 2008 Toyin Akin (toyin_akin@hotmail.com) + + This file is part of QLNet Project https://github.com/amaggiulli/qlnet + + QLNet is free software: you can redistribute it and/or modify it + under the terms of the QLNet license. You should have received a + copy of the license along with this program; if not, license is + available online at . + + QLNet is a based on QuantLib, a free-software/open-source library + for financial quantitative analysts and developers - http://quantlib.org/ + The QuantLib license is available online at http://quantlib.org/license.shtml. + + This program is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS + FOR A PARTICULAR PURPOSE. See the license for more details. */ using System; namespace QLNet { //! Ornstein-Uhlenbeck process class - /*! This class describes the Ornstein-Uhlenbeck process governed by - \f[ - dx = a (r - x_t) dt + \sigma dW_t. - \f] - - \ingroup processes + /*! This class describes the Ornstein-Uhlenbeck process governed by + \f[ + dx = a (r - x_t) dt + \sigma dW_t. + \f] + + \ingroup processes */ public class OrnsteinUhlenbeckProcess : StochasticProcess1D { @@ -37,10 +37,10 @@ public OrnsteinUhlenbeckProcess( double speed, double vol, double x0 = 0.0, doub level_ = level; volatility_ = vol; if ( !( speed_ >= 0.0 ) ) - throw new ApplicationException( "negative speed given" ); + throw new Exception( "negative speed given" ); if ( !( volatility_ >= 0.0 ) ) - throw new ApplicationException( "negative volatility given" ); + throw new Exception( "negative volatility given" ); } //! \name StochasticProcess interface //@{ @@ -96,4 +96,4 @@ public override double variance( double UnnamedParameter1, double UnnamedParamet } -} +} diff --git a/QLNet/processes/stochasticprocessarray.cs b/QLNet/processes/stochasticprocessarray.cs index fb95add96..b2a9610b8 100644 --- a/QLNet/processes/stochasticprocessarray.cs +++ b/QLNet/processes/stochasticprocessarray.cs @@ -31,9 +31,9 @@ public StochasticProcessArray(List processes, Matrix correl sqrtCorrelation_ = MatrixUtilitites.pseudoSqrt(correlation, MatrixUtilitites.SalvagingAlgorithm.Spectral); if (processes.Count == 0) - throw new ApplicationException("no processes given"); + throw new Exception("no processes given"); if(correlation.rows() != processes.Count) - throw new ApplicationException("mismatch between number of processes and size of correlation matrix"); + throw new Exception("mismatch between number of processes and size of correlation matrix"); for (int i=0; i= 1.6.0" + ], + ".NETStandard,Version=v1.1": [] + }, + "tools": {}, + "projectFileToolGroups": {} +} \ No newline at end of file diff --git a/QLNet/qlnet.project.json b/QLNet/qlnet.project.json new file mode 100644 index 000000000..0bf285ccf --- /dev/null +++ b/QLNet/qlnet.project.json @@ -0,0 +1,7 @@ +{ + "runtime": { + "win":{ + } + } + +} \ No newline at end of file diff --git a/QLNet/timegrid.cs b/QLNet/timegrid.cs index 224a35862..e2800d591 100644 --- a/QLNet/timegrid.cs +++ b/QLNet/timegrid.cs @@ -41,7 +41,7 @@ public TimeGrid(double end, int steps) { // We seem to assume that the grid begins at 0. // Let's enforce the assumption for the time being // (even though I'm not sure that I agree.) - if (!(end > 0.0)) throw new ApplicationException("negative times not allowed"); + if (!(end > 0.0)) throw new Exception("negative times not allowed"); double dt = end/steps; times_ = new List(steps+1); for (int i=0; i<=steps; i++) @@ -59,7 +59,7 @@ public TimeGrid( List times, int offset ) mandatoryTimes_ = times.GetRange( 0, offset ); mandatoryTimes_.Sort(); - if ( !( mandatoryTimes_[0] >= 0.0 ) ) throw new ApplicationException( "negative times not allowed" ); + if ( !( mandatoryTimes_[0] >= 0.0 ) ) throw new Exception( "negative times not allowed" ); for ( int i = 0; i < mandatoryTimes_.Count - 1; ++i ) { @@ -86,7 +86,7 @@ public TimeGrid(List times, int offset, int steps) mandatoryTimes_ = times.GetRange( 0, offset ); mandatoryTimes_.Sort(); - if (!(mandatoryTimes_[0] >= 0.0)) throw new ApplicationException("negative times not allowed"); + if (!(mandatoryTimes_[0] >= 0.0)) throw new Exception("negative times not allowed"); for (int i = 0; i < mandatoryTimes_.Count - 1; ++i) { @@ -151,10 +151,10 @@ public int index(double t) { return i; } else { if (t < times_.First()) { - throw new ApplicationException("using inadequate time grid: all nodes are later than the required time t = " + throw new Exception("using inadequate time grid: all nodes are later than the required time t = " + t + " (earliest node is t1 = " + times_.First() + ")"); } else if (t > times_.Last()) { - throw new ApplicationException("using inadequate time grid: all nodes are earlier than the required time t = " + throw new Exception("using inadequate time grid: all nodes are earlier than the required time t = " + t + " (latest node is t1 = " + times_.Last() + ")"); } else { int j, k; @@ -165,7 +165,7 @@ public int index(double t) { j = i-1; k = i; } - throw new ApplicationException("using inadequate time grid: the nodes closest to the required time t = " + throw new Exception("using inadequate time grid: the nodes closest to the required time t = " + t + " are t1 = " + times_[j] + " and t2 = " + times_[k]); } } diff --git a/QLNet_Core.sln b/QLNet_Core.sln new file mode 100644 index 000000000..d5c10ea6a --- /dev/null +++ b/QLNet_Core.sln @@ -0,0 +1,39 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio 14 +VisualStudioVersion = 14.0.25420.1 +MinimumVisualStudioVersion = 10.0.40219.1 +#Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{CA67E024-9133-421F-83A8-DE4C52A748DA}" +#EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{59F9E043-A06B-440E-82EF-A81B4ACD2A3A}" + ProjectSection(SolutionItems) = preProject + global.json = global.json + EndProjectSection +EndProject +Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "QLNet", "QLNet\QLNet.xproj", "{57246126-D94B-48EC-A3E3-4167BCEFF7C5}" +EndProject +Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Test", "Test\Test.xproj", "{E95EC6F5-40E7-48C0-952B-D6AE1942EEF9}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {57246126-D94B-48EC-A3E3-4167BCEFF7C5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {57246126-D94B-48EC-A3E3-4167BCEFF7C5}.Debug|Any CPU.Build.0 = Debug|Any CPU + {57246126-D94B-48EC-A3E3-4167BCEFF7C5}.Release|Any CPU.ActiveCfg = Release|Any CPU + {57246126-D94B-48EC-A3E3-4167BCEFF7C5}.Release|Any CPU.Build.0 = Release|Any CPU + {E95EC6F5-40E7-48C0-952B-D6AE1942EEF9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {E95EC6F5-40E7-48C0-952B-D6AE1942EEF9}.Debug|Any CPU.Build.0 = Debug|Any CPU + {E95EC6F5-40E7-48C0-952B-D6AE1942EEF9}.Release|Any CPU.ActiveCfg = Release|Any CPU + {E95EC6F5-40E7-48C0-952B-D6AE1942EEF9}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(NestedProjects) = preSolution + {57246126-D94B-48EC-A3E3-4167BCEFF7C5} = {CA67E024-9133-421F-83A8-DE4C52A748DA} + {E95EC6F5-40E7-48C0-952B-D6AE1942EEF9} = {CA67E024-9133-421F-83A8-DE4C52A748DA} + EndGlobalSection +EndGlobal diff --git a/QLNet_with_Examples.sln b/QLNet_with_Examples.sln index 8f31cfe38..38b567cbf 100644 --- a/QLNet_with_Examples.sln +++ b/QLNet_with_Examples.sln @@ -21,6 +21,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CallableBonds", "Examples\C EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FittedBondCurve", "Examples\FittedBondCurve\FittedBondCurve.csproj", "{81459545-A095-4977-8C52-2C4BBC50558F}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CVAIRS", "examples\CVAIRS\CVAIRS.csproj", "{46817C48-9DE1-4A56-82CF-3B7A3BEF712B}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -131,6 +133,16 @@ Global {81459545-A095-4977-8C52-2C4BBC50558F}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU {81459545-A095-4977-8C52-2C4BBC50558F}.Release|Mixed Platforms.Build.0 = Release|Any CPU {81459545-A095-4977-8C52-2C4BBC50558F}.Release|x86.ActiveCfg = Release|Any CPU + {46817C48-9DE1-4A56-82CF-3B7A3BEF712B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {46817C48-9DE1-4A56-82CF-3B7A3BEF712B}.Debug|Any CPU.Build.0 = Debug|Any CPU + {46817C48-9DE1-4A56-82CF-3B7A3BEF712B}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU + {46817C48-9DE1-4A56-82CF-3B7A3BEF712B}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU + {46817C48-9DE1-4A56-82CF-3B7A3BEF712B}.Debug|x86.ActiveCfg = Debug|Any CPU + {46817C48-9DE1-4A56-82CF-3B7A3BEF712B}.Release|Any CPU.ActiveCfg = Release|Any CPU + {46817C48-9DE1-4A56-82CF-3B7A3BEF712B}.Release|Any CPU.Build.0 = Release|Any CPU + {46817C48-9DE1-4A56-82CF-3B7A3BEF712B}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU + {46817C48-9DE1-4A56-82CF-3B7A3BEF712B}.Release|Mixed Platforms.Build.0 = Release|Any CPU + {46817C48-9DE1-4A56-82CF-3B7A3BEF712B}.Release|x86.ActiveCfg = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/README.md b/README.md index 6a53254a8..f887bb98b 100644 --- a/README.md +++ b/README.md @@ -2,9 +2,9 @@ QLNet ===== QLNet C# library official repository. -QLNet is a financial library written in c# for the Windows enviroment derived primarily from its C++ counterpart, Quantlib, -which has been used as a base reference for modelling of various financial instruments. -QLNet contains also new developments on the bond market like MBS , Amortized Cost, PSA Curve and others. +QLNet is a financial library written in C# for the Windows enviroment derived primarily from its C++ counterpart, Quantlib, +which has been used as a base reference for modelling various financial instruments. +QLNet also contains new developments on the bond market like MBS, Amortized Cost, PSA Curve and others. [![Build status](https://ci.appveyor.com/api/projects/status/iii1m7n3cdq3v5xm?svg=true)](https://ci.appveyor.com/project/amaggiulli/qlnet) [![Release](https://img.shields.io/github/release/amaggiulli/qlnet.svg)](https://github.com/amaggiulli/qlnet/releases/latest) @@ -12,17 +12,17 @@ QLNet contains also new developments on the bond market like MBS , Amortized Cos [![Stars](https://img.shields.io/github/stars/amaggiulli/qlnet.svg)](https://github.com/amaggiulli/qlnet/stargazers) [![Coverity](https://scan.coverity.com/projects/7000/badge.svg)](https://scan.coverity.com/projects/amaggiulli-qlnet) -## Developments workflow +## Development workflow ###### QLNet use git flow workflow. Instead of a single master branch, this workflow uses two branches to record the history of the project. -The master branch stores the official release history, and the develop branch serves as an integration branch for features. -Develop branch will contain the complete history of the project. +The *master* branch stores the official release history, and the *develop* branch serves as an integration branch for features. +The *develop* branch will also contain the complete history of the project. ###### Features -To contribute with features you should clone the repository , create a tracking branch for develop and create the feature: +To contribute features, you should clone the repository, create a tracking branch for develop and create the feature: ``` git clone https://github.com/amaggiulli/qlnet.git @@ -30,23 +30,22 @@ git checkout -b develop origin/develop git checkout -b some-feature develop ``` -When feature is ready you can make pull request to merge feature into develop. -Note that features will never be merged directly into master. +When the feature is ready, you can make a pull request to merge that feature into *develop*. +Note that features will never be merged directly into *master*. ###### Releases -When a release is ready we fork a release branch from develop. Creating this branch starts the next release cycle, -so no new features can be added after this point ; only bug fixes, documentation generation, and other release-oriented tasks go in this branch. -Once it's ready to ship, the release gets merged into master and tagged with a version number. +When a release is ready, we fork a release branch from *develop*. Creating this branch starts the next release cycle, +so no new features can be added after this point; only bug fixes, documentation generation, and other release-oriented tasks go in this branch. +Once it's ready to ship, the release gets merged into *master* and tagged with a version number. ###### HotFix -Maintenance or “hotfix” branches are used to quickly patch production releases. This is the only branch that fork directly off of master. -As soon as the fix is complete, it will be merged into both master and develop , and master will be tagged with an updated version number. - +Maintenance or “hotfix” branches are used to quickly patch production releases. This is the only branch that fork directly off of *master*. +As soon as the fix is complete, it will be merged into both *master* and *develop*, and *master* will be tagged with an updated version number. ## Acknowledgements Thanks to all Quantlib creators and contributors. Thanks to all QLNet contributors. -Special thanks to JetBrains for their support of open source projects , QLNet make extensive use of Resharper. \ No newline at end of file +Special thanks to JetBrains for their support of open source projects; QLNet makes extensive use of Resharper. diff --git a/Test/Properties/AssemblyInfo.cs b/Test/Properties/AssemblyInfo.cs index 495a3de9c..fab0525d9 100644 --- a/Test/Properties/AssemblyInfo.cs +++ b/Test/Properties/AssemblyInfo.cs @@ -1,6 +1,11 @@ using System.Reflection; using System.Runtime.InteropServices; +#if ! QL_DOTNET_FRAMEWORK +using Xunit; +[assembly: CollectionBehavior(DisableTestParallelization = true)] +#endif + // Le informazioni generali relative a un assembly sono controllate dal seguente // insieme di attributi. Per modificare le informazioni associate a un assembly // è necessario modificare i valori di questi attributi. @@ -9,7 +14,7 @@ [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("")] [assembly: AssemblyProduct("Test")] -[assembly: AssemblyCopyright("")] +[assembly: AssemblyCopyright( "Copyright (c) 2008-2016 Andrea Maggiulli (a.maggiulli@gmail.com)" )] [assembly: AssemblyTrademark("")] [assembly: AssemblyCulture("")] @@ -30,5 +35,5 @@ // // È possibile specificare tutti i valori oppure impostare i valori predefiniti per i numeri relativi alla build e alla revisione // utilizzando l'asterisco (*) come descritto di seguito: -[assembly: AssemblyVersion( "1.7.0.0" )] -[assembly: AssemblyFileVersion( "1.7.0.0" )] +[assembly: AssemblyVersion( "1.8.0.0" )] +[assembly: AssemblyFileVersion( "1.8.0.0" )] diff --git a/Test/T_AmericanOption.cs b/Test/T_AmericanOption.cs index 72a7bb0cb..e54bfd7b7 100644 --- a/Test/T_AmericanOption.cs +++ b/Test/T_AmericanOption.cs @@ -21,7 +21,11 @@ under the terms of the QLNet license. You should have received a using System; using System.Collections.Generic; using System.Linq; -using Microsoft.VisualStudio.TestTools.UnitTesting; +#if QL_DOTNET_FRAMEWORK + using Microsoft.VisualStudio.TestTools.UnitTesting; +#else + using Xunit; +#endif using QLNet; namespace TestSuite { @@ -54,8 +58,9 @@ public AmericanOptionData(Option.Type type_, result = result_; } } - + #if QL_DOTNET_FRAMEWORK [TestClass()] + #endif public class T_AmericanOption { /* The data below are from @@ -130,8 +135,12 @@ Journal of Derivatives Winter 1999 new AmericanOptionData( Option.Type.Call, 100.00, 110.00, 0.03, 0.07, 3.0, 0.3, 30.028 ), new AmericanOptionData( Option.Type.Call, 100.00, 120.00, 0.03, 0.07, 3.0, 0.3, 37.177 ) }; - + +#if QL_DOTNET_FRAMEWORK [TestMethod()] +#else + [Fact] +#endif public void testBaroneAdesiWhaleyValues() { // ("Testing Barone-Adesi and Whaley approximation for American options..."); @@ -226,7 +235,11 @@ The following values were replicated only up to the second digit } } +#if QL_DOTNET_FRAMEWORK [TestMethod()] +#else + [Fact] +#endif public void testBjerksundStenslandValues() { // ("Testing Bjerksund and Stensland approximation for American options..."); @@ -293,7 +306,11 @@ public void testBjerksundStenslandValues() { } } +#if QL_DOTNET_FRAMEWORK [TestMethod()] +#else + [Fact] +#endif public void testJuValues() { // ("Testing Ju approximation for American options..."); @@ -342,7 +359,11 @@ public void testJuValues() { } } +#if QL_DOTNET_FRAMEWORK [TestMethod()] +#else + [Fact] +#endif public void testFdValues() { //("Testing finite-difference engine for American options..."); @@ -391,128 +412,148 @@ public void testFdValues() { } } - public void testFdGreeks() where Engine : IFDEngine, new() { - - //SavedSettings backup; - - Dictionary calculated = new Dictionary(), - expected = new Dictionary(), - tolerance = new Dictionary(); - - tolerance.Add("delta", 7.0e-4); - tolerance.Add("gamma", 2.0e-4); - //tolerance["theta"] = 1.0e-4; - - Option.Type[] types = new Option.Type[] { Option.Type.Call, Option.Type.Put }; - double[] strikes = { 50.0, 99.5, 100.0, 100.5, 150.0 }; - double[] underlyings = { 100.0 }; - double[] qRates = { 0.04, 0.05, 0.06 }; - double[] rRates = { 0.01, 0.05, 0.15 }; - int[] years = { 1, 2 }; - double[] vols = { 0.11, 0.50, 1.20 }; - - Date today = Date.Today; - Settings.setEvaluationDate(today); - - DayCounter dc = new Actual360(); - SimpleQuote spot = new SimpleQuote(0.0); - SimpleQuote qRate = new SimpleQuote(0.0); - YieldTermStructure qTS = Utilities.flatRate(today, qRate, dc); - - SimpleQuote rRate = new SimpleQuote(0.0); - YieldTermStructure rTS = Utilities.flatRate(today, rRate, dc); - SimpleQuote vol = new SimpleQuote(0.0); - BlackVolTermStructure volTS = Utilities.flatVol(today, vol, dc); - - for (int i=0; i(spot), - new Handle(qTS), - new Handle(rTS), - new Handle(volTS)); - - IPricingEngine engine = new Engine().factory(stochProcess); - - VanillaOption option = new VanillaOption(payoff, exercise); - option.setPricingEngine(engine); - - for (int l=0; l spot.value()*1.0e-5) { - // perturb spot and get delta and gamma - double du = u*1.0e-4; - spot.setValue(u+du); - double value_p = option.NPV(), - delta_p = option.delta(); - spot.setValue(u-du); - double value_m = option.NPV(), - delta_m = option.delta(); - spot.setValue(u); - expected.Add("delta", (value_p - value_m)/(2*du)); - expected.Add("gamma", (delta_p - delta_m)/(2*du)); - - /* - // perturb date and get theta - Time dT = dc.yearFraction(today-1, today+1); - Settings::instance().setEvaluationDate(today-1); - value_m = option.NPV(); - Settings::instance().setEvaluationDate(today+1); - value_p = option.NPV(); - Settings::instance().setEvaluationDate(today); - expected["theta"] = (value_p - value_m)/dT; - */ - - // compare - foreach (string greek in calculated.Keys) { - double expct = expected [greek], - calcl = calculated[greek], - tol = tolerance [greek]; - double error = Utilities.relativeError(expct,calcl,u); - if (error>tol) { - REPORT_FAILURE(greek, payoff, exercise, - u, q, r, today, v, - expct, calcl, error, tol); - } + public void testFdGreeks() where Engine : IFDEngine, new() + { + using ( SavedSettings backup = new SavedSettings() ) + { + + Dictionary calculated = new Dictionary(), + expected = new Dictionary(), + tolerance = new Dictionary(); + + tolerance.Add( "delta", 7.0e-4 ); + tolerance.Add( "gamma", 2.0e-4 ); + //tolerance["theta"] = 1.0e-4; + + Option.Type[] types = new Option.Type[] { Option.Type.Call, Option.Type.Put }; + double[] strikes = { 50.0, 99.5, 100.0, 100.5, 150.0 }; + double[] underlyings = { 100.0 }; + double[] qRates = { 0.04, 0.05, 0.06 }; + double[] rRates = { 0.01, 0.05, 0.15 }; + int[] years = { 1, 2 }; + double[] vols = { 0.11, 0.50, 1.20 }; + + Date today = Date.Today; + Settings.setEvaluationDate( today ); + + DayCounter dc = new Actual360(); + SimpleQuote spot = new SimpleQuote( 0.0 ); + SimpleQuote qRate = new SimpleQuote( 0.0 ); + YieldTermStructure qTS = Utilities.flatRate( today, qRate, dc ); + + SimpleQuote rRate = new SimpleQuote( 0.0 ); + YieldTermStructure rTS = Utilities.flatRate( today, rRate, dc ); + SimpleQuote vol = new SimpleQuote( 0.0 ); + BlackVolTermStructure volTS = Utilities.flatVol( today, vol, dc ); + + for ( int i = 0; i < types.Length; i++ ) + { + for ( int j = 0; j < strikes.Length; j++ ) + { + for ( int k = 0; k < years.Length; k++ ) + { + Date exDate = today + new Period( years[k], TimeUnit.Years ); + Exercise exercise = new AmericanExercise( today, exDate ); + StrikedTypePayoff payoff = new PlainVanillaPayoff( types[i], strikes[j] ); + BlackScholesMertonProcess stochProcess = new BlackScholesMertonProcess( new Handle( spot ), + new Handle( qTS ), + new Handle( rTS ), + new Handle( volTS ) ); + + IPricingEngine engine = new Engine().factory( stochProcess ); + + VanillaOption option = new VanillaOption( payoff, exercise ); + option.setPricingEngine( engine ); + + for ( int l = 0; l < underlyings.Length; l++ ) + { + for ( int m = 0; m < qRates.Length; m++ ) + { + for ( int n = 0; n < rRates.Length; n++ ) + { + for ( int p = 0; p < vols.Length; p++ ) + { + double u = underlyings[l]; + double q = qRates[m], + r = rRates[n]; + double v = vols[p]; + spot.setValue( u ); + qRate.setValue( q ); + rRate.setValue( r ); + vol.setValue( v ); + + double value = option.NPV(); + calculated.Add( "delta", option.delta() ); + calculated.Add( "gamma", option.gamma() ); + //calculated["theta"] = option.theta(); + + if ( value > spot.value() * 1.0e-5 ) + { + // perturb spot and get delta and gamma + double du = u * 1.0e-4; + spot.setValue( u + du ); + double value_p = option.NPV(), + delta_p = option.delta(); + spot.setValue( u - du ); + double value_m = option.NPV(), + delta_m = option.delta(); + spot.setValue( u ); + expected.Add( "delta", ( value_p - value_m ) / ( 2 * du ) ); + expected.Add( "gamma", ( delta_p - delta_m ) / ( 2 * du ) ); + + /* + // perturb date and get theta + Time dT = dc.yearFraction(today-1, today+1); + Settings::instance().setEvaluationDate(today-1); + value_m = option.NPV(); + Settings::instance().setEvaluationDate(today+1); + value_p = option.NPV(); + Settings::instance().setEvaluationDate(today); + expected["theta"] = (value_p - value_m)/dT; + */ + + // compare + foreach ( string greek in calculated.Keys ) + { + double expct = expected[greek], + calcl = calculated[greek], + tol = tolerance[greek]; + double error = Utilities.relativeError( expct, calcl, u ); + if ( error > tol ) + { + REPORT_FAILURE( greek, payoff, exercise, + u, q, r, today, v, + expct, calcl, error, tol ); + } + } + } + calculated.Clear(); + expected.Clear(); } - } - calculated.Clear(); - expected.Clear(); + } } - } - } + } } - } + } } - } + } } +#if QL_DOTNET_FRAMEWORK [TestMethod()] +#else + [Fact] +#endif public void testFdAmericanGreeks() { //("Testing finite-differences American option greeks..."); testFdGreeks(); } +#if QL_DOTNET_FRAMEWORK [TestMethod()] +#else + [Fact] +#endif public void testFdShoutGreeks() { // ("Testing finite-differences shout option greeks..."); testFdGreeks(); @@ -520,7 +561,7 @@ public void testFdShoutGreeks() { void REPORT_FAILURE(string greekName, StrikedTypePayoff payoff, Exercise exercise, double s, double q, double r, Date today, double v, double expected, double calculated, double error, double tolerance) { - Assert.Fail(exercise + " " + QAssert.Fail(exercise + " " + payoff.optionType() + " option with " + payoff + " payoff:\n" + " spot value: " + s + "\n" @@ -536,7 +577,11 @@ void REPORT_FAILURE(string greekName, StrikedTypePayoff payoff, Exercise exercis + " tolerance: " + tolerance); } +#if QL_DOTNET_FRAMEWORK [TestMethod()] +#else + [Fact] +#endif public void testFdImpliedVol() { var settlementDate = new Date(26, 2, 2015); @@ -565,7 +610,7 @@ public void testFdImpliedVol() const double tolerance = 3.0e-3; if (Math.Abs(impliedVol - volatility) > tolerance) - Assert.Fail(string.Format("Implied volatility calculation failed. Expected {0}. Actual {1}", volatility, impliedVol)); + QAssert.Fail(string.Format("Implied volatility calculation failed. Expected {0}. Actual {1}", volatility, impliedVol)); } } } diff --git a/Test/T_AsianOptions.cs b/Test/T_AsianOptions.cs index 20e90460e..2113d8651 100644 --- a/Test/T_AsianOptions.cs +++ b/Test/T_AsianOptions.cs @@ -21,12 +21,18 @@ under the terms of the QLNet license. You should have received a using System; using System.Collections.Generic; using System.Linq; +#if QL_DOTNET_FRAMEWORK using Microsoft.VisualStudio.TestTools.UnitTesting; +#else + using Xunit; +#endif using QLNet; namespace TestSuite { + #if QL_DOTNET_FRAMEWORK [TestClass()] + #endif public class T_AsianOptions { public void REPORT_FAILURE( string greekName, Average.Type averageType, @@ -36,7 +42,7 @@ public void REPORT_FAILURE( string greekName, Average.Type averageType, Date today, double v, double expected, double calculated, double tolerance ) { - Assert.Fail( exercise + " " + QAssert.Fail( exercise + " " + exercise + " Asian option with " + averageType + " and " @@ -73,7 +79,11 @@ public string averageTypeToString( Average.Type averageType ) return String.Empty; } - [TestMethod()] +#if QL_DOTNET_FRAMEWORK + [TestMethod()] +#else + [Fact] +#endif public void testAnalyticContinuousGeometricAveragePrice() { // Testing analytic continuous geometric average-price Asians @@ -152,7 +162,11 @@ public void testAnalyticContinuousGeometricAveragePrice() } - [TestMethod()] +#if QL_DOTNET_FRAMEWORK + [TestMethod()] +#else + [Fact] +#endif public void testAnalyticContinuousGeometricAveragePriceGreeks() { // Testing analytic continuous geometric average-price Asian greeks @@ -313,7 +327,11 @@ public void testAnalyticContinuousGeometricAveragePriceGreeks() } } - [TestMethod()] +#if QL_DOTNET_FRAMEWORK + [TestMethod()] +#else + [Fact] +#endif public void testAnalyticDiscreteGeometricAveragePrice() { // Testing analytic discrete geometric average-price Asians @@ -371,8 +389,12 @@ public void testAnalyticDiscreteGeometricAveragePrice() vol.value(), expected, calculated, tolerance ); } } - - [TestMethod()] + +#if QL_DOTNET_FRAMEWORK + [TestMethod()] +#else + [Fact] +#endif public void testAnalyticDiscreteGeometricAverageStrike() { // Testing analytic discrete geometric average-strike Asians @@ -500,7 +522,11 @@ public void testMCDiscreteGeometricAveragePrice() } } - [TestMethod()] +#if QL_DOTNET_FRAMEWORK + [TestMethod()] +#else + [Fact] +#endif public void testAnalyticDiscreteGeometricAveragePriceGreeks() { // Testing discrete-averaging geometric Asian greeks @@ -1120,7 +1146,7 @@ public void testAnalyticDiscreteGeometricAveragePriceGreeks() // double price2 = option2.NPV(); // if (Utils.close(price1, price2)) { - // Assert.Fail( + // QAssert.Fail( // "past fixings had no effect on arithmetic average-price option" // + "\n without fixings: " + price1 // + "\n with fixings: " + price2); @@ -1138,7 +1164,7 @@ public void testAnalyticDiscreteGeometricAveragePriceGreeks() // price2 = option2.NPV(); // if (Utils.close(price1, price2)) { - // Assert.Fail( + // QAssert.Fail( // "past fixings had no effect on arithmetic average-strike option" // + "\n without fixings: " + price1 // + "\n with fixings: " + price2); @@ -1170,7 +1196,7 @@ public void testAnalyticDiscreteGeometricAveragePriceGreeks() // double price4 = option4.NPV(); // if (Utils.close(price3, price4)) { - // Assert.Fail( + // QAssert.Fail( // "past fixings had no effect on geometric average-price option" // + "\n without fixings: " + price3 // + "\n with fixings: " + price4); @@ -1189,7 +1215,7 @@ public void testAnalyticDiscreteGeometricAveragePriceGreeks() // price4 = option4.NPV(); // if (Utils.close(price3, price4)) { - // Assert.Fail( + // QAssert.Fail( // "past fixings had no effect on geometric average-price option" // + "\n without fixings: " + price3 // + "\n with fixings: " + price4); diff --git a/Test/T_AssetSwap.cs b/Test/T_AssetSwap.cs index f557823fc..0584cf33f 100644 --- a/Test/T_AssetSwap.cs +++ b/Test/T_AssetSwap.cs @@ -17,15 +17,49 @@ under the terms of the QLNet license. You should have received a FOR A PARTICULAR PURPOSE. See the license for more details. */ using System; -using System.Collections.Generic; -using Microsoft.VisualStudio.TestTools.UnitTesting; +using System.Collections.Generic; +#if QL_DOTNET_FRAMEWORK +using Microsoft.VisualStudio.TestTools.UnitTesting; +#else + using Xunit; +#endif using QLNet; namespace TestSuite -{ - [TestClass()] - public class T_AssetSwap +{ + #if QL_DOTNET_FRAMEWORK + [TestClass()] + #endif + public class T_AssetSwap : IDisposable { + #region Initialize&Cleanup + private SavedSettings backup; + private IndexHistoryCleaner cleaner; + #if QL_DOTNET_FRAMEWORK + [TestInitialize] + public void testInitialize() + { + #else + public T_AssetSwap() + { + #endif + backup = new SavedSettings(); + cleaner = new IndexHistoryCleaner(); + } + #if QL_DOTNET_FRAMEWORK + [TestCleanup] + #endif + public void testCleanup() + { + Dispose(); + } + public void Dispose() + { + backup.Dispose(); + cleaner.Dispose(); + } + #endregion + class CommonVars { // common data @@ -39,15 +73,9 @@ class CommonVars public Compounding compounding; public RelinkableHandle termStructure = new RelinkableHandle(); - // clean-up - public SavedSettings backup; - //public IndexHistoryCleaner indexCleaner; - // initial setup public CommonVars() { - backup = new SavedSettings(); - //indexCleaner = new IndexHistoryCleaner(); termStructure = new RelinkableHandle(); int swapSettlementDays = 2; faceAmount = 100.0; @@ -77,9 +105,13 @@ public CommonVars() Handle meanReversionQuote = new Handle(new SimpleQuote(0.01)); cmspricer = new AnalyticHaganPricer(swaptionVolatilityStructure, GFunctionFactory.YieldCurveModel.Standard, meanReversionQuote); } - } - - [TestMethod()] + } + +#if QL_DOTNET_FRAMEWORK + [TestMethod()] +#else + [Fact] +#endif public void testConsistency() { @@ -126,7 +158,7 @@ public void testConsistency() assetSwap2.setPricingEngine(swapEngine); if (Math.Abs(assetSwap2.NPV()) > tolerance) { - Assert.Fail("npar asset swap fair clean price doesn't zero the NPV: " + + QAssert.Fail("npar asset swap fair clean price doesn't zero the NPV: " + "\n clean price: " + bondPrice + "\n fair clean price: " + fairCleanPrice + "\n NPV: " + assetSwap2.NPV() + @@ -134,7 +166,7 @@ public void testConsistency() } if (Math.Abs(assetSwap2.fairCleanPrice() - fairCleanPrice) > tolerance) { - Assert.Fail("\npar asset swap fair clean price doesn't equal input clean price at zero NPV: " + + QAssert.Fail("\npar asset swap fair clean price doesn't equal input clean price at zero NPV: " + "\n input clean price: " + fairCleanPrice + "\n fair clean price: " + assetSwap2.fairCleanPrice() + "\n NPV: " + assetSwap2.NPV() + @@ -142,7 +174,7 @@ public void testConsistency() } if (Math.Abs(assetSwap2.fairSpread() - vars.spread) > tolerance) { - Assert.Fail("\npar asset swap fair spread doesn't equal input spread at zero NPV: " + + QAssert.Fail("\npar asset swap fair spread doesn't equal input spread at zero NPV: " + "\n input spread: " + vars.spread + "\n fair spread: " + assetSwap2.fairSpread() + "\n NPV: " + assetSwap2.NPV() + @@ -155,7 +187,7 @@ public void testConsistency() assetSwap3.setPricingEngine(swapEngine); if (Math.Abs(assetSwap3.NPV()) > tolerance) { - Assert.Fail("\npar asset swap fair spread doesn't zero the NPV: " + + QAssert.Fail("\npar asset swap fair spread doesn't zero the NPV: " + "\n spread: " + vars.spread + "\n fair spread: " + fairSpread + "\n NPV: " + assetSwap3.NPV() + @@ -163,7 +195,7 @@ public void testConsistency() } if (Math.Abs(assetSwap3.fairCleanPrice() - bondPrice) > tolerance) { - Assert.Fail("\npar asset swap fair clean price doesn't equal input clean price at zero NPV: " + + QAssert.Fail("\npar asset swap fair clean price doesn't equal input clean price at zero NPV: " + "\n input clean price: " + bondPrice + "\n fair clean price: " + assetSwap3.fairCleanPrice() + "\n NPV: " + assetSwap3.NPV() + @@ -171,7 +203,7 @@ public void testConsistency() } if (Math.Abs(assetSwap3.fairSpread() - fairSpread) > tolerance) { - Assert.Fail("\npar asset swap fair spread doesn't equal input spread at zero NPV: " + + QAssert.Fail("\npar asset swap fair spread doesn't equal input spread at zero NPV: " + "\n input spread: " + fairSpread + "\n fair spread: " + assetSwap3.fairSpread() + "\n NPV: " + assetSwap3.NPV() + @@ -185,14 +217,14 @@ public void testConsistency() // fair clean price and fair spread should not change if (Math.Abs(parAssetSwap.fairCleanPrice() - fairCleanPrice) > tolerance) { - Assert.Fail("\npar asset swap fair clean price changed with NpvDate:" + + QAssert.Fail("\npar asset swap fair clean price changed with NpvDate:" + "\n expected clean price: " + fairCleanPrice + "\n fair clean price: " + parAssetSwap.fairCleanPrice() + "\n tolerance: " + tolerance); } if (Math.Abs(parAssetSwap.fairSpread() - fairSpread) > tolerance) { - Assert.Fail("\npar asset swap fair spread changed with NpvDate:" + + QAssert.Fail("\npar asset swap fair spread changed with NpvDate:" + "\n expected spread: " + fairSpread + "\n fair spread: " + parAssetSwap.fairSpread() + "\n tolerance: " + tolerance); @@ -203,7 +235,7 @@ public void testConsistency() assetSwap2.setPricingEngine(swapEngine); if (Math.Abs(assetSwap2.NPV()) > tolerance) { - Assert.Fail("\npar asset swap fair clean price doesn't zero the NPV: " + + QAssert.Fail("\npar asset swap fair clean price doesn't zero the NPV: " + "\n clean price: " + bondPrice + "\n fair clean price: " + fairCleanPrice + "\n NPV: " + assetSwap2.NPV() + @@ -211,7 +243,7 @@ public void testConsistency() } if (Math.Abs(assetSwap2.fairCleanPrice() - fairCleanPrice) > tolerance) { - Assert.Fail("\npar asset swap fair clean price doesn't equal input clean price at zero NPV: " + + QAssert.Fail("\npar asset swap fair clean price doesn't equal input clean price at zero NPV: " + "\n input clean price: " + fairCleanPrice + "\n fair clean price: " + assetSwap2.fairCleanPrice() + "\n NPV: " + assetSwap2.NPV() + @@ -219,7 +251,7 @@ public void testConsistency() } if (Math.Abs(assetSwap2.fairSpread() - vars.spread) > tolerance) { - Assert.Fail("\npar asset swap fair spread doesn't equal input spread at zero NPV: " + + QAssert.Fail("\npar asset swap fair spread doesn't equal input spread at zero NPV: " + "\n input spread: " + vars.spread + "\n fair spread: " + assetSwap2.fairSpread() + "\n NPV: " + assetSwap2.NPV() + @@ -231,7 +263,7 @@ public void testConsistency() assetSwap3.setPricingEngine(swapEngine); if (Math.Abs(assetSwap3.NPV()) > tolerance) { - Assert.Fail("\npar asset swap fair spread doesn't zero the NPV: " + + QAssert.Fail("\npar asset swap fair spread doesn't zero the NPV: " + "\n spread: " + vars.spread + "\n fair spread: " + fairSpread + "\n NPV: " + assetSwap3.NPV() + @@ -239,7 +271,7 @@ public void testConsistency() } if (Math.Abs(assetSwap3.fairCleanPrice() - bondPrice) > tolerance) { - Assert.Fail("\npar asset swap fair clean price doesn't equal input clean price at zero NPV: " + + QAssert.Fail("\npar asset swap fair clean price doesn't equal input clean price at zero NPV: " + "\n input clean price: " + bondPrice + "\n fair clean price: " + assetSwap3.fairCleanPrice() + "\n NPV: " + assetSwap3.NPV() + @@ -247,7 +279,7 @@ public void testConsistency() } if (Math.Abs(assetSwap3.fairSpread() - fairSpread) > tolerance) { - Assert.Fail("\npar asset swap fair spread doesn't equal input spread at zero NPV: " + + QAssert.Fail("\npar asset swap fair spread doesn't equal input spread at zero NPV: " + "\n input spread: " + fairSpread + "\n fair spread: " + assetSwap3.fairSpread() + "\n NPV: " + assetSwap3.NPV() + @@ -272,7 +304,7 @@ public void testConsistency() assetSwap4.setPricingEngine(swapEngine); if (Math.Abs(assetSwap4.NPV()) > tolerance) { - Assert.Fail("\nmarket asset swap fair clean price doesn't zero the NPV: " + + QAssert.Fail("\nmarket asset swap fair clean price doesn't zero the NPV: " + "\n clean price: " + bondPrice + "\n fair clean price: " + fairCleanPrice + "\n NPV: " + assetSwap4.NPV() + @@ -280,7 +312,7 @@ public void testConsistency() } if (Math.Abs(assetSwap4.fairCleanPrice() - fairCleanPrice) > tolerance) { - Assert.Fail("\nmarket asset swap fair clean price doesn't equal input clean price at zero NPV: " + + QAssert.Fail("\nmarket asset swap fair clean price doesn't equal input clean price at zero NPV: " + "\n input clean price: " + fairCleanPrice + "\n fair clean price: " + assetSwap4.fairCleanPrice() + "\n NPV: " + assetSwap4.NPV() + @@ -288,7 +320,7 @@ public void testConsistency() } if (Math.Abs(assetSwap4.fairSpread() - vars.spread) > tolerance) { - Assert.Fail("\nmarket asset swap fair spread doesn't equal input spread at zero NPV: " + + QAssert.Fail("\nmarket asset swap fair spread doesn't equal input spread at zero NPV: " + "\n input spread: " + vars.spread + "\n fair spread: " + assetSwap4.fairSpread() + "\n NPV: " + assetSwap4.NPV() + @@ -300,7 +332,7 @@ public void testConsistency() assetSwap5.setPricingEngine(swapEngine); if (Math.Abs(assetSwap5.NPV()) > tolerance) { - Assert.Fail("\nmarket asset swap fair spread doesn't zero the NPV: " + + QAssert.Fail("\nmarket asset swap fair spread doesn't zero the NPV: " + "\n spread: " + vars.spread + "\n fair spread: " + fairSpread + "\n NPV: " + assetSwap5.NPV() + @@ -308,7 +340,7 @@ public void testConsistency() } if (Math.Abs(assetSwap5.fairCleanPrice() - bondPrice) > tolerance) { - Assert.Fail("\nmarket asset swap fair clean price doesn't equal input clean price at zero NPV: " + + QAssert.Fail("\nmarket asset swap fair clean price doesn't equal input clean price at zero NPV: " + "\n input clean price: " + bondPrice + "\n fair clean price: " + assetSwap5.fairCleanPrice() + "\n NPV: " + assetSwap5.NPV() + @@ -316,7 +348,7 @@ public void testConsistency() } if (Math.Abs(assetSwap5.fairSpread() - fairSpread) > tolerance) { - Assert.Fail("\nmarket asset swap fair spread doesn't equal input spread at zero NPV: " + + QAssert.Fail("\nmarket asset swap fair spread doesn't equal input spread at zero NPV: " + "\n input spread: " + fairSpread + "\n fair spread: " + assetSwap5.fairSpread() + "\n NPV: " + assetSwap5.NPV() + @@ -330,14 +362,14 @@ public void testConsistency() // fair clean price and fair spread should not change if (Math.Abs(mktAssetSwap.fairCleanPrice() - fairCleanPrice) > tolerance) { - Assert.Fail("\nmarket asset swap fair clean price changed with NpvDate:" + + QAssert.Fail("\nmarket asset swap fair clean price changed with NpvDate:" + "\n expected clean price: " + fairCleanPrice + "\n fair clean price: " + mktAssetSwap.fairCleanPrice() + "\n tolerance: " + tolerance); } if (Math.Abs(mktAssetSwap.fairSpread() - fairSpread) > tolerance) { - Assert.Fail("\nmarket asset swap fair spread changed with NpvDate:" + + QAssert.Fail("\nmarket asset swap fair spread changed with NpvDate:" + "\n expected spread: " + fairSpread + "\n fair spread: " + mktAssetSwap.fairSpread() + "\n tolerance: " + tolerance); @@ -348,7 +380,7 @@ public void testConsistency() assetSwap4.setPricingEngine(swapEngine); if (Math.Abs(assetSwap4.NPV()) > tolerance) { - Assert.Fail("\nmarket asset swap fair clean price doesn't zero the NPV: " + + QAssert.Fail("\nmarket asset swap fair clean price doesn't zero the NPV: " + "\n clean price: " + bondPrice + "\n fair clean price: " + fairCleanPrice + "\n NPV: " + assetSwap4.NPV() + @@ -356,7 +388,7 @@ public void testConsistency() } if (Math.Abs(assetSwap4.fairCleanPrice() - fairCleanPrice) > tolerance) { - Assert.Fail("\nmarket asset swap fair clean price doesn't equal input clean price at zero NPV: " + + QAssert.Fail("\nmarket asset swap fair clean price doesn't equal input clean price at zero NPV: " + "\n input clean price: " + fairCleanPrice + "\n fair clean price: " + assetSwap4.fairCleanPrice() + "\n NPV: " + assetSwap4.NPV() + @@ -364,7 +396,7 @@ public void testConsistency() } if (Math.Abs(assetSwap4.fairSpread() - vars.spread) > tolerance) { - Assert.Fail("\nmarket asset swap fair spread doesn't equal input spread at zero NPV: " + + QAssert.Fail("\nmarket asset swap fair spread doesn't equal input spread at zero NPV: " + "\n input spread: " + vars.spread + "\n fair spread: " + assetSwap4.fairSpread() + "\n NPV: " + assetSwap4.NPV() + @@ -376,7 +408,7 @@ public void testConsistency() assetSwap5.setPricingEngine(swapEngine); if (Math.Abs(assetSwap5.NPV()) > tolerance) { - Assert.Fail("\nmarket asset swap fair spread doesn't zero the NPV: " + + QAssert.Fail("\nmarket asset swap fair spread doesn't zero the NPV: " + "\n spread: " + vars.spread + "\n fair spread: " + fairSpread + "\n NPV: " + assetSwap5.NPV() + @@ -384,7 +416,7 @@ public void testConsistency() } if (Math.Abs(assetSwap5.fairCleanPrice() - bondPrice) > tolerance) { - Assert.Fail("\nmarket asset swap fair clean price doesn't equal input clean price at zero NPV: " + + QAssert.Fail("\nmarket asset swap fair clean price doesn't equal input clean price at zero NPV: " + "\n input clean price: " + bondPrice + "\n fair clean price: " + assetSwap5.fairCleanPrice() + "\n NPV: " + assetSwap5.NPV() + @@ -392,15 +424,19 @@ public void testConsistency() } if (Math.Abs(assetSwap5.fairSpread() - fairSpread) > tolerance) { - Assert.Fail("\nmarket asset swap fair spread doesn't equal input spread at zero NPV: " + + QAssert.Fail("\nmarket asset swap fair spread doesn't equal input spread at zero NPV: " + "\n input spread: " + fairSpread + "\n fair spread: " + assetSwap5.fairSpread() + "\n NPV: " + assetSwap5.NPV() + "\n tolerance: " + tolerance); } - } - - [TestMethod()] + } + +#if QL_DOTNET_FRAMEWORK + [TestMethod()] +#else + [Fact] +#endif public void testImpliedValue() { // Testing implied bond value against asset-swap fair price with null spread @@ -441,7 +477,7 @@ public void testImpliedValue() double error1 = Math.Abs(fixedBondAssetSwapPrice1-fixedBondPrice1); if (error1>tolerance) { - Assert.Fail("wrong zero spread asset swap price for fixed bond:" + + QAssert.Fail("wrong zero spread asset swap price for fixed bond:" + "\n bond's clean price: " + fixedBondPrice1 + "\n asset swap fair price: " + fixedBondAssetSwapPrice1 + "\n error: " + error1 + @@ -473,7 +509,7 @@ public void testImpliedValue() double error2 = Math.Abs(fixedBondAssetSwapPrice2-fixedBondPrice2); if (error2>tolerance) { - Assert.Fail("wrong zero spread asset swap price for fixed bond:" + + QAssert.Fail("wrong zero spread asset swap price for fixed bond:" + "\n bond's clean price: " + fixedBondPrice2 + "\n asset swap fair price: " + fixedBondAssetSwapPrice2 + "\n error: " + error2 + @@ -512,7 +548,7 @@ public void testImpliedValue() double error3 = Math.Abs(floatingBondAssetSwapPrice1-floatingBondPrice1); if (error3>tolerance) { - Assert.Fail("wrong zero spread asset swap price for floater:" + + QAssert.Fail("wrong zero spread asset swap price for floater:" + "\n bond's clean price: " + floatingBondPrice1 + "\n asset swap fair price: " + floatingBondAssetSwapPrice1 + "\n error: " + error3 + @@ -546,7 +582,7 @@ public void testImpliedValue() double floatingCurrentCoupon= floatingBond2.nextCouponRate(); double error4= Math.Abs(floatingCurrentCoupon-currentCoupon); if (error4>tolerance) { - Assert.Fail("wrong current coupon is returned for floater bond:" + + QAssert.Fail("wrong current coupon is returned for floater bond:" + "\n bond's calculated current coupon: " + currentCoupon + "\n current coupon asked to the bond: " + @@ -563,7 +599,7 @@ public void testImpliedValue() double error5 = Math.Abs(floatingBondAssetSwapPrice2-floatingBondPrice2); if (error5>tolerance) { - Assert.Fail("wrong zero spread asset swap price for floater:" + + QAssert.Fail("wrong zero spread asset swap price for floater:" + "\n bond's clean price: " + floatingBondPrice2 + "\n asset swap fair price: " + floatingBondAssetSwapPrice2 + "\n error: " + error5 + @@ -601,7 +637,7 @@ public void testImpliedValue() double error6 = Math.Abs(cmsBondAssetSwapPrice1-cmsBondPrice1); if (error6>tolerance) { - Assert.Fail("wrong zero spread asset swap price for cms bond:" + + QAssert.Fail("wrong zero spread asset swap price for cms bond:" + "\n bond's clean price: " + cmsBondPrice1 + "\n asset swap fair price: " + cmsBondAssetSwapPrice1 + "\n error: " + error6 + @@ -636,7 +672,7 @@ public void testImpliedValue() double error7 = Math.Abs(cmsBondAssetSwapPrice2-cmsBondPrice2); if (error7>tolerance) { - Assert.Fail("wrong zero spread asset swap price for cms bond:" + + QAssert.Fail("wrong zero spread asset swap price for cms bond:" + "\n bond's clean price: " + cmsBondPrice2 + "\n asset swap fair price: " + cmsBondAssetSwapPrice2 + "\n error: " + error7 + @@ -661,7 +697,7 @@ public void testImpliedValue() double error8 = Math.Abs(cmsBondAssetSwapPrice1-cmsBondPrice1); if (error8>tolerance) { - Assert.Fail("wrong zero spread asset swap price for zero cpn bond:" + + QAssert.Fail("wrong zero spread asset swap price for zero cpn bond:" + "\n bond's clean price: " + zeroCpnBondPrice1 + "\n asset swap fair price: " + zeroCpnBondAssetSwapPrice1 + "\n error: " + error8 + @@ -686,16 +722,20 @@ public void testImpliedValue() double error9 = Math.Abs(cmsBondAssetSwapPrice2-cmsBondPrice2); if (error9>tolerance) { - Assert.Fail("wrong zero spread asset swap price for zero cpn bond:" + + QAssert.Fail("wrong zero spread asset swap price for zero cpn bond:" + "\n bond's clean price: " + zeroCpnBondPrice2 + "\n asset swap fair price: " + zeroCpnBondAssetSwapPrice2 + "\n error: " + error9 + "\n tolerance: " + tolerance); } - } - - [TestMethod()] + } + +#if QL_DOTNET_FRAMEWORK + [TestMethod()] +#else + [Fact] +#endif public void testMarketASWSpread() { // Testing relationship between market asset swap and par asset swap... @@ -749,7 +789,7 @@ public void testMarketASWSpread() double error1 = Math.Abs(fixedBondMktAssetSwapSpread1- 100*fixedBondParAssetSwapSpread1/fixedBondMktFullPrice1); if (error1>tolerance) { - Assert.Fail("wrong asset swap spreads for fixed bond:" + + QAssert.Fail("wrong asset swap spreads for fixed bond:" + "\n market ASW spread: " + fixedBondMktAssetSwapSpread1 + "\n par ASW spread: " + fixedBondParAssetSwapSpread1 + "\n error: " + error1 + @@ -793,7 +833,7 @@ public void testMarketASWSpread() 100*fixedBondParAssetSwapSpread2/fixedBondMktFullPrice2); if (error2>tolerance) { - Assert.Fail("wrong asset swap spreads for fixed bond:" + + QAssert.Fail("wrong asset swap spreads for fixed bond:" + "\n market ASW spread: " + fixedBondMktAssetSwapSpread2 + "\n par ASW spread: " + fixedBondParAssetSwapSpread2 + "\n error: " + error2 + @@ -845,7 +885,7 @@ public void testMarketASWSpread() 100*floatingBondParAssetSwapSpread1/floatingBondMktFullPrice1); if (error3>tolerance) { - Assert.Fail("wrong asset swap spreads for floating bond:" + + QAssert.Fail("wrong asset swap spreads for floating bond:" + "\n market ASW spread: " + floatingBondMktAssetSwapSpread1 + "\n par ASW spread: " + floatingBondParAssetSwapSpread1 + "\n error: " + error3 + @@ -896,7 +936,7 @@ public void testMarketASWSpread() 100*floatingBondParAssetSwapSpread2/floatingBondMktFullPrice2); if (error4>tolerance) { - Assert.Fail("wrong asset swap spreads for floating bond:" + + QAssert.Fail("wrong asset swap spreads for floating bond:" + "\n market ASW spread: " + floatingBondMktAssetSwapSpread2 + "\n par ASW spread: " + floatingBondParAssetSwapSpread2 + "\n error: " + error4 + @@ -945,7 +985,7 @@ public void testMarketASWSpread() 100*cmsBondParAssetSwapSpread1/cmsBondMktFullPrice1); if (error5>tolerance) { - Assert.Fail("wrong asset swap spreads for cms bond:" + + QAssert.Fail("wrong asset swap spreads for cms bond:" + "\n market ASW spread: " + cmsBondMktAssetSwapSpread1 + "\n par ASW spread: " + cmsBondParAssetSwapSpread1 + "\n error: " + error5 + @@ -994,7 +1034,7 @@ public void testMarketASWSpread() 100*cmsBondParAssetSwapSpread2/cmsBondMktFullPrice2); if (error6>tolerance) { - Assert.Fail("wrong asset swap spreads for cms bond:" + + QAssert.Fail("wrong asset swap spreads for cms bond:" + "\n market ASW spread: " + cmsBondMktAssetSwapSpread2 + "\n par ASW spread: " + cmsBondParAssetSwapSpread2 + "\n error: " + error6 + @@ -1033,7 +1073,7 @@ public void testMarketASWSpread() 100*zeroCpnBondParAssetSwapSpread1/zeroCpnBondMktFullPrice1); if (error7>tolerance) { - Assert.Fail("wrong asset swap spreads for zero cpn bond:" + + QAssert.Fail("wrong asset swap spreads for zero cpn bond:" + "\n market ASW spread: " + zeroCpnBondMktAssetSwapSpread1 + "\n par ASW spread: " + zeroCpnBondParAssetSwapSpread1 + "\n error: " + error7 + @@ -1075,15 +1115,19 @@ public void testMarketASWSpread() 100*zeroCpnBondParAssetSwapSpread2/zeroCpnBondMktFullPrice2); if (error8>tolerance) { - Assert.Fail("wrong asset swap spreads for zero cpn bond:" + + QAssert.Fail("wrong asset swap spreads for zero cpn bond:" + "\n market ASW spread: " + zeroCpnBondMktAssetSwapSpread2 + "\n par ASW spread: " + zeroCpnBondParAssetSwapSpread2 + "\n error: " + error8 + "\n tolerance: " + tolerance); } - } - - [TestMethod()] + } + +#if QL_DOTNET_FRAMEWORK + [TestMethod()] +#else + [Fact] +#endif public void testZSpread() { // Testing clean and dirty price with null Z-spread against theoretical prices... @@ -1119,7 +1163,7 @@ public void testZSpread() double tolerance = 1.0e-13; double error1 = Math.Abs(fixedBondImpliedValue1-fixedBondCleanPrice1); if (error1>tolerance) { - Assert.Fail("wrong clean price for fixed bond:" + + QAssert.Fail("wrong clean price for fixed bond:" + "\n market asset swap spread: " + fixedBondImpliedValue1 + "\n par asset swap spread: " + fixedBondCleanPrice1 + @@ -1150,7 +1194,7 @@ public void testZSpread() new Actual365Fixed(), vars.compounding, Frequency.Annual, fixedBondSettlementDate2); double error3 = Math.Abs(fixedBondImpliedValue2-fixedBondCleanPrice2); if (error3>tolerance) { - Assert.Fail("wrong clean price for fixed bond:" + + QAssert.Fail("wrong clean price for fixed bond:" + "\n market asset swap spread: " + fixedBondImpliedValue2 + "\n par asset swap spread: " + fixedBondCleanPrice2 + @@ -1187,7 +1231,7 @@ public void testZSpread() new Actual365Fixed(), vars.compounding, Frequency.Semiannual, fixedBondSettlementDate1); double error5 = Math.Abs(floatingBondImpliedValue1-floatingBondCleanPrice1); if (error5>tolerance) { - Assert.Fail("wrong clean price for fixed bond:" + + QAssert.Fail("wrong clean price for fixed bond:" + "\n market asset swap spread: " + floatingBondImpliedValue1 + "\n par asset swap spread: " + floatingBondCleanPrice1 + @@ -1223,7 +1267,7 @@ public void testZSpread() vars.spread, new Actual365Fixed(), vars.compounding, Frequency.Semiannual, fixedBondSettlementDate1); double error7 = Math.Abs(floatingBondImpliedValue2-floatingBondCleanPrice2); if (error7>tolerance) { - Assert.Fail("wrong clean price for fixed bond:" + QAssert.Fail("wrong clean price for fixed bond:" + "\n market asset swap spread: " + floatingBondImpliedValue2 + "\n par asset swap spread: " + floatingBondCleanPrice2 @@ -1259,7 +1303,7 @@ public void testZSpread() new Actual365Fixed(), vars.compounding, Frequency.Annual, cmsBondSettlementDate1); double error9 = Math.Abs(cmsBondImpliedValue1-cmsBondCleanPrice1); if (error9>tolerance) { - Assert.Fail("wrong clean price for fixed bond:" + QAssert.Fail("wrong clean price for fixed bond:" + "\n market asset swap spread: " + cmsBondImpliedValue1 + "\n par asset swap spread: " + cmsBondCleanPrice1 + "\n error: " + error9 @@ -1294,7 +1338,7 @@ public void testZSpread() new Actual365Fixed(), vars.compounding, Frequency.Annual, cmsBondSettlementDate2); double error11 = Math.Abs(cmsBondImpliedValue2-cmsBondCleanPrice2); if (error11>tolerance) { - Assert.Fail("wrong clean price for fixed bond:" + QAssert.Fail("wrong clean price for fixed bond:" + "\n market asset swap spread: " + cmsBondImpliedValue2 + "\n par asset swap spread: " + cmsBondCleanPrice2 + "\n error: " + error11 @@ -1319,7 +1363,7 @@ public void testZSpread() new Actual365Fixed(), vars.compounding, Frequency.Annual, zeroCpnBondSettlementDate1); double error13 = Math.Abs(zeroCpnBondImpliedValue1-zeroCpnBondCleanPrice1); if (error13>tolerance) { - Assert.Fail("wrong clean price for zero coupon bond:" + QAssert.Fail("wrong clean price for zero coupon bond:" + "\n zero cpn implied value: " + zeroCpnBondImpliedValue1 + "\n zero cpn price: " + zeroCpnBondCleanPrice1 @@ -1345,16 +1389,20 @@ public void testZSpread() new Actual365Fixed(), vars.compounding, Frequency.Annual, zeroCpnBondSettlementDate2); double error15 = Math.Abs(zeroCpnBondImpliedValue2-zeroCpnBondCleanPrice2); if (error15>tolerance) { - Assert.Fail("wrong clean price for zero coupon bond:" + QAssert.Fail("wrong clean price for zero coupon bond:" + "\n zero cpn implied value: " + zeroCpnBondImpliedValue2 + "\n zero cpn price: " + zeroCpnBondCleanPrice2 + "\n error: " + error15 + "\n tolerance: " + tolerance); } - } - - [TestMethod()] + } + +#if QL_DOTNET_FRAMEWORK + [TestMethod()] +#else + [Fact] +#endif public void testGenericBondImplied() { @@ -1403,7 +1451,7 @@ public void testGenericBondImplied() double error1 = Math.Abs(fixedBondAssetSwapPrice1-fixedBondPrice1); if (error1>tolerance) { - Assert.Fail("wrong zero spread asset swap price for fixed bond:" + QAssert.Fail("wrong zero spread asset swap price for fixed bond:" + "\n bond's clean price: " + fixedBondPrice1 + "\n asset swap fair price: " + fixedBondAssetSwapPrice1 + "\n error: " + error1 @@ -1440,7 +1488,7 @@ public void testGenericBondImplied() double error2 = Math.Abs(fixedBondAssetSwapPrice2-fixedBondPrice2); if (error2>tolerance) { - Assert.Fail("wrong zero spread asset swap price for fixed bond:" + QAssert.Fail("wrong zero spread asset swap price for fixed bond:" + "\n bond's clean price: " + fixedBondPrice2 + "\n asset swap fair price: " + fixedBondAssetSwapPrice2 + "\n error: " + error2 @@ -1483,7 +1531,7 @@ public void testGenericBondImplied() double error3 = Math.Abs(floatingBondAssetSwapPrice1-floatingBondPrice1); if (error3>tolerance) { - Assert.Fail("wrong zero spread asset swap price for floater:" + QAssert.Fail("wrong zero spread asset swap price for floater:" + "\n bond's clean price: " + floatingBondPrice1 + "\n asset swap fair price: " + floatingBondAssetSwapPrice1 @@ -1520,7 +1568,7 @@ public void testGenericBondImplied() double floatingCurrentCoupon= floatingBond2.nextCouponRate(); double error4= Math.Abs(floatingCurrentCoupon-currentCoupon); if (error4>tolerance) { - Assert.Fail("wrong current coupon is returned for floater bond:" + QAssert.Fail("wrong current coupon is returned for floater bond:" + "\n bond's calculated current coupon: " + currentCoupon + "\n current coupon asked to the bond: " + @@ -1541,7 +1589,7 @@ public void testGenericBondImplied() double error5 = Math.Abs(floatingBondAssetSwapPrice2-floatingBondPrice2); if (error5>tolerance) { - Assert.Fail("wrong zero spread asset swap price for floater:" + QAssert.Fail("wrong zero spread asset swap price for floater:" + "\n bond's clean price: " + floatingBondPrice2 + "\n asset swap fair price: " + floatingBondAssetSwapPrice2 @@ -1585,7 +1633,7 @@ public void testGenericBondImplied() double error6 = Math.Abs(cmsBondAssetSwapPrice1-cmsBondPrice1); if (error6>tolerance) { - Assert.Fail("wrong zero spread asset swap price for cms bond:" + QAssert.Fail("wrong zero spread asset swap price for cms bond:" + "\n bond's clean price: " + cmsBondPrice1 + "\n asset swap fair price: " + cmsBondAssetSwapPrice1 + "\n error: " + error6 @@ -1627,7 +1675,7 @@ public void testGenericBondImplied() double error7 = Math.Abs(cmsBondAssetSwapPrice2-cmsBondPrice2); if (error7>tolerance) { - Assert.Fail("wrong zero spread asset swap price for cms bond:" + QAssert.Fail("wrong zero spread asset swap price for cms bond:" + "\n bond's clean price: " + cmsBondPrice2 + "\n asset swap fair price: " + cmsBondAssetSwapPrice2 + "\n error: " + error7 @@ -1656,7 +1704,7 @@ public void testGenericBondImplied() double error8 = Math.Abs(zeroCpnBondAssetSwapPrice1-zeroCpnBondPrice1); if (error8>tolerance) { - Assert.Fail("wrong zero spread asset swap price for zero cpn bond:" + QAssert.Fail("wrong zero spread asset swap price for zero cpn bond:" + "\n bond's clean price: " + zeroCpnBondPrice1 + "\n asset swap fair price: " + zeroCpnBondAssetSwapPrice1 + "\n error: " + error8 @@ -1685,15 +1733,19 @@ public void testGenericBondImplied() double error9 = Math.Abs(cmsBondAssetSwapPrice2-cmsBondPrice2); if (error9>tolerance) { - Assert.Fail("wrong zero spread asset swap price for zero cpn bond:" + QAssert.Fail("wrong zero spread asset swap price for zero cpn bond:" + "\n bond's clean price: " + zeroCpnBondPrice2 + "\n asset swap fair price: " + zeroCpnBondAssetSwapPrice2 + "\n error: " + error9 + "\n tolerance: " + tolerance); } - } - - [TestMethod()] + } + +#if QL_DOTNET_FRAMEWORK + [TestMethod()] +#else + [Fact] +#endif public void testMASWWithGenericBond() { // Testing market asset swap against par asset swap with generic bond... @@ -1754,7 +1806,7 @@ public void testMASWWithGenericBond() 100*fixedBondParAssetSwapSpread1/fixedBondMktFullPrice1); if (error1>tolerance) - Assert.Fail("wrong asset swap spreads for fixed bond:" + + QAssert.Fail("wrong asset swap spreads for fixed bond:" + "\n market asset swap spread: " + fixedBondMktAssetSwapSpread1 + "\n par asset swap spread: " + fixedBondParAssetSwapSpread1 + "\n error: " + error1 + @@ -1801,7 +1853,7 @@ public void testMASWWithGenericBond() 100*fixedBondParAssetSwapSpread2/fixedBondMktFullPrice2); if (error2>tolerance) - Assert.Fail("wrong asset swap spreads for fixed bond:" + + QAssert.Fail("wrong asset swap spreads for fixed bond:" + "\n market asset swap spread: " + fixedBondMktAssetSwapSpread2 + "\n par asset swap spread: " + fixedBondParAssetSwapSpread2 + "\n error: " + error2 + @@ -1858,7 +1910,7 @@ public void testMASWWithGenericBond() 100*floatingBondParAssetSwapSpread1/floatingBondMktFullPrice1); if (error3>tolerance) - Assert.Fail("wrong asset swap spreads for floating bond:" + + QAssert.Fail("wrong asset swap spreads for floating bond:" + "\n market asset swap spread: " + floatingBondMktAssetSwapSpread1 + "\n par asset swap spread: " + floatingBondParAssetSwapSpread1 + "\n error: " + error3 + @@ -1916,7 +1968,7 @@ public void testMASWWithGenericBond() 100*floatingBondParAssetSwapSpread2/floatingBondMktFullPrice2); if (error4>tolerance) - Assert.Fail("wrong asset swap spreads for floating bond:" + + QAssert.Fail("wrong asset swap spreads for floating bond:" + "\n market asset swap spread: " + floatingBondMktAssetSwapSpread2 + "\n par asset swap spread: " + floatingBondParAssetSwapSpread2 + "\n error: " + error4 + @@ -1970,7 +2022,7 @@ public void testMASWWithGenericBond() 100*cmsBondParAssetSwapSpread1/cmsBondMktFullPrice1); if (error5>tolerance) - Assert.Fail("wrong asset swap spreads for cms bond:" + + QAssert.Fail("wrong asset swap spreads for cms bond:" + "\n market asset swap spread: " + cmsBondMktAssetSwapSpread1 + "\n par asset swap spread: " + cmsBondParAssetSwapSpread1 + "\n error: " + error5 + @@ -2023,7 +2075,7 @@ public void testMASWWithGenericBond() 100*cmsBondParAssetSwapSpread2/cmsBondMktFullPrice2); if (error6>tolerance) - Assert.Fail("wrong asset swap spreads for cms bond:" + + QAssert.Fail("wrong asset swap spreads for cms bond:" + "\n market asset swap spread: " + cmsBondMktAssetSwapSpread2 + "\n par asset swap spread: " + cmsBondParAssetSwapSpread2 + "\n error: " + error6 + @@ -2066,7 +2118,7 @@ public void testMASWWithGenericBond() 100*zeroCpnBondParAssetSwapSpread1/zeroCpnBondMktFullPrice1); if (error7>tolerance) - Assert.Fail("wrong asset swap spreads for zero cpn bond:" + + QAssert.Fail("wrong asset swap spreads for zero cpn bond:" + "\n market asset swap spread: " + zeroCpnBondMktAssetSwapSpread1 + "\n par asset swap spread: " + zeroCpnBondParAssetSwapSpread1 + "\n error: " + error7 + @@ -2110,14 +2162,18 @@ public void testMASWWithGenericBond() 100*zeroCpnBondParAssetSwapSpread2/zeroCpnBondMktFullPrice2); if (error8>tolerance) - Assert.Fail("wrong asset swap spreads for zero cpn bond:" + + QAssert.Fail("wrong asset swap spreads for zero cpn bond:" + "\n market asset swap spread: " + zeroCpnBondMktAssetSwapSpread2 + "\n par asset swap spread: " + zeroCpnBondParAssetSwapSpread2 + "\n error: " + error8 + "\n tolerance: " + tolerance); - } - - [TestMethod()] + } + +#if QL_DOTNET_FRAMEWORK + [TestMethod()] +#else + [Fact] +#endif public void testZSpreadWithGenericBond() { // Testing clean and dirty price with null Z-spread against theoretical prices... @@ -2159,7 +2215,7 @@ public void testZSpreadWithGenericBond() double tolerance = 1.0e-13; double error1 = Math.Abs(fixedBondImpliedValue1-fixedBondCleanPrice1); if (error1>tolerance) { - Assert.Fail("wrong clean price for fixed bond:" + QAssert.Fail("wrong clean price for fixed bond:" + "\n market asset swap spread: " + fixedBondImpliedValue1 + "\n par asset swap spread: " + fixedBondCleanPrice1 @@ -2195,7 +2251,7 @@ public void testZSpreadWithGenericBond() new Actual365Fixed(), vars.compounding, Frequency.Annual, fixedBondSettlementDate2); double error3 = Math.Abs(fixedBondImpliedValue2-fixedBondCleanPrice2); if (error3>tolerance) { - Assert.Fail("wrong clean price for fixed bond:" + QAssert.Fail("wrong clean price for fixed bond:" + "\n market asset swap spread: " + fixedBondImpliedValue2 + "\n par asset swap spread: " + fixedBondCleanPrice2 @@ -2236,7 +2292,7 @@ public void testZSpreadWithGenericBond() new Actual365Fixed(), vars.compounding, Frequency.Semiannual, fixedBondSettlementDate1); double error5 = Math.Abs(floatingBondImpliedValue1-floatingBondCleanPrice1); if (error5>tolerance) { - Assert.Fail("wrong clean price for fixed bond:" + QAssert.Fail("wrong clean price for fixed bond:" + "\n market asset swap spread: " + floatingBondImpliedValue1 + "\n par asset swap spread: " + floatingBondCleanPrice1 @@ -2276,7 +2332,7 @@ public void testZSpreadWithGenericBond() new Actual365Fixed(), vars.compounding, Frequency.Semiannual, fixedBondSettlementDate1); double error7 = Math.Abs(floatingBondImpliedValue2-floatingBondCleanPrice2); if (error7>tolerance) { - Assert.Fail("wrong clean price for fixed bond:" + QAssert.Fail("wrong clean price for fixed bond:" + "\n market asset swap spread: " + floatingBondImpliedValue2 + "\n par asset swap spread: " + floatingBondCleanPrice2 @@ -2318,7 +2374,7 @@ public void testZSpreadWithGenericBond() cmsBondSettlementDate1); double error9 = Math.Abs(cmsBondImpliedValue1-cmsBondCleanPrice1); if (error9>tolerance) { - Assert.Fail("wrong clean price for fixed bond:" + QAssert.Fail("wrong clean price for fixed bond:" + "\n market asset swap spread: " + cmsBondImpliedValue1 + "\n par asset swap spread: " + cmsBondCleanPrice1 + "\n error: " + error9 @@ -2358,7 +2414,7 @@ public void testZSpreadWithGenericBond() cmsBondSettlementDate2); double error11 = Math.Abs(cmsBondImpliedValue2-cmsBondCleanPrice2); if (error11>tolerance) { - Assert.Fail("wrong clean price for fixed bond:" + QAssert.Fail("wrong clean price for fixed bond:" + "\n market asset swap spread: " + cmsBondImpliedValue2 + "\n par asset swap spread: " + cmsBondCleanPrice2 + "\n error: " + error11 @@ -2390,7 +2446,7 @@ public void testZSpreadWithGenericBond() zeroCpnBondSettlementDate1); double error13 = Math.Abs(zeroCpnBondImpliedValue1-zeroCpnBondCleanPrice1); if (error13>tolerance) { - Assert.Fail("wrong clean price for zero coupon bond:" + QAssert.Fail("wrong clean price for zero coupon bond:" + "\n zero cpn implied value: " + zeroCpnBondImpliedValue1 + "\n zero cpn price: " + zeroCpnBondCleanPrice1 @@ -2423,16 +2479,20 @@ public void testZSpreadWithGenericBond() zeroCpnBondSettlementDate2); double error15 = Math.Abs(zeroCpnBondImpliedValue2-zeroCpnBondCleanPrice2); if (error15>tolerance) { - Assert.Fail("wrong clean price for zero coupon bond:" + QAssert.Fail("wrong clean price for zero coupon bond:" + "\n zero cpn implied value: " + zeroCpnBondImpliedValue2 + "\n zero cpn price: " + zeroCpnBondCleanPrice2 + "\n error: " + error15 + "\n tolerance: " + tolerance); } - } - - [TestMethod()] + } + +#if QL_DOTNET_FRAMEWORK + [TestMethod()] +#else + [Fact] +#endif public void testSpecializedBondVsGenericBond() { // Testing clean and dirty prices for specialized bond against equivalent generic bond... @@ -2476,7 +2536,7 @@ public void testSpecializedBondVsGenericBond() double tolerance = 1.0e-13; double error1 = Math.Abs(fixedBondTheoValue1-fixedSpecializedBondTheoValue1); if (error1>tolerance) { - Assert.Fail("wrong clean price for fixed bond:" + QAssert.Fail("wrong clean price for fixed bond:" + "\n specialized fixed rate bond's theo clean price: " + fixedBondTheoValue1 + "\n generic equivalent bond's theo clean price: " @@ -2489,7 +2549,7 @@ public void testSpecializedBondVsGenericBond() fixedSpecializedBond1.accruedAmount(); double error2 = Math.Abs(fixedBondTheoDirty1-fixedSpecializedTheoDirty1); if (error2>tolerance) { - Assert.Fail("wrong dirty price for fixed bond:" + QAssert.Fail("wrong dirty price for fixed bond:" + "\n specialized fixed rate bond's theo dirty price: " + fixedBondTheoDirty1 + "\n generic equivalent bond's theo dirty price: " @@ -2530,7 +2590,7 @@ public void testSpecializedBondVsGenericBond() double error3 = Math.Abs(fixedBondTheoValue2-fixedSpecializedBondTheoValue2); if (error3>tolerance) { - Assert.Fail("wrong clean price for fixed bond:" + QAssert.Fail("wrong clean price for fixed bond:" + "\n specialized fixed rate bond's theo clean price: " + fixedBondTheoValue2 + "\n generic equivalent bond's theo clean price: " @@ -2545,7 +2605,7 @@ public void testSpecializedBondVsGenericBond() double error4 = Math.Abs(fixedBondTheoDirty2-fixedSpecializedBondTheoDirty2); if (error4>tolerance) { - Assert.Fail("wrong dirty price for fixed bond:" + QAssert.Fail("wrong dirty price for fixed bond:" + "\n specialized fixed rate bond's dirty clean price: " + fixedBondTheoDirty2 + "\n generic equivalent bond's theo dirty price: " @@ -2598,7 +2658,7 @@ public void testSpecializedBondVsGenericBond() double error5 = Math.Abs(floatingBondTheoValue1- floatingSpecializedBondTheoValue1); if (error5>tolerance) { - Assert.Fail("wrong clean price for fixed bond:" + QAssert.Fail("wrong clean price for fixed bond:" + "\n generic fixed rate bond's theo clean price: " + floatingBondTheoValue1 + "\n equivalent specialized bond's theo clean price: " @@ -2614,7 +2674,7 @@ public void testSpecializedBondVsGenericBond() double error6 = Math.Abs(floatingBondTheoDirty1- floatingSpecializedBondTheoDirty1); if (error6>tolerance) { - Assert.Fail("wrong dirty price for frn bond:" + QAssert.Fail("wrong dirty price for frn bond:" + "\n generic frn bond's dirty clean price: " + floatingBondTheoDirty1 + "\n equivalent specialized bond's theo dirty price: " @@ -2671,7 +2731,7 @@ public void testSpecializedBondVsGenericBond() double error7 = Math.Abs(floatingBondTheoValue2-floatingSpecializedBondTheoValue2); if (error7>tolerance) { - Assert.Fail("wrong clean price for floater bond:" + QAssert.Fail("wrong clean price for floater bond:" + "\n generic floater bond's theo clean price: " + floatingBondTheoValue2 + "\n equivalent specialized bond's theo clean price: " @@ -2687,7 +2747,7 @@ public void testSpecializedBondVsGenericBond() double error8 = Math.Abs(floatingBondTheoDirty2-floatingSpecializedTheoDirty2); if (error8>tolerance) { - Assert.Fail("wrong dirty price for floater bond:" + QAssert.Fail("wrong dirty price for floater bond:" + "\n generic floater bond's theo dirty price: " + floatingBondTheoDirty2 + "\n equivalent specialized bond's theo dirty price: " @@ -2737,7 +2797,7 @@ public void testSpecializedBondVsGenericBond() double cmsSpecializedBondTheoValue1 = cmsSpecializedBond1.cleanPrice(); double error9 = Math.Abs(cmsBondTheoValue1-cmsSpecializedBondTheoValue1); if (error9>tolerance) { - Assert.Fail("wrong clean price for cms bond:" + QAssert.Fail("wrong clean price for cms bond:" + "\n generic cms bond's theo clean price: " + cmsBondTheoValue1 + "\n equivalent specialized bond's theo clean price: " @@ -2750,7 +2810,7 @@ public void testSpecializedBondVsGenericBond() cmsSpecializedBond1.accruedAmount(); double error10 = Math.Abs(cmsBondTheoDirty1-cmsSpecializedBondTheoDirty1); if (error10>tolerance) { - Assert.Fail("wrong dirty price for cms bond:" + QAssert.Fail("wrong dirty price for cms bond:" + "\n generic cms bond's theo dirty price: " + cmsBondTheoDirty1 + "\n specialized cms bond's theo dirty price: " @@ -2798,7 +2858,7 @@ public void testSpecializedBondVsGenericBond() double error11 = Math.Abs(cmsBondTheoValue2-cmsSpecializedBondTheoValue2); if (error11>tolerance) { - Assert.Fail("wrong clean price for cms bond:" + QAssert.Fail("wrong clean price for cms bond:" + "\n generic cms bond's theo clean price: " + cmsBondTheoValue2 + "\n cms bond's theo clean price: " @@ -2811,7 +2871,7 @@ public void testSpecializedBondVsGenericBond() cmsSpecializedBondTheoValue2+cmsSpecializedBond2.accruedAmount(); double error12 = Math.Abs(cmsBondTheoDirty2-cmsSpecializedBondTheoDirty2); if (error12>tolerance) { - Assert.Fail("wrong dirty price for cms bond:" + QAssert.Fail("wrong dirty price for cms bond:" + "\n generic cms bond's dirty price: " + cmsBondTheoDirty2 + "\n specialized cms bond's theo dirty price: " @@ -2846,7 +2906,7 @@ public void testSpecializedBondVsGenericBond() double error13 = Math.Abs(zeroCpnBondTheoValue1-zeroCpnSpecializedBondTheoValue1); if (error13>tolerance) { - Assert.Fail("wrong clean price for zero coupon bond:" + QAssert.Fail("wrong clean price for zero coupon bond:" + "\n generic zero bond's clean price: " + zeroCpnBondTheoValue1 + "\n specialized zero bond's clean price: " @@ -2862,7 +2922,7 @@ public void testSpecializedBondVsGenericBond() double error14 = Math.Abs(zeroCpnBondTheoDirty1-zeroCpnSpecializedBondTheoDirty1); if (error14>tolerance) { - Assert.Fail("wrong dirty price for zero bond:" + QAssert.Fail("wrong dirty price for zero bond:" + "\n generic zerocpn bond's dirty price: " + zeroCpnBondTheoDirty1 + "\n specialized zerocpn bond's clean price: " @@ -2897,7 +2957,7 @@ public void testSpecializedBondVsGenericBond() double error15 = Math.Abs(zeroCpnBondTheoValue2 -zeroCpnSpecializedBondTheoValue2); if (error15>tolerance) { - Assert.Fail("wrong clean price for zero coupon bond:" + QAssert.Fail("wrong clean price for zero coupon bond:" + "\n generic zerocpn bond's clean price: " + zeroCpnBondTheoValue2 + "\n specialized zerocpn bond's clean price: " @@ -2915,7 +2975,7 @@ public void testSpecializedBondVsGenericBond() double error16 = Math.Abs(zeroCpnBondTheoDirty2-zeroCpnSpecializedBondTheoDirty2); if (error16>tolerance) { - Assert.Fail("wrong dirty price for zero coupon bond:" + QAssert.Fail("wrong dirty price for zero coupon bond:" + "\n generic zerocpn bond's dirty price: " + zeroCpnBondTheoDirty2 + "\n specialized zerocpn bond's dirty price: " @@ -2923,9 +2983,13 @@ public void testSpecializedBondVsGenericBond() + "\n error: " + error16 + "\n tolerance: " + tolerance); } - } - - [TestMethod()] + } + +#if QL_DOTNET_FRAMEWORK + [TestMethod()] +#else + [Fact] +#endif public void testSpecializedBondVsGenericBondUsingAsw() { // Testing asset-swap prices and spreads for specialized bond against equivalent generic bond... @@ -2991,7 +3055,7 @@ public void testSpecializedBondVsGenericBondUsingAsw() double error1 = Math.Abs(fixedBondAssetSwapPrice1-fixedSpecializedBondAssetSwapPrice1); if (error1>tolerance) { - Assert.Fail("wrong clean price for fixed bond:" + QAssert.Fail("wrong clean price for fixed bond:" + "\n generic fixed rate bond's clean price: " + fixedBondAssetSwapPrice1 + "\n equivalent specialized bond's clean price: " @@ -3020,7 +3084,7 @@ public void testSpecializedBondVsGenericBondUsingAsw() double fixedSpecializedBondASWSpread1 = fixedSpecializedBondASW1.fairSpread(); double error2 = Math.Abs(fixedBondASWSpread1-fixedSpecializedBondASWSpread1); if (error2>tolerance) { - Assert.Fail("wrong asw spread for fixed bond:" + QAssert.Fail("wrong asw spread for fixed bond:" + "\n generic fixed rate bond's asw spread: " + fixedBondASWSpread1 + "\n equivalent specialized bond's asw spread: " @@ -3080,7 +3144,7 @@ public void testSpecializedBondVsGenericBondUsingAsw() double error3 = Math.Abs(fixedBondAssetSwapPrice2-fixedSpecializedBondAssetSwapPrice2); if (error3>tolerance) { - Assert.Fail("wrong clean price for fixed bond:" + QAssert.Fail("wrong clean price for fixed bond:" + "\n generic fixed rate bond's clean price: " + fixedBondAssetSwapPrice2 + "\n equivalent specialized bond's clean price: " @@ -3109,7 +3173,7 @@ public void testSpecializedBondVsGenericBondUsingAsw() double fixedSpecializedBondASWSpread2 = fixedSpecializedBondASW2.fairSpread(); double error4 = Math.Abs(fixedBondASWSpread2-fixedSpecializedBondASWSpread2); if (error4>tolerance) { - Assert.Fail("wrong asw spread for fixed bond:" + QAssert.Fail("wrong asw spread for fixed bond:" + "\n generic fixed rate bond's asw spread: " + fixedBondASWSpread2 + "\n equivalent specialized bond's asw spread: " @@ -3181,7 +3245,7 @@ public void testSpecializedBondVsGenericBondUsingAsw() double error5 = Math.Abs(floatingBondAssetSwapPrice1-floatingSpecializedBondAssetSwapPrice1); if (error5>tolerance) { - Assert.Fail("wrong clean price for frnbond:" + QAssert.Fail("wrong clean price for frnbond:" + "\n generic frn rate bond's clean price: " + floatingBondAssetSwapPrice1 + "\n equivalent specialized bond's price: " @@ -3212,7 +3276,7 @@ public void testSpecializedBondVsGenericBondUsingAsw() double error6 = Math.Abs(floatingBondASWSpread1-floatingSpecializedBondASWSpread1); if (error6>tolerance) { - Assert.Fail("wrong asw spread for fixed bond:" + QAssert.Fail("wrong asw spread for fixed bond:" + "\n generic frn rate bond's asw spread: " + floatingBondASWSpread1 + "\n equivalent specialized bond's asw spread: " @@ -3284,7 +3348,7 @@ public void testSpecializedBondVsGenericBondUsingAsw() double error7 = Math.Abs(floatingBondAssetSwapPrice2-floatingSpecializedBondAssetSwapPrice2); if (error7>tolerance) { - Assert.Fail("wrong clean price for frnbond:" + QAssert.Fail("wrong clean price for frnbond:" + "\n generic frn rate bond's clean price: " + floatingBondAssetSwapPrice2 + "\n equivalent specialized frn bond's price: " @@ -3315,7 +3379,7 @@ public void testSpecializedBondVsGenericBondUsingAsw() double error8 = Math.Abs(floatingBondASWSpread2-floatingSpecializedBondASWSpread2); if (error8>tolerance) { - Assert.Fail("wrong asw spread for frn bond:" + QAssert.Fail("wrong asw spread for frn bond:" + "\n generic frn rate bond's asw spread: " + floatingBondASWSpread2 + "\n equivalent specialized bond's asw spread: " @@ -3382,7 +3446,7 @@ public void testSpecializedBondVsGenericBondUsingAsw() double error9 = Math.Abs(cmsBondAssetSwapPrice1-cmsSpecializedBondAssetSwapPrice1); if (error9>tolerance) { - Assert.Fail("wrong clean price for cmsbond:" + QAssert.Fail("wrong clean price for cmsbond:" + "\n generic bond's clean price: " + cmsBondAssetSwapPrice1 + "\n equivalent specialized cms rate bond's price: " @@ -3410,7 +3474,7 @@ public void testSpecializedBondVsGenericBondUsingAsw() double cmsSpecializedBondASWSpread1 = cmsSpecializedBondASW1.fairSpread(); double error10 = Math.Abs(cmsBondASWSpread1-cmsSpecializedBondASWSpread1); if (error10>tolerance) { - Assert.Fail("wrong asw spread for cm bond:" + QAssert.Fail("wrong asw spread for cm bond:" + "\n generic cms rate bond's asw spread: " + cmsBondASWSpread1 + "\n equivalent specialized bond's asw spread: " @@ -3477,7 +3541,7 @@ public void testSpecializedBondVsGenericBondUsingAsw() double error11 = Math.Abs(cmsBondAssetSwapPrice2-cmsSpecializedBondAssetSwapPrice2); if (error11>tolerance) { - Assert.Fail("wrong clean price for cmsbond:" + QAssert.Fail("wrong clean price for cmsbond:" + "\n generic bond's clean price: " + cmsBondAssetSwapPrice2 + "\n equivalent specialized cms rate bond's price: " @@ -3505,7 +3569,7 @@ public void testSpecializedBondVsGenericBondUsingAsw() double cmsSpecializedBondASWSpread2 = cmsSpecializedBondASW2.fairSpread(); double error12 = Math.Abs(cmsBondASWSpread2-cmsSpecializedBondASWSpread2); if (error12>tolerance) { - Assert.Fail("wrong asw spread for cm bond:" + QAssert.Fail("wrong asw spread for cm bond:" + "\n generic cms rate bond's asw spread: " + cmsBondASWSpread2 + "\n equivalent specialized bond's asw spread: " @@ -3558,7 +3622,7 @@ public void testSpecializedBondVsGenericBondUsingAsw() double error13 = Math.Abs(zeroCpnBondAssetSwapPrice1-zeroCpnSpecializedBondAssetSwapPrice1); if (error13>tolerance) { - Assert.Fail("wrong clean price for zerocpn bond:" + QAssert.Fail("wrong clean price for zerocpn bond:" + "\n generic zero cpn bond's clean price: " + zeroCpnBondAssetSwapPrice1 + "\n specialized equivalent bond's price: " @@ -3589,7 +3653,7 @@ public void testSpecializedBondVsGenericBondUsingAsw() double error14 = Math.Abs(zeroCpnBondASWSpread1-zeroCpnSpecializedBondASWSpread1); if (error14>tolerance) { - Assert.Fail("wrong asw spread for zeroCpn bond:" + QAssert.Fail("wrong asw spread for zeroCpn bond:" + "\n generic zeroCpn bond's asw spread: " + zeroCpnBondASWSpread1 + "\n equivalent specialized bond's asw spread: " @@ -3643,7 +3707,7 @@ public void testSpecializedBondVsGenericBondUsingAsw() double error15 = Math.Abs(zeroCpnBondAssetSwapPrice2 -zeroCpnSpecializedBondAssetSwapPrice2); if (error15>tolerance) { - Assert.Fail("wrong clean price for zerocpn bond:" + QAssert.Fail("wrong clean price for zerocpn bond:" + "\n generic zero cpn bond's clean price: " + zeroCpnBondAssetSwapPrice2 + "\n equivalent specialized bond's price: " @@ -3674,7 +3738,7 @@ public void testSpecializedBondVsGenericBondUsingAsw() double error16 = Math.Abs(zeroCpnBondASWSpread2-zeroCpnSpecializedBondASWSpread2); if (error16>tolerance) { - Assert.Fail("wrong asw spread for zeroCpn bond:" + QAssert.Fail("wrong asw spread for zeroCpn bond:" + "\n generic zeroCpn bond's asw spread: " + zeroCpnBondASWSpread2 + "\n equivalent specialized bond's asw spread: " @@ -3685,5 +3749,7 @@ public void testSpecializedBondVsGenericBondUsingAsw() } - } + + +} } diff --git a/Test/T_BasketOption.cs b/Test/T_BasketOption.cs index 5fe174967..e18f8599e 100644 --- a/Test/T_BasketOption.cs +++ b/Test/T_BasketOption.cs @@ -1,69 +1,75 @@ -/* - Copyright (C) 2008-2016 Andrea Maggiulli (a.maggiulli@gmail.com) - - This file is part of QLNet Project https://github.com/amaggiulli/qlnet - QLNet is free software: you can redistribute it and/or modify it - under the terms of the QLNet license. You should have received a - copy of the license along with this program; if not, license is - available online at . - - QLNet is a based on QuantLib, a free-software/open-source library - for financial quantitative analysts and developers - http://quantlib.org/ - The QuantLib license is available online at http://quantlib.org/license.shtml. - - This program is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS - FOR A PARTICULAR PURPOSE. See the license for more details. -*/ - -using System; +/* + Copyright (C) 2008-2016 Andrea Maggiulli (a.maggiulli@gmail.com) + + This file is part of QLNet Project https://github.com/amaggiulli/qlnet + QLNet is free software: you can redistribute it and/or modify it + under the terms of the QLNet license. You should have received a + copy of the license along with this program; if not, license is + available online at . + + QLNet is a based on QuantLib, a free-software/open-source library + for financial quantitative analysts and developers - http://quantlib.org/ + The QuantLib license is available online at http://quantlib.org/license.shtml. + + This program is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS + FOR A PARTICULAR PURPOSE. See the license for more details. +*/ + +using System; using System.Collections.Generic; +#if QL_DOTNET_FRAMEWORK using Microsoft.VisualStudio.TestTools.UnitTesting; -using QLNet; - - -namespace TestSuite -{ - [TestClass()] - public class T_BasketOption - { - public enum BasketType { MinBasket, MaxBasket, SpreadBasket }; - public struct BasketOptionTwoData - { - public BasketOptionTwoData( BasketType _basketType,Option.Type _type,double _strike,double _s1,double _s2,double _q1, - double _q2,double _r,double _t,double _v1,double _v2,double _rho,double _result,double _tol) - { - - basketType=_basketType; - type= _type; - strike=_strike; - s1=_s1; - s2=_s2; - q1=_q1; - q2=_q2; - r = _r; - t = _t; // years - v1=_v1; - v2=_v2; - rho=_rho; - result= _result; - tol = _tol; - } - - public BasketType basketType; - public Option.Type type; - public double strike; - public double s1; - public double s2; - public double q1; - public double q2; - public double r; - public double t; // years - public double v1; - public double v2; - public double rho; - public double result; - public double tol; +#else + using Xunit; +#endif +using QLNet; + + +namespace TestSuite +{ +#if QL_DOTNET_FRAMEWORK + [TestClass()] +#endif + public class T_BasketOption + { + public enum BasketType { MinBasket, MaxBasket, SpreadBasket }; + public struct BasketOptionTwoData + { + public BasketOptionTwoData( BasketType _basketType,Option.Type _type,double _strike,double _s1,double _s2,double _q1, + double _q2,double _r,double _t,double _v1,double _v2,double _rho,double _result,double _tol) + { + + basketType=_basketType; + type= _type; + strike=_strike; + s1=_s1; + s2=_s2; + q1=_q1; + q2=_q2; + r = _r; + t = _t; // years + v1=_v1; + v2=_v2; + rho=_rho; + result= _result; + tol = _tol; + } + + public BasketType basketType; + public Option.Type type; + public double strike; + public double s1; + public double s2; + public double q1; + public double q2; + public double r; + public double t; // years + public double v1; + public double v2; + public double rho; + public double result; + public double tol; }; public BasketPayoff basketTypeToPayoff(BasketType basketType,Payoff p) { @@ -75,28 +81,28 @@ public BasketPayoff basketTypeToPayoff(BasketType basketType,Payoff p) case BasketType.SpreadBasket: return new SpreadBasketPayoff(p); } - Utils.QL_FAIL("unknown basket option type"); - return null; - } + Utils.QL_FAIL("unknown basket option type"); + return null; + } public string basketTypeToString(BasketType basketType) { - switch (basketType) - { + switch (basketType) + { case BasketType.MinBasket: - return "MinBasket"; + return "MinBasket"; case BasketType.MaxBasket: - return "MaxBasket"; + return "MaxBasket"; case BasketType.SpreadBasket: return "Spread"; } - Utils.QL_FAIL("unknown basket option type"); - return String.Empty; - } + Utils.QL_FAIL("unknown basket option type"); + return String.Empty; + } public void REPORT_FAILURE_2(String greekName, BasketType basketType, PlainVanillaPayoff payoff, Exercise exercise, double s1, double s2, double q1, double q2, double r, Date today, double v1, double v2, double rho, double expected, double calculated, double error, double tolerance) { - Assert.Fail( Utilities.exerciseTypeToString(exercise) + " " + QAssert.Fail( Utilities.exerciseTypeToString(exercise) + " " + payoff.optionType() + " option on " + basketTypeToString(basketType) + " with " + Utilities.payoffTypeToString(payoff) + " payoff:\n" @@ -114,11 +120,15 @@ public void REPORT_FAILURE_2(String greekName, BasketType basketType, PlainVanil + " expected " + greekName + ": " + expected + "\n" + " calculated " + greekName + ": " + calculated + "\n" + " error: " + error + "\n" - + " tolerance: " + tolerance); - + + " tolerance: " + tolerance); + } - [TestMethod()] +#if QL_DOTNET_FRAMEWORK + [TestMethod()] +#else + [Fact] +#endif public void testEuroTwoValues() { // Testing two-asset European basket options... @@ -205,7 +215,7 @@ European two asset max basket options new BasketOptionTwoData(BasketType.SpreadBasket, Option.Type.Call, 3.0, 122.0, 120.0, 0.0, 0.0, 0.10, 0.5, 0.20, 0.25, 0.5, 6.9284, 1.0e-3) }; - DayCounter dc = new Actual360(); + DayCounter dc = new Actual360(); Date today = Date.Today; @@ -216,8 +226,8 @@ European two asset max basket options SimpleQuote qRate1 = new SimpleQuote(0.0); YieldTermStructure qTS1 = Utilities.flatRate(today, qRate1, dc); SimpleQuote qRate2 = new SimpleQuote(0.0); - YieldTermStructure qTS2 = Utilities.flatRate(today, qRate2, dc); - + YieldTermStructure qTS2 = Utilities.flatRate(today, qRate2, dc); + SimpleQuote rRate = new SimpleQuote(0.0); YieldTermStructure rTS = Utilities.flatRate(today, rRate, dc); @@ -276,13 +286,13 @@ European two asset max basket options break; default: - Utils.QL_FAIL("unknown basket type"); - break; - } - - - List procs = new List {p1, p2}; - + Utils.QL_FAIL("unknown basket type"); + break; + } + + + List procs = new List {p1, p2}; + Matrix correlationMatrix = new Matrix(2,2, values[i].rho); for (int j=0; j < 2; j++) { @@ -294,8 +304,8 @@ European two asset max basket options //IPricingEngine mcEngine = MakeMCEuropeanBasketEngine(process) // .withStepsPerYear(1) // .withSamples(10000) - // .withSeed(42); - + // .withSeed(42); + //IPricingEngine fdEngine = new Fd2dBlackScholesVanillaEngine(p1, p2, values[i].rho, 50, 50, 15); @@ -343,6 +353,6 @@ European two asset max basket options // mcRelativeErrorTolerance); //} } - } - } -} + } + } +} diff --git a/Test/T_Bermudanswaption.cs b/Test/T_Bermudanswaption.cs index 66013d1a5..f47267d11 100644 --- a/Test/T_Bermudanswaption.cs +++ b/Test/T_Bermudanswaption.cs @@ -18,15 +18,46 @@ under the terms of the QLNet license. You should have received a */ using System; -using System.Collections.Generic; -using Microsoft.VisualStudio.TestTools.UnitTesting; +using System.Collections.Generic; +#if QL_DOTNET_FRAMEWORK +using Microsoft.VisualStudio.TestTools.UnitTesting; +#else + using Xunit; +#endif using QLNet; namespace TestSuite -{ - [TestClass()] - public class T_Bermudanswaption +{ +#if QL_DOTNET_FRAMEWORK + [TestClass()] +#endif + public class T_Bermudanswaption : IDisposable { + #region Initialize&Cleanup + private SavedSettings backup; + #if QL_DOTNET_FRAMEWORK + [TestInitialize] + public void testInitialize() + { + #else + public T_Bermudanswaption() + { + #endif + backup = new SavedSettings(); + } + #if QL_DOTNET_FRAMEWORK + [TestCleanup] + #endif + public void testCleanup() + { + Dispose(); + } + public void Dispose() + { + backup.Dispose(); + } + #endregion + public class CommonVars { // global data @@ -45,9 +76,6 @@ public class CommonVars public RelinkableHandle termStructure; - // cleanup - public SavedSettings backup; - // setup public CommonVars() { @@ -96,9 +124,13 @@ public VanillaSwap makeSwap(double fixedRate) swap.setPricingEngine((IPricingEngine)(new DiscountingSwapEngine(termStructure))); return swap; } - } - - [TestMethod()] + } + +#if QL_DOTNET_FRAMEWORK + [TestMethod()] +#else + [Fact] +#endif public void testCachedValues() { //("Testing Bermudan swaption against cached values..."); @@ -145,21 +177,21 @@ public void testCachedValues() { Swaption swaption = new Swaption(itmSwap, exercise); swaption.setPricingEngine(engine); if (Math.Abs(swaption.NPV()-itmValue) > tolerance) - Assert.Fail("failed to reproduce cached in-the-money swaption value:\n" + QAssert.Fail("failed to reproduce cached in-the-money swaption value:\n" + "calculated: " + swaption.NPV() + "\n" + "expected: " + itmValue); swaption = new Swaption(atmSwap, exercise); swaption.setPricingEngine(engine); if (Math.Abs(swaption.NPV()-atmValue) > tolerance) - Assert.Fail("failed to reproduce cached at-the-money swaption value:\n" + QAssert.Fail("failed to reproduce cached at-the-money swaption value:\n" + "calculated: " + swaption.NPV() + "\n" + "expected: " + atmValue); swaption = new Swaption(otmSwap, exercise); swaption.setPricingEngine(engine); if (Math.Abs(swaption.NPV()-otmValue) > tolerance) - Assert.Fail("failed to reproduce cached out-of-the-money " + QAssert.Fail("failed to reproduce cached out-of-the-money " + "swaption value:\n" + "calculated: " + swaption.NPV() + "\n" + "expected: " + otmValue); @@ -177,21 +209,21 @@ public void testCachedValues() { swaption = new Swaption(itmSwap, exercise); swaption.setPricingEngine(engine); if (Math.Abs(swaption.NPV()-itmValue) > tolerance) - Assert.Fail("failed to reproduce cached in-the-money swaption value:\n" + QAssert.Fail("failed to reproduce cached in-the-money swaption value:\n" + "calculated: " + swaption.NPV() + "\n" + "expected: " + itmValue); swaption = new Swaption(atmSwap, exercise); swaption.setPricingEngine(engine); if (Math.Abs(swaption.NPV()-atmValue) > tolerance) - Assert.Fail("failed to reproduce cached at-the-money swaption value:\n" + QAssert.Fail("failed to reproduce cached at-the-money swaption value:\n" + "calculated: " + swaption.NPV() + "\n" + "expected: " + atmValue); swaption = new Swaption(otmSwap, exercise); swaption.setPricingEngine(engine); if (Math.Abs(swaption.NPV()-otmValue) > tolerance) - Assert.Fail("failed to reproduce cached out-of-the-money " + QAssert.Fail("failed to reproduce cached out-of-the-money " + "swaption value:\n" + "calculated: " + swaption.NPV() + "\n" + "expected: " + otmValue); diff --git a/Test/T_BlackFormula.cs b/Test/T_BlackFormula.cs index 0a27dca5b..577132b11 100644 --- a/Test/T_BlackFormula.cs +++ b/Test/T_BlackFormula.cs @@ -16,16 +16,26 @@ under the terms of the QLNet license. You should have received a ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the license for more details. */ -using System; -using Microsoft.VisualStudio.TestTools.UnitTesting; +using System; +#if QL_DOTNET_FRAMEWORK +using Microsoft.VisualStudio.TestTools.UnitTesting; +#else + using Xunit; +#endif using QLNet; namespace TestSuite -{ - [TestClass()] +{ +#if QL_DOTNET_FRAMEWORK + [TestClass()] +#endif public class T_BlackFormula - { - [TestMethod()] + { +#if QL_DOTNET_FRAMEWORK + [TestMethod()] +#else + [Fact] +#endif public void testBachelierImpliedVol() { // Testing Bachelier implied vol... @@ -46,7 +56,7 @@ public void testBachelierImpliedVol() if (Math.Abs(bpvol-impliedBpVol)>1.0e-12) { - Assert.Fail("Failed, expected " + bpvol + " realised " + impliedBpVol ); + QAssert.Fail("Failed, expected " + bpvol + " realised " + impliedBpVol ); } } return; diff --git a/Test/T_Bonds.cs b/Test/T_Bonds.cs index 9de438ec5..18bb16af6 100644 --- a/Test/T_Bonds.cs +++ b/Test/T_Bonds.cs @@ -20,14 +20,45 @@ under the terms of the QLNet license. You should have received a using System; using System.Collections.Generic; +#if QL_DOTNET_FRAMEWORK using Microsoft.VisualStudio.TestTools.UnitTesting; +#else + using Xunit; +#endif using QLNet; namespace TestSuite { +#if QL_DOTNET_FRAMEWORK [TestClass()] - public class T_Bonds +#endif + public class T_Bonds : IDisposable { + #region Initialize&Cleanup + private SavedSettings backup; + #if QL_DOTNET_FRAMEWORK + [TestInitialize] + public void testInitialize() + { + #else + public T_Bonds() + { + #endif + backup = new SavedSettings(); + } + #if QL_DOTNET_FRAMEWORK + [TestCleanup] + #endif + public void testCleanup() + { + Dispose(); + } + public void Dispose() + { + backup.Dispose(); + } + #endregion + class CommonVars { // common data @@ -35,10 +66,6 @@ class CommonVars public Date today; public double faceAmount; - // todo - // cleanup - // SavedSettings backup; - // setup public CommonVars() { @@ -49,7 +76,11 @@ public CommonVars() } } - [TestMethod()] +#if QL_DOTNET_FRAMEWORK + [TestMethod()] +#else + [Fact] +#endif public void testYield() { @@ -109,7 +140,7 @@ public void testYield() double price2 = bond.cleanPrice(calculated, bondDayCount, compounding[n], frequencies[l]); if (Math.Abs(price - price2) / price > tolerance) { - Assert.Fail("yield recalculation failed:\n" + QAssert.Fail("yield recalculation failed:\n" + " issue: " + issue + "\n" + " maturity: " + maturity + "\n" + " coupon: " + coupons[k] + "\n" @@ -128,7 +159,11 @@ public void testYield() } } } - [TestMethod()] +#if QL_DOTNET_FRAMEWORK + [TestMethod()] +#else + [Fact] +#endif public void testTheoretical() { // "Testing theoretical bond price/yield calculation..."); @@ -182,7 +217,7 @@ public void testTheoretical() if (Math.Abs(price - calculatedPrice) > tolerance) { - Assert.Fail("price calculation failed:" + QAssert.Fail("price calculation failed:" + "\n issue: " + issue + "\n maturity: " + maturity + "\n coupon: " + coupons[k] @@ -197,7 +232,7 @@ public void testTheoretical() tolerance, maxEvaluations); if (Math.Abs(yields[m] - calculatedYield) > tolerance) { - Assert.Fail("yield calculation failed:" + QAssert.Fail("yield calculation failed:" + "\n issue: " + issue + "\n maturity: " + maturity + "\n coupon: " + coupons[k] @@ -211,7 +246,11 @@ public void testTheoretical() } } } - [TestMethod()] +#if QL_DOTNET_FRAMEWORK + [TestMethod()] +#else + [Fact] +#endif public void testCached() { // ("Testing bond price/yield calculation against cached values..."); @@ -270,7 +309,7 @@ public void testCached() price = bond1.cleanPrice(marketYield1, bondDayCount, Compounding.Compounded, freq); if (Math.Abs(price - cachedPrice1a) > tolerance) { - Assert.Fail("failed to reproduce cached price:" + QAssert.Fail("failed to reproduce cached price:" + "\n calculated: " + price + "\n expected: " + cachedPrice1a + "\n tolerance: " + tolerance @@ -280,7 +319,7 @@ public void testCached() price = bond1.cleanPrice(); if (Math.Abs(price - cachedPrice1b) > tolerance) { - Assert.Fail("failed to reproduce cached price:" + QAssert.Fail("failed to reproduce cached price:" + "\n calculated: " + price + "\n expected: " + cachedPrice1b + "\n tolerance: " + tolerance @@ -290,7 +329,7 @@ public void testCached() yield = bond1.yield(marketPrice1, bondDayCount, Compounding.Compounded, freq); if (Math.Abs(yield - cachedYield1a) > tolerance) { - Assert.Fail("failed to reproduce cached compounded yield:" + QAssert.Fail("failed to reproduce cached compounded yield:" + "\n calculated: " + yield + "\n expected: " + cachedYield1a + "\n tolerance: " + tolerance @@ -300,7 +339,7 @@ public void testCached() yield = bond1.yield(marketPrice1, bondDayCount, Compounding.Continuous, freq); if (Math.Abs(yield - cachedYield1b) > tolerance) { - Assert.Fail("failed to reproduce cached continuous yield:" + QAssert.Fail("failed to reproduce cached continuous yield:" + "\n calculated: " + yield + "\n expected: " + cachedYield1b + "\n tolerance: " + tolerance @@ -310,7 +349,7 @@ public void testCached() yield = bond1.yield(bondDayCount, Compounding.Continuous, freq); if (Math.Abs(yield - cachedYield1c) > tolerance) { - Assert.Fail("failed to reproduce cached continuous yield:" + QAssert.Fail("failed to reproduce cached continuous yield:" + "\n calculated: " + yield + "\n expected: " + cachedYield1c + "\n tolerance: " + tolerance @@ -321,7 +360,7 @@ public void testCached() price = bond2.cleanPrice(marketYield2, bondDayCount, Compounding.Compounded, freq); if (Math.Abs(price - cachedPrice2a) > tolerance) { - Assert.Fail("failed to reproduce cached price:" + QAssert.Fail("failed to reproduce cached price:" + "\n calculated: " + price + "\n expected: " + cachedPrice2a + "\n tolerance: " + tolerance @@ -331,7 +370,7 @@ public void testCached() price = bond2.cleanPrice(); if (Math.Abs(price - cachedPrice2b) > tolerance) { - Assert.Fail("failed to reproduce cached price:" + QAssert.Fail("failed to reproduce cached price:" + "\n calculated: " + price + "\n expected: " + cachedPrice2b + "\n tolerance: " + tolerance @@ -341,7 +380,7 @@ public void testCached() yield = bond2.yield(marketPrice2, bondDayCount, Compounding.Compounded, freq); if (Math.Abs(yield - cachedYield2a) > tolerance) { - Assert.Fail("failed to reproduce cached compounded yield:" + QAssert.Fail("failed to reproduce cached compounded yield:" + "\n calculated: " + yield + "\n expected: " + cachedYield2a + "\n tolerance: " + tolerance @@ -351,7 +390,7 @@ public void testCached() yield = bond2.yield(marketPrice2, bondDayCount, Compounding.Continuous, freq); if (Math.Abs(yield - cachedYield2b) > tolerance) { - Assert.Fail("failed to reproduce cached continuous yield:" + QAssert.Fail("failed to reproduce cached continuous yield:" + "\n calculated: " + yield + "\n expected: " + cachedYield2b + "\n tolerance: " + tolerance @@ -361,7 +400,7 @@ public void testCached() yield = bond2.yield(bondDayCount, Compounding.Continuous, freq); if (Math.Abs(yield - cachedYield2c) > tolerance) { - Assert.Fail("failed to reproduce cached continuous yield:" + QAssert.Fail("failed to reproduce cached continuous yield:" + "\n calculated: " + yield + "\n expected: " + cachedYield2c + "\n tolerance: " + tolerance @@ -387,7 +426,7 @@ public void testCached() price = bond3.cleanPrice(marketYield3, bondDayCount, Compounding.Compounded, freq, settlementDate); if (Math.Abs(price - cachedPrice3) > tolerance) { - Assert.Fail("failed to reproduce cached price:" + QAssert.Fail("failed to reproduce cached price:" + "\n calculated: " + price + "" + "\n expected: " + cachedPrice3 + "" + "\n error: " + (price - cachedPrice3)); @@ -400,16 +439,20 @@ public void testCached() price = bond3.cleanPrice(marketYield3, bondDayCount, Compounding.Compounded, freq); if (Math.Abs(price - cachedPrice3) > tolerance) { - Assert.Fail("failed to reproduce cached price:" + QAssert.Fail("failed to reproduce cached price:" + "\n calculated: " + price + "" + "\n expected: " + cachedPrice3 + "" + "\n error: " + (price - cachedPrice3)); } } - [TestMethod()] +#if QL_DOTNET_FRAMEWORK + [TestMethod()] +#else + [Fact] +#endif public void testCachedZero() { - Console.WriteLine("Testing zero-coupon bond prices against cached values..."); + // Testing zero-coupon bond prices against cached values CommonVars vars = new CommonVars(); @@ -435,7 +478,7 @@ public void testCachedZero() double price = bond1.cleanPrice(); if (Math.Abs(price - cachedPrice1) > tolerance) { - Console.WriteLine("failed to reproduce cached price:\n" + QAssert.Fail("failed to reproduce cached price:\n" + " calculated: " + price + "\n" + " expected: " + cachedPrice1 + "\n" + " error: " + (price - cachedPrice1)); @@ -452,7 +495,7 @@ public void testCachedZero() price = bond2.cleanPrice(); if (Math.Abs(price - cachedPrice2) > tolerance) { - Console.WriteLine("failed to reproduce cached price:\n" + QAssert.Fail("failed to reproduce cached price:\n" + " calculated: " + price + "\n" + " expected: " + cachedPrice2 + "\n" + " error: " + (price - cachedPrice2)); @@ -469,13 +512,17 @@ public void testCachedZero() price = bond3.cleanPrice(); if (Math.Abs(price - cachedPrice3) > tolerance) { - Console.WriteLine("failed to reproduce cached price:\n" + QAssert.Fail("failed to reproduce cached price:\n" + " calculated: " + price + "\n" + " expected: " + cachedPrice3 + "\n" + " error: " + (price - cachedPrice3)); } } - [TestMethod()] +#if QL_DOTNET_FRAMEWORK + [TestMethod()] +#else + [Fact] +#endif public void testCachedFixed() { // "Testing fixed-coupon bond prices against cached values..."); @@ -509,7 +556,7 @@ public void testCachedFixed() double price = bond1.cleanPrice(); if (Math.Abs(price - cachedPrice1) > tolerance) { - Console.WriteLine("failed to reproduce cached price:\n" + QAssert.Fail("failed to reproduce cached price:\n" + " calculated: " + price + "\n" + " expected: " + cachedPrice1 + "\n" + " error: " + (price - cachedPrice1)); @@ -534,7 +581,7 @@ public void testCachedFixed() price = bond2.cleanPrice(); if (Math.Abs(price - cachedPrice2) > tolerance) { - Console.WriteLine("failed to reproduce cached price:\n" + QAssert.Fail("failed to reproduce cached price:\n" + " calculated: " + price + "\n" + " expected: " + cachedPrice2 + "\n" + " error: " + (price - cachedPrice2)); @@ -559,13 +606,17 @@ public void testCachedFixed() price = bond3.cleanPrice(); if (Math.Abs(price - cachedPrice3) > tolerance) { - Assert.Fail("failed to reproduce cached price:\n" + QAssert.Fail("failed to reproduce cached price:\n" + " calculated: " + price + "\n" + " expected: " + cachedPrice3 + "\n" + " error: " + (price - cachedPrice3)); } } - [TestMethod()] +#if QL_DOTNET_FRAMEWORK + [TestMethod()] +#else + [Fact] +#endif public void testCachedFloating() { // "Testing floating-rate bond prices against cached values..."); @@ -616,7 +667,7 @@ public void testCachedFloating() double price = bond1.cleanPrice(); if (Math.Abs(price - cachedPrice1) > tolerance) { - Assert.Fail("failed to reproduce cached price:\n" + QAssert.Fail("failed to reproduce cached price:\n" + " calculated: " + price + "\n" + " expected: " + cachedPrice1 + "\n" + " error: " + (price - cachedPrice1)); @@ -645,7 +696,7 @@ public void testCachedFloating() price = bond2.cleanPrice(); if (Math.Abs(price - cachedPrice2) > tolerance) { - Assert.Fail("failed to reproduce cached price:\n" + QAssert.Fail("failed to reproduce cached price:\n" + " calculated: " + price + "\n" + " expected: " + cachedPrice2 + "\n" + " error: " + (price - cachedPrice2)); @@ -679,13 +730,17 @@ public void testCachedFloating() price = bond3.cleanPrice(); if (Math.Abs(price - cachedPrice3) > tolerance) { - Assert.Fail("failed to reproduce cached price:\n" + QAssert.Fail("failed to reproduce cached price:\n" + " calculated: " + price + "\n" + " expected: " + cachedPrice3 + "\n" + " error: " + (price - cachedPrice3)); } } - [TestMethod()] +#if QL_DOTNET_FRAMEWORK + [TestMethod()] +#else + [Fact] +#endif public void testBrazilianCached() { //("Testing Brazilian public bond prices against cached values..."); @@ -766,7 +821,7 @@ public void testBrazilianCached() today) + bond.accruedAmount(today)) / 100; if (Math.Abs(price - cachedPrice) > tolerance) { - Assert.Fail("failed to reproduce cached price:\n" + QAssert.Fail("failed to reproduce cached price:\n" + " calculated: " + price + "\n" + " expected: " + cachedPrice + "\n" + " error: " + (price - cachedPrice) + "\n" @@ -775,7 +830,11 @@ public void testBrazilianCached() } } - [TestMethod()] +#if QL_DOTNET_FRAMEWORK + [TestMethod()] +#else + [Fact] +#endif public void testAmortizingFixedBond() { Date startDate = new Date(2, 1, 2007); @@ -800,25 +859,29 @@ public void testAmortizingFixedBond() 102255461,68340166,34255295,0 }; // test total cashflow count - Assert.AreEqual(bond.cashflows().Count, totCashflow, "Cashflow size different"); + QAssert.AreEqual(bond.cashflows().Count, totCashflow, "Cashflow size different"); // test notional cashflow count - Assert.AreEqual(bond.notionals().Count, totNotionals, "Notionals size different"); + QAssert.AreEqual(bond.notionals().Count, totNotionals, "Notionals size different"); // test notional amortization values for (int i = 0; i < totNotionals; i++) { - Assert.AreEqual(bond.notionals()[i], notionals[i], 1, "Notionals " + i + "is different"); + QAssert.AreEqual(bond.notionals()[i], notionals[i], 1, "Notionals " + i + "is different"); } // test PV difference double cash = bond.CASH(); - Assert.AreEqual(cash - amount, PVDifference, 0.1, "PV Difference wrong"); + QAssert.AreEqual(cash - amount, PVDifference, 0.1, "PV Difference wrong"); } - [TestMethod()] +#if QL_DOTNET_FRAMEWORK + [TestMethod()] +#else + [Fact] +#endif public void testMBSFixedBondCached() { // Test MBS Bond against cached values @@ -989,7 +1052,7 @@ public void testMBSFixedBondCached() if (c is QLNet.FixedRateCoupon) { FixedRateCoupon frc = c as FixedRateCoupon; - Assert.AreEqual(OutstandingBalance[i], frc.nominal(), 1, "Outstanding Balance " + i++ + "is different"); + QAssert.AreEqual(OutstandingBalance[i], frc.nominal(), 1, "Outstanding Balance " + i++ + "is different"); } } @@ -999,7 +1062,7 @@ public void testMBSFixedBondCached() { if (c is QLNet.VoluntaryPrepay) { - Assert.AreEqual(Prepayments[i], c.amount(), 1, "Prepayments " + i++ + "is different"); + QAssert.AreEqual(Prepayments[i], c.amount(), 1, "Prepayments " + i++ + "is different"); } } @@ -1010,7 +1073,7 @@ public void testMBSFixedBondCached() if (c is QLNet.FixedRateCoupon) { FixedRateCoupon frc = c as FixedRateCoupon; - Assert.AreEqual(NetInterest[i], frc.amount(), 1, "Net Interest " + i++ + "is different"); + QAssert.AreEqual(NetInterest[i], frc.amount(), 1, "Net Interest " + i++ + "is different"); } } @@ -1020,18 +1083,22 @@ public void testMBSFixedBondCached() { if (c is QLNet.AmortizingPayment) { - Assert.AreEqual(ScheduledPrincipal[i], c.amount(), 1, "Scheduled Principal " + i++ + "is different"); + QAssert.AreEqual(ScheduledPrincipal[i], c.amount(), 1, "Scheduled Principal " + i++ + "is different"); } } // Monthly Yield - Assert.AreEqual(0.00458333333333381, bond.MonthlyYield(), 0.000000001, "MonthlyYield is different"); + QAssert.AreEqual(0.00458333333333381, bond.MonthlyYield(), 0.000000001, "MonthlyYield is different"); // Bond Equivalent Yield - Assert.AreEqual(0.0556, bond.BondEquivalentYield(), 0.0001, " Bond Equivalent Yield is different"); + QAssert.AreEqual(0.0556, bond.BondEquivalentYield(), 0.0001, " Bond Equivalent Yield is different"); } - [TestMethod()] +#if QL_DOTNET_FRAMEWORK + [TestMethod()] +#else + [Fact] +#endif public void testAmortizingBond1() { // Input Values @@ -1050,19 +1117,23 @@ public void testAmortizingBond1() // Amortizing Yield ( Effective Rate ) double y1 = bond.Yield(); - Assert.AreEqual(-0.0236402, y1, 0.001, "Amortizing Yield is different"); + QAssert.AreEqual(-0.0236402, y1, 0.001, "Amortizing Yield is different"); // Amortized Cost at Date double Amort1 = bond.AmortizationValue(new Date(31, Month.August, 2004)); - Assert.AreEqual(41126.01, Amort1, 100, "Amortized Cost at 08/31/2004 is different"); + QAssert.AreEqual(41126.01, Amort1, 100, "Amortized Cost at 08/31/2004 is different"); double Amort2 = bond.AmortizationValue(new Date(30, Month.September, 2004)); - Assert.AreEqual(40842.83, Amort2, 100, "Amortized Cost at 09/30/2004 is different"); + QAssert.AreEqual(40842.83, Amort2, 100, "Amortized Cost at 09/30/2004 is different"); } - [TestMethod()] +#if QL_DOTNET_FRAMEWORK + [TestMethod()] +#else + [Fact] +#endif public void testAmortizingBond2() { // Par – 500,000 @@ -1090,19 +1161,23 @@ public void testAmortizingBond2() // Amortizing Yield ( Effective Rate ) double y1 = bond.Yield(); - Assert.AreEqual(0.0575649, y1, 0.001, "Amortizing Yield is different"); + QAssert.AreEqual(0.0575649, y1, 0.001, "Amortizing Yield is different"); // Amortized Cost at Date double Amort1 = bond.AmortizationValue(new Date(30, Month.November, 2012)); - Assert.AreEqual(475698.12, Amort1, 100, "Amortized Cost at 11/30/2012 is different"); + QAssert.AreEqual(475698.12, Amort1, 100, "Amortized Cost at 11/30/2012 is different"); double Amort2 = bond.AmortizationValue(new Date(30, Month.December, 2012)); - Assert.AreEqual(475779.55, Amort1, 100, "Amortized Cost at 12/30/2012 is different"); + QAssert.AreEqual(475779.55, Amort1, 100, "Amortized Cost at 12/30/2012 is different"); } - [TestMethod()] +#if QL_DOTNET_FRAMEWORK + [TestMethod()] +#else + [Fact] +#endif public void testAmortizingFixedRateBond() { // Testing amortizing fixed rate bond @@ -1143,7 +1218,7 @@ public void testAmortizingFixedRateBond() double error = Math.Abs(totalAmount - amounts[i]); if (error > tolerance) { - Assert.Fail(" Rate: " + rates[i] + + QAssert.Fail(" Rate: " + rates[i] + " " + k + "th cash flow " + " Failed!" + " Expected Amount: " + amounts[i] + @@ -1156,7 +1231,7 @@ public void testAmortizingFixedRateBond() if (error > tolerance) { - Assert.Fail(" Rate: " + rates[i] + + QAssert.Fail(" Rate: " + rates[i] + " " + k + "th cash flow " + " Failed!" + " Expected Coupon: " + expectedCoupon + @@ -1172,82 +1247,81 @@ public void testAmortizingFixedRateBond() /// This requires the use of the Schedule to be constructed /// with a custom date vector /// - [TestMethod()] +#if QL_DOTNET_FRAMEWORK + [TestMethod()] +#else + [Fact] +#endif public void testBondFromScheduleWithDateVector() { // Testing South African R2048 bond price using Schedule constructor with Date vector - using (SavedSettings backup = new SavedSettings()) + + //When pricing bond from Yield To Maturity, use NullCalendar() + Calendar calendar = new NullCalendar(); + + int settlementDays = 3; + + Date issueDate = new Date(29, Month.June, 2012); + Date today = new Date(7, Month.September, 2015); + Date evaluationDate = calendar.adjust(today); + Date settlementDate = calendar.advance(evaluationDate, new Period(settlementDays, TimeUnit.Days)); + Settings.setEvaluationDate(evaluationDate); + + // For the schedule to generate correctly for Feb-28's, make maturity date on Feb 29 + Date maturityDate = new Date(29, Month.February, 2048); + + double coupon = 0.0875; + Compounding comp = Compounding.Compounded; + Frequency freq = Frequency.Semiannual; + DayCounter dc = new ActualActual(ActualActual.Convention.Bond); + + // Yield as quoted in market + InterestRate yield = new InterestRate(0.09185, dc, comp, freq); + + Period tenor = new Period(6, TimeUnit.Months); + Period exCouponPeriod = new Period(10, TimeUnit.Days); + + // Generate coupon dates for 31 Aug and end of Feb each year + // For leap years, this will generate 29 Feb, but the bond + // actually pays coupons on 28 Feb, regardsless of whether + // it is a leap year or not. + Schedule schedule = new Schedule(issueDate, maturityDate, tenor, + new NullCalendar(), BusinessDayConvention.Unadjusted, BusinessDayConvention.Unadjusted, + DateGeneration.Rule.Backward, true); + + // Adjust the 29 Feb's to 28 Feb + List dates = new List(); + for (int i = 0; i < schedule.Count; ++i) { - //When pricing bond from Yield To Maturity, use NullCalendar() - Calendar calendar = new NullCalendar(); - - int settlementDays = 3; - - Date issueDate = new Date(29, Month.June, 2012); - Date today = new Date(7, Month.September, 2015); - Date evaluationDate = calendar.adjust(today); - Date settlementDate = calendar.advance(evaluationDate, new Period(settlementDays, TimeUnit.Days)); - Settings.setEvaluationDate(evaluationDate); - - // For the schedule to generate correctly for Feb-28's, make maturity date on Feb 29 - Date maturityDate = new Date(29, Month.February, 2048); - - double coupon = 0.0875; - Compounding comp = Compounding.Compounded; - Frequency freq = Frequency.Semiannual; - DayCounter dc = new ActualActual(ActualActual.Convention.Bond); - - // Yield as quoted in market - InterestRate yield = new InterestRate(0.09185, dc, comp, freq); - - Period tenor = new Period(6, TimeUnit.Months); - Period exCouponPeriod = new Period(10, TimeUnit.Days); - - // Generate coupon dates for 31 Aug and end of Feb each year - // For leap years, this will generate 29 Feb, but the bond - // actually pays coupons on 28 Feb, regardsless of whether - // it is a leap year or not. - Schedule schedule = new Schedule(issueDate, maturityDate, tenor, - new NullCalendar(), BusinessDayConvention.Unadjusted, BusinessDayConvention.Unadjusted, - DateGeneration.Rule.Backward, true); - - // Adjust the 29 Feb's to 28 Feb - List dates = new List(); - for (int i = 0; i < schedule.Count; ++i) - { - Date d = schedule.date(i); - if (d.Month == 2 && d.Day == 29) - dates.Add(new Date(28, Month.February, d.Year)); - else - dates.Add(d); - } + Date d = schedule.date(i); + if (d.Month == 2 && d.Day == 29) + dates.Add(new Date(28, Month.February, d.Year)); + else + dates.Add(d); + } - schedule = new Schedule(dates, - schedule.calendar(), - schedule.businessDayConvention(), - schedule.terminationDateBusinessDayConvention(), - schedule.tenor(), - schedule.rule(), - schedule.endOfMonth(), - schedule.isRegular()); - - FixedRateBond bond = new FixedRateBond( - 0, - 100.0, - schedule, - new List() { coupon }, - dc, BusinessDayConvention.Following, 100.0, - issueDate, calendar, - exCouponPeriod, calendar, BusinessDayConvention.Unadjusted, false); - - double calculatedPrice = BondFunctions.dirtyPrice(bond, yield, settlementDate); - double expectedPrice = 95.75706; - double tolerance = 1e-5; - if (Math.Abs(calculatedPrice - expectedPrice) > tolerance) - { - Assert.Fail(string.Format("failed to reproduce R2048 dirty price\nexpected: {0}\ncalculated: {1}", expectedPrice, calculatedPrice)); - } + schedule = new Schedule(dates, + schedule.calendar(), + schedule.businessDayConvention(), + schedule.terminationDateBusinessDayConvention(), + schedule.tenor(), + schedule.rule(), + schedule.endOfMonth(), + schedule.isRegular()); + + FixedRateBond bond = new FixedRateBond(0,100.0,schedule,new List() {coupon},dc, + BusinessDayConvention.Following, 100.0,issueDate, calendar,exCouponPeriod, calendar, + BusinessDayConvention.Unadjusted, false); + + double calculatedPrice = BondFunctions.dirtyPrice(bond, yield, settlementDate); + double expectedPrice = 95.75706; + double tolerance = 1e-5; + if (Math.Abs(calculatedPrice - expectedPrice) > tolerance) + { + QAssert.Fail(string.Format("failed to reproduce R2048 dirty price\nexpected: {0}\ncalculated: {1}", + expectedPrice, calculatedPrice)); } } } + } diff --git a/Test/T_BusinessDayConvention.cs b/Test/T_BusinessDayConvention.cs index 70025b0e4..a9e13a5b4 100644 --- a/Test/T_BusinessDayConvention.cs +++ b/Test/T_BusinessDayConvention.cs @@ -15,17 +15,23 @@ under the terms of the QLNet license. You should have received a This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the license for more details. -*/ -using Microsoft.VisualStudio.TestTools.UnitTesting; -using QLNet; - -namespace TestSuite -{ - [TestClass()] - public class T_BusinessDayConvention - { +*/ +#if QL_DOTNET_FRAMEWORK +using Microsoft.VisualStudio.TestTools.UnitTesting; +#else + using Xunit; +#endif +using QLNet; + +namespace TestSuite +{ +#if QL_DOTNET_FRAMEWORK + [TestClass()] +#endif + public class T_BusinessDayConvention + { struct SingleCase - { + { public SingleCase( Calendar calendar_, BusinessDayConvention convention_, Date start_, @@ -40,15 +46,19 @@ public SingleCase( Calendar calendar_, endOfMonth = endOfMonth_; result = result_; } - public Calendar calendar; - public BusinessDayConvention convention; - public Date start; - public Period period; - public bool endOfMonth; + public Calendar calendar; + public BusinessDayConvention convention; + public Date start; + public Period period; + public bool endOfMonth; public Date result; - } - - [TestMethod()] + } + +#if QL_DOTNET_FRAMEWORK + [TestMethod()] +#else + [Fact] +#endif public void testConventions() { // Testing business day conventions... @@ -111,7 +121,7 @@ public void testConventions() Calendar calendar = new Calendar(testCases[i].calendar); Date result = calendar.advance( testCases[i].start, testCases[i].period, testCases[i].convention, testCases[i].endOfMonth); - Assert.IsTrue( result == testCases[i].result, + QAssert.IsTrue( result == testCases[i].result, "\ncase " + i + ":\n" //<< j << " ("<< desc << "): " + "start date: " + testCases[i].start + "\n" + "calendar: " + calendar + "\n" @@ -120,6 +130,6 @@ public void testConventions() + "expected: " + testCases[i].result + " vs. actual: " + result); } - } - } -} + } + } +} diff --git a/Test/T_Calendars.cs b/Test/T_Calendars.cs index 26e65ab5a..327fdc6a4 100644 --- a/Test/T_Calendars.cs +++ b/Test/T_Calendars.cs @@ -19,53 +19,67 @@ under the terms of the QLNet license. You should have received a */ using System; -using System.Collections.Generic; -using Microsoft.VisualStudio.TestTools.UnitTesting; +using System.Collections.Generic; +#if QL_DOTNET_FRAMEWORK +using Microsoft.VisualStudio.TestTools.UnitTesting; +#else + using Xunit; +#endif using QLNet; using System.Diagnostics; -namespace TestSuite { - [TestClass()] - public class T_Calendars { - [TestMethod()] +namespace TestSuite { +#if QL_DOTNET_FRAMEWORK + [TestClass()] +#endif + public class T_Calendars { +#if QL_DOTNET_FRAMEWORK + [TestMethod()] +#else + [Fact] +#endif public void testModifiedCalendars() { Calendar c1 = new TARGET(); Calendar c2 = new UnitedStates(UnitedStates.Market.NYSE); Date d1 = new Date(1, Month.May, 2004); // holiday for both calendars Date d2 = new Date(26, Month.April, 2004); // business day - Assert.IsTrue(c1.isHoliday(d1), "wrong assumption---correct the test"); - Assert.IsTrue(c1.isBusinessDay(d2), "wrong assumption---correct the test"); + QAssert.IsTrue(c1.isHoliday(d1), "wrong assumption---correct the test"); + QAssert.IsTrue(c1.isBusinessDay(d2), "wrong assumption---correct the test"); - Assert.IsTrue(c2.isHoliday(d1), "wrong assumption---correct the test"); - Assert.IsTrue(c2.isBusinessDay(d2), "wrong assumption---correct the test"); + QAssert.IsTrue(c2.isHoliday(d1), "wrong assumption---correct the test"); + QAssert.IsTrue(c2.isBusinessDay(d2), "wrong assumption---correct the test"); // modify the TARGET calendar c1.removeHoliday(d1); c1.addHoliday(d2); // test - Assert.IsFalse(c1.isHoliday(d1), d1 + " still a holiday for original TARGET instance"); - Assert.IsFalse(c1.isBusinessDay(d2), d2 + " still a business day for original TARGET instance"); + QAssert.IsFalse(c1.isHoliday(d1), d1 + " still a holiday for original TARGET instance"); + QAssert.IsFalse(c1.isBusinessDay(d2), d2 + " still a business day for original TARGET instance"); // any instance of TARGET should be modified... Calendar c3 = new TARGET(); - Assert.IsFalse(c3.isHoliday(d1), d1 + " still a holiday for generic TARGET instance"); - Assert.IsFalse(c3.isBusinessDay(d2), d2 + " still a business day for generic TARGET instance"); + QAssert.IsFalse(c3.isHoliday(d1), d1 + " still a holiday for generic TARGET instance"); + QAssert.IsFalse(c3.isBusinessDay(d2), d2 + " still a business day for generic TARGET instance"); // ...but not other calendars - Assert.IsFalse(c2.isBusinessDay(d1), d1 + " business day for New York"); - Assert.IsFalse(c2.isHoliday(d2), d2 + " holiday for New York"); + QAssert.IsFalse(c2.isBusinessDay(d1), d1 + " business day for New York"); + QAssert.IsFalse(c2.isHoliday(d2), d2 + " holiday for New York"); // restore original holiday set---test the other way around c3.addHoliday(d1); c3.removeHoliday(d2); - Assert.IsFalse(c1.isBusinessDay(d1), d1 + " still a business day"); - Assert.IsFalse(c1.isHoliday(d2), d2 + " still a holiday"); - } - - [TestMethod()] + QAssert.IsFalse(c1.isBusinessDay(d1), d1 + " still a business day"); + QAssert.IsFalse(c1.isHoliday(d2), d2 + " still a holiday"); + } + +#if QL_DOTNET_FRAMEWORK + [TestMethod()] +#else + [Fact] +#endif public void testJointCalendars() { Calendar c1 = new TARGET(), c2 = new UnitedKingdom(), @@ -91,47 +105,51 @@ public void testJointCalendars() { b4 = c4.isBusinessDay(d); if ((b1 && b2) != c12h.isBusinessDay(d)) - Assert.Fail("At date " + d + ":\n" + QAssert.Fail("At date " + d + ":\n" + " inconsistency between joint calendar " + c12h.name() + " (joining holidays)\n" + " and its components"); if ((b1 || b2) != c12b.isBusinessDay(d)) - Assert.Fail("At date " + d + ":\n" + QAssert.Fail("At date " + d + ":\n" + " inconsistency between joint calendar " + c12b.name() + " (joining business days)\n" + " and its components"); if ((b1 && b2 && b3) != c123h.isBusinessDay(d)) - Assert.Fail("At date " + d + ":\n" + QAssert.Fail("At date " + d + ":\n" + " inconsistency between joint calendar " + c123h.name() + " (joining holidays)\n" + " and its components"); if ((b1 || b2 || b3) != c123b.isBusinessDay(d)) - Assert.Fail("At date " + d + ":\n" + QAssert.Fail("At date " + d + ":\n" + " inconsistency between joint calendar " + c123b.name() + " (joining business days)\n" + " and its components"); if ((b1 && b2 && b3 && b4) != c1234h.isBusinessDay(d)) - Assert.Fail("At date " + d + ":\n" + QAssert.Fail("At date " + d + ":\n" + " inconsistency between joint calendar " + c1234h.name() + " (joining holidays)\n" + " and its components"); if ((b1 || b2 || b3 || b4) != c1234b.isBusinessDay(d)) - Assert.Fail("At date " + d + ":\n" + QAssert.Fail("At date " + d + ":\n" + " inconsistency between joint calendar " + c1234b.name() + " (joining business days)\n" + " and its components"); } - } - - [TestMethod()] + } + +#if QL_DOTNET_FRAMEWORK + [TestMethod()] +#else + [Fact] +#endif public void testUSSettlement() { - Debug.Print("Testing US settlement holiday list..."); + // Testing US settlement holiday list List expectedHol = new List(); expectedHol.Add(new Date(1, Month.January, 2004)); @@ -162,16 +180,20 @@ public void testUSSettlement() { for (int i = 0; i < Math.Min(hol.Count, expectedHol.Count); i++) { if (hol[i] != expectedHol[i]) - Assert.Fail("expected holiday was " + expectedHol[i] + " while calculated holiday is " + hol[i]); + QAssert.Fail("expected holiday was " + expectedHol[i] + " while calculated holiday is " + hol[i]); } if (hol.Count != expectedHol.Count) - Assert.Fail("there were " + expectedHol.Count + + QAssert.Fail("there were " + expectedHol.Count + " expected holidays, while there are " + hol.Count + " calculated holidays"); - } - - [TestMethod()] + } + +#if QL_DOTNET_FRAMEWORK + [TestMethod()] +#else + [Fact] +#endif public void testUSGovernmentBondMarket() { List expectedHol = new List(); @@ -192,15 +214,19 @@ public void testUSGovernmentBondMarket() { for (int i = 0; i < Math.Min(hol.Count, expectedHol.Count); i++) { if (hol[i] != expectedHol[i]) - Assert.Fail("expected holiday was " + expectedHol[i] + " while calculated holiday is " + hol[i]); + QAssert.Fail("expected holiday was " + expectedHol[i] + " while calculated holiday is " + hol[i]); } if (hol.Count != expectedHol.Count) - Assert.Fail("there were " + expectedHol.Count + + QAssert.Fail("there were " + expectedHol.Count + " expected holidays, while there are " + hol.Count + " calculated holidays"); - } - - [TestMethod()] + } + +#if QL_DOTNET_FRAMEWORK + [TestMethod()] +#else + [Fact] +#endif public void testUSNewYorkStockExchange() { List expectedHol = new List(); @@ -240,10 +266,10 @@ public void testUSNewYorkStockExchange() { int i; for (i = 0; i < Math.Min(hol.Count, expectedHol.Count); i++) { if (hol[i] != expectedHol[i]) - Assert.Fail("expected holiday was " + expectedHol[i] + " while calculated holiday is " + hol[i]); + QAssert.Fail("expected holiday was " + expectedHol[i] + " while calculated holiday is " + hol[i]); } if (hol.Count != expectedHol.Count) - Assert.Fail("there were " + expectedHol.Count + + QAssert.Fail("there were " + expectedHol.Count + " expected holidays, while there are " + hol.Count + " calculated holidays"); @@ -293,12 +319,16 @@ public void testUSNewYorkStockExchange() { for (i = 0; i < histClose.Count; i++) { if (!c.isHoliday(histClose[i])) - Assert.Fail(histClose[i] + " should be holiday (historical close)"); + QAssert.Fail(histClose[i] + " should be holiday (historical close)"); } - } - - [TestMethod()] + } + +#if QL_DOTNET_FRAMEWORK + [TestMethod()] +#else + [Fact] +#endif public void testTARGET() { List expectedHol = new List(); expectedHol.Add(new Date(1,Month.January,1999)); @@ -351,17 +381,21 @@ public void testTARGET() { for (int i=0; i expectedHol = new List(); @@ -384,16 +418,20 @@ public void testGermanyFrankfurt() { List hol = Calendar.holidayList(c, new Date(1,Month.January,2003), new Date(31,Month.December,2004)); for (int i=0; i expectedHol = new List(); @@ -417,16 +455,20 @@ public void testGermanyEurex() { new Date(31,Month.December,2004)); for (int i=0; i expectedHol = new List(); @@ -449,15 +491,19 @@ public void testGermanyXetra() { List hol = Calendar.holidayList(c, new Date(1,Month.January,2003), new Date(31,Month.December,2004)); for (int i=0; i hol = Calendar.holidayList(c, new Date(1,Month.January,2004), new Date(31,Month.December,2007)); for (int i=0; i hol = Calendar.holidayList(c, new Date(1,Month.January,2004), new Date(31,Month.December,2007)); for (int i=0; i hol = Calendar.holidayList(c, new Date(1,Month.January,2004), new Date(31,Month.December,2007)); for (int i=0; i hol = Calendar.holidayList(c, new Date(1,Month.January,2002), new Date(31,Month.December,2004)); for (int i=0; i hol = Calendar.holidayList(c, new Date(1,Month.January,2005), new Date(31,Month.December,2006)); for (int i=0; i testDates = new List(); testDates.Add(new Date(1,Month.February,2002)); @@ -962,18 +1040,22 @@ public void testBusinessDaysBetween() { for (int i=1; i tolerance) - Assert.Fail( + QAssert.Fail( "failed to compute cap/floor vega:" + "\n lengths: " + new Period(lengths[j], TimeUnit.Years) + "\n strike: " + strikes[k] + @@ -160,9 +197,13 @@ public void testVega() { } } } - } - - [TestMethod()] + } + +#if QL_DOTNET_FRAMEWORK + [TestMethod()] +#else + [Fact] +#endif public void testStrikeDependency() { CommonVars vars = new CommonVars(); @@ -190,7 +231,7 @@ public void testStrikeDependency() { // and check that they go the right way for (int k = 0; k < cap_values.Count - 1; k++) { if (cap_values[k] < cap_values[k + 1]) - Assert.Fail( + QAssert.Fail( "NPV is increasing with the strike in a cap: \n" + " length: " + lengths[i] + " years\n" + " volatility: " + vols[j] + "\n" @@ -203,7 +244,7 @@ public void testStrikeDependency() { // same for floors for (int k = 0; k < floor_values.Count - 1; k++) { if (floor_values[k] > floor_values[k + 1]) - Assert.Fail( + QAssert.Fail( "NPV is decreasing with the strike in a floor: \n" + " length: " + lengths[i] + " years\n" + " volatility: " + vols[j] + "\n" @@ -214,9 +255,13 @@ public void testStrikeDependency() { } } } - } - - [TestMethod()] + } + +#if QL_DOTNET_FRAMEWORK + [TestMethod()] +#else + [Fact] +#endif public void testConsistency() { CommonVars vars = new CommonVars(); @@ -242,7 +287,7 @@ public void testConsistency() { collar.setPricingEngine(vars.makeEngine(vols[l])); if (Math.Abs((cap.NPV() - floor.NPV()) - collar.NPV()) > 1e-10) { - Assert.Fail( + QAssert.Fail( "inconsistency between cap, floor and collar:\n" + " length: " + lengths[i] + " years\n" + " volatility: " + vols[l] + "\n" @@ -256,9 +301,13 @@ public void testConsistency() { } } } - } - - [TestMethod()] + } + +#if QL_DOTNET_FRAMEWORK + [TestMethod()] +#else + [Fact] +#endif public void testParity() { CommonVars vars = new CommonVars(); @@ -287,7 +336,7 @@ public void testParity() { swap.setPricingEngine((IPricingEngine)new DiscountingSwapEngine(vars.termStructure)); // FLOATING_POINT_EXCEPTION if (Math.Abs((cap.NPV() - floor.NPV()) - swap.NPV()) > 1.0e-10) { - Assert.Fail( + QAssert.Fail( "put/call parity violated:\n" + " length: " + lengths[i] + " years\n" + " volatility: " + vols[k] + "\n" @@ -299,9 +348,13 @@ public void testParity() { } } } - } - - [TestMethod()] + } + +#if QL_DOTNET_FRAMEWORK + [TestMethod()] +#else + [Fact] +#endif public void testATMRate() { CommonVars vars = new CommonVars(); @@ -328,7 +381,7 @@ public void testATMRate() { double floorATMRate = floor.atmRate(vars.termStructure); if (!checkAbsError(floorATMRate, capATMRate, 1.0e-10)) - Assert.Fail( + QAssert.Fail( "Cap ATM Rate and floor ATM Rate should be equal :\n" + " length: " + lengths[i] + " years\n" + " volatility: " + vols[k] + "\n" @@ -346,7 +399,7 @@ public void testATMRate() { new DiscountingSwapEngine(vars.termStructure))); double swapNPV = swap.NPV(); if (!checkAbsError(swapNPV, 0, 1.0e-10)) - Assert.Fail( + QAssert.Fail( "the NPV of a Swap struck at ATM rate " + "should be equal to 0:\n" + " length: " + lengths[i] + " years\n" @@ -357,9 +410,13 @@ public void testATMRate() { } } } - } - - [TestMethod()] + } + +#if QL_DOTNET_FRAMEWORK + [TestMethod()] +#else + [Fact] +#endif public void testImpliedVolatility() { CommonVars vars = new CommonVars(); @@ -407,7 +464,7 @@ public void testImpliedVolatility() { } // otherwise, report error - Assert.Fail("implied vol failure: " + typeToString(types[i]) + + QAssert.Fail("implied vol failure: " + typeToString(types[i]) + " strike: " + strikes[j] + " risk-free: " + r + " length: " + lengths[k] + "Y" + @@ -418,7 +475,7 @@ public void testImpliedVolatility() { capfloor.setPricingEngine(vars.makeEngine(implVol)); double value2 = capfloor.NPV(); if (Math.Abs(value - value2) > tolerance) { - Assert.Fail( + QAssert.Fail( typeToString(types[i]) + ":" + " strike: " + strikes[j] + "\n" @@ -440,9 +497,13 @@ public void testImpliedVolatility() { } } } - } - - [TestMethod()] + } + +#if QL_DOTNET_FRAMEWORK + [TestMethod()] +#else + [Fact] +#endif public void testCachedValue() { CommonVars vars = new CommonVars(); @@ -465,13 +526,13 @@ public void testCachedValue() { // test Black cap price against cached value if (Math.Abs(cap.NPV() - cachedCapNPV) > 1.0e-11) - Assert.Fail("failed to reproduce cached cap value:\n" + QAssert.Fail("failed to reproduce cached cap value:\n" + " calculated: " + cap.NPV() + "\n" + " expected: " + cachedCapNPV); // test Black floor price against cached value if (Math.Abs(floor.NPV() - cachedFloorNPV) > 1.0e-11) - Assert.Fail("failed to reproduce cached floor value:\n" + QAssert.Fail("failed to reproduce cached floor value:\n" + " calculated: " + floor.NPV() + "\n" + " expected: " + cachedFloorNPV); } diff --git a/Test/T_CashFlows.cs b/Test/T_CashFlows.cs index ad694a8d9..1bf5cac46 100644 --- a/Test/T_CashFlows.cs +++ b/Test/T_CashFlows.cs @@ -17,21 +17,27 @@ under the terms of the QLNet license. You should have received a FOR A PARTICULAR PURPOSE. See the license for more details. */ +#if QL_DOTNET_FRAMEWORK using Microsoft.VisualStudio.TestTools.UnitTesting; +#else + using Xunit; +#endif using QLNet; using System; using System.Collections.Generic; namespace TestSuite { +#if QL_DOTNET_FRAMEWORK [TestClass()] +#endif public class T_CashFlows { private void CHECK_INCLUSION(int n, int days, bool expected, List leg, Date today) { if ((!leg[n].hasOccurred(today + days)) != expected) { - Assert.Fail("cashflow at T+" + n + " " + QAssert.Fail("cashflow at T+" + n + " " + (expected ? "not" : "") + "included" + " at T+" + days); } @@ -44,7 +50,7 @@ private void CHECK_NPV(bool includeRef, double expected, InterestRate no_discoun double NPV = CashFlows.npv(leg, no_discount, includeRef, today); if (Math.Abs(NPV - expected) > 1e-6) { - Assert.Fail("NPV mismatch:\n" + QAssert.Fail("NPV mismatch:\n" + " calculated: " + NPV + "\n" + " expected: " + expected); } @@ -52,7 +58,11 @@ private void CHECK_NPV(bool includeRef, double expected, InterestRate no_discoun while (false); } - [TestMethod()] +#if QL_DOTNET_FRAMEWORK + [TestMethod()] +#else + [Fact] +#endif public void testSettings() { // Testing cash-flow settings... @@ -168,7 +178,11 @@ public void testSettings() } } - [TestMethod()] +#if QL_DOTNET_FRAMEWORK + [TestMethod()] +#else + [Fact] +#endif public void testAccessViolation() { // Testing dynamic cast of coupon in Black pricer... @@ -198,7 +212,7 @@ public void testAccessViolation() Date endDate = new Date(20, Month.December, 2013); double spread = 0.0115; IborCouponPricer pricer = new BlackIborCouponPricer(vol); - FloatingRateCoupon coupon = new FloatingRateCoupon(100, payDate, startDate, endDate, 2, + FloatingRateCoupon coupon = new FloatingRateCoupon( payDate, 100, startDate, endDate, 2, index3m, 1.0, spread / 100); coupon.setPricer(pricer); @@ -214,7 +228,11 @@ public void testAccessViolation() } } - [TestMethod()] +#if QL_DOTNET_FRAMEWORK + [TestMethod()] +#else + [Fact] +#endif public void testDefaultSettlementDate() { // Testing default evaluation date in cashflows methods... @@ -235,18 +253,22 @@ public void testDefaultSettlementDate() double accruedPeriod = CashFlows.accruedPeriod(leg, false); if (accruedPeriod == 0.0) - Assert.Fail("null accrued period with default settlement date"); + QAssert.Fail("null accrued period with default settlement date"); int accruedDays = CashFlows.accruedDays(leg, false); if (accruedDays == 0) - Assert.Fail("no accrued days with default settlement date"); + QAssert.Fail("no accrued days with default settlement date"); double accruedAmount = CashFlows.accruedAmount(leg, false); if (accruedAmount == 0.0) - Assert.Fail("null accrued amount with default settlement date"); + QAssert.Fail("null accrued amount with default settlement date"); } - [TestMethod()] +#if QL_DOTNET_FRAMEWORK + [TestMethod()] +#else + [Fact] +#endif public void testNullFixingDays() { // Testing ibor leg construction with null fixing days... diff --git a/Test/T_CreditDefaultSwap.cs b/Test/T_CreditDefaultSwap.cs index 3035d421a..a67c33526 100644 --- a/Test/T_CreditDefaultSwap.cs +++ b/Test/T_CreditDefaultSwap.cs @@ -17,17 +17,27 @@ under the terms of the QLNet license. You should have received a FOR A PARTICULAR PURPOSE. See the license for more details. */ +#if QL_DOTNET_FRAMEWORK using Microsoft.VisualStudio.TestTools.UnitTesting; +#else + using Xunit; +#endif using QLNet; using System; using System.Collections.Generic; namespace TestSuite { +#if QL_DOTNET_FRAMEWORK [TestClass()] +#endif public class T_CreditDefaultSwap { - [TestMethod()] +#if QL_DOTNET_FRAMEWORK + [TestMethod()] +#else + [Fact] +#endif public void testCachedValue() { // Testing credit-default swap against cached values... @@ -75,13 +85,13 @@ public void testCachedValue() double tolerance = 1.0e-7; if (Math.Abs(calculatedNpv - npv) > tolerance) - Assert.Fail( + QAssert.Fail( "Failed to reproduce NPV with mid-point engine\n" + " calculated NPV: " + calculatedNpv + "\n" + " expected NPV: " + npv); if (Math.Abs(calculatedFairRate - fairRate) > tolerance) - Assert.Fail( + QAssert.Fail( "Failed to reproduce fair rate with mid-point engine\n" + " calculated fair rate: " + calculatedFairRate + "\n" + " expected fair rate: " + fairRate); @@ -94,14 +104,14 @@ public void testCachedValue() tolerance = 1.0e-5; if (Math.Abs(calculatedNpv - npv) > notional * tolerance * 10) - Assert.Fail( + QAssert.Fail( "Failed to reproduce NPV with integral engine " + "(step = 1 day)\n" + " calculated NPV: " + calculatedNpv + "\n" + " expected NPV: " + npv); if (Math.Abs(calculatedFairRate - fairRate) > tolerance) - Assert.Fail( + QAssert.Fail( "Failed to reproduce fair rate with integral engine " + "(step = 1 day)\n" + " calculated fair rate: " + calculatedFairRate + "\n" @@ -114,14 +124,14 @@ public void testCachedValue() tolerance = 1.0e-5; if (Math.Abs(calculatedNpv - npv) > notional * tolerance * 10) - Assert.Fail( + QAssert.Fail( "Failed to reproduce NPV with integral engine " + "(step = 1 week)\n" + " calculated NPV: " + calculatedNpv + "\n" + " expected NPV: " + npv); if (Math.Abs(calculatedFairRate - fairRate) > tolerance) - Assert.Fail( + QAssert.Fail( "Failed to reproduce fair rate with integral engine " + "(step = 1 week)\n" + " calculated fair rate: " + calculatedFairRate + "\n" @@ -129,7 +139,11 @@ public void testCachedValue() } } - [TestMethod()] +#if QL_DOTNET_FRAMEWORK + [TestMethod()] +#else + [Fact] +#endif public void testCachedMarketValue() { // Testing credit-default swap against cached market values... @@ -252,19 +266,23 @@ public void testCachedMarketValue() double tolerance = 1e-9; if (Math.Abs(npv - calculatedNpv) > tolerance) - Assert.Fail( + QAssert.Fail( "Failed to reproduce the npv for the given credit-default swap\n" + " computed NPV: " + calculatedNpv + "\n" + " Given NPV: " + npv); if (Math.Abs(fairRate - calculatedFairRate) > tolerance) - Assert.Fail("Failed to reproduce the fair rate for the given credit-default swap\n" + QAssert.Fail("Failed to reproduce the fair rate for the given credit-default swap\n" + " computed fair rate: " + calculatedFairRate + "\n" + " Given fair rate: " + fairRate); } } - [TestMethod()] +#if QL_DOTNET_FRAMEWORK + [TestMethod()] +#else + [Fact] +#endif public void testImpliedHazardRate() { // Testing implied hazard-rate for credit-default swaps... @@ -328,7 +346,7 @@ public void testImpliedHazardRate() if (flatRate < h1 || flatRate > h2) { - Assert.Fail("implied hazard rate outside expected range\n" + QAssert.Fail("implied hazard rate outside expected range\n" + " maturity: " + n + " years\n" + " expected minimum: " + h1 + "\n" + " expected maximum: " + h2 + "\n" @@ -337,7 +355,7 @@ public void testImpliedHazardRate() if (n > 6 && flatRate < latestRate) { - Assert.Fail("implied hazard rate decreasing with swap maturity\n" + QAssert.Fail("implied hazard rate decreasing with swap maturity\n" + " maturity: " + n + " years\n" + " previous rate: " + latestRate + "\n" + " implied rate: " + flatRate); @@ -356,7 +374,7 @@ public void testImpliedHazardRate() double tolerance = 1.0; if (Math.Abs(NPV - NPV2) > tolerance) { - Assert.Fail("failed to reproduce NPV with implied rate\n" + QAssert.Fail("failed to reproduce NPV with implied rate\n" + " expected: " + NPV + "\n" + " calculated: " + NPV2); } @@ -364,7 +382,11 @@ public void testImpliedHazardRate() } } - [TestMethod()] +#if QL_DOTNET_FRAMEWORK + [TestMethod()] +#else + [Fact] +#endif public void testFairSpread() { // Testing fair-spread calculation for credit-default swaps... @@ -421,14 +443,18 @@ public void testFairSpread() double tolerance = 1e-10; if (Math.Abs(fairNPV) > tolerance) - Assert.Fail( + QAssert.Fail( "Failed to reproduce null NPV with calculated fair spread\n" + " calculated spread: " + fairRate + "\n" + " calculated NPV: " + fairNPV); } } - [TestMethod()] +#if QL_DOTNET_FRAMEWORK + [TestMethod()] +#else + [Fact] +#endif public void testFairUpfront() { // Testing fair-upfront calculation for credit-default swaps... @@ -485,7 +511,7 @@ public void testFairUpfront() double tolerance = 1e-10; if (Math.Abs(fairNPV) > tolerance) - Assert.Fail( + QAssert.Fail( "Failed to reproduce null NPV with calculated fair upfront\n" + " calculated upfront: " + fairUpfront + "\n" + " calculated NPV: " + fairNPV); @@ -505,7 +531,7 @@ public void testFairUpfront() fairNPV = fairCds2.NPV(); if (Math.Abs(fairNPV) > tolerance) - Assert.Fail( + QAssert.Fail( "Failed to reproduce null NPV with calculated fair upfront\n" + " calculated upfront: " + fairUpfront + "\n" + " calculated NPV: " + fairNPV); diff --git a/Test/T_Dates.cs b/Test/T_Dates.cs index 4384340ec..a78182213 100644 --- a/Test/T_Dates.cs +++ b/Test/T_Dates.cs @@ -20,27 +20,37 @@ under the terms of the QLNet license. You should have received a using System; using System.Collections.Generic; using System.Linq; +#if QL_DOTNET_FRAMEWORK using Microsoft.VisualStudio.TestTools.UnitTesting; +#else + using Xunit; +#endif using QLNet; namespace TestSuite { +#if QL_DOTNET_FRAMEWORK [TestClass()] +#endif public class T_Dates { - [TestMethod()] +#if QL_DOTNET_FRAMEWORK + [TestMethod()] +#else + [Fact] +#endif public void testECBDates() { // Testing ECB dates List knownDates = ECB.knownDates(); if (knownDates.empty()) - Assert.Fail("Empty EBC date vector"); + QAssert.Fail("Empty EBC date vector"); int n = ECB.nextDates(Date.minDate()).Count; if (n != knownDates.Count) - Assert.Fail("NextDates(minDate) returns " + n + + QAssert.Fail("NextDates(minDate) returns " + n + " instead of " + knownDates.Count + " dates"); Date previousEcbDate = Date.minDate(), @@ -52,18 +62,18 @@ public void testECBDates() currentEcbDate = knownDates[i]; if (!ECB.isECBdate(currentEcbDate)) - Assert.Fail( currentEcbDate + " fails isECBdate check"); + QAssert.Fail( currentEcbDate + " fails isECBdate check"); ecbDateMinusOne = currentEcbDate-1; if (ECB.isECBdate(ecbDateMinusOne)) - Assert.Fail(ecbDateMinusOne + " fails isECBdate check"); + QAssert.Fail(ecbDateMinusOne + " fails isECBdate check"); if (ECB.nextDate(ecbDateMinusOne)!=currentEcbDate) - Assert.Fail("Next EBC date following " + ecbDateMinusOne + + QAssert.Fail("Next EBC date following " + ecbDateMinusOne + " must be " + currentEcbDate); if (ECB.nextDate(previousEcbDate)!=currentEcbDate) - Assert.Fail("Next EBC date following " + previousEcbDate + + QAssert.Fail("Next EBC date following " + previousEcbDate + " must be " + currentEcbDate); previousEcbDate = currentEcbDate; @@ -72,15 +82,19 @@ public void testECBDates() Date knownDate = knownDates.First(); ECB.removeDate(knownDate); if (ECB.isECBdate(knownDate)) - Assert.Fail("Unable to remove an EBC date"); + QAssert.Fail("Unable to remove an EBC date"); ECB.addDate(knownDate); if (!ECB.isECBdate(knownDate)) - Assert.Fail("Unable to add an EBC date"); + QAssert.Fail("Unable to add an EBC date"); } - [TestMethod()] +#if QL_DOTNET_FRAMEWORK + [TestMethod()] +#else + [Fact] +#endif public void testIMMDates() { // ("Testing IMM dates..."); @@ -109,19 +123,19 @@ public void testIMMDates() // check that imm is greater than counter if (imm <= counter) - Assert.Fail(imm.DayOfWeek + " " + imm + QAssert.Fail(imm.DayOfWeek + " " + imm + " is not greater than " + counter.DayOfWeek + " " + counter); // check that imm is an IMM date if (!IMM.isIMMdate(imm, false)) - Assert.Fail(imm.DayOfWeek + " " + imm + QAssert.Fail(imm.DayOfWeek + " " + imm + " is not an IMM date (calculated from " + counter.DayOfWeek + " " + counter + ")"); // check that imm is <= to the next IMM date in the main cycle if (imm > IMM.nextDate(counter, true)) - Assert.Fail(imm.DayOfWeek + " " + imm + QAssert.Fail(imm.DayOfWeek + " " + imm + " is not less than or equal to the next future in the main cycle " + IMM.nextDate(counter, true)); @@ -134,7 +148,7 @@ public void testIMMDates() // check that for every date IMMdate is the inverse of IMMcode if (IMM.date(IMM.code(imm), counter) != imm) - Assert.Fail(IMM.code(imm) + QAssert.Fail(IMM.code(imm) + " at calendar day " + counter + " is not the IMM code matching " + imm); @@ -142,7 +156,7 @@ public void testIMMDates() for (int i = 0; i < 40; ++i) { if (IMM.date(IMMcodes[i], counter) < counter) - Assert.Fail(IMM.date(IMMcodes[i], counter) + QAssert.Fail(IMM.date(IMMcodes[i], counter) + " is wrong for " + IMMcodes[i] + " at reference date " + counter); } @@ -151,7 +165,11 @@ public void testIMMDates() } } - [TestMethod()] +#if QL_DOTNET_FRAMEWORK + [TestMethod()] +#else + [Fact] +#endif public void testConsistency() { //("Testing dates..."); @@ -172,7 +190,7 @@ public void testConsistency() // check serial number consistency if (serial != i) - Assert.Fail("inconsistent serial number:\n" + QAssert.Fail("inconsistent serial number:\n" + " original: " + i + "\n" + " date: " + t + "\n" + " serial number: " + serial); @@ -187,7 +205,7 @@ public void testConsistency() if (!((dy == dyold + 1) || (dy == 1 && dyold == 365 && !Date.IsLeapYear(yold)) || (dy == 1 && dyold == 366 && Date.IsLeapYear(yold)))) - Assert.Fail("wrong day of year increment: \n" + QAssert.Fail("wrong day of year increment: \n" + " date: " + t + "\n" + " day of year: " + dy + "\n" + " previous: " + dyold); @@ -196,7 +214,7 @@ public void testConsistency() if (!((d == dold + 1 && m == mold && y == yold) || (d == 1 && m == mold + 1 && y == yold) || (d == 1 && m == 1 && y == yold + 1))) - Assert.Fail("wrong day,month,year increment: \n" + QAssert.Fail("wrong day,month,year increment: \n" + " date: " + t + "\n" + " day,month,year: " + d + "," + m + "," + y + "\n" @@ -206,13 +224,13 @@ public void testConsistency() // check month definition if (m < 1 || m > 12) - Assert.Fail("invalid month: \n" + QAssert.Fail("invalid month: \n" + " date: " + t + "\n" + " month: " + m); // check day definition if (d < 1) - Assert.Fail("invalid day of month: \n" + QAssert.Fail("invalid day of month: \n" + " date: " + t + "\n" + " day: " + d); if (!((m == 1 && d <= 31) || @@ -228,14 +246,14 @@ public void testConsistency() (m == 10 && d <= 31) || (m == 11 && d <= 30) || (m == 12 && d <= 31))) - Assert.Fail("invalid day of month: \n" + QAssert.Fail("invalid day of month: \n" + " date: " + t + "\n" + " day: " + d); // check weekday definition if (!((wd == wdold + 1) || (wd == 1 && wdold == 7))) - Assert.Fail("invalid weekday: \n" + QAssert.Fail("invalid weekday: \n" + " date: " + t + "\n" + " weekday: " + wd + "\n" + " previous: " + wdold); @@ -246,7 +264,7 @@ public void testConsistency() // check serial number consistency serial = s.serialNumber(); if (serial != i) - Assert.Fail("inconsistent serial number:\n" + QAssert.Fail("inconsistent serial number:\n" + " date: " + t + "\n" + " serial number: " + i + "\n" + " cloned date: " + s + "\n" @@ -255,7 +273,11 @@ public void testConsistency() } - [TestMethod()] +#if QL_DOTNET_FRAMEWORK + [TestMethod()] +#else + [Fact] +#endif public void testASXDates() { //Testing ASX dates..."); @@ -283,26 +305,26 @@ public void testASXDates() // check that asx is greater than counter if (asx <= counter) - Assert.Fail( asx.weekday() + " " + asx + QAssert.Fail( asx.weekday() + " " + asx + " is not greater than " + counter.weekday() + " " + counter); // check that asx is an ASX date if (!ASX.isASXdate(asx, false)) - Assert.Fail( asx.weekday() + " " + asx + QAssert.Fail( asx.weekday() + " " + asx + " is not an ASX date (calculated from " + counter.weekday() + " " + counter + ")"); // check that asx is <= to the next ASX date in the main cycle if (asx > ASX.nextDate(counter, true)) - Assert.Fail( asx.weekday() + " " + asx + QAssert.Fail( asx.weekday() + " " + asx + " is not less than or equal to the next future in the main cycle " + ASX.nextDate(counter, true)); // check that for every date ASXdate is the inverse of ASXcode if (ASX.date(ASX.code(asx), counter) != asx) - Assert.Fail( ASX.code(asx) + QAssert.Fail( ASX.code(asx) + " at calendar day " + counter + " is not the ASX code matching " + asx); @@ -310,7 +332,7 @@ public void testASXDates() for (int i = 0; i<120; ++i) { if (ASX.date(ASXcodes[i], counter) 1.0e-10) { - Assert.Fail(dayCounter.name() + "period: " + d1 + " to " + d2 + + QAssert.Fail(dayCounter.name() + "period: " + d1 + " to " + d2 + " calculated: " + calculated + " expected: " + testCases[i]._result); } } } - [TestMethod()] +#if QL_DOTNET_FRAMEWORK + [TestMethod()] +#else + [Fact] +#endif public void testSimple() { Period[] p = { new Period(3, TimeUnit.Months), new Period(6, TimeUnit.Months), new Period(1, TimeUnit.Years) }; @@ -176,7 +190,7 @@ public void testSimple() double calculated = dayCounter.yearFraction(start,end,null ,null ); if (Math.Abs(calculated-expected[i]) > 1.0e-12) { - Assert.Fail ("from " + start + " to " + end + + QAssert.Fail ("from " + start + " to " + end + "Calculated: " + calculated + "Expected: " + expected[i]); } @@ -184,8 +198,12 @@ public void testSimple() } } - - [TestMethod()] + +#if QL_DOTNET_FRAMEWORK + [TestMethod()] +#else + [Fact] +#endif public void testOne() { Period[] p = { new Period(3,TimeUnit.Months), new Period(6,TimeUnit.Months), new Period(1,TimeUnit.Years) }; @@ -204,7 +222,7 @@ public void testOne() double calculated = dayCounter.yearFraction(start,end,null,null); if (Math.Abs(calculated-expected[i]) > 1.0e-12) { - Assert.Fail("from " + start + " to " + end + + QAssert.Fail("from " + start + " to " + end + "Calculated: " + calculated + "Expected: " + expected[i]); } @@ -213,7 +231,11 @@ public void testOne() } - [TestMethod()] +#if QL_DOTNET_FRAMEWORK + [TestMethod()] +#else + [Fact] +#endif public void testBusiness252() { // Testing business/252 day counter @@ -261,7 +283,7 @@ public void testBusiness252() calculated = dayCounter1.yearFraction(testDates[i-1],testDates[i]); if (Math.Abs(calculated-expected[i-1]) > 1.0e-12) { - Assert.Fail("from " + testDates[i-1] + QAssert.Fail("from " + testDates[i-1] + " to " + testDates[i] + ":\n" + " calculated: " + calculated + "\n" + " expected: " + expected[i-1]); @@ -275,7 +297,7 @@ public void testBusiness252() calculated = dayCounter2.yearFraction(testDates[i-1],testDates[i]); if (Math.Abs(calculated-expected[i-1]) > 1.0e-12) { - Assert.Fail("from " + testDates[i-1] + QAssert.Fail("from " + testDates[i-1] + " to " + testDates[i] + ":\n" + " calculated: " + calculated + "\n" + " expected: " + expected[i-1]); @@ -284,7 +306,11 @@ public void testBusiness252() } } - [TestMethod()] +#if QL_DOTNET_FRAMEWORK + [TestMethod()] +#else + [Fact] +#endif public void testThirty360_BondBasis() { // Testing thirty/360 day counter (Bond Basis) @@ -341,7 +367,7 @@ public void testThirty360_BondBasis() calculated = dayCounter.dayCount(testStartDates[i], testEndDates[i]); if (calculated != expected[i]) { - Assert.Fail("from " + testStartDates[i] + QAssert.Fail("from " + testStartDates[i] + " to " + testEndDates[i] + ":\n" + " calculated: " + calculated + "\n" + " expected: " + expected[i]); @@ -349,7 +375,11 @@ public void testThirty360_BondBasis() } } - [TestMethod()] +#if QL_DOTNET_FRAMEWORK + [TestMethod()] +#else + [Fact] +#endif public void testThirty360_EurobondBasis() { // Testing thirty/360 day counter (Eurobond Basis) @@ -413,7 +443,7 @@ public void testThirty360_EurobondBasis() calculated = dayCounter.dayCount(testStartDates[i], testEndDates[i]); if (calculated != expected[i]) { - Assert.Fail("from " + testStartDates[i] + QAssert.Fail("from " + testStartDates[i] + " to " + testEndDates[i] + ":\n" + " calculated: " + calculated + "\n" + " expected: " + expected[i]); @@ -421,7 +451,11 @@ public void testThirty360_EurobondBasis() } } - [TestMethod()] +#if QL_DOTNET_FRAMEWORK + [TestMethod()] +#else + [Fact] +#endif public void testIntraday() { // Testing intraday behavior of day counter @@ -441,10 +475,10 @@ public void testIntraday() * dc.yearFraction(d1, d1+1)/86400 + dc.yearFraction(d1, d1+2); - Assert.IsTrue( Math.Abs(dc.yearFraction(d1, d2) - expected) < tol, + QAssert.IsTrue( Math.Abs(dc.yearFraction(d1, d2) - expected) < tol, "can not reproduce result for day counter " + dc.name()); - Assert.IsTrue( Math.Abs(dc.yearFraction(d2, d1) + expected) < tol, + QAssert.IsTrue( Math.Abs(dc.yearFraction(d2, d1) + expected) < tol, "can not reproduce result for day counter " + dc.name()); } } diff --git a/Test/T_DefaultProbabilityCurves.cs b/Test/T_DefaultProbabilityCurves.cs index 928013105..ee7b4e974 100644 --- a/Test/T_DefaultProbabilityCurves.cs +++ b/Test/T_DefaultProbabilityCurves.cs @@ -16,16 +16,26 @@ under the terms of the QLNet license. You should have received a ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the license for more details. */ -using System; -using Microsoft.VisualStudio.TestTools.UnitTesting; +using System; +#if QL_DOTNET_FRAMEWORK +using Microsoft.VisualStudio.TestTools.UnitTesting; +#else + using Xunit; +#endif using QLNet; namespace TestSuite -{ - [TestClass()] +{ +#if QL_DOTNET_FRAMEWORK + [TestClass()] +#endif public class T_DefaultProbabilityCurves - { - [TestMethod()] + { +#if QL_DOTNET_FRAMEWORK + [TestMethod()] +#else + [Fact] +#endif public void testDefaultProbability() { // Testing default-probability structure... @@ -57,7 +67,7 @@ public void testDefaultProbability() double pBetween = pEnd - pStart; if (Math.Abs(pBetween - pBetweenComputed) > tolerance) - Assert.Fail( "Failed to reproduce probability(d1, d2) " + QAssert.Fail( "Failed to reproduce probability(d1, d2) " + "for default probability structure\n" + " calculated probability: " + pBetweenComputed + "\n" + " expected probability: " + pBetween); @@ -68,7 +78,7 @@ public void testDefaultProbability() flatHazardRate.defaultProbability(endDate); if (Math.Abs(timeProbability - dateProbability) > tolerance) - Assert.Fail( "single-time probability and single-date probability do not match\n" + QAssert.Fail( "single-time probability and single-date probability do not match\n" + " time probability: " + timeProbability + "\n" + " date probability: " + dateProbability); @@ -77,14 +87,18 @@ public void testDefaultProbability() dateProbability = flatHazardRate.defaultProbability(startDate, endDate); if (Math.Abs(timeProbability - dateProbability) > tolerance) - Assert.Fail( "double-time probability and double-date probability do not match\n" + QAssert.Fail( "double-time probability and double-date probability do not match\n" + " time probability: " + timeProbability + "\n" + " date probability: " + dateProbability); } - } - - [TestMethod()] + } + +#if QL_DOTNET_FRAMEWORK + [TestMethod()] +#else + [Fact] +#endif public void testFlatHazardRate() { @@ -111,13 +125,17 @@ public void testFlatHazardRate() double computedProbability = flatHazardRate.defaultProbability(t); if (Math.Abs(probability - computedProbability) > tolerance) - Assert.Fail( "Failed to reproduce probability for flat hazard rate\n" + QAssert.Fail( "Failed to reproduce probability for flat hazard rate\n" + " calculated probability: " + computedProbability + "\n" + " expected probability: " + probability); } - } - - [TestMethod()] + } + +#if QL_DOTNET_FRAMEWORK + [TestMethod()] +#else + [Fact] +#endif public void testFlatHazardConsistency() { // Testing piecewise-flat hazard-rate consistency... diff --git a/Test/T_DigitalOption.cs b/Test/T_DigitalOption.cs index bcc32b8b4..278eb6318 100644 --- a/Test/T_DigitalOption.cs +++ b/Test/T_DigitalOption.cs @@ -16,12 +16,18 @@ using System; using System.Collections.Generic; +#if QL_DOTNET_FRAMEWORK using Microsoft.VisualStudio.TestTools.UnitTesting; +#else + using Xunit; +#endif using QLNet; namespace TestSuite { +#if QL_DOTNET_FRAMEWORK [TestClass()] +#endif public class T_DigitalOption { struct DigitalOptionData @@ -56,7 +62,7 @@ void REPORT_FAILURE( string greekName, StrikedTypePayoff payoff, Exercise exerci Date today, double v, double expected, double calculated, double error, double tolerance, bool knockin ) { - Assert.Fail( exercise + " " + QAssert.Fail( exercise + " " + payoff.optionType() + " option with " + payoff + " payoff:\n" + " spot value: " + s + "\n" @@ -74,7 +80,11 @@ void REPORT_FAILURE( string greekName, StrikedTypePayoff payoff, Exercise exerci } - [TestMethod()] +#if QL_DOTNET_FRAMEWORK + [TestMethod()] +#else + [Fact] +#endif public void testCashOrNothingEuropeanValues() { // Testing European cash-or-nothing digital option @@ -130,7 +140,11 @@ public void testCashOrNothingEuropeanValues() } } - [TestMethod()] +#if QL_DOTNET_FRAMEWORK + [TestMethod()] +#else + [Fact] +#endif public void testAssetOrNothingEuropeanValues() { @@ -186,7 +200,11 @@ public void testAssetOrNothingEuropeanValues() } } - [TestMethod()] +#if QL_DOTNET_FRAMEWORK + [TestMethod()] +#else + [Fact] +#endif public void testGapEuropeanValues() { // Testing European gap digital option @@ -241,7 +259,11 @@ public void testGapEuropeanValues() } } - [TestMethod()] +#if QL_DOTNET_FRAMEWORK + [TestMethod()] +#else + [Fact] +#endif public void testCashAtHitOrNothingAmericanValues() { // Testing American cash-(at-hit)-or-nothing digital option @@ -307,7 +329,11 @@ public void testCashAtHitOrNothingAmericanValues() } } - [TestMethod()] +#if QL_DOTNET_FRAMEWORK + [TestMethod()] +#else + [Fact] +#endif public void testAssetAtHitOrNothingAmericanValues() { // Testing American asset-(at-hit)-or-nothing "digital option @@ -371,7 +397,11 @@ public void testAssetAtHitOrNothingAmericanValues() } } - [TestMethod()] +#if QL_DOTNET_FRAMEWORK + [TestMethod()] +#else + [Fact] +#endif public void testCashAtExpiryOrNothingAmericanValues() { // Testing American cash-(at-expiry)-or-nothing digital option @@ -438,7 +468,11 @@ public void testCashAtExpiryOrNothingAmericanValues() } } - [TestMethod()] +#if QL_DOTNET_FRAMEWORK + [TestMethod()] +#else + [Fact] +#endif public void testAssetAtExpiryOrNothingAmericanValues() { @@ -511,7 +545,11 @@ public void testAssetAtExpiryOrNothingAmericanValues() } } - [TestMethod()] +#if QL_DOTNET_FRAMEWORK + [TestMethod()] +#else + [Fact] +#endif public void testCashAtHitOrNothingAmericanGreeks() { diff --git a/Test/T_DividendOption.cs b/Test/T_DividendOption.cs index de7fcb439..48eeedb58 100644 --- a/Test/T_DividendOption.cs +++ b/Test/T_DividendOption.cs @@ -17,21 +17,27 @@ under the terms of the QLNet license. You should have received a FOR A PARTICULAR PURPOSE. See the license for more details. */ +#if QL_DOTNET_FRAMEWORK using Microsoft.VisualStudio.TestTools.UnitTesting; +#else + using Xunit; +#endif using QLNet; using System; using System.Collections.Generic; namespace TestSuite { +#if QL_DOTNET_FRAMEWORK [TestClass()] +#endif public class T_DividendOption { public void REPORT_FAILURE(string greekName, StrikedTypePayoff payoff, Exercise exercise, double s, double q, double r, Date today, double v, double expected, double calculated, double error, double tolerance) { - Assert.Fail(exercise + " " + QAssert.Fail(exercise + " " + payoff.optionType() + " option with " + payoff + " payoff:\n" + " spot value: " + s + "\n" @@ -206,14 +212,18 @@ public void REPORT_FAILURE(string greekName, StrikedTypePayoff payoff, Exercise double value = option.NPV(); if (Math.Abs(refValue - value) > tolerance) - Assert.Fail("NPV changed by null dividend :\n" + QAssert.Fail("NPV changed by null dividend :\n" + " previous value: " + value + "\n" + " current value: " + refValue + "\n" + " change: " + (value - refValue)); } } - [TestMethod()] +#if QL_DOTNET_FRAMEWORK + [TestMethod()] +#else + [Fact] +#endif public void testEuropeanValues() { // Testing dividend European option values with no dividends... @@ -378,7 +388,11 @@ private void testEuropeanKnownValue() } } - [TestMethod()] +#if QL_DOTNET_FRAMEWORK + [TestMethod()] +#else + [Fact] +#endif public void testEuropeanStartLimit() { // Testing dividend European option with a dividend on today's date... @@ -474,7 +488,11 @@ public void testEuropeanStartLimit() } } - [TestMethod()] +#if QL_DOTNET_FRAMEWORK + [TestMethod()] +#else + [Fact] +#endif public void testEuropeanGreeks() { // Testing dividend European option greeks... @@ -630,7 +648,11 @@ public void testEuropeanGreeks() } } - [TestMethod()] +#if QL_DOTNET_FRAMEWORK + [TestMethod()] +#else + [Fact] +#endif public void testFdEuropeanValues() { // Testing finite-difference dividend European option values... @@ -736,7 +758,11 @@ public void testFdEuropeanValues() } } - [TestMethod()] +#if QL_DOTNET_FRAMEWORK + [TestMethod()] +#else + [Fact] +#endif public void testFdEuropeanGreeks() { // Testing finite-differences dividend European option greeks... @@ -755,7 +781,11 @@ public void testFdEuropeanGreeks() } } - [TestMethod()] +#if QL_DOTNET_FRAMEWORK + [TestMethod()] +#else + [Fact] +#endif public void testFdAmericanGreeks() { // Testing finite-differences dividend American option greeks... @@ -774,7 +804,11 @@ public void testFdAmericanGreeks() } } - [TestMethod()] +#if QL_DOTNET_FRAMEWORK + [TestMethod()] +#else + [Fact] +#endif public void testFdEuropeanDegenerate() { // Testing degenerate finite-differences dividend European option... @@ -790,7 +824,11 @@ public void testFdEuropeanDegenerate() } } - [TestMethod()] +#if QL_DOTNET_FRAMEWORK + [TestMethod()] +#else + [Fact] +#endif public void testFdAmericanDegenerate() { // Testing degenerate finite-differences dividend American option... diff --git a/Test/T_EuropeanOption.cs b/Test/T_EuropeanOption.cs index 6e7b08a4a..b37db60a2 100644 --- a/Test/T_EuropeanOption.cs +++ b/Test/T_EuropeanOption.cs @@ -17,15 +17,45 @@ under the terms of the QLNet license. You should have received a FOR A PARTICULAR PURPOSE. See the license for more details. */ using System; -using System.Collections.Generic; -using Microsoft.VisualStudio.TestTools.UnitTesting; +using System.Collections.Generic; +#if QL_DOTNET_FRAMEWORK +using Microsoft.VisualStudio.TestTools.UnitTesting; +#else + using Xunit; +#endif using QLNet; namespace TestSuite -{ - [TestClass()] - public class T_EuropeanOption +{ +#if QL_DOTNET_FRAMEWORK + [TestClass()] +#endif + public class T_EuropeanOption : IDisposable { + #region Initialize&Cleanup + private SavedSettings backup; + #if QL_DOTNET_FRAMEWORK + [TestInitialize] + public void testInitialize() + { + #else + public T_EuropeanOption() + { + #endif + backup = new SavedSettings(); + } + #if QL_DOTNET_FRAMEWORK + [TestCleanup] + #endif + public void testCleanup() + { + Dispose(); + } + public void Dispose() + { + backup.Dispose(); + } + #endregion enum EngineType { @@ -34,16 +64,17 @@ enum EngineType FiniteDifferences, Integral, PseudoMonteCarlo, QuasiMonteCarlo - }; - - - [TestMethod()] + }; + + +#if QL_DOTNET_FRAMEWORK + [TestMethod()] +#else + [Fact] +#endif public void testJRBinomialEngines() { - //("Testing JR binomial European engines against analytic results..."); - - //SavedSettings backup; - + // Testing JR binomial European engines against analytic results EngineType engine = EngineType.JR; int steps = 251; int samples = 0; @@ -53,15 +84,15 @@ public void testJRBinomialEngines() relativeTol.Add("gamma", 1.0e-4); relativeTol.Add("theta", 0.03); testEngineConsistency(engine, steps, samples, relativeTol, true); - } - [TestMethod()] + } +#if QL_DOTNET_FRAMEWORK + [TestMethod()] +#else + [Fact] +#endif public void testCRRBinomialEngines() { - - //("Testing CRR binomial European engines against analytic results..."); - - //SavedSettings backup; - + // Testing CRR binomial European engines against analytic results EngineType engine = EngineType.CRR; int steps = 501; int samples = 0; @@ -71,15 +102,15 @@ public void testCRRBinomialEngines() relativeTol.Add("gamma", 1.0e-4); relativeTol.Add("theta", 0.03); testEngineConsistency(engine, steps, samples, relativeTol, true); - } - [TestMethod()] + } +#if QL_DOTNET_FRAMEWORK + [TestMethod()] +#else + [Fact] +#endif public void testEQPBinomialEngines() { - - //("Testing EQP binomial European engines against analytic results..."); - - //SavedSettings backup; - + // Testing EQP binomial European engines against analytic results EngineType engine = EngineType.EQP; int steps = 501; int samples = 0; @@ -89,15 +120,15 @@ public void testEQPBinomialEngines() relativeTol.Add("gamma", 1.0e-4); relativeTol.Add("theta", 0.03); testEngineConsistency(engine, steps, samples, relativeTol, true); - } - [TestMethod()] + } +#if QL_DOTNET_FRAMEWORK + [TestMethod()] +#else + [Fact] +#endif public void testTGEOBinomialEngines() { - - //("Testing TGEO binomial European engines " against analytic results..."); - - //SavedSettings backup; - + // Testing TGEO binomial European engines " against analytic results EngineType engine = EngineType.TGEO; int steps = 251; int samples = 0; @@ -107,15 +138,15 @@ public void testTGEOBinomialEngines() relativeTol.Add("gamma", 1.0e-4); relativeTol.Add("theta", 0.03); testEngineConsistency(engine, steps, samples, relativeTol, true); - } - [TestMethod()] + } +#if QL_DOTNET_FRAMEWORK + [TestMethod()] +#else + [Fact] +#endif public void testTIANBinomialEngines() { - - //("Testing TIAN binomial European engines against analytic results..."); - - //SavedSettings backup; - + // Testing TIAN binomial European engines against analytic results EngineType engine = EngineType.TIAN; int steps = 251; int samples = 0; @@ -125,15 +156,15 @@ public void testTIANBinomialEngines() relativeTol.Add("gamma", 1.0e-4); relativeTol.Add("theta", 0.03); testEngineConsistency(engine, steps, samples, relativeTol, true); - } - [TestMethod()] + } +#if QL_DOTNET_FRAMEWORK + [TestMethod()] +#else + [Fact] +#endif public void testLRBinomialEngines() { - - //"Testing LR binomial European engines against analytic results..."); - - //SavedSettings backup; - + // Testing LR binomial European engines against analytic results EngineType engine = EngineType.LR; int steps = 251; int samples = 0; @@ -143,15 +174,15 @@ public void testLRBinomialEngines() relativeTol.Add("gamma", 1.0e-4); relativeTol.Add("theta", 0.03); testEngineConsistency(engine, steps, samples, relativeTol, true); - } - [TestMethod()] + } +#if QL_DOTNET_FRAMEWORK + [TestMethod()] +#else + [Fact] +#endif public void testJOSHIBinomialEngines() { - - //("Testing Joshi binomial European engines against analytic results..."); - - //SavedSettings backup; - + // Testing Joshi binomial European engines against analytic results EngineType engine = EngineType.JOSHI; int steps = 251; int samples = 0; @@ -161,10 +192,14 @@ public void testJOSHIBinomialEngines() relativeTol.Add("gamma", 1.0e-4); relativeTol.Add("theta", 0.03); testEngineConsistency(engine, steps, samples, relativeTol, true); - } - - - [TestMethod()] + } + + +#if QL_DOTNET_FRAMEWORK + [TestMethod()] +#else + [Fact] +#endif public void testFdEngines() { @@ -250,8 +285,7 @@ VanillaOption makeOption(StrikedTypePayoff payoff, Exercise exercise, Quote u, Y return option; } - //void testEngineConsistency(EngineType engine, int binomialSteps, int samples, Dictionary tolerance, - // bool testGreeks = false) { + void testEngineConsistency(EngineType engine, int binomialSteps, int samples, Dictionary tolerance, bool testGreeks) { @@ -358,7 +392,7 @@ void testEngineConsistency(EngineType engine, int binomialSteps, int samples, Di void REPORT_FAILURE(string greekName, StrikedTypePayoff payoff, Exercise exercise, double s, double q, double r, Date today, double v, double expected, double calculated, double error, double tolerance) { - Assert.Fail(exercise + " " + QAssert.Fail(exercise + " " + payoff.optionType() + " option with " + payoff + " payoff:\n" + " spot value: " + s + "\n" diff --git a/Test/T_ExchangeRate.cs b/Test/T_ExchangeRate.cs index f24bc0656..988a59974 100644 --- a/Test/T_ExchangeRate.cs +++ b/Test/T_ExchangeRate.cs @@ -15,16 +15,26 @@ under the terms of the QLNet license. You should have received a This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the license for more details. -*/ -using Microsoft.VisualStudio.TestTools.UnitTesting; +*/ +#if QL_DOTNET_FRAMEWORK +using Microsoft.VisualStudio.TestTools.UnitTesting; +#else + using Xunit; +#endif using QLNet; namespace TestSuite -{ - [TestClass()] +{ +#if QL_DOTNET_FRAMEWORK + [TestClass()] +#endif public class T_ExchangeRate - { - [TestMethod()] + { +#if QL_DOTNET_FRAMEWORK + [TestMethod()] +#else + [Fact] +#endif public void testDirect() { @@ -42,7 +52,7 @@ public void testDirect() if (!Utils.close(calculated, expected)) { - Assert.Fail("Wrong result: expected: " + expected + " calculated: " + calculated); + QAssert.Fail("Wrong result: expected: " + expected + " calculated: " + calculated); } calculated = eur_usd.exchange(m2); @@ -50,14 +60,18 @@ public void testDirect() if (!Utils.close(calculated, expected)) { - Assert.Fail("Wrong result: expected: " + expected + " calculated: " + calculated); + QAssert.Fail("Wrong result: expected: " + expected + " calculated: " + calculated); } } /// /// Testing derived exchange rates - /// - [TestMethod()] + /// +#if QL_DOTNET_FRAMEWORK + [TestMethod()] +#else + [Fact] +#endif public void testDerived() { @@ -78,7 +92,7 @@ public void testDerived() if (!Utils.close(calculated, expected)) { - Assert.Fail("Wrong result: expected: " + expected + " calculated: " + calculated); + QAssert.Fail("Wrong result: expected: " + expected + " calculated: " + calculated); } calculated = derived.exchange(m2); @@ -86,14 +100,18 @@ public void testDerived() if (!Utils.close(calculated, expected)) { - Assert.Fail("Wrong result: expected: " + expected + " calculated: " + calculated); + QAssert.Fail("Wrong result: expected: " + expected + " calculated: " + calculated); } } /// /// Testing lookup of direct exchange rates - /// - [TestMethod()] + /// +#if QL_DOTNET_FRAMEWORK + [TestMethod()] +#else + [Fact] +#endif public void testDirectLookup() { ExchangeRateManager rateManager = ExchangeRateManager.Instance; @@ -117,7 +135,7 @@ public void testDirectLookup() if (!Utils.close(calculated, expected)) { - Assert.Fail("Wrong result: expected: " + expected + " calculated: " + calculated); + QAssert.Fail("Wrong result: expected: " + expected + " calculated: " + calculated); } eur_usd = rateManager.lookup(EUR, USD,new Date(5,Month.August,2004),ExchangeRate.Type.Direct); @@ -126,7 +144,7 @@ public void testDirectLookup() if (!Utils.close(calculated, expected)) { - Assert.Fail("Wrong result: expected: " + expected + " calculated: " + calculated); + QAssert.Fail("Wrong result: expected: " + expected + " calculated: " + calculated); } ExchangeRate usd_eur = rateManager.lookup(USD, EUR,new Date(4,Month.August,2004),ExchangeRate.Type.Direct); @@ -136,7 +154,7 @@ public void testDirectLookup() if (!Utils.close(calculated, expected)) { - Assert.Fail("Wrong result: expected: " + expected + " calculated: " + calculated); + QAssert.Fail("Wrong result: expected: " + expected + " calculated: " + calculated); } usd_eur = rateManager.lookup(USD, EUR,new Date(5,Month.August,2004),ExchangeRate.Type.Direct); @@ -146,14 +164,18 @@ public void testDirectLookup() if (!Utils.close(calculated, expected)) { - Assert.Fail("Wrong result: expected: " + expected + " calculated: " + calculated); + QAssert.Fail("Wrong result: expected: " + expected + " calculated: " + calculated); } } /// /// Testing lookup of triangulated exchange rates - /// - [TestMethod()] + /// +#if QL_DOTNET_FRAMEWORK + [TestMethod()] +#else + [Fact] +#endif public void testTriangulatedLookup() { @@ -178,7 +200,7 @@ public void testTriangulatedLookup() if (!Utils.close(calculated, expected)) { - Assert.Fail("Wrong result: expected: " + expected + " calculated: " + calculated); + QAssert.Fail("Wrong result: expected: " + expected + " calculated: " + calculated); } itl_usd = rateManager.lookup(ITL, USD,new Date(5,Month.August,2004)); @@ -187,7 +209,7 @@ public void testTriangulatedLookup() if (!Utils.close(calculated, expected)) { - Assert.Fail("Wrong result: expected: " + expected + " calculated: " + calculated); + QAssert.Fail("Wrong result: expected: " + expected + " calculated: " + calculated); } ExchangeRate usd_itl = rateManager.lookup(USD, ITL, new Date(4, Month.August, 2004)); @@ -197,7 +219,7 @@ public void testTriangulatedLookup() if (!Utils.close(calculated, expected)) { - Assert.Fail("Wrong result: expected: " + expected + " calculated: " + calculated); + QAssert.Fail("Wrong result: expected: " + expected + " calculated: " + calculated); } usd_itl = rateManager.lookup(USD, ITL, new Date(5, Month.August, 2004)); @@ -207,14 +229,18 @@ public void testTriangulatedLookup() if (!Utils.close(calculated, expected)) { - Assert.Fail("Wrong result: expected: " + expected + " calculated: " + calculated); + QAssert.Fail("Wrong result: expected: " + expected + " calculated: " + calculated); } } /// /// Testing lookup of derived exchange rates - /// - [TestMethod()] + /// +#if QL_DOTNET_FRAMEWORK + [TestMethod()] +#else + [Fact] +#endif public void testSmartLookup() { @@ -266,7 +292,7 @@ public void testSmartLookup() if (!Utils.close(calculated, expected)) { - Assert.Fail("Wrong result: expected: " + expected + " calculated: " + calculated); + QAssert.Fail("Wrong result: expected: " + expected + " calculated: " + calculated); } usd_sek = rateManager.lookup(SEK, USD, new Date(5,Month.August,2004)); @@ -275,7 +301,7 @@ public void testSmartLookup() if (!Utils.close(calculated, expected)) { - Assert.Fail("Wrong result: expected: " + expected + " calculated: " + calculated); + QAssert.Fail("Wrong result: expected: " + expected + " calculated: " + calculated); } // three-rate chain @@ -286,7 +312,7 @@ public void testSmartLookup() if (!Utils.close(calculated, expected)) { - Assert.Fail("Wrong result: expected: " + expected + " calculated: " + calculated); + QAssert.Fail("Wrong result: expected: " + expected + " calculated: " + calculated); } eur_sek = rateManager.lookup(SEK, EUR, new Date(5,Month.August,2004)); @@ -295,7 +321,7 @@ public void testSmartLookup() if (!Utils.close(calculated, expected)) { - Assert.Fail("Wrong result: expected: " + expected + " calculated: " + calculated); + QAssert.Fail("Wrong result: expected: " + expected + " calculated: " + calculated); } // four-rate chain @@ -306,7 +332,7 @@ public void testSmartLookup() if (!Utils.close(calculated, expected)) { - Assert.Fail("Wrong result: expected: " + expected + " calculated: " + calculated); + QAssert.Fail("Wrong result: expected: " + expected + " calculated: " + calculated); } eur_jpy = rateManager.lookup(JPY, EUR, new Date(5,Month.August,2004)); @@ -315,7 +341,7 @@ public void testSmartLookup() if (!Utils.close(calculated, expected)) { - Assert.Fail("Wrong result: expected: " + expected + " calculated: " + calculated); + QAssert.Fail("Wrong result: expected: " + expected + " calculated: " + calculated); } // five-rate chain @@ -326,7 +352,7 @@ public void testSmartLookup() if (!Utils.close(calculated, expected)) { - Assert.Fail("Wrong result: expected: " + expected + " calculated: " + calculated); + QAssert.Fail("Wrong result: expected: " + expected + " calculated: " + calculated); } gbp_jpy = rateManager.lookup(JPY, GBP, new Date(5,Month.August,2004)); @@ -335,7 +361,7 @@ public void testSmartLookup() if (!Utils.close(calculated, expected)) { - Assert.Fail("Wrong result: expected: " + expected + " calculated: " + calculated); + QAssert.Fail("Wrong result: expected: " + expected + " calculated: " + calculated); } } } diff --git a/Test/T_Functions.cs b/Test/T_Functions.cs index c5234ff32..73f4d2b3f 100644 --- a/Test/T_Functions.cs +++ b/Test/T_Functions.cs @@ -16,17 +16,27 @@ under the terms of the QLNet license. You should have received a ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the license for more details. */ -using System; -using Microsoft.VisualStudio.TestTools.UnitTesting; +using System; +#if QL_DOTNET_FRAMEWORK +using Microsoft.VisualStudio.TestTools.UnitTesting; +#else + using Xunit; +#endif using QLNet; using System.Numerics; namespace TestSuite -{ - [TestClass()] +{ +#if QL_DOTNET_FRAMEWORK + [TestClass()] +#endif public class T_Functions - { - [TestMethod()] + { +#if QL_DOTNET_FRAMEWORK + [TestMethod()] +#else + [Fact] +#endif public void testFactorial() { // Testing factorial numbers @@ -34,22 +44,26 @@ public void testFactorial() double expected = 1.0; double calculated = Factorial.get(0); if (calculated!=expected) - Assert.Fail("Factorial(0) = " + calculated); + QAssert.Fail("Factorial(0) = " + calculated); for (uint i=1; i<171; ++i) { expected *= i; calculated = Factorial.get(i); if (Math.Abs(calculated-expected)/expected > 1.0e-9) - Assert.Fail("Factorial(" + i + ")" + + QAssert.Fail("Factorial(" + i + ")" + "\n calculated: " + calculated + "\n expected: " + expected + "\n rel. error: " + Math.Abs(calculated-expected)/expected); } - } - - [TestMethod()] + } + +#if QL_DOTNET_FRAMEWORK + [TestMethod()] +#else + [Fact] +#endif public void testGammaFunction() { // Testing Gamma function @@ -57,7 +71,7 @@ public void testGammaFunction() double expected = 0.0; double calculated = GammaFunction.logValue(1); if (Math.Abs(calculated) > 1.0e-15) - Assert.Fail("GammaFunction(1)\n" + QAssert.Fail("GammaFunction(1)\n" + " calculated: " + calculated + "\n" + " expected: " + expected); @@ -66,15 +80,19 @@ public void testGammaFunction() expected += Math.Log(i); calculated = GammaFunction.logValue((i+1)); if (Math.Abs(calculated-expected)/expected > 1.0e-9) - Assert.Fail("GammaFunction(" + i + ")\n" + QAssert.Fail("GammaFunction(" + i + ")\n" + " calculated: " + calculated + "\n" + " expected: " + expected + "\n" + " rel. error: " + Math.Abs(calculated-expected)/expected); } - } - - [TestMethod()] + } + +#if QL_DOTNET_FRAMEWORK + [TestMethod()] +#else + [Fact] +#endif public void testGammaValues() { // Testing Gamma values @@ -102,7 +120,7 @@ public void testGammaValues() if (Math.Abs(calculated - expected) > tol) { - Assert.Fail("GammaFunction(" + x + ")\n" + QAssert.Fail("GammaFunction(" + x + ")\n" + " calculated: " + calculated + "\n" + " expected: " + expected + "\n" + " rel. error: " @@ -110,9 +128,13 @@ public void testGammaValues() } } - } - - [TestMethod()] + } + +#if QL_DOTNET_FRAMEWORK + [TestMethod()] +#else + [Fact] +#endif public void testModifiedBesselFunctions() { // Testing modified Bessel function of first and second kind @@ -144,7 +166,7 @@ public void testModifiedBesselFunctions() double calculated_k = Utils.modifiedBesselFunction_k(nu, x); if (Math.Abs(expected_i - calculated_i) > tol_i) { - Assert.Fail("failed to reproduce modified Bessel " + QAssert.Fail("failed to reproduce modified Bessel " + "function of first kind" + "\n order : " + nu + "\n argument : " + x @@ -152,7 +174,7 @@ public void testModifiedBesselFunctions() + "\n expected : " + expected_i); } if (Math.Abs(expected_k - calculated_k) > tol_k) { - Assert.Fail("failed to reproduce modified Bessel " + QAssert.Fail("failed to reproduce modified Bessel " + "function of second kind" + "\n order : " + nu + "\n argument : " + x @@ -196,7 +218,7 @@ public void testModifiedBesselFunctions() if (Complex.Abs(expected_i - calculated_i) > tol_i) { - Assert.Fail("failed to reproduce modified Bessel " + QAssert.Fail("failed to reproduce modified Bessel " + "function of first kind" + "\n order : " + nu + "\n argument : " + z @@ -207,7 +229,7 @@ public void testModifiedBesselFunctions() if ( Complex.Abs(expected_k) > 1e-4 // do not check small values && Complex.Abs(expected_k - calculated_k) > tol_k) { - Assert.Fail("failed to reproduce modified Bessel " + QAssert.Fail("failed to reproduce modified Bessel " + "function of second kind" + "\n order : " + nu + "\n argument : " + z @@ -216,9 +238,13 @@ public void testModifiedBesselFunctions() + "\n expected : " + expected_k); } } - } - - [TestMethod()] + } + +#if QL_DOTNET_FRAMEWORK + [TestMethod()] +#else + [Fact] +#endif public void testWeightedModifiedBesselFunctions() { // Testing weighted modified Bessel functions @@ -234,14 +260,14 @@ public void testWeightedModifiedBesselFunctions() double wk = Const.M_PI_2 * (Utils.modifiedBesselFunction_i(-nu,x)*Math.Exp(-x)- Utils.modifiedBesselFunction_i(nu,x)*Math.Exp(-x)) / Math.Sin(Const.M_PI*nu); if (Math.Abs((vi - wi) / (Math.Max(Math.Exp(x), 1.0) * vi)) > 1E3 * Const.QL_EPSILON) - Assert.Fail("failed to verify exponentially weighted" + QAssert.Fail("failed to verify exponentially weighted" + "modified Bessel function of first kind" + "\n order : " + nu + "\n argument : " + x + "\n calcuated : " + vi + "\n expecetd : " + wi); if (Math.Abs((vk - wk) / (Math.Max(Math.Exp(x), 1.0) * vk)) > 1E3 * Const.QL_EPSILON) - Assert.Fail("failed to verify exponentially weighted" + QAssert.Fail("failed to verify exponentially weighted" + "modified Bessel function of second kind" + "\n order : " + nu + "\n argument : " + x + "\n calcuated : " + vk @@ -266,14 +292,14 @@ public void testWeightedModifiedBesselFunctions() Utils.modifiedBesselFunction_i(nu, z) * Complex.Exp(-z)) / Math.Sin(Const.M_PI * nu); if (Complex.Abs((vi - wi) / vi) > 1E3 * Const.QL_EPSILON) - Assert.Fail("failed to verify exponentially weighted" + QAssert.Fail("failed to verify exponentially weighted" + "modified Bessel function of first kind" + "\n order : " + nu + "\n argument : " + z + "\n calcuated: " + vi + "\n expecetd : " + wi); if (Complex.Abs((vk - wk) / vk) > 1E3 * Const.QL_EPSILON) - Assert.Fail("failed to verify exponentially weighted" + QAssert.Fail("failed to verify exponentially weighted" + "modified Bessel function of second kind" + "\n order : " + nu + "\n argument : " + z + diff --git a/Test/T_HestonModel.cs b/Test/T_HestonModel.cs index 8c6c438a5..9527e449b 100644 --- a/Test/T_HestonModel.cs +++ b/Test/T_HestonModel.cs @@ -15,12 +15,18 @@ // FOR A PARTICULAR PURPOSE. See the license for more details. using System; using System.Collections.Generic; +#if QL_DOTNET_FRAMEWORK using Microsoft.VisualStudio.TestTools.UnitTesting; +#else + using Xunit; +#endif using QLNet; namespace TestSuite { +#if QL_DOTNET_FRAMEWORK [TestClass()] +#endif public class T_HestonModel { struct CalibrationMarketData @@ -109,7 +115,11 @@ Pricing European-Style Options under Jump Diffusion Processes return marketData; } - [TestMethod()] +#if QL_DOTNET_FRAMEWORK + [TestMethod()] +#else + [Fact] +#endif public void testBlackCalibration() { // Testing Heston model calibration using a flat volatility surface @@ -182,7 +192,7 @@ In addition theta and v0 should be equal to the constant variance */ if (model.sigma() > tolerance) { - Assert.Fail("Failed to reproduce expected sigma" + QAssert.Fail("Failed to reproduce expected sigma" + "\n calculated: " + model.sigma() + "\n expected: " + 0.0 + "\n tolerance: " + tolerance); @@ -190,14 +200,14 @@ In addition theta and v0 should be equal to the constant variance */ if (Math.Abs(model.kappa() *(model.theta()-volatility*volatility)) > tolerance) { - Assert.Fail("Failed to reproduce expected theta" + QAssert.Fail("Failed to reproduce expected theta" + "\n calculated: " + model.theta() + "\n expected: " + volatility*volatility); } if (Math.Abs(model.v0()-volatility*volatility) > tolerance) { - Assert.Fail("Failed to reproduce expected v0" + QAssert.Fail("Failed to reproduce expected v0" + "\n calculated: " + model.v0() + "\n expected: " + volatility*volatility); } @@ -205,7 +215,11 @@ In addition theta and v0 should be equal to the constant variance */ } } - [TestMethod()] +#if QL_DOTNET_FRAMEWORK + [TestMethod()] +#else + [Fact] +#endif public void testDAXCalibration() { // Testing Heston model calibration using DAX volatility data @@ -250,7 +264,7 @@ public void testDAXCalibration() double expected = 177.2; //see article by A. Sepp. if (Math.Abs(sse - expected) > 1.0) { - Assert.Fail("Failed to reproduce calibration error" + QAssert.Fail("Failed to reproduce calibration error" + "\n calculated: " + sse + "\n expected: " + expected); } @@ -302,7 +316,7 @@ public void testAnalyticVsBlack() //double tolerance = 2.0e-7; //if (error > tolerance) //{ - // Assert.Fail("failed to reproduce Black price with AnalyticHestonEngine" + // QAssert.Fail("failed to reproduce Black price with AnalyticHestonEngine" // + "\n calculated: " + calculated // + "\n expected: " + expected // + "\n error: " + error); @@ -316,7 +330,7 @@ public void testAnalyticVsBlack() //tolerance = 1.0e-3; //if (error > tolerance) //{ - // Assert.Fail("failed to reproduce Black price with FdHestonVanillaEngine" + // QAssert.Fail("failed to reproduce Black price with FdHestonVanillaEngine" // +"\n calculated: " + calculated // +"\n expected: " + expected // +"\n error: " + error); @@ -324,7 +338,11 @@ public void testAnalyticVsBlack() //} } - [TestMethod()] +#if QL_DOTNET_FRAMEWORK + [TestMethod()] +#else + [Fact] +#endif public void testAnalyticVsCached() { // Testing analytic Heston engine against cached values @@ -363,7 +381,7 @@ public void testAnalyticVsCached() if (Math.Abs(calculated1 - expected1) > tolerance) { - Assert.Fail("Failed to reproduce cached analytic price" + QAssert.Fail("Failed to reproduce cached analytic price" + "\n calculated: " + calculated1 + "\n expected: " + expected1); } @@ -409,7 +427,7 @@ public void testAnalyticVsCached() if (Math.Abs(interpolated - expected2[i]) > 100*tolerance) { - Assert.Fail("Failed to reproduce cached analytic prices:" + QAssert.Fail("Failed to reproduce cached analytic prices:" + "\n calculated: " + interpolated + "\n expected: " + expected2[i]); } @@ -417,7 +435,11 @@ public void testAnalyticVsCached() } } - [TestMethod()] +#if QL_DOTNET_FRAMEWORK + [TestMethod()] +#else + [Fact] +#endif public void testMcVsCached() { // Testing Monte Carlo Heston engine against cached values @@ -456,7 +478,7 @@ public void testMcVsCached() if (Math.Abs(calculated - expected) > 2.34*errorEstimate) { - Assert.Fail("Failed to reproduce cached price" + QAssert.Fail("Failed to reproduce cached price" + "\n calculated: " + calculated + "\n expected: " + expected + " +/- " + errorEstimate); @@ -464,7 +486,7 @@ public void testMcVsCached() if (errorEstimate > tolerance) { - Assert.Fail("failed to reproduce error estimate" + QAssert.Fail("failed to reproduce error estimate" + "\n calculated: " + errorEstimate + "\n expected: " + tolerance); } @@ -503,7 +525,7 @@ public void testFdBarrierVsCached() // double error = Math.Abs(calculated - expected); // if (error > 1.0e-3) // { - // Assert.Fail("failed to reproduce cached price with FD Barrier engine" + // QAssert.Fail("failed to reproduce cached price with FD Barrier engine" // + "\n calculated: " + calculated // + "\n expected: " + expected // + "\n error: " + error); @@ -517,7 +539,7 @@ public void testFdBarrierVsCached() // error = Math.Abs(calculated - expected); // if (error > 1.0e-3) // { - // Assert.Fail("failed to reproduce cached price with FD Barrier engine" + // QAssert.Fail("failed to reproduce cached price with FD Barrier engine" // + "\n calculated: " + calculated // + "\n expected: " + expected // + "\n error: " + error); @@ -561,7 +583,7 @@ public void testFdVanillaVsCached() // if (error > tolerance) // { - // Assert.Fail("failed to reproduce cached price with FD engine" + // QAssert.Fail("failed to reproduce cached price with FD engine" // + "\n calculated: " + calculated // + "\n expected: " + expected // + "\n error: " + error); @@ -601,7 +623,7 @@ public void testFdVanillaVsCached() // if (error > tolerance) // { - // Assert.Fail("failed to reproduce discrete dividend price with FD engine" + // QAssert.Fail("failed to reproduce discrete dividend price with FD engine" // + "\n calculated: " + calculated // + "\n expected: " + expected // + "\n error: " + error); @@ -630,7 +652,7 @@ public void testFdVanillaVsCached() // if (error > tolerance) // { - // Assert.Fail("failed to reproduce american option price with FD engine" + // QAssert.Fail("failed to reproduce american option price with FD engine" // + "\n calculated: " + calculated // + "\n expected: " + expected // + "\n error: " + error); @@ -701,7 +723,7 @@ public void testKahlJaeckelCase() // if (Math.Abs(calculated - expected) > 2.34*errorEstimate) // { - // Assert.Fail("Failed to reproduce cached price with MC engine" + // QAssert.Fail("Failed to reproduce cached price with MC engine" // + "\n discretization: " + descriptions[i].name // + "\n expected: " + expected // + "\n calculated: " + calculated @@ -710,7 +732,7 @@ public void testKahlJaeckelCase() // if (errorEstimate > tolerance) // { - // Assert.Fail("failed to reproduce error estimate with MC engine" + // QAssert.Fail("failed to reproduce error estimate with MC engine" // + "\n discretization: " + descriptions[i].name // + "\n calculated : " + errorEstimate // + "\n expected : " + tolerance); @@ -726,7 +748,7 @@ public void testKahlJaeckelCase() //double calculated = option.NPV(); //if (Math.Abs(calculated - expected) > tolerance) //{ - // Assert.Fail("Failed to reproduce cached price with MC engine" + // QAssert.Fail("Failed to reproduce cached price with MC engine" // + "\n discretization: BroadieKayaExactSchemeLobatto" // + "\n calculated: " + calculated // + "\n expected: " + expected @@ -740,7 +762,7 @@ public void testKahlJaeckelCase() //double error = Math.Abs(calculated - expected); //if (error > 5.0e-2) //{ - // Assert.Fail("failed to reproduce cached price with FD engine" + // QAssert.Fail("failed to reproduce cached price with FD engine" // + "\n calculated: " + calculated // + "\n expected: " + expected // + "\n error: " + error); @@ -761,7 +783,11 @@ public HestonParameter(double _v0, double _kappa, double _theta, double _sigma, } } - [TestMethod()] +#if QL_DOTNET_FRAMEWORK + [TestMethod()] +#else + [Fact] +#endif public void testDifferentIntegrals() { // Testing different numerical Heston integration algorithms @@ -856,7 +882,7 @@ public void testDifferentIntegrals() double tr = tol[count++]; if (maxDiff > tr) { - Assert.Fail("Failed to reproduce Heston pricing values within given tolerance" + QAssert.Fail("Failed to reproduce Heston pricing values within given tolerance" + "\n maxDifference: " + maxDiff + "\n tolerance: " + tr); } @@ -920,28 +946,28 @@ public void testMultipleStrikesEngine() // if (Math.Abs(npvCalculated - npvExpected)/npvExpected > relTol) // { - // Assert.Fail("failed to reproduce price with FD multi strike engine" + // QAssert.Fail("failed to reproduce price with FD multi strike engine" // + "\n calculated: " + npvCalculated // + "\n expected: " + npvExpected // + "\n error: " + relTol); // } // if (Math.Abs(deltaCalculated - deltaExpected)/deltaExpected > relTol) // { - // Assert.Fail("failed to reproduce delta with FD multi strike engine" + // QAssert.Fail("failed to reproduce delta with FD multi strike engine" // + "\n calculated: " + deltaCalculated // + "\n expected: " + deltaExpected // + "\n error: " + relTol); // } // if (Math.Abs(gammaCalculated - gammaExpected)/gammaExpected > relTol) // { - // Assert.Fail("failed to reproduce gamma with FD multi strike engine" + // QAssert.Fail("failed to reproduce gamma with FD multi strike engine" // + "\n calculated: " + gammaCalculated // + "\n expected: " + gammaExpected // + "\n error: " + relTol); // } // if (Math.Abs(thetaCalculated - thetaExpected)/thetaExpected > relTol) // { - // Assert.Fail( "failed to reproduce theta with FD multi strike engine" + // QAssert.Fail( "failed to reproduce theta with FD multi strike engine" // + "\n calculated: " + thetaCalculated // + "\n expected: " + thetaExpected // + "\n error: " + relTol); @@ -950,7 +976,11 @@ public void testMultipleStrikesEngine() //} } - [TestMethod()] +#if QL_DOTNET_FRAMEWORK + [TestMethod()] +#else + [Fact] +#endif public void testAnalyticPiecewiseTimeDependent() { // Testing analytic piecewise time dependent Heston prices @@ -1005,14 +1035,18 @@ public void testAnalyticPiecewiseTimeDependent() if (Math.Abs(calculated - expected) > 1e-12) { - Assert.Fail("failed to reproduce heston prices " + QAssert.Fail("failed to reproduce heston prices " + "\n calculated: " + calculated + "\n expected: " + expected); } } } - [TestMethod()] +#if QL_DOTNET_FRAMEWORK + [TestMethod()] +#else + [Fact] +#endif public void testDAXCalibrationOfTimeDependentModel() { // Testing time-dependent Heston model calibration @@ -1068,14 +1102,18 @@ public void testDAXCalibrationOfTimeDependentModel() double expected = 74.4; if (Math.Abs(sse - expected) > 1.0) { - Assert.Fail("Failed to reproduce calibration error" + QAssert.Fail("Failed to reproduce calibration error" + "\n calculated: " + sse + "\n expected: " + expected); } } } - [TestMethod()] +#if QL_DOTNET_FRAMEWORK + [TestMethod()] +#else + [Fact] +#endif public void testAlanLewisReferencePrices() { // Testing Alan Lewis reference prices @@ -1156,7 +1194,7 @@ public void testAlanLewisReferencePrices() if (relError > tol) { - Assert.Fail("failed to reproduce Alan Lewis Reference prices " + QAssert.Fail("failed to reproduce Alan Lewis Reference prices " + "\n strike : " + strike + "\n option type: " + type + "\n engine type: " + k @@ -1168,7 +1206,11 @@ public void testAlanLewisReferencePrices() } } - [TestMethod()] +#if QL_DOTNET_FRAMEWORK + [TestMethod()] +#else + [Fact] +#endif public void testExpansionOnAlanLewisReference() { // Testing expansion on Alan Lewis reference prices @@ -1243,7 +1285,7 @@ public void testExpansionOnAlanLewisReference() if (relError > tol[k]) { - Assert.Fail( "failed to reproduce Alan Lewis Reference prices " + QAssert.Fail( "failed to reproduce Alan Lewis Reference prices " + "\n strike : " + strike + "\n option type: " + type + "\n engine type: " + k @@ -1255,7 +1297,11 @@ public void testExpansionOnAlanLewisReference() } } - [TestMethod()] +#if QL_DOTNET_FRAMEWORK + [TestMethod()] +#else + [Fact] +#endif public void testExpansionOnFordeReference() { // Testing expansion on Forde reference prices @@ -1357,7 +1403,7 @@ public void testExpansionOnFordeReference() double refTol = strike == forward ? tolAtm[k][j] : tol[k][j]; if (relError > refTol) { - Assert.Fail( "failed to reproduce Forde reference vols " + QAssert.Fail( "failed to reproduce Forde reference vols " + "\n strike : " + strike + "\n expansion type: " + k + "\n rel. error : " + relError); diff --git a/Test/T_HybridHestonHullWhiteProcess.cs b/Test/T_HybridHestonHullWhiteProcess.cs index 1330a7715..7e1c45bbf 100644 --- a/Test/T_HybridHestonHullWhiteProcess.cs +++ b/Test/T_HybridHestonHullWhiteProcess.cs @@ -16,20 +16,54 @@ using System; using System.Collections.Generic; using System.Linq; +#if QL_DOTNET_FRAMEWORK using Microsoft.VisualStudio.TestTools.UnitTesting; +#else + using Xunit; +#endif using QLNet; namespace TestSuite { +#if QL_DOTNET_FRAMEWORK [TestClass()] - public class T_HybridHestonHullWhiteProcess +#endif + public class T_HybridHestonHullWhiteProcess : IDisposable { - [TestMethod()] + #region Initialize&Cleanup + private SavedSettings backup; + #if QL_DOTNET_FRAMEWORK + [TestInitialize] + public void testInitialize() + { + #else + public T_HybridHestonHullWhiteProcess() + { + #endif + + backup = new SavedSettings(); + } + #if QL_DOTNET_FRAMEWORK + [TestCleanup] + #endif + public void testCleanup() + { + Dispose(); + } + public void Dispose() + { + backup.Dispose(); + } + #endregion + +#if QL_DOTNET_FRAMEWORK + [TestMethod()] +#else + [Fact] +#endif public void testBsmHullWhiteEngine() { // Testing European option pricing for a BSM process with one-factor Hull-White model - SavedSettings backup = new SavedSettings(); - DayCounter dc = new Actual365Fixed(); Date today = Date.Today; @@ -81,48 +115,51 @@ public void testBsmHullWhiteEngine() if (Math.Abs(impliedVol - expectedVol[i]) > tol) { - Assert.Fail("Failed to reproduce implied volatility" + QAssert.Fail("Failed to reproduce implied volatility" + "\n calculated: " + impliedVol + "\n expected : " + expectedVol[i]); } if (Math.Abs((comp.NPV() - npv)/npv) > tol) { - Assert.Fail("Failed to reproduce NPV" + QAssert.Fail("Failed to reproduce NPV" + "\n calculated: " + npv + "\n expected : " + comp.NPV()); } if (Math.Abs(comp.delta() - option.delta()) > tol) { - Assert.Fail("Failed to reproduce NPV" + QAssert.Fail("Failed to reproduce NPV" + "\n calculated: " + npv + "\n expected : " + comp.NPV()); } if (Math.Abs((comp.gamma() - option.gamma())/npv) > tol) { - Assert.Fail("Failed to reproduce NPV" + QAssert.Fail("Failed to reproduce NPV" + "\n calculated: " + npv + "\n expected : " + comp.NPV()); } if (Math.Abs((comp.theta() - option.theta())/npv) > tol) { - Assert.Fail("Failed to reproduce NPV" + QAssert.Fail("Failed to reproduce NPV" + "\n calculated: " + npv + "\n expected : " + comp.NPV()); } if (Math.Abs((comp.vega() - option.vega())/npv) > tol) { - Assert.Fail("Failed to reproduce NPV" + QAssert.Fail("Failed to reproduce NPV" + "\n calculated: " + npv + "\n expected : " + comp.NPV()); } } } - [TestMethod()] - public void testCompareBsmHWandHestonHW() +#if QL_DOTNET_FRAMEWORK + [TestMethod()] +#else + [Fact] +#endif + public void testCompareBsmHWandHestonHW() { // Comparing European option pricing for a BSM process with one-factor Hull-White model - SavedSettings backup = new SavedSettings(); DayCounter dc = new Actual365Fixed(); Date today = Date.Today; Settings.setEvaluationDate(today); @@ -192,7 +229,7 @@ public void testCompareBsmHWandHestonHW() if (Math.Abs(calculated - expected) > calculated*tol && Math.Abs(calculated - expected) > tol) { - Assert.Fail("Failed to reproduce npvs" + QAssert.Fail("Failed to reproduce npvs" + "\n calculated: " + calculated + "\n expected : " + expected + "\n strike : " + strike[j] @@ -205,11 +242,14 @@ public void testCompareBsmHWandHestonHW() } } - [TestMethod()] - public void testZeroBondPricing() +#if QL_DOTNET_FRAMEWORK + [TestMethod()] +#else + [Fact] +#endif + public void testZeroBondPricing() { // Testing Monte-Carlo zero bond pricing - SavedSettings backup = new SavedSettings(); DayCounter dc = new Actual360(); Date today = Date.Today; @@ -303,7 +343,7 @@ double zeroBond if (Math.Abs(calculated - expected) > 0.03) { - Assert.Fail("Failed to reproduce expected zero bond prices" + QAssert.Fail("Failed to reproduce expected zero bond prices" + "\n t: " + t + "\n calculated: " + calculated + "\n expected: " + expected); @@ -316,7 +356,7 @@ double zeroBond if (Math.Abs(calculated - expected) > 0.0035) { - Assert.Fail("Failed to reproduce expected zero bond option prices" + QAssert.Fail("Failed to reproduce expected zero bond option prices" + "\n t: " + t + "\n T: " + T + "\n calculated: " + calculated @@ -324,14 +364,15 @@ double zeroBond } } } - - [TestMethod()] - public void testMcVanillaPricing() + +#if QL_DOTNET_FRAMEWORK + [TestMethod()] +#else + [Fact] +#endif + public void testMcVanillaPricing() { // Testing Monte-Carlo vanilla option pricing - - SavedSettings backup = new SavedSettings(); - DayCounter dc = new Actual360(); Date today = Date.Today; @@ -405,7 +446,7 @@ public void testMcVanillaPricing() if ((corr[i] != 0.0 && Math.Abs(calculated - expected) > 3*error) || (corr[i] == 0.0 && Math.Abs(calculated - expected) > 1e-4)) { - Assert.Fail("Failed to reproduce BSM-HW vanilla prices" + QAssert.Fail("Failed to reproduce BSM-HW vanilla prices" + "\n corr: " + corr[i] + "\n strike: " + strike[j] + "\n calculated: " + calculated @@ -416,13 +457,14 @@ public void testMcVanillaPricing() } } - [TestMethod()] - public void testMcPureHestonPricing() +#if QL_DOTNET_FRAMEWORK + [TestMethod()] +#else + [Fact] +#endif + public void testMcPureHestonPricing() { // Testing Monte-Carlo Heston option pricing - - SavedSettings backup = new SavedSettings(); - DayCounter dc = new Actual360(); Date today = Date.Today; @@ -488,7 +530,7 @@ public void testMcPureHestonPricing() if (Math.Abs(calculated - expected) > 3*error && Math.Abs(calculated - expected) > tol) { - Assert.Fail("Failed to reproduce pure heston vanilla prices" + QAssert.Fail("Failed to reproduce pure heston vanilla prices" + "\n corr: " + corr[i] + "\n strike: " + strike[j] + "\n calculated: " + calculated @@ -499,13 +541,14 @@ public void testMcPureHestonPricing() } } - [TestMethod()] - public void testAnalyticHestonHullWhitePricing() +#if QL_DOTNET_FRAMEWORK + [TestMethod()] +#else + [Fact] +#endif + public void testAnalyticHestonHullWhitePricing() { // Testing analytic Heston Hull-White option pricing - - SavedSettings backup = new SavedSettings(); - DayCounter dc = new Actual360(); Date today = Date.Today; @@ -571,7 +614,7 @@ public void testAnalyticHestonHullWhitePricing() if (Math.Abs(calculated - expected) > 3*error && Math.Abs(calculated - expected) > tol) { - Assert.Fail("Failed to reproduce hw heston vanilla prices" + QAssert.Fail("Failed to reproduce hw heston vanilla prices" + "\n strike: " + strike[j] + "\n calculated: " + calculated + "\n error: " + error @@ -581,19 +624,21 @@ public void testAnalyticHestonHullWhitePricing() } } - [TestMethod()] - public void testCallableEquityPricing() +#if QL_DOTNET_FRAMEWORK + [TestMethod()] +#else + [Fact] +#endif + public void testCallableEquityPricing() { // Testing the pricing of a callable equity product - SavedSettings backup = new SavedSettings(); - - /* - For the definition of the example product see - Alexander Giese, On the Pricing of Auto-Callable Equity - Structures in the Presence of Stochastic Volatility and - Stochastic Interest Rates . - http://workshop.mathfinance.de/2006/papers/giese/slides.pdf + /* + For the definition of the example product see + Alexander Giese, On the Pricing of Auto-Callable Equity + Structures in the Presence of Stochastic Volatility and + Stochastic Interest Rates . + http://workshop.mathfinance.de/2006/papers/giese/slides.pdf */ int maturity = 7; @@ -632,7 +677,7 @@ Stochastic Interest Rates . } ulong seed = 42; - IRNG rsg = (InverseCumulativeRsg + IRNG rsg = (InverseCumulativeRsg ,InverseCumulativeNormal>) new PseudoRandom().make_sequence_generator(jointProcess.factors()*(grid.size() - 1), seed); @@ -689,19 +734,21 @@ Stochastic Interest Rates . if (Math.Abs(expected - calculated) > 3*error) { - Assert.Fail("Failed to reproduce auto-callable equity structure price" + QAssert.Fail("Failed to reproduce auto-callable equity structure price" + "\n calculated: " + calculated + "\n error: " + error + "\n expected: " + expected); } } - [TestMethod()] - public void testDiscretizationError() +#if QL_DOTNET_FRAMEWORK + [TestMethod()] +#else + [Fact] +#endif + public void testDiscretizationError() { // Testing the discretization error of the Heston Hull-White process - SavedSettings backup = new SavedSettings(); - DayCounter dc = new Actual360(); Date today = Date.Today; @@ -772,7 +819,7 @@ public void testDiscretizationError() if ((Math.Abs(calculated - expected) > 3*error && Math.Abs(calculated - expected) > 1e-5)) { - Assert.Fail("Failed to reproduce discretization error" + QAssert.Fail("Failed to reproduce discretization error" + "\n corr: " + corr[i] + "\n strike: " + strike[j] + "\n calculated: " + calculated @@ -783,15 +830,18 @@ public void testDiscretizationError() } } - [TestMethod()] - public void testH1HWPricingEngine() +#if QL_DOTNET_FRAMEWORK + [TestMethod()] +#else + [Fact] +#endif + public void testH1HWPricingEngine() { - SavedSettings backup = new SavedSettings(); - /* - * Example taken from Lech Aleksander Grzelak, - * Equity and Foreign Exchange Hybrid Models for Pricing Long-Maturity - * Financial Derivatives, - * http://repository.tudelft.nl/assets/uuid:a8e1a007-bd89-481a-aee3-0e22f15ade6b/PhDThesis_main.pdf + /* + * Example taken from Lech Aleksander Grzelak, + * Equity and Foreign Exchange Hybrid Models for Pricing Long-Maturity + * Financial Derivatives, + * http://repository.tudelft.nl/assets/uuid:a8e1a007-bd89-481a-aee3-0e22f15ade6b/PhDThesis_main.pdf */ Date today = new Date(15, Month.July, 2012); Settings.setEvaluationDate(today); @@ -847,7 +897,7 @@ public void testH1HWPricingEngine() if (Math.Abs(expected[j][i] - impliedH1HW) > tol) { - Assert.Fail("Failed to reproduce H1HW implied volatility" + QAssert.Fail("Failed to reproduce H1HW implied volatility" + "\n expected : " + expected[j][i] + "\n calculated : " + impliedH1HW + "\n tol : " + tol diff --git a/Test/T_Inflation.cs b/Test/T_Inflation.cs index fd1f27c2a..9c3b0fb14 100644 --- a/Test/T_Inflation.cs +++ b/Test/T_Inflation.cs @@ -1,5 +1,5 @@ /* - Copyright (C) 2008, 2009 , 2010 Andrea Maggiulli (a.maggiulli@gmail.com) + Copyright (C) 2008-2016 Andrea Maggiulli (a.maggiulli@gmail.com) This file is part of QLNet Project https://github.com/amaggiulli/qlnet @@ -17,7 +17,11 @@ under the terms of the QLNet license. You should have received a FOR A PARTICULAR PURPOSE. See the license for more details. */ +#if QL_DOTNET_FRAMEWORK using Microsoft.VisualStudio.TestTools.UnitTesting; +#else + using Xunit; +#endif using QLNet; using System; using System.Collections.Generic; @@ -40,7 +44,9 @@ public Datum(Date d, double r) // zero inflation tests, index, termstructure, and swaps //=========================================================================================== +#if QL_DOTNET_FRAMEWORK [TestClass()] +#endif public class T_Inflation { private YieldTermStructure nominalTermStructure() @@ -85,7 +91,11 @@ private List> makeHelpers(Datum[] iiD return instruments; } - [TestMethod()] +#if QL_DOTNET_FRAMEWORK + [TestMethod()] +#else + [Fact] +#endif public void testZeroIndex() { // Testing zero inflation indices... @@ -97,7 +107,7 @@ public void testZeroIndex() || !euhicp.interpolated() || euhicp.availabilityLag() != new Period(1, TimeUnit.Months)) { - Assert.Fail("wrong EU HICP data (" + QAssert.Fail("wrong EU HICP data (" + euhicp.name() + ", " + euhicp.frequency() + ", " + euhicp.revised() + ", " @@ -112,7 +122,7 @@ public void testZeroIndex() || ukrpi.interpolated() || ukrpi.availabilityLag() != new Period(1, TimeUnit.Months)) { - Assert.Fail("wrong UK RPI data (" + QAssert.Fail("wrong UK RPI data (" + ukrpi.name() + ", " + ukrpi.frequency() + ", " + ukrpi.revised() + ", " @@ -168,7 +178,7 @@ public void testZeroIndex() if (d < Utils.inflationPeriod(todayMinusLag, iir.frequency()).Key) { if (Math.Abs(iir.fixing(d) - fixData[i]) > eps) - Assert.Fail("Fixings not constant within a period: " + QAssert.Fail("Fixings not constant within a period: " + iir.fixing(d) + ", should be " + fixData[i]); } @@ -176,7 +186,11 @@ public void testZeroIndex() } } - [TestMethod()] +#if QL_DOTNET_FRAMEWORK + [TestMethod()] +#else + [Fact] +#endif public void testZeroTermStructure() { // Testing zero inflation term structure... @@ -256,7 +270,7 @@ public void testZeroTermStructure() bool forceLinearInterpolation = false; for (int i = 0; i < zcData.Length; i++) { - Assert.IsTrue(Math.Abs(zcData[i].rate / 100.0 + QAssert.IsTrue(Math.Abs(zcData[i].rate / 100.0 - pZITS.zeroRate(zcData[i].date, observationLag, forceLinearInterpolation)) < eps, "ZITS zeroRate != instrument " + pZITS.zeroRate(zcData[i].date, observationLag, forceLinearInterpolation) @@ -264,7 +278,7 @@ public void testZeroTermStructure() + " interpolation: " + ii.interpolated() + " forceLinearInterpolation " + forceLinearInterpolation); - Assert.IsTrue(Math.Abs(helpers[i].impliedQuote() + QAssert.IsTrue(Math.Abs(helpers[i].impliedQuote() - zcData[i].rate / 100.0) < eps, "ZITS implied quote != instrument " + helpers[i].impliedQuote() @@ -295,7 +309,7 @@ public void testZeroTermStructure() if (t <= 0) calc = ii.fixing(d, false); // still historical if (Math.Abs(calc - ii.fixing(d, true)) / 10000.0 > eps) - Assert.Fail("ZC index does not forecast correctly for date " + d + QAssert.Fail("ZC index does not forecast correctly for date " + d + " from base date " + bd + " with fixing " + bf + ", correct: " + calc @@ -317,7 +331,7 @@ public void testZeroTermStructure() IndexedCashFlow iicf = new IndexedCashFlow(notional, ind, baseDate, fixDate, payDate); double correctIndexed = ii.fixing(iicf.fixingDate()) / ii.fixing(iicf.baseDate()); double calculatedIndexed = iicf.amount() / iicf.notional(); - Assert.IsTrue(Math.Abs(correctIndexed - calculatedIndexed) < eps, + QAssert.IsTrue(Math.Abs(correctIndexed - calculatedIndexed) < eps, "IndexedCashFlow indexing wrong: " + calculatedIndexed + " vs correct = " + correctIndexed); @@ -343,7 +357,7 @@ public void testZeroTermStructure() nzcis.setPricingEngine(sppe); // ... and price it, should be zero - Assert.IsTrue(Math.Abs(nzcis.NPV()) < 0.00001, "ZCIS does not reprice to zero " + QAssert.IsTrue(Math.Abs(nzcis.NPV()) < 0.00001, "ZCIS does not reprice to zero " + nzcis.NPV() + evaluationDate + " to " + zcData[6].date + " becoming " + nzcis.maturityDate() + " rate " + zcData[6].rate @@ -420,7 +434,7 @@ public void testZeroTermStructure() { if (Math.Abs(fixing[i] - seasonalityFixing_1[i]) > eps) { - Assert.Fail("Seasonality doesn't work correctly when seasonality factors are set = 1"); + QAssert.Fail("Seasonality doesn't work correctly when seasonality factors are set = 1"); } } @@ -464,7 +478,7 @@ public void testZeroTermStructure() { if (Math.Abs(expectedFixing[i] - seasonalityFixing_real[i]) > 0.01) { - Assert.Fail("Seasonality doesn't work correctly when considering seasonality factors != 1 " + QAssert.Fail("Seasonality doesn't work correctly when considering seasonality factors != 1 " + expectedFixing[i] + " vs " + seasonalityFixing_real[i]); } } @@ -494,7 +508,7 @@ public void testZeroTermStructure() { if (Math.Abs(seasonalityFixing_unset[i] - seasonalityFixing_1[i]) > eps) { - Assert.Fail("UnsetSeasonality doesn't work correctly " + QAssert.Fail("UnsetSeasonality doesn't work correctly " + seasonalityFixing_unset[i] + " vs " + seasonalityFixing_1[i]); } } @@ -531,7 +545,7 @@ public void testZeroTermStructure() forceLinearInterpolation = false; // still for (int i = 0; i < zcData.Length; i++) { - Assert.IsTrue(Math.Abs(zcData[i].rate / 100.0 + QAssert.IsTrue(Math.Abs(zcData[i].rate / 100.0 - pZITSyes.zeroRate(zcData[i].date, observationLagyes, forceLinearInterpolation)) < eps, "ZITS INTERPOLATED zeroRate != instrument " + pZITSyes.zeroRate(zcData[i].date, observationLagyes, forceLinearInterpolation) @@ -539,7 +553,7 @@ public void testZeroTermStructure() + " vs " + zcData[i].rate / 100.0 + " interpolation: " + iiyes.interpolated() + " forceLinearInterpolation " + forceLinearInterpolation); - Assert.IsTrue(Math.Abs(helpersyes[i].impliedQuote() + QAssert.IsTrue(Math.Abs(helpersyes[i].impliedQuote() - zcData[i].rate / 100.0) < eps, "ZITS INTERPOLATED implied quote != instrument " + helpersyes[i].impliedQuote() @@ -567,7 +581,7 @@ public void testZeroTermStructure() double calc = bf * Math.Pow(1 + z, t); if (t <= 0) calc = iiyes.fixing(d); // still historical if (Math.Abs(calc - iiyes.fixing(d)) > eps) - Assert.Fail("ZC INTERPOLATED index does not forecast correctly for date " + d + QAssert.Fail("ZC INTERPOLATED index does not forecast correctly for date " + d + " from base date " + bd + " with fixing " + bf + ", correct: " + calc @@ -593,7 +607,7 @@ public void testZeroTermStructure() nzcisyes.setPricingEngine(sppe); // ... and price it, should be zero - Assert.IsTrue(Math.Abs(nzcisyes.NPV()) < 0.00001, "ZCIS-I does not reprice to zero " + QAssert.IsTrue(Math.Abs(nzcisyes.NPV()) < 0.00001, "ZCIS-I does not reprice to zero " + nzcisyes.NPV() + evaluationDate + " to " + zcData[6].date + " becoming " + nzcisyes.maturityDate() + " rate " + zcData[6].rate @@ -603,14 +617,18 @@ public void testZeroTermStructure() ); // remove circular refernce - hz.linkTo(new ZeroInflationTermStructure()); + hz.linkTo(null); } } //=========================================================================================== // year on year tests, index, termstructure, and swaps //=========================================================================================== - [TestMethod()] +#if QL_DOTNET_FRAMEWORK + [TestMethod()] +#else + [Fact] +#endif public void testYYIndex() { // Testing year-on-year inflation indices @@ -627,7 +645,7 @@ public void testYYIndex() || yyeuhicp.ratio() || yyeuhicp.availabilityLag() != new Period(1, TimeUnit.Months)) { - Assert.Fail("wrong year-on-year EU HICP data (" + QAssert.Fail("wrong year-on-year EU HICP data (" + yyeuhicp.name() + ", " + yyeuhicp.frequency() + ", " + yyeuhicp.revised() + ", " @@ -644,7 +662,7 @@ public void testYYIndex() || !yyeuhicpr.ratio() || yyeuhicpr.availabilityLag() != new Period(1, TimeUnit.Months)) { - Assert.Fail("wrong year-on-year EU HICPr data (" + QAssert.Fail("wrong year-on-year EU HICPr data (" + yyeuhicpr.name() + ", " + yyeuhicpr.frequency() + ", " + yyeuhicpr.revised() + ", " @@ -661,7 +679,7 @@ public void testYYIndex() || yyukrpi.ratio() || yyukrpi.availabilityLag() != new Period(1, TimeUnit.Months)) { - Assert.Fail("wrong year-on-year UK RPI data (" + QAssert.Fail("wrong year-on-year UK RPI data (" + yyukrpi.name() + ", " + yyukrpi.frequency() + ", " + yyukrpi.revised() + ", " @@ -678,7 +696,7 @@ public void testYYIndex() || !yyukrpir.ratio() || yyukrpir.availabilityLag() != new Period(1, TimeUnit.Months)) { - Assert.Fail("wrong year-on-year UK RPIr data (" + QAssert.Fail("wrong year-on-year UK RPIr data (" + yyukrpir.name() + ", " + yyukrpir.frequency() + ", " + yyukrpir.revised() + ", " @@ -737,7 +755,7 @@ public void testYYIndex() { double expected = fixData[i] / fixData[i - 12] - 1.0; double calculated = iir.fixing(d); - Assert.IsTrue(Math.Abs(calculated - expected) < eps, + QAssert.IsTrue(Math.Abs(calculated - expected) < eps, "Non-interpolated fixings not constant within a period: " + calculated + ", should be " @@ -754,7 +772,7 @@ public void testYYIndex() double linearBef = fixData[i - 12] + (fixData[i + 1 - 12] - fixData[i - 12]) * dlBef / dpBef; double expectedYES = linearNow / linearBef - 1.0; double calculatedYES = iirYES.fixing(d); - Assert.IsTrue(Math.Abs(expectedYES - calculatedYES) < eps, + QAssert.IsTrue(Math.Abs(expectedYES - calculatedYES) < eps, "Error in interpolated fixings: expect " + expectedYES + " see " + calculatedYES + " flat " + calculated @@ -771,7 +789,11 @@ public void testYYIndex() } - [TestMethod()] +#if QL_DOTNET_FRAMEWORK + [TestMethod()] +#else + [Fact] +#endif public void testYYTermStructure() { // Testing year-on-year inflation term structure... @@ -879,7 +901,7 @@ public void testYYTermStructure() yyS2.setPricingEngine(sppe); - Assert.IsTrue(Math.Abs(yyS2.NPV()) < eps, "fresh yoy swap NPV!=0 from TS " + QAssert.IsTrue(Math.Abs(yyS2.NPV()) < eps, "fresh yoy swap NPV!=0 from TS " + "swap quote for pt " + j + ", is " + yyData[j].rate / 100.0 + " vs YoY rate " + pYYTS.yoyRate(yyData[j].date - observationLag) @@ -915,14 +937,14 @@ public void testYYTermStructure() yyS3.setPricingEngine(sppe); - Assert.IsTrue(Math.Abs(yyS3.NPV()) < 20000.0, + QAssert.IsTrue(Math.Abs(yyS3.NPV()) < 20000.0, "unexpected size of aged YoY swap, aged " + k + " months: YY aged NPV = " + yyS3.NPV() + ", legs " + yyS3.legNPV(0) + " and " + yyS3.legNPV(1) ); } // remove circular refernce - hy.linkTo(new YoYInflationTermStructure()); + hy.linkTo(null); } } } diff --git a/Test/T_InflationCapFloorTest.cs b/Test/T_InflationCapFloorTest.cs index 62e0d10d8..9621feff3 100644 --- a/Test/T_InflationCapFloorTest.cs +++ b/Test/T_InflationCapFloorTest.cs @@ -1,5 +1,5 @@ /* - Copyright (C) 2008-2014 Andrea Maggiulli (a.maggiulli@gmail.com) + Copyright (C) 2008-2016 Andrea Maggiulli (a.maggiulli@gmail.com) This file is part of QLNet Project https://github.com/amaggiulli/qlnet @@ -18,14 +18,44 @@ under the terms of the QLNet license. You should have received a */ using System; using System.Collections.Generic; +#if QL_DOTNET_FRAMEWORK using Microsoft.VisualStudio.TestTools.UnitTesting; +#else + using Xunit; +#endif using QLNet; namespace TestSuite { - [TestClass()] - public class T_InflationCapFloorTest +#if QL_DOTNET_FRAMEWORK + [TestClass()] +#endif + public class T_InflationCapFloorTest : IDisposable { + #region Initialize&Cleanup + private SavedSettings backup; + #if QL_DOTNET_FRAMEWORK + [TestInitialize] + public void testInitialize() + { + #else + public T_InflationCapFloorTest() + { + #endif + backup = new SavedSettings(); + } + #if QL_DOTNET_FRAMEWORK + [TestCleanup] + #endif + public void testCleanup() + { + Dispose(); + } + public void Dispose() + { + backup.Dispose(); + } + #endregion class CommonVars { @@ -47,10 +77,6 @@ class CommonVars public YoYInflationTermStructure yoyTS; public RelinkableHandle hy = new RelinkableHandle(); - // cleanup - - SavedSettings backup = new SavedSettings(); - // setup public CommonVars() { @@ -177,7 +203,7 @@ public IPricingEngine makeEngine(double volatility,int which) return new YoYInflationBachelierCapFloorEngine(iir, vol); //break; default: - Assert.Fail("unknown engine request: which = "+which + QAssert.Fail("unknown engine request: which = "+which +"should be 0=Black,1=DD,2=Bachelier"); break; } @@ -230,7 +256,11 @@ private List> makeHelpers( Datum[] ii } } - [TestMethod()] +#if QL_DOTNET_FRAMEWORK + [TestMethod()] +#else + [Fact] +#endif public void testConsistency() { // Testing consistency between yoy inflation cap,floor and collar... @@ -267,7 +297,7 @@ public void testConsistency() if (Math.Abs((cap.NPV()-floor.NPV())-collar.NPV()) > 1e-6) { - Assert.Fail( + QAssert.Fail( "inconsistency between cap, floor and collar:\n" + " length: " + lengths[i] + " years\n" + " volatility: " + "\n" @@ -290,7 +320,7 @@ public void testConsistency() if (Math.Abs(cap.NPV() - capletsNPV) > 1e-6) { - Assert.Fail( + QAssert.Fail( "sum of caplet NPVs does not equal cap NPV:\n" + " length: " + lengths[i] + " years\n" + " volatility: " + "\n" @@ -312,7 +342,7 @@ public void testConsistency() if (Math.Abs(floor.NPV() - floorletsNPV) > 1e-6) { - Assert.Fail( + QAssert.Fail( "sum of floorlet NPVs does not equal floor NPV:\n" + " length: " + lengths[i] + " years\n" + " volatility: " + "\n" @@ -334,7 +364,7 @@ public void testConsistency() if (Math.Abs(collar.NPV() - collarletsNPV) > 1e-6) { - Assert.Fail( + QAssert.Fail( "sum of collarlet NPVs does not equal floor NPV:\n" + " length: " + lengths[i] + " years\n" + " volatility: " + vols[l] + "\n" @@ -352,7 +382,7 @@ public void testConsistency() } } // pricer loop // remove circular refernce - vars.hy.linkTo(new YoYInflationTermStructure()); + vars.hy.linkTo(null); } // Test inflation cap/floor parity, i.e. that cap-floor = swap, note that this @@ -362,7 +392,11 @@ public void testConsistency() // (actually in arrears with a lag of a few months) thus the first optionlet // is relevant. Hence we can do a parity test without a special definition // of the YoY cap/floor instrument. - [TestMethod()] +#if QL_DOTNET_FRAMEWORK + [TestMethod()] +#else + [Fact] +#endif public void testParity() { @@ -416,7 +450,7 @@ public void testParity() // N.B. nominals are 10e6 if (Math.Abs((cap.NPV()-floor.NPV()) - swap.NPV()) > 1.0e-6) { - Assert.Fail( + QAssert.Fail( "put/call parity violated:\n" + " length: " + lengths[i] + " years\n" + " volatility: " + vols[k] + "\n" @@ -430,11 +464,15 @@ public void testParity() } } // remove circular refernce - vars.hy.linkTo(new YoYInflationTermStructure()); + vars.hy.linkTo(null); } - - [TestMethod()] + +#if QL_DOTNET_FRAMEWORK + [TestMethod()] +#else + [Fact] +#endif public void testCachedValue() { // Testing Black yoy inflation cap/floor price against cached values... @@ -454,10 +492,10 @@ public void testCachedValue() double cachedCapNPVblack = 219.452; double cachedFloorNPVblack = 314.641; // N.B. notionals are 10e6. - Assert.IsTrue(Math.Abs(cap.NPV()-cachedCapNPVblack)<0.02,"yoy cap cached NPV wrong " + QAssert.IsTrue(Math.Abs(cap.NPV()-cachedCapNPVblack)<0.02,"yoy cap cached NPV wrong " +cap.NPV()+" should be "+cachedCapNPVblack+" Black pricer" +" diff was "+(Math.Abs(cap.NPV()-cachedCapNPVblack))); - Assert.IsTrue(Math.Abs(floor.NPV()-cachedFloorNPVblack)<0.02,"yoy floor cached NPV wrong " + QAssert.IsTrue(Math.Abs(floor.NPV()-cachedFloorNPVblack)<0.02,"yoy floor cached NPV wrong " +floor.NPV()+" should be "+cachedFloorNPVblack+" Black pricer" +" diff was "+(Math.Abs(floor.NPV()-cachedFloorNPVblack))); @@ -470,10 +508,10 @@ public void testCachedValue() double cachedCapNPVdd = 9114.61; double cachedFloorNPVdd = 9209.8; // N.B. notionals are 10e6. - Assert.IsTrue(Math.Abs(cap.NPV()-cachedCapNPVdd)<0.22,"yoy cap cached NPV wrong " + QAssert.IsTrue(Math.Abs(cap.NPV()-cachedCapNPVdd)<0.22,"yoy cap cached NPV wrong " +cap.NPV()+" should be "+cachedCapNPVdd+" dd Black pricer" +" diff was "+(Math.Abs(cap.NPV()-cachedCapNPVdd))); - Assert.IsTrue(Math.Abs(floor.NPV()-cachedFloorNPVdd)<0.22,"yoy floor cached NPV wrong " + QAssert.IsTrue(Math.Abs(floor.NPV()-cachedFloorNPVdd)<0.22,"yoy floor cached NPV wrong " +floor.NPV()+" should be "+cachedFloorNPVdd+" dd Black pricer" +" diff was "+(Math.Abs(floor.NPV()-cachedFloorNPVdd))); @@ -486,15 +524,15 @@ public void testCachedValue() double cachedCapNPVbac = 8852.4; double cachedFloorNPVbac = 8947.59; // N.B. notionals are 10e6. - Assert.IsTrue(Math.Abs(cap.NPV()-cachedCapNPVbac)<0.22,"yoy cap cached NPV wrong " + QAssert.IsTrue(Math.Abs(cap.NPV()-cachedCapNPVbac)<0.22,"yoy cap cached NPV wrong " +cap.NPV()+" should be "+cachedCapNPVbac+" bac Black pricer" +" diff was "+(Math.Abs(cap.NPV()-cachedCapNPVbac))); - Assert.IsTrue(Math.Abs(floor.NPV()-cachedFloorNPVbac)<0.22,"yoy floor cached NPV wrong " + QAssert.IsTrue(Math.Abs(floor.NPV()-cachedFloorNPVbac)<0.22,"yoy floor cached NPV wrong " +floor.NPV()+" should be "+cachedFloorNPVbac+" bac Black pricer" +" diff was "+(Math.Abs(floor.NPV()-cachedFloorNPVbac))); // remove circular refernce - vars.hy.linkTo(new YoYInflationTermStructure()); + vars.hy.linkTo(null); } } diff --git a/Test/T_InflationCapFlooredCouponTest.cs b/Test/T_InflationCapFlooredCouponTest.cs index 6d98be15d..2d78c235e 100644 --- a/Test/T_InflationCapFlooredCouponTest.cs +++ b/Test/T_InflationCapFlooredCouponTest.cs @@ -1,5 +1,5 @@ /* - Copyright (C) 2008-2014 Andrea Maggiulli (a.maggiulli@gmail.com) + Copyright (C) 2008-2016 Andrea Maggiulli (a.maggiulli@gmail.com) This file is part of QLNet Project https://github.com/amaggiulli/qlnet @@ -18,14 +18,45 @@ under the terms of the QLNet license. You should have received a */ using System; using System.Collections.Generic; +#if QL_DOTNET_FRAMEWORK using Microsoft.VisualStudio.TestTools.UnitTesting; +#else + using Xunit; +#endif using QLNet; namespace TestSuite { - [TestClass()] - public class T_InflationCapFlooredCouponTest +#if QL_DOTNET_FRAMEWORK + [TestClass()] +#endif + public class T_InflationCapFlooredCouponTest : IDisposable { + #region Initialize&Cleanup + private SavedSettings backup; + #if QL_DOTNET_FRAMEWORK + [TestInitialize] + public void testInitialize() + { + #else + public T_InflationCapFlooredCouponTest() + { + #endif + backup = new SavedSettings(); + } + #if QL_DOTNET_FRAMEWORK + [TestCleanup] + #endif + public void testCleanup() + { + Dispose(); + } + public void Dispose() + { + backup.Dispose(); + } + #endregion + class CommonVars { // common data @@ -49,10 +80,6 @@ class CommonVars public YoYInflationTermStructure yoyTS; public RelinkableHandle hy = new RelinkableHandle(); - // cleanup - - SavedSettings backup = new SavedSettings(); - // setup public CommonVars() { @@ -202,7 +229,7 @@ public List makeYoYCapFlooredLeg(int which, Date startDate, pricer = new BachelierYoYInflationCouponPricer(vol); break; default: - Assert.Fail("unknown coupon pricer request: which = "+which + QAssert.Fail("unknown coupon pricer request: which = "+which +"should be 0=Black,1=DD,2=Bachelier"); break; } @@ -264,7 +291,7 @@ public IPricingEngine makeEngine(double volatility, int which) return new YoYInflationBachelierCapFloorEngine(iir, vol); //break; default: - Assert.Fail("unknown engine request: which = "+which + QAssert.Fail("unknown engine request: which = "+which +"should be 0=Black,1=DD,2=Bachelier"); break; } @@ -319,7 +346,11 @@ private List> makeHelpers( Datum[] ii } } - [TestMethod()] +#if QL_DOTNET_FRAMEWORK + [TestMethod()] +#else + [Fact] +#endif public void testDecomposition() { // Testing collared coupon against its decomposition... @@ -382,7 +413,7 @@ public void testDecomposition() error = Math.Abs(npvCappedLeg - (npvVanilla-npvCap)); if (error>tolerance) { - Assert.Fail("\nYoY Capped Leg: gearing=1, spread=0%, strike=" + capstrike*100 + + QAssert.Fail("\nYoY Capped Leg: gearing=1, spread=0%, strike=" + capstrike*100 + "%\n" + " Capped Floating Leg NPV: " + npvCappedLeg + "\n" + " Floating Leg NPV - Cap NPV: " + (npvVanilla - npvCap) + "\n" + @@ -408,7 +439,7 @@ public void testDecomposition() error = Math.Abs(npvFlooredLeg-(npvVanilla + npvFloor)); if (error>tolerance) { - Assert.Fail("YoY Floored Leg: gearing=1, spread=0%, strike=" + floorstrike *100 + + QAssert.Fail("YoY Floored Leg: gearing=1, spread=0%, strike=" + floorstrike *100 + "%\n" + " Floored Floating Leg NPV: " + npvFlooredLeg + "\n" + " Floating Leg NPV + Floor NPV: " + (npvVanilla + npvFloor) + "\n" + @@ -434,7 +465,7 @@ public void testDecomposition() error = Math.Abs(npvCollaredLeg -(npvVanilla - npvCollar)); if (error>tolerance) { - Assert.Fail("\nYoY Collared Leg: gearing=1, spread=0%, strike=" + + QAssert.Fail("\nYoY Collared Leg: gearing=1, spread=0%, strike=" + floorstrike*100 + "% and " + capstrike*100 + "%\n" + " Collared Floating Leg NPV: " + npvCollaredLeg + "\n" + " Floating Leg NPV - Collar NPV: " + (npvVanilla - npvCollar) + "\n" + @@ -467,7 +498,7 @@ public void testDecomposition() error = Math.Abs(npvCappedLeg - (npvVanilla-npvCap)); if (error>tolerance) { - Assert.Fail("\nYoY Capped Leg: gearing=" + gearing_p + ", " + + QAssert.Fail("\nYoY Capped Leg: gearing=" + gearing_p + ", " + "spread= " + spread_p *100 + "%, strike=" + capstrike*100 + "%, " + "effective strike= " + (capstrike-spread_p)/gearing_p*100 + @@ -492,7 +523,7 @@ public void testDecomposition() error = Math.Abs(npvCappedLeg - (npvVanilla+ gearing_n*npvFloor)); if (error>tolerance) { - Assert.Fail("\nYoY Capped Leg: gearing=" + gearing_n + ", " + + QAssert.Fail("\nYoY Capped Leg: gearing=" + gearing_n + ", " + "spread= " + spread_n *100 + "%, strike=" + capstrike*100 + "%, " + "effective strike= " + ((capstrike-spread_n)/gearing_n*100) + @@ -530,7 +561,7 @@ public void testDecomposition() error = Math.Abs(npvFlooredLeg - (npvVanilla+npvFloor)); if (error>tolerance) { - Assert.Fail("\nYoY Floored Leg: gearing=" + gearing_p + ", " + QAssert.Fail("\nYoY Floored Leg: gearing=" + gearing_p + ", " + "spread= " + spread_p *100+ "%, strike=" + floorstrike *100 + "%, " + "effective strike= " + (floorstrike-spread_p)/gearing_p*100 + "%\n" + @@ -553,7 +584,7 @@ public void testDecomposition() error = Math.Abs(npvFlooredLeg - (npvVanilla - gearing_n*npvCap)); if (error>tolerance) { - Assert.Fail("\nYoY Capped Leg: gearing=" + gearing_n + ", " + + QAssert.Fail("\nYoY Capped Leg: gearing=" + gearing_n + ", " + "spread= " + spread_n *100 + "%, strike=" + floorstrike*100 + "%, " + "effective strike= " + (floorstrike-spread_n)/gearing_n*100 + @@ -585,7 +616,7 @@ public void testDecomposition() error = Math.Abs(npvCollaredLeg - (npvVanilla - npvCollar)); if (error>tolerance) { - Assert.Fail("\nYoY Collared Leg: gearing=" + gearing_p + ", " + QAssert.Fail("\nYoY Collared Leg: gearing=" + gearing_p + ", " + "spread= " + spread_p*100 + "%, strike=" + floorstrike*100 + "% and " + capstrike*100 + "%, " @@ -613,7 +644,7 @@ public void testDecomposition() error = Math.Abs(npvCollaredLeg - (npvVanilla - gearing_n*npvCollar)); if (error>tolerance) { - Assert.Fail("\nYoY Collared Leg: gearing=" + gearing_n + ", " + QAssert.Fail("\nYoY Collared Leg: gearing=" + gearing_n + ", " + "spread= " + spread_n*100 + "%, strike=" + floorstrike*100 + "% and " + capstrike*100 + "%, " @@ -627,10 +658,14 @@ public void testDecomposition() " Diff: " + error ); } // remove circular refernce - vars.hy.linkTo(new YoYInflationTermStructure()); + vars.hy.linkTo(null); } - [TestMethod()] +#if QL_DOTNET_FRAMEWORK + [TestMethod()] +#else + [Fact] +#endif public void testInstrumentEquality() { @@ -704,7 +739,7 @@ public void testInstrumentEquality() double capped = CashFlows.npv(leg2,vars.nominalTS,false); if ( Math.Abs(capped - (swap.NPV() - cap.NPV())) > 1.0e-6) { - Assert.Fail( + QAssert.Fail( "capped coupon != swap(0) - cap:\n" + " length: " + lengths[i] + " years\n" + " volatility: " + vols[k] + "\n" @@ -719,7 +754,7 @@ public void testInstrumentEquality() double floored = CashFlows.npv(leg3,vars.nominalTS,false); if ( Math.Abs(floored - (swap.NPV() + floor.NPV())) > 1.0e-6) { - Assert.Fail( + QAssert.Fail( "floored coupon != swap(0) + floor :\n" + " length: " + lengths[i] + " years\n" + " volatility: " + vols[k] + "\n" @@ -734,7 +769,7 @@ public void testInstrumentEquality() } // remove circular refernce - vars.hy.linkTo(new YoYInflationTermStructure()); + vars.hy.linkTo(null); } } } diff --git a/Test/T_Instruments.cs b/Test/T_Instruments.cs index d9b1b625e..9125511a2 100644 --- a/Test/T_Instruments.cs +++ b/Test/T_Instruments.cs @@ -15,17 +15,27 @@ under the terms of the QLNet license. You should have received a This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the license for more details. -*/ - -using Microsoft.VisualStudio.TestTools.UnitTesting; +*/ + +#if QL_DOTNET_FRAMEWORK +using Microsoft.VisualStudio.TestTools.UnitTesting; +#else + using Xunit; +#endif using QLNet; namespace TestSuite -{ - [TestClass()] +{ +#if QL_DOTNET_FRAMEWORK + [TestClass()] +#endif public class T_Instruments - { - [TestMethod()] + { +#if QL_DOTNET_FRAMEWORK + [TestMethod()] +#else + [Fact] +#endif public void testObservable() { //.("Testing observability of instruments..."); @@ -41,25 +51,25 @@ public void testObservable() s.NPV(); me1.setValue(3.14); if (!f.isUp()) - Assert.Fail("Observer was not notified of instrument change"); + QAssert.Fail("Observer was not notified of instrument change"); s.NPV(); f.lower(); SimpleQuote me2 = new SimpleQuote(0.0); h.linkTo(me2); if (!f.isUp()) - Assert.Fail("Observer was not notified of instrument change"); + QAssert.Fail("Observer was not notified of instrument change"); f.lower(); s.freeze(); s.NPV(); me2.setValue(2.71); if (f.isUp()) - Assert.Fail("Observer was notified of frozen instrument change"); + QAssert.Fail("Observer was notified of frozen instrument change"); s.NPV(); s.unfreeze(); if (!f.isUp()) - Assert.Fail("Observer was not notified of instrument change"); + QAssert.Fail("Observer was not notified of instrument change"); } public void suite() diff --git a/Test/T_InterestRate.cs b/Test/T_InterestRate.cs index 5ff8b8237..07da5b674 100644 --- a/Test/T_InterestRate.cs +++ b/Test/T_InterestRate.cs @@ -17,13 +17,19 @@ under the terms of the QLNet license. You should have received a FOR A PARTICULAR PURPOSE. See the license for more details. */ -using System; -using Microsoft.VisualStudio.TestTools.UnitTesting; +using System; +#if QL_DOTNET_FRAMEWORK +using Microsoft.VisualStudio.TestTools.UnitTesting; +#else + using Xunit; +#endif using QLNet; namespace TestSuite -{ - [TestClass()] +{ +#if QL_DOTNET_FRAMEWORK + [TestClass()] +#endif public class T_InterestRate { public struct InterestRateData @@ -49,10 +55,14 @@ public InterestRateData(double _r, Compounding _comp, Frequency _freq, double _t precision = _precision; } - }; - - - [TestMethod()] + }; + + +#if QL_DOTNET_FRAMEWORK + [TestMethod()] +#else + [Fact] +#endif public void testConversions() { InterestRateData[] cases = { @@ -120,7 +130,7 @@ public void testConversions() disc = ir.discountFactor(d1, d2); error = Math.Abs(disc - 1.0 / compoundf); if (error > 1e-15) - Assert.Fail(ir + " 1.0/compound_factor: " + 1.0 / compoundf); + QAssert.Fail(ir + " 1.0/compound_factor: " + 1.0 / compoundf); // check that the equivalent InterestRate with *same* daycounter, // compounding, and frequency is the *same* InterestRate @@ -128,13 +138,13 @@ public void testConversions() ir2 = ir.equivalentRate(ir.dayCounter(), ir.compounding(), ir.frequency(), d1, d2); error = Math.Abs(ir.rate() - ir2.rate()); if (error > 1e-15) - Assert.Fail("original interest rate: " + ir + " equivalent interest rate: " + ir2 + " rate error: " + error); + QAssert.Fail("original interest rate: " + ir + " equivalent interest rate: " + ir2 + " rate error: " + error); if (ir.dayCounter() != ir2.dayCounter()) - Assert.Fail("day counter error original interest rate: " + ir + " equivalent interest rate: " + ir2); + QAssert.Fail("day counter error original interest rate: " + ir + " equivalent interest rate: " + ir2); if (ir.compounding() != ir2.compounding()) - Assert.Fail("compounding error original interest rate: " + ir + " equivalent interest rate: " + ir2); + QAssert.Fail("compounding error original interest rate: " + ir + " equivalent interest rate: " + ir2); if (ir.frequency() != ir2.frequency()) - Assert.Fail("frequency error original interest rate: " + ir + " equivalent interest rate: " + ir2); + QAssert.Fail("frequency error original interest rate: " + ir + " equivalent interest rate: " + ir2); // check that the equivalent rate with *same* daycounter, // compounding, and frequency is the *same* rate @@ -142,7 +152,7 @@ public void testConversions() r2 = ir.equivalentRate(ir.dayCounter(), ir.compounding(), ir.frequency(),d1, d2).value(); error = Math.Abs(ir.rate() - r2); if (error > 1e-15) - Assert.Fail("original rate: " + ir + " equivalent rate: " + r2 + " error: " + error); + QAssert.Fail("original rate: " + ir + " equivalent rate: " + r2 + " error: " + error); // check that the equivalent InterestRate with *different* // compounding, and frequency is the *expected* InterestRate @@ -152,13 +162,13 @@ public void testConversions() r3 = roundingPrecision.Round(ir3.rate()); error = Math.Abs(r3 - expectedIR.rate()); if (error > 1.0e-17) - Assert.Fail("original interest rate: " + ir + " calculated equivalent interest rate: " + ir3 + " truncated equivalent rate: " + r3 + " expected equivalent interest rate: " + expectedIR + " rate error: " + error); + QAssert.Fail("original interest rate: " + ir + " calculated equivalent interest rate: " + ir3 + " truncated equivalent rate: " + r3 + " expected equivalent interest rate: " + expectedIR + " rate error: " + error); if (ir3.dayCounter() != expectedIR.dayCounter()) - Assert.Fail("day counter error original interest rate: " + ir3 + " equivalent interest rate: " + expectedIR); + QAssert.Fail("day counter error original interest rate: " + ir3 + " equivalent interest rate: " + expectedIR); if (ir3.compounding() != expectedIR.compounding()) - Assert.Fail("compounding error original interest rate: " + ir3 + " equivalent interest rate: " + expectedIR); + QAssert.Fail("compounding error original interest rate: " + ir3 + " equivalent interest rate: " + expectedIR); if (ir3.frequency() != expectedIR.frequency()) - Assert.Fail("frequency error original interest rate: " + ir3 + " equivalent interest rate: " + expectedIR); + QAssert.Fail("frequency error original interest rate: " + ir3 + " equivalent interest rate: " + expectedIR); // check that the equivalent rate with *different* // compounding, and frequency is the *expected* rate @@ -167,7 +177,7 @@ public void testConversions() r3 = roundingPrecision.Round(r3); error = Math.Abs(r3 - cases[i].expected); if (error > 1.0e-17) - Assert.Fail("calculated equivalent rate: " + r3 + " expected equivalent rate: " + cases[i].expected + " error: " + error); + QAssert.Fail("calculated equivalent rate: " + r3 + " expected equivalent rate: " + cases[i].expected + " error: " + error); } diff --git a/Test/T_Interpolations.cs b/Test/T_Interpolations.cs index af4f4cccc..138046c7d 100644 --- a/Test/T_Interpolations.cs +++ b/Test/T_Interpolations.cs @@ -19,22 +19,32 @@ under the terms of the QLNet license. You should have received a */ using System; using System.Collections.Generic; -using System.Linq; -using Microsoft.VisualStudio.TestTools.UnitTesting; +using System.Linq; +#if QL_DOTNET_FRAMEWORK +using Microsoft.VisualStudio.TestTools.UnitTesting; +#else + using Xunit; +#endif using QLNet; namespace TestSuite -{ - - [TestClass()] +{ + +#if QL_DOTNET_FRAMEWORK + [TestClass()] +#endif public class T_Interpolations { /* See J. M. Hyman, "Accurate monotonicity preserving cubic interpolation" SIAM J. of Scientific and Statistical Computing, v. 4, 1983, pp. 645-654. http://math.lanl.gov/~mac/papers/numerics/H83.pdf - */ - [TestMethod()] + */ +#if QL_DOTNET_FRAMEWORK + [TestMethod()] +#else + [Fact] +#endif public void testSplineErrorOnGaussianValues() { //("Testing spline approximation on Gaussian data sets..."); @@ -72,7 +82,7 @@ public void testSplineErrorOnGaussianValues() double result = Math.Sqrt(integral.value(make_error_function(f).value, -1.7, 1.9)); result /= scaleFactor; if (Math.Abs(result-tabulatedErrors[i]) > toleranceOnTabErr[i]) - Assert.Fail("Not-a-knot spline interpolation " + QAssert.Fail("Not-a-knot spline interpolation " + "\n sample points: " + n + "\n norm of difference: " + result + "\n it should be: " + tabulatedErrors[i]); @@ -86,7 +96,7 @@ public void testSplineErrorOnGaussianValues() result = Math.Sqrt(integral.value(make_error_function(f).value, -1.7, 1.9)); result /= scaleFactor; if (Math.Abs(result-tabulatedMCErrors[i]) > toleranceOnTabMCErr[i]) - Assert.Fail("MC Not-a-knot spline interpolation " + QAssert.Fail("MC Not-a-knot spline interpolation " + "\n sample points: " + n + "\n norm of difference: " + result + "\n it should be: " @@ -97,8 +107,12 @@ public void testSplineErrorOnGaussianValues() /* See J. M. Hyman, "Accurate monotonicity preserving cubic interpolation" SIAM J. of Scientific and Statistical Computing, v. 4, 1983, pp. 645-654. http://math.lanl.gov/~mac/papers/numerics/H83.pdf - */ - [TestMethod()] + */ +#if QL_DOTNET_FRAMEWORK + [TestMethod()] +#else + [Fact] +#endif public void testSplineOnGaussianValues() { //("Testing spline interpolation on a Gaussian data set..."); @@ -125,7 +139,7 @@ public void testSplineOnGaussianValues() { interpolated = f.value(x1_bad); interpolated2= f.value(x2_bad); if (interpolated>0.0 && interpolated2>0.0 ) { - Assert.Fail("Not-a-knot spline interpolation " + QAssert.Fail("Not-a-knot spline interpolation " + "bad performance unverified" + "\nat x = " + x1_bad + " interpolated value: " + interpolated @@ -144,7 +158,7 @@ public void testSplineOnGaussianValues() { // good performance interpolated = f.value(x1_bad); if (interpolated<0.0) { - Assert.Fail("MC not-a-knot spline interpolation " + QAssert.Fail("MC not-a-knot spline interpolation " + "good performance unverified\n" + "at x = " + x1_bad + "\ninterpolated value: " + interpolated @@ -152,7 +166,7 @@ public void testSplineOnGaussianValues() { } interpolated = f.value(x2_bad); if (interpolated<0.0) { - Assert.Fail("MC not-a-knot spline interpolation " + QAssert.Fail("MC not-a-knot spline interpolation " + "good performance unverified\n" + "at x = " + x2_bad + "\ninterpolated value: " + interpolated @@ -164,8 +178,12 @@ public void testSplineOnGaussianValues() { /* See J. M. Hyman, "Accurate monotonicity preserving cubic interpolation" SIAM J. of Scientific and Statistical Computing, v. 4, 1983, pp. 645-654. http://math.lanl.gov/~mac/papers/numerics/H83.pdf - */ - [TestMethod()] + */ +#if QL_DOTNET_FRAMEWORK + [TestMethod()] +#else + [Fact] +#endif public void testSplineOnRPN15AValues() { //("Testing spline interpolation on RPN15A data set..."); @@ -194,7 +212,7 @@ public void testSplineOnRPN15AValues() { double x_bad = 11.0; interpolated = f.value(x_bad); if (interpolated<1.0) { - Assert.Fail("Natural spline interpolation " + QAssert.Fail("Natural spline interpolation " + "poor performance unverified\n" + "at x = " + x_bad + "\ninterpolated value: " + interpolated @@ -214,7 +232,7 @@ public void testSplineOnRPN15AValues() { // poor performance interpolated = f.value(x_bad); if (interpolated<1.0) { - Assert.Fail("Clamped spline interpolation " + QAssert.Fail("Clamped spline interpolation " + "poor performance unverified\n" + "at x = " + x_bad + "\ninterpolated value: " + interpolated @@ -234,7 +252,7 @@ public void testSplineOnRPN15AValues() { // poor performance interpolated = f.value(x_bad); if (interpolated<1.0) { - Assert.Fail("Not-a-knot spline interpolation " + QAssert.Fail("Not-a-knot spline interpolation " + "poor performance unverified\n" + "at x = " + x_bad + "\ninterpolated value: " + interpolated @@ -252,7 +270,7 @@ public void testSplineOnRPN15AValues() { // good performance interpolated = f.value(x_bad); if (interpolated>1.0) { - Assert.Fail("MC natural spline interpolation " + QAssert.Fail("MC natural spline interpolation " + "good performance unverified\n" + "at x = " + x_bad + "\ninterpolated value: " + interpolated @@ -273,7 +291,7 @@ public void testSplineOnRPN15AValues() { // good performance interpolated = f.value(x_bad); if (interpolated>1.0) { - Assert.Fail("MC clamped spline interpolation " + QAssert.Fail("MC clamped spline interpolation " + "good performance unverified\n" + "at x = " + x_bad + "\ninterpolated value: " + interpolated @@ -291,7 +309,7 @@ public void testSplineOnRPN15AValues() { // good performance interpolated = f.value(x_bad); if (interpolated>1.0) { - Assert.Fail("MC clamped spline interpolation " + QAssert.Fail("MC clamped spline interpolation " + "good performance unverified\n" + "at x = " + x_bad + "\ninterpolated value: " + interpolated @@ -302,8 +320,12 @@ public void testSplineOnRPN15AValues() { /* Blossey, Frigyik, Farnum "A Note On CubicSpline Splines" Applied Linear Algebra and Numerical Analysis AMATH 352 Lecture Notes http://www.amath.washington.edu/courses/352-winter-2002/spline_note.pdf - */ - [TestMethod()] + */ +#if QL_DOTNET_FRAMEWORK + [TestMethod()] +#else + [Fact] +#endif public void testSplineOnGenericValues() { //("Testing spline interpolation on generic values..."); @@ -330,7 +352,7 @@ public void testSplineOnGenericValues() { interpolated = f.secondDerivative(generic_x[i]); error = interpolated - generic_natural_y2[i]; if (Math.Abs(error)>3e-16) { - Assert.Fail("Natural spline interpolation " + QAssert.Fail("Natural spline interpolation " + "second derivative failed at x=" + generic_x[i] + "\ninterpolated value: " + interpolated + "\nexpected value: " + generic_natural_y2[i] @@ -365,16 +387,20 @@ public void testSplineOnGenericValues() { x35[2] = f.value(3.5); if (x35[0]>x35[1] || x35[1]>x35[2]) { - Assert.Fail("Spline interpolation failure" + QAssert.Fail("Spline interpolation failure" + "\nat x = " + 3.5 + "\nclamped spline " + x35[0] + "\nnatural spline " + x35[1] + "\nnot-a-knot spline " + x35[2] + "\nvalues should be in increasing order"); } - } - - [TestMethod()] + } + +#if QL_DOTNET_FRAMEWORK + [TestMethod()] +#else + [Fact] +#endif public void testSimmetricEndConditions() { //("Testing symmetry of spline interpolation end-conditions..."); @@ -404,9 +430,13 @@ public void testSimmetricEndConditions() { f.update(); checkValues("MC not-a-knot spline", f, x, y); checkSymmetry("MC not-a-knot spline", f, x[0]); - } - - [TestMethod()] + } + +#if QL_DOTNET_FRAMEWORK + [TestMethod()] +#else + [Fact] +#endif public void testDerivativeEndConditions() { //("Testing derivative end-conditions for spline interpolation..."); @@ -502,8 +532,12 @@ public void testDerivativeEndConditions() { "Nonnegativity-, Monotonicity-, or Convexity-Preserving CubicSpline and Quintic Hermite Interpolation" Mathematics Of Computation, v. 52, n. 186, April 1989, pp. 471-494. - */ - [TestMethod()] + */ +#if QL_DOTNET_FRAMEWORK + [TestMethod()] +#else + [Fact] +#endif public void testNonRestrictiveHymanFilter() { //("Testing non-restrictive Hyman filter..."); @@ -523,7 +557,7 @@ public void testNonRestrictiveHymanFilter() { f.update(); interpolated = f.value(zero); if (Math.Abs(interpolated-expected)>1e-15) { - Assert.Fail("MC not-a-knot spline" + QAssert.Fail("MC not-a-knot spline" + " interpolation failed at x = " + zero + "\n interpolated value: " + interpolated + "\n expected value: " + expected @@ -540,7 +574,7 @@ public void testNonRestrictiveHymanFilter() { f.update(); interpolated = f.value(zero); if (Math.Abs(interpolated-expected)>1e-15) { - Assert.Fail("MC clamped spline" + QAssert.Fail("MC clamped spline" + " interpolation failed at x = " + zero + "\n interpolated value: " + interpolated + "\n expected value: " + expected @@ -557,7 +591,7 @@ public void testNonRestrictiveHymanFilter() { f.update(); interpolated = f.value(zero); if (Math.Abs(interpolated-expected)>1e-15) { - Assert.Fail("MC SecondDerivative spline" + QAssert.Fail("MC SecondDerivative spline" + " interpolation failed at x = " + zero + "\n interpolated value: " + interpolated + "\n expected value: " + expected @@ -632,7 +666,7 @@ public void testNonRestrictiveHymanFilter() { // double error = Math.Abs(interpolated-expected); // double tolerance = 1e-16; // if (error > tolerance) { - // Assert.Fail( + // QAssert.Fail( // "\n At (" // + s + "," + t + "," + u + "," // + v + "," + w + "):" @@ -659,7 +693,7 @@ public void testNonRestrictiveHymanFilter() { // double interpolated = cs(args), expected = multif(s, t, u, v, w); // double error = Math.Abs(interpolated-expected); // if (error > tolerance) { - // Assert.Fail( + // QAssert.Fail( // "\n At (" // + s + "," + t + "," + u + "," + v + "," + w + "):" // + "\n interpolated: " + interpolated @@ -670,9 +704,13 @@ public void testNonRestrictiveHymanFilter() { // } //} - class NotThrown : ApplicationException { } - - [TestMethod()] + class NotThrown : Exception { } + +#if QL_DOTNET_FRAMEWORK + [TestMethod()] +#else + [Fact] +#endif public void testAsFunctor() { //("Testing use of interpolations as functors..."); @@ -690,28 +728,40 @@ public void testAsFunctor() { // case 1: extrapolation not allowed try { - y2 = x2.ConvertAll(f.value); + for ( int xx = 0; xx < x2.Count; xx++) + { + y2[xx] = f.value(x2[xx]); + } + //y2 = x2.ConvertAll(f.value); throw new NotThrown(); } catch (NotThrown) { - throw new ApplicationException("failed to throw exception when trying to extrapolate"); + throw new Exception("failed to throw exception when trying to extrapolate"); } catch { } // case 2: enable extrapolation f.enableExtrapolation(); - y2 = new InitializedList(N); - y2 = x2.ConvertAll(f.value); + y2 = new InitializedList(N); + for ( int xx = 0; xx < x2.Count; xx++ ) + { + y2[xx] = f.value( x2[xx] ); + } + //y2 = x2.ConvertAll(f.value); for (int i=0; i tolerance) - Assert.Fail( + QAssert.Fail( "failed to reproduce " + (i+1) + " expected datum" + "\n expected: " + expected + "\n calculated: " + y2[i] + "\n error: " + Math.Abs(y2[i]-expected)); } - } - - [TestMethod()] + } + +#if QL_DOTNET_FRAMEWORK + [TestMethod()] +#else + [Fact] +#endif public void testBackwardFlat() { //("Testing backward-flat interpolation..."); @@ -732,7 +782,7 @@ public void testBackwardFlat() { calculated = f.value(p); expected = y[i]; if (Math.Abs(expected-calculated) > tolerance) - Assert.Fail( + QAssert.Fail( "failed to reproduce " + (i+1) + " datum" + "\n expected: " + expected + "\n calculated: " + calculated @@ -745,7 +795,7 @@ public void testBackwardFlat() { calculated = f.value(p); expected = y[i + 1]; if (Math.Abs(expected-calculated) > tolerance) - Assert.Fail( + QAssert.Fail( "failed to interpolate correctly at " + p + "\n expected: " + expected + "\n calculated: " + calculated @@ -759,7 +809,7 @@ public void testBackwardFlat() { calculated = f.value(p); expected = y[0]; if (Math.Abs(expected-calculated) > tolerance) - Assert.Fail( + QAssert.Fail( "failed to extrapolate correctly at " + p + "\n expected: " + expected + "\n calculated: " + calculated @@ -769,7 +819,7 @@ public void testBackwardFlat() { calculated = f.value(p); expected = y[N-1]; if (Math.Abs(expected-calculated) > tolerance) - Assert.Fail( + QAssert.Fail( "failed to extrapolate correctly at " + p + "\n expected: " + expected + "\n calculated: " + calculated @@ -779,7 +829,7 @@ public void testBackwardFlat() { calculated = f.primitive(x[0]); expected = 0.0; if (Math.Abs(expected-calculated) > tolerance) - Assert.Fail( + QAssert.Fail( "failed to calculate primitive at " + x[0] + "\n expected: " + expected + "\n calculated: " + calculated @@ -791,7 +841,7 @@ public void testBackwardFlat() { calculated = f.primitive(x[i]); expected = sum; if (Math.Abs(expected-calculated) > tolerance) - Assert.Fail( + QAssert.Fail( "failed to calculate primitive at " + x[i] + "\n expected: " + expected + "\n calculated: " + calculated @@ -807,16 +857,20 @@ public void testBackwardFlat() { expected = sum; sum += (x[i+1]-x[i])*y[i+1]/2; if (Math.Abs(expected-calculated) > tolerance) - Assert.Fail( + QAssert.Fail( "failed to calculate primitive at " + x[i] + "\n expected: " + expected + "\n calculated: " + calculated + "\n error: " + Math.Abs(calculated-expected)); } - } - - [TestMethod()] + } + +#if QL_DOTNET_FRAMEWORK + [TestMethod()] +#else + [Fact] +#endif public void testForwardFlat() { //("Testing forward-flat interpolation..."); @@ -837,7 +891,7 @@ public void testForwardFlat() { calculated = f.value(p); expected = y[i]; if (Math.Abs(expected-calculated) > tolerance) - Assert.Fail( + QAssert.Fail( "failed to reproduce " + (i+1) + " datum" + "\n expected: " + expected + "\n calculated: " + calculated @@ -850,7 +904,7 @@ public void testForwardFlat() { calculated = f.value(p); expected = y[i]; if (Math.Abs(expected-calculated) > tolerance) - Assert.Fail( + QAssert.Fail( "failed to interpolate correctly at " + p + "\n expected: " + expected + "\n calculated: " + calculated @@ -864,7 +918,7 @@ public void testForwardFlat() { calculated = f.value(p); expected = y[0]; if (Math.Abs(expected-calculated) > tolerance) - Assert.Fail( + QAssert.Fail( "failed to extrapolate correctly at " + p + "\n expected: " + expected + "\n calculated: " + calculated @@ -874,7 +928,7 @@ public void testForwardFlat() { calculated = f.value(p); expected = y[N-1]; if (Math.Abs(expected-calculated) > tolerance) - Assert.Fail( + QAssert.Fail( "failed to extrapolate correctly at " + p + "\n expected: " + expected + "\n calculated: " + calculated @@ -884,7 +938,7 @@ public void testForwardFlat() { calculated = f.primitive(x[0]); expected = 0.0; if (Math.Abs(expected-calculated) > tolerance) - Assert.Fail( + QAssert.Fail( "failed to calculate primitive at " + x[0] + "\n expected: " + expected + "\n calculated: " + calculated @@ -896,7 +950,7 @@ public void testForwardFlat() { calculated = f.primitive(x[i]); expected = sum; if (Math.Abs(expected-calculated) > tolerance) - Assert.Fail( + QAssert.Fail( "failed to calculate primitive at " + x[i] + "\n expected: " + expected + "\n calculated: " + calculated @@ -912,15 +966,19 @@ public void testForwardFlat() { expected = sum; sum += (x[i+1]-x[i])*y[i]/2; if (Math.Abs(expected-calculated) > tolerance) - Assert.Fail( + QAssert.Fail( "failed to calculate primitive at " + p + "\n expected: " + expected + "\n calculated: " + calculated + "\n error: " + Math.Abs(calculated-expected)); } - } - - [TestMethod()] + } + +#if QL_DOTNET_FRAMEWORK + [TestMethod()] +#else + [Fact] +#endif public void testSabrInterpolation() { // Testing Sabr interpolation... @@ -968,7 +1026,7 @@ public void testSabrInterpolation() initialAlpha, initialBeta, initialNu, initialRho); if (Math.Abs(volatilities[i]-calculatedVol) > tolerance) - Assert.Fail( "failed to calculate Sabr function at strike " + strikes[i] + QAssert.Fail( "failed to calculate Sabr function at strike " + strikes[i] + "\n expected: " + volatilities[i] + "\n calculated: " + calculatedVol + "\n error: " + Math.Abs(calculatedVol-volatilities[i])); @@ -1038,7 +1096,7 @@ public void testSabrInterpolation() // compare results: alpha error = Math.Abs(initialAlpha-calibratedAlpha); if (error > calibrationTolerance) { - Assert.Fail("\nfailed to calibrate alpha Sabr parameter:" + + QAssert.Fail("\nfailed to calibrate alpha Sabr parameter:" + "\n expected: " + initialAlpha + "\n calibrated: " + calibratedAlpha + "\n error: " + error); @@ -1047,7 +1105,7 @@ public void testSabrInterpolation() // Beta error = Math.Abs(initialBeta-calibratedBeta); if (error > calibrationTolerance) { - Assert.Fail("\nfailed to calibrate beta Sabr parameter:" + + QAssert.Fail("\nfailed to calibrate beta Sabr parameter:" + "\n expected: " + initialBeta + "\n calibrated: " + calibratedBeta + "\n error: " + error); @@ -1056,7 +1114,7 @@ public void testSabrInterpolation() // Nu error = Math.Abs(initialNu-calibratedNu); if (error > calibrationTolerance) { - Assert.Fail("\nfailed to calibrate nu Sabr parameter:" + + QAssert.Fail("\nfailed to calibrate nu Sabr parameter:" + "\n expected: " + initialNu + "\n calibrated: " + calibratedNu + "\n error: " + error); @@ -1065,7 +1123,7 @@ public void testSabrInterpolation() // Rho error = Math.Abs(initialRho-calibratedRho); if (error > calibrationTolerance) { - Assert.Fail("\nfailed to calibrate rho Sabr parameter:" + + QAssert.Fail("\nfailed to calibrate rho Sabr parameter:" + "\n expected: " + initialRho + "\n calibrated: " + calibratedRho + "\n error: " + error); @@ -1073,7 +1131,7 @@ public void testSabrInterpolation() } if (failed) - Assert.Fail("\nSabr calibration failure:" + + QAssert.Fail("\nSabr calibration failure:" + "\n isAlphaFixed: " + isAlphaFixed[k_a] + "\n isBetaFixed: " + isBetaFixed[k_b] + "\n isNuFixed: " + isNuFixed[k_n] + @@ -1085,9 +1143,13 @@ public void testSabrInterpolation() } } } - } - - [TestMethod()] + } + +#if QL_DOTNET_FRAMEWORK + [TestMethod()] +#else + [Fact] +#endif public void testKernelInterpolation() { @@ -1143,7 +1205,7 @@ public void testKernelInterpolation() if (Math.Abs(expectedVal-calcVal)>tolerance) { - Assert.Fail("Kernel interpolation failed at x = " + QAssert.Fail("Kernel interpolation failed at x = " + deltaGrid[dIt] + "\n interpolated value: " + calcVal + "\n expected value: " + expectedVal @@ -1201,7 +1263,7 @@ public void testKernelInterpolation() if (Math.Abs(expectedVal-calcVal)>tolerance) { - Assert.Fail("Kernel interpolation failed at x = " + QAssert.Fail("Kernel interpolation failed at x = " + deltaGrid[dIt] + "\n interpolated value: " + calcVal + "\n expected value: " + expectedVal @@ -1212,9 +1274,13 @@ public void testKernelInterpolation() } - } - - [TestMethod()] + } + +#if QL_DOTNET_FRAMEWORK + [TestMethod()] +#else + [Fact] +#endif public void testKernelInterpolation2D() { // No test values known from the literature. @@ -1258,7 +1324,7 @@ public void testKernelInterpolation2D() if(Math.Abs(expectedVal-calcVal)>tolerance){ - Assert.Fail("2D Kernel interpolation failed at x = " + xVec[i] + QAssert.Fail("2D Kernel interpolation failed at x = " + xVec[i] + ", y = " + yVec[j] + "\n interpolated value: " + calcVal + "\n expected value: " + expectedVal @@ -1296,7 +1362,7 @@ public void testKernelInterpolation2D() if(Math.Abs(expectedVal-calcVal)>tolerance){ - Assert.Fail("2D Epanechnkikov Kernel interpolation failed at x = " + xVec1[i] + QAssert.Fail("2D Epanechnkikov Kernel interpolation failed at x = " + xVec1[i] + ", y = " + yVec1[j] + "\n interpolated value: " + calcVal + "\n expected value: " + expectedVal @@ -1322,7 +1388,7 @@ public void testKernelInterpolation2D() if(Math.Abs(expectedVal-calcVal)>tolerance){ - Assert.Fail("2D Epanechnkikov Kernel updated interpolation failed at x = " + xVec1[i] + QAssert.Fail("2D Epanechnkikov Kernel updated interpolation failed at x = " + xVec1[i] + ", y = " + yVec1[j] + "\n interpolated value: " + calcVal + "\n expected value: " + expectedVal @@ -1331,9 +1397,13 @@ public void testKernelInterpolation2D() } } } - } - - [TestMethod()] + } + +#if QL_DOTNET_FRAMEWORK + [TestMethod()] +#else + [Fact] +#endif public void testBicubicDerivatives() { // Testing bicubic spline derivatives... @@ -1363,25 +1433,29 @@ public void testBicubicDerivatives() double f_xy = spline.derivativeXY(x[j],y[i]); if (Math.Abs(f_x - y[i]/10*Math.Cos(x[j])) > tol) { - Assert.Fail("Failed to reproduce f_x"); + QAssert.Fail("Failed to reproduce f_x"); } if (Math.Abs(f_xx + y[i]/10*Math.Sin(x[j])) > tol) { - Assert.Fail("Failed to reproduce f_xx"); + QAssert.Fail("Failed to reproduce f_xx"); } if (Math.Abs(f_y - (Math.Sin(x[j])/10-Math.Sin(y[i]))) > tol) { - Assert.Fail("Failed to reproduce f_y"); + QAssert.Fail("Failed to reproduce f_y"); } if (Math.Abs(f_yy + Math.Cos(y[i])) > tol) { - Assert.Fail("Failed to reproduce f_yy"); + QAssert.Fail("Failed to reproduce f_yy"); } if (Math.Abs(f_xy - Math.Cos(x[j])/10) > tol) { - Assert.Fail("Failed to reproduce f_xy"); + QAssert.Fail("Failed to reproduce f_xy"); } } } - } - - [TestMethod()] + } + +#if QL_DOTNET_FRAMEWORK + [TestMethod()] +#else + [Fact] +#endif public void testBicubicUpdate() { // Testing that bicubic splines actually update... @@ -1407,10 +1481,14 @@ public void testBicubicUpdate() double new_result = spline.value(x[2]+0.1, y[4]); if (Math.Abs(old_result-new_result) < 0.5) - Assert.Fail("Failed to update bicubic spline"); -} - - [TestMethod()] + QAssert.Fail("Failed to update bicubic spline"); +} + +#if QL_DOTNET_FRAMEWORK + [TestMethod()] +#else + [Fact] +#endif public void testRichardsonExtrapolation() { // Testing Richardson extrapolation... @@ -1438,12 +1516,12 @@ public void testRichardsonExtrapolation() double calculated = extrap.value(scalingFactor); if (Math.Abs(expected-calculated) > tol) { - Assert.Fail("failed to reproduce Richardson extrapolation"); + QAssert.Fail("failed to reproduce Richardson extrapolation"); } calculated = extrap.value(); if (Math.Abs(expected-calculated) > tol) { - Assert.Fail("failed to reproduce Richardson extrapolation"); + QAssert.Fail("failed to reproduce Richardson extrapolation"); } expected = 2.721376; @@ -1451,12 +1529,16 @@ public void testRichardsonExtrapolation() calculated = extrap.value(scalingFactor2, scalingFactor); if (Math.Abs(expected-calculated) > tol) { - Assert.Fail("failed to reproduce Richardson extrapolation"); + QAssert.Fail("failed to reproduce Richardson extrapolation"); } -} - - - [TestMethod()] +} + + +#if QL_DOTNET_FRAMEWORK + [TestMethod()] +#else + [Fact] +#endif public void testSabrSingleCases() { // Testing Sabr calibration single cases... @@ -1475,7 +1557,7 @@ public void testSabrSingleCases() if (s0.maxError() > 0.01 || s0.rmsError() > 0.01) { - Assert.Fail("Sabr case #1 failed with max error (" + QAssert.Fail("Sabr case #1 failed with max error (" + s0.maxError() + ") and rms error (" + s0.rmsError() + "), both should be < 0.01"); @@ -1512,7 +1594,7 @@ void checkValues(string type, CubicInterpolation cubic, List xBegin, Lis for(int i=0; i tolerance) { - Assert.Fail(type + " interpolation failed at x = " + xBegin[i] + QAssert.Fail(type + " interpolation failed at x = " + xBegin[i] + "\n interpolated value: " + interpolated + "\n expected value: " + yBegin[i] + "\n error: " @@ -1526,7 +1608,7 @@ void check1stDerivativeValue(string type, CubicInterpolation cubic, double x, do double interpolated = cubic.derivative(x); double error = Math.Abs(interpolated-value); if (error > tolerance) { - Assert.Fail(type + " interpolation first derivative failure\n" + QAssert.Fail(type + " interpolation first derivative failure\n" + "at x = " + x + "\n interpolated value: " + interpolated + "\n expected value: " + value @@ -1539,7 +1621,7 @@ void check2ndDerivativeValue(string type, CubicInterpolation cubic, double x, do double interpolated = cubic.secondDerivative(x); double error = Math.Abs(interpolated-value); if (error > tolerance) { - Assert.Fail(type + " interpolation second derivative failure\n" + QAssert.Fail(type + " interpolation second derivative failure\n" + "at x = " + x + "\n interpolated value: " + interpolated + "\n expected value: " + value @@ -1551,7 +1633,7 @@ void checkNotAKnotCondition(string type, CubicInterpolation cubic) { double tolerance = 1.0e-14; List c = cubic.cCoefficients(); if (Math.Abs(c[0]-c[1]) > tolerance) { - Assert.Fail(type + " interpolation failure" + QAssert.Fail(type + " interpolation failure" + "\n cubic coefficient of the first" + " polinomial is " + c[0] + "\n cubic coefficient of the second" @@ -1559,7 +1641,7 @@ void checkNotAKnotCondition(string type, CubicInterpolation cubic) { } int n = c.Count; if (Math.Abs(c[n - 2] - c[n - 1]) > tolerance) { - Assert.Fail(type + " interpolation failure" + QAssert.Fail(type + " interpolation failure" + "\n cubic coefficient of the 2nd to last" + " polinomial is " + c[n-2] + "\n cubic coefficient of the last" @@ -1572,7 +1654,7 @@ void checkSymmetry(string type, CubicInterpolation cubic, double xMin) { for (double x = xMin; x < 0.0; x += 0.1) { double y1 = cubic.value(x), y2 = cubic.value(-x); if (Math.Abs(y1-y2) > tolerance) { - Assert.Fail(type + " interpolation not symmetric" + QAssert.Fail(type + " interpolation not symmetric" + "\n x = " + x + "\n g(x) = " + y1 + "\n g(-x) = " + y2 diff --git a/Test/T_LiborMarketModel.cs b/Test/T_LiborMarketModel.cs index 7478ad0fc..5dffcf2bb 100644 --- a/Test/T_LiborMarketModel.cs +++ b/Test/T_LiborMarketModel.cs @@ -19,15 +19,45 @@ under the terms of the QLNet license. You should have received a */ using System; -using System.Collections.Generic; -using Microsoft.VisualStudio.TestTools.UnitTesting; +using System.Collections.Generic; +#if QL_DOTNET_FRAMEWORK +using Microsoft.VisualStudio.TestTools.UnitTesting; +#else + using Xunit; +#endif using QLNet; namespace TestSuite -{ - [TestClass()] - public class T_LiborMarketModel +{ +#if QL_DOTNET_FRAMEWORK + [TestClass()] +#endif + public class T_LiborMarketModel : IDisposable { + #region Initialize&Cleanup + private SavedSettings backup; + #if QL_DOTNET_FRAMEWORK + [TestInitialize] + public void testInitialize() + { + #else + public T_LiborMarketModel() + { + #endif + backup = new SavedSettings(); + } + #if QL_DOTNET_FRAMEWORK + [TestCleanup] + #endif + public void testCleanup() + { + Dispose(); + } + public void Dispose() + { + backup.Dispose(); + } + #endregion IborIndex makeIndex(List dates, List rates) @@ -80,13 +110,14 @@ OptionletVolatilityStructure makeCapVolCurve(Date todaysDate) capletVols,new Actual360()); } + #if QL_DOTNET_FRAMEWORK [TestCategory( "LongRun" ), TestMethod()] + #else + [Fact(Skip = "LongRun")] + #endif public void testSimpleCovarianceModels() { - //"Testing simple covariance models..."; - - //SavedSettings backup; - + // Testing simple covariance models const int size = 10; const double tolerance = 1e-14; int i; @@ -99,7 +130,7 @@ public void testSimpleCovarianceModels() for (i=0; i tolerance) - Assert.Fail("Failed to reproduce correlation matrix" + QAssert.Fail("Failed to reproduce correlation matrix" + "\n calculated: " + recon[i,j] + "\n expected: " + 0); } @@ -130,7 +161,7 @@ public void testSimpleCovarianceModels() for (int k=0; k tolerance) - Assert.Fail("Failed to reproduce correlation matrix" + QAssert.Fail("Failed to reproduce correlation matrix" + "\n calculated: " + recon[k,j] + "\n expected: " + 0); } @@ -146,20 +177,21 @@ public void testSimpleCovarianceModels() } if (Math.Abs(expected - volatility[k]) > tolerance) - Assert.Fail("Failed to reproduce volatities" + QAssert.Fail("Failed to reproduce volatities" + "\n calculated: " + volatility[k] + "\n expected: " + expected); } } } + #if QL_DOTNET_FRAMEWORK [TestCategory( "LongRun" ), TestMethod()] + #else + [Fact(Skip = "LongRun")] + #endif public void testCapletPricing() { - //"Testing caplet pricing..."; - - //SavedSettings backup; - + // Testing caplet pricing const int size = 10; #if QL_USE_INDEXED_COUPON const double tolerance = 1e-5; @@ -193,18 +225,19 @@ public void testCapletPricing() double calculated = cap1.NPV(); if (Math.Abs(expected - calculated) > tolerance) - Assert.Fail("Failed to reproduce npv" + QAssert.Fail("Failed to reproduce npv" + "\n calculated: " + calculated + "\n expected: " + expected); } - [TestCategory("LongRun"), TestMethod()] + #if QL_DOTNET_FRAMEWORK + [TestCategory( "LongRun" ), TestMethod()] + #else + [Fact(Skip = "LongRun")] + #endif public void testCalibration() { - //("Testing calibration of a Libor forward model..."); - - //SavedSettings backup; - + // Testing calibration of a Libor forward model const int size = 14; const double tolerance = 8e-3; @@ -293,18 +326,19 @@ public void testCalibration() } if (Math.Sqrt(calculated) > tolerance) - Assert.Fail("Failed to calibrate libor forward model" + QAssert.Fail("Failed to calibrate libor forward model" + "\n calculated diff: " + Math.Sqrt(calculated) + "\n expected : smaller than " + tolerance); } - [TestCategory("LongRun"),TestMethod()] + #if QL_DOTNET_FRAMEWORK + [TestCategory( "LongRun" ), TestMethod()] + #else + [Fact(Skip = "LongRun")] + #endif public void testSwaptionPricing() { - //"Testing forward swap and swaption pricing..."); - - //SavedSettings backup; - + // Testing forward swap and swaption pricing const int size = 10; const int steps = 8*size; #if QL_USE_INDEXED_COUPON @@ -386,7 +420,7 @@ public void testSwaptionPricing() double calculated = liborModel.S_0(i-1,i+j-1); if (Math.Abs(expected - calculated) > tolerance) - Assert.Fail("Failed to reproduce fair forward swap rate" + QAssert.Fail("Failed to reproduce fair forward swap rate" + "\n calculated: " + calculated + "\n expected: " + expected); @@ -409,10 +443,10 @@ public void testSwaptionPricing() GeneralStatistics stat = new GeneralStatistics(); - for (int n=0; n path = ( n % 2 != 0 ) ? generator.antithetic() - : generator.next(); - MultiPath value = path.value as MultiPath; + : generator.next(); + MultiPath value = path.value as MultiPath; Utils.QL_REQUIRE( value != null, () => "Invalid Path" ); //Sample path = generator.next(); List rates_ = new InitializedList(size); @@ -432,7 +466,7 @@ public void testSwaptionPricing() if (Math.Abs(swaption.NPV() - stat.mean()) > stat.errorEstimate()*2.35) - Assert.Fail("Failed to reproduce swaption npv" + QAssert.Fail("Failed to reproduce swaption npv" + "\n calculated: " + stat.mean() + "\n expected: " + swaption.NPV()); } diff --git a/Test/T_LiborMarketModelProcess.cs b/Test/T_LiborMarketModelProcess.cs index 43f67d399..95d018b36 100644 --- a/Test/T_LiborMarketModelProcess.cs +++ b/Test/T_LiborMarketModelProcess.cs @@ -19,15 +19,46 @@ under the terms of the QLNet license. You should have received a using System; using System.Collections.Generic; -using System.Linq; -using Microsoft.VisualStudio.TestTools.UnitTesting; +using System.Linq; +#if QL_DOTNET_FRAMEWORK +using Microsoft.VisualStudio.TestTools.UnitTesting; +#else + using Xunit; +#endif using QLNet; namespace TestSuite -{ - [TestClass()] - public class T_LiborMarketModelProcess +{ +#if QL_DOTNET_FRAMEWORK + [TestClass()] +#endif + public class T_LiborMarketModelProcess : IDisposable { + #region Initialize&Cleanup + private SavedSettings backup; + #if QL_DOTNET_FRAMEWORK + [TestInitialize] + public void testInitialize() + { + #else + public T_LiborMarketModelProcess() + { + #endif + + backup = new SavedSettings(); + } + #if QL_DOTNET_FRAMEWORK + [TestCleanup] + #endif + public void testCleanup() + { + Dispose(); + } + public void Dispose() + { + backup.Dispose(); + } + #endregion int len = 10; @@ -101,13 +132,14 @@ LiborForwardModelProcess makeProcess(Matrix volaComp) return process; } + #if QL_DOTNET_FRAMEWORK [TestCategory( "LongRun" ), TestMethod()] + #else + [Fact(Skip = "LongRun")] + #endif public void testInitialisation() { - //"Testing caplet LMM process initialisation..." - - //SavedSettings backup; - + // Testing caplet LMM process initialisation DayCounter dayCounter = new Actual360(); RelinkableHandle termStructure= new RelinkableHandle(); termStructure.linkTo(Utilities.flatRate(Date.Today, 0.04, dayCounter)); @@ -139,20 +171,21 @@ public void testInitialisation() int ii = process.nextIndexReset(fixings[i]); if ((ileft != i) || (iright != i+1) || (ii != i+1)) { - Assert.Fail("Failed to next index resets"); + QAssert.Fail("Failed to next index resets"); } } } } + #if QL_DOTNET_FRAMEWORK [TestCategory( "LongRun" ), TestMethod()] + #else + [Fact(Skip = "LongRun")] + #endif public void testLambdaBootstrapping() { - //"Testing caplet LMM lambda bootstrapping..." - - //SavedSettings backup; - + // Testing caplet LMM lambda bootstrapping double tolerance = 1e-10; double[] lambdaExpected = {14.3010297550, 19.3821411939, 15.9816590141, 15.9953118303, 14.0570815635, 13.5687599894, @@ -166,7 +199,7 @@ public void testLambdaBootstrapping() double expected = lambdaExpected[i]/100; if (Math.Abs(calculated - expected) > tolerance) - Assert.Fail("Failed to reproduce expected lambda values" + QAssert.Fail("Failed to reproduce expected lambda values" + "\n calculated: " + calculated + "\n expected: " + expected); } @@ -187,7 +220,7 @@ public void testLambdaBootstrapping() { if (Math.Abs(diff[i,j]) > tolerance) { - Assert.Fail("Failed to reproduce integrated covariance" + QAssert.Fail("Failed to reproduce integrated covariance" + "\n calculated: " + diff[i,j] + "\n expected: " + 0); } @@ -196,12 +229,14 @@ public void testLambdaBootstrapping() } } - [TestCategory("LongRun") , TestMethod()] + #if QL_DOTNET_FRAMEWORK + [TestCategory( "LongRun" ), TestMethod()] + #else + [Fact(Skip = "LongRun")] + #endif public void testMonteCarloCapletPricing() { - //"Testing caplet LMM Monte-Carlo caplet pricing..." - - //SavedSettings backup; + // Testing caplet LMM Monte-Carlo caplet pricing /* factor loadings are taken from Hull & White article plus extra normalisation to get orthogonal eigenvectors @@ -257,10 +292,10 @@ plus extra normalisation to get orthogonal eigenvectors List stat3 = new InitializedList(process2.size() - 1); for (int i=0; i path1 = generator1.next(); - Sample path2 = generator2.next(); - MultiPath value1 = path1.value as MultiPath; - Utils.QL_REQUIRE( value1 != null, () => "Invalid Path" ); - MultiPath value2 = path2.value as MultiPath; + Sample path2 = generator2.next(); + MultiPath value1 = path1.value as MultiPath; + Utils.QL_REQUIRE( value1 != null, () => "Invalid Path" ); + MultiPath value2 = path2.value as MultiPath; Utils.QL_REQUIRE( value2 != null, () => "Invalid Path" ); List rates1=new InitializedList(len); @@ -309,7 +344,7 @@ plus extra normalisation to get orthogonal eigenvectors double expected = capletNpv[k]; if (Math.Abs(calculated1 - expected) > tolerance1) { - Assert.Fail("Failed to reproduce expected caplet NPV" + QAssert.Fail("Failed to reproduce expected caplet NPV" + "\n calculated: " + calculated1 + "\n error int: " + tolerance1 + "\n expected: " + expected); @@ -319,7 +354,7 @@ plus extra normalisation to get orthogonal eigenvectors double tolerance2 = stat2[k].errorEstimate(); if (Math.Abs(calculated2 - expected) > tolerance2) { - Assert.Fail("Failed to reproduce expected caplet NPV" + QAssert.Fail("Failed to reproduce expected caplet NPV" + "\n calculated: " + calculated2 + "\n error int: " + tolerance2 + "\n expected: " + expected); @@ -333,7 +368,7 @@ plus extra normalisation to get orthogonal eigenvectors double refError = 1e-5; // 1e-5. error bars of the reference values if (Math.Abs(calculated3 - expected) > tolerance3 + refError) { - Assert.Fail("Failed to reproduce expected caplet NPV" + QAssert.Fail("Failed to reproduce expected caplet NPV" + "\n calculated: " + calculated3 + "\n error int: " + tolerance3 + refError + "\n expected: " + expected); @@ -341,13 +376,6 @@ plus extra normalisation to get orthogonal eigenvectors } } } - - public void T_LiborMarketModelProcess_suite() - { - testInitialisation(); - testLambdaBootstrapping(); - testMonteCarloCapletPricing(); - } } } diff --git a/Test/T_LinearLeastSquaresRegression.cs b/Test/T_LinearLeastSquaresRegression.cs index ef81bbf39..870cc389e 100644 --- a/Test/T_LinearLeastSquaresRegression.cs +++ b/Test/T_LinearLeastSquaresRegression.cs @@ -15,26 +15,62 @@ under the terms of the QLNet license. You should have received a This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the license for more details. -*/ +*/ using System; -using System.Collections.Generic; -using Microsoft.VisualStudio.TestTools.UnitTesting; +using System.Collections.Generic; +#if QL_DOTNET_FRAMEWORK +using Microsoft.VisualStudio.TestTools.UnitTesting; +#else + using Xunit; +#endif using QLNet; namespace TestSuite { /// /// Summary description for LinearLeastSquaresRegression - /// - [TestClass] - public class T_LinearLeastSquaresRegression { - const double tolerance = 0.025; - - [TestMethod] - public void testRegression() { - //("Testing linear least-squares regression..."); - - //SavedSettings backup; - + /// + #if QL_DOTNET_FRAMEWORK + [TestClass] + #endif + public class T_LinearLeastSquaresRegression : IDisposable + { + + #region Initialize&Cleanup + private SavedSettings backup; + #if QL_DOTNET_FRAMEWORK + [TestInitialize] + public void testInitialize() + { + #else + public T_LinearLeastSquaresRegression() + { + #endif + + backup = new SavedSettings(); + } + #if QL_DOTNET_FRAMEWORK + [TestCleanup] + #endif + public void testCleanup() + { + Dispose(); + } + public void Dispose() + { + backup.Dispose(); + } + #endregion + + const double tolerance = 0.025; + +#if QL_DOTNET_FRAMEWORK + [TestMethod()] +#else + [Fact] +#endif + public void testRegression() + { + // Testing linear least-squares regression const int nr=100000; var rng = new InverseCumulativeRng( @@ -69,12 +105,12 @@ public void testRegression() { for (i=0; i tolerance) { - Assert.Fail("Failed to reproduce linear regression coef." + QAssert.Fail("Failed to reproduce linear regression coef." + "\n error: " + m.standardErrors()[i] + "\n tolerance: " + tolerance); } if (Math.Abs(m.coefficients()[i]-a[i]) > 3*m.error()[i]) { - Assert.Fail("Failed to reproduce linear regression coef." + QAssert.Fail("Failed to reproduce linear regression coef." + "\n calculated: " + m.coefficients()[i] + "\n error: " + m.standardErrors()[i] + "\n expected: " + a[i]); @@ -90,7 +126,7 @@ public void testRegression() { m.standardErrors()[3]}; for (i = 0; i < v.Count; ++i) { if (Math.Abs(ma[i] - a[i]) > 3 * err[i]) { - Assert.Fail("Failed to reproduce linear regression coef." + QAssert.Fail("Failed to reproduce linear regression coef." + "\n calculated: " + ma[i] + "\n error: " + err[i] + "\n expected: " + a[i]); @@ -98,18 +134,20 @@ public void testRegression() { } } - } - - [TestMethod] - public void test1dLinearRegression() { - - //BOOST_MESSAGE("Testing 1d simple linear least-squares regression..."); + } + +#if QL_DOTNET_FRAMEWORK + [TestMethod()] +#else + [Fact] +#endif + public void test1dLinearRegression() + { + // Testing 1d simple linear least-squares regression /* Example taken from the QuantLib-User list, see posting * Multiple linear regression/weighted regression, Boris Skorodumov */ - //SavedSettings backup; - List x = new InitializedList(9), y = new InitializedList(9); x[0] = 2.4; x[1] = 1.8; x[2] = 2.5; x[3] = 3.0; @@ -130,28 +168,29 @@ public void test1dLinearRegression() { for (int i = 0; i < 2; ++i) { if (Math.Abs(m.standardErrors()[i] - errorsExpected[i]) > tol) { - Assert.Fail("Failed to reproduce linear regression standard errors" + QAssert.Fail("Failed to reproduce linear regression standard errors" + "\n calculated: " + m.standardErrors()[i] + "\n expected: " + errorsExpected[i] + "\n tolerance: " + tol); } if (Math.Abs(m.coefficients()[i] - coeffExpected[i]) > tol) { - Assert.Fail("Failed to reproduce linear regression coef." + QAssert.Fail("Failed to reproduce linear regression coef." + "\n calculated: " + m.coefficients()[i] + "\n expected: " + coeffExpected[i] + "\n tolerance: " + tol); } } - } - - [TestMethod] - public void testMultiDimRegression() { - - //BOOST_MESSAGE("Testing linear least-squares regression..."); - - //SavedSettings backup; - + } + +#if QL_DOTNET_FRAMEWORK + [TestMethod()] +#else + [Fact] +#endif + public void testMultiDimRegression() + { + // Testing linear least-squares regression const int nr=100000; const int dims = 4; const double tolerance = 0.01; @@ -188,13 +227,13 @@ public void testMultiDimRegression() { for (int i=0; i < v.Count; ++i) { if (m.standardErrors()[i] > tolerance) { - Assert.Fail("Failed to reproduce linear regression coef." + QAssert.Fail("Failed to reproduce linear regression coef." + "\n error: " + m.standardErrors()[i] + "\n tolerance: " + tolerance); } if (Math.Abs(m.coefficients()[i]-coeff[i]) > 3*tolerance) { - Assert.Fail("Failed to reproduce linear regression coef." + QAssert.Fail("Failed to reproduce linear regression coef." + "\n calculated: " + m.coefficients()[i] + "\n error: " + m.standardErrors()[i] + "\n expected: " + coeff[i]); diff --git a/Test/T_Loan.cs b/Test/T_Loan.cs deleted file mode 100644 index 25869f62b..000000000 --- a/Test/T_Loan.cs +++ /dev/null @@ -1,69 +0,0 @@ -/* - Copyright (C) 2008, 2009 , 2010 Andrea Maggiulli (a.maggiulli@gmail.com) - - This file is part of QLNet Project http://www.qlnet.org - - QLNet is free software: you can redistribute it and/or modify it - under the terms of the QLNet license. You should have received a - copy of the license along with this program; if not, license is - available online at . - - QLNet is a based on QuantLib, a free-software/open-source library - for financial quantitative analysts and developers - http://quantlib.org/ - The QuantLib license is available online at http://quantlib.org/license.shtml. - - This program is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS - FOR A PARTICULAR PURPOSE. See the license for more details. -*/ - -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using Microsoft.VisualStudio.TestTools.UnitTesting; -using QLNet; - -namespace TestSuite -{ - [TestClass()] - public class T_Loan - { - [TestMethod()] - public void testFairRate() - { - Calendar calendar = new TARGET(); - - Date settlementDate = new Date(10, Month.Mar, 2010); - - /********************* - * LOAN TO BE PRICED * - **********************/ - - // constant nominal 1,000,000 Euro - double nominal = 1000000.0; - // fixed leg - Frequency fixedLegFrequency = Frequency.Monthly; - BusinessDayConvention fixedLegConvention = BusinessDayConvention.Unadjusted; - BusinessDayConvention principalLegConvention = BusinessDayConvention.ModifiedFollowing; - DayCounter fixedLegDayCounter = new Thirty360(Thirty360.Thirty360Convention.European); - double fixedRate = 0.04; - - // Principal leg - Frequency pricipalLegFrequency = Frequency.Annual; - - int lenghtInMonths = 3; - Loan.Type loanType = Loan.Type.Payer; - - Date maturity = settlementDate + new Period(lenghtInMonths, TimeUnit.Years); - Schedule fixedSchedule = new Schedule(settlementDate, maturity, new Period(fixedLegFrequency), - calendar, fixedLegConvention, fixedLegConvention, DateGeneration.Rule.Forward, false); - Schedule principalSchedule = new Schedule(settlementDate, maturity, new Period(pricipalLegFrequency), - calendar, principalLegConvention, principalLegConvention, DateGeneration.Rule.Forward, false); - Loan testLoan = new FixedLoan(loanType, nominal, fixedSchedule, fixedRate, fixedLegDayCounter, - principalSchedule, principalLegConvention); - - - } - } -} diff --git a/Test/T_LowDiscrepancySequences.cs b/Test/T_LowDiscrepancySequences.cs index 6cc2234d3..f639dadf0 100644 --- a/Test/T_LowDiscrepancySequences.cs +++ b/Test/T_LowDiscrepancySequences.cs @@ -18,8 +18,12 @@ under the terms of the QLNet license. You should have received a */ using System; -using System.Collections.Generic; -using Microsoft.VisualStudio.TestTools.UnitTesting; +using System.Collections.Generic; +#if QL_DOTNET_FRAMEWORK +using Microsoft.VisualStudio.TestTools.UnitTesting; +#else + using Xunit; +#endif using QLNet; namespace TestSuite @@ -90,7 +94,7 @@ public string name() prefix = "Kuo3"; break; default: - Assert.Fail("unknown direction integers"); + QAssert.Fail("unknown direction integers"); break; } return prefix + "Sobol sequences: "; @@ -126,19 +130,25 @@ public string name() private bool start_, shift_; }; - #endregion - - - [TestClass()] + #endregion + + +#if QL_DOTNET_FRAMEWORK + [TestClass()] +#endif public class T_LowDiscrepancySequences { public void testSeedGenerator() { //("Testing random-seed generator..."); SeedGenerator.instance().get(); - } - - [TestMethod()] + } + +#if QL_DOTNET_FRAMEWORK + [TestMethod()] +#else + [Fact] +#endif public void testPolynomialsModuloTwo() { @@ -168,7 +178,7 @@ public void testPolynomialsModuloTwo() --n; if (j != jj[i]) { - Assert.Fail("Only " + j + " polynomials in degree " + i + 1 + QAssert.Fail("Only " + j + " polynomials in degree " + i + 1 + " instead of " + jj[i]); } } @@ -176,9 +186,13 @@ public void testPolynomialsModuloTwo() ++n; // Increase overall polynomial counter } - } - - [TestMethod()] + } + +#if QL_DOTNET_FRAMEWORK + [TestMethod()] +#else + [Fact] +#endif public void testSobol() { @@ -198,7 +212,7 @@ public void testSobol() point = rsg.nextSequence().value; if (point.Count != dimensionality) { - Assert.Fail("Sobol sequence generator returns " + + QAssert.Fail("Sobol sequence generator returns " + " a sequence of wrong dimensionality: " + point.Count + " instead of " + dimensionality); } @@ -226,7 +240,7 @@ public void testSobol() double error = Math.Abs(mean[i] - 0.5); if (error > tolerance) { - Assert.Fail(i + 1 + " dimension: " + QAssert.Fail(i + 1 + " dimension: " // + QL_FIXED + "mean (" + mean[i] + ") at the end of the " + j + 1 @@ -262,7 +276,7 @@ public void testSobol() double error = Math.Abs(point[0] - vanderCorputSequenceModuloTwo[i]); if (error > tolerance) { - Assert.Fail(i + 1 + " draw (" + QAssert.Fail(i + 1 + " draw (" //+ QL_FIXED + point[0] + ") in 1-D Sobol sequence is not in the " @@ -289,7 +303,7 @@ public void testSobol() for (i=0; i tolerance) { - Assert.Fail(io::ordinal(i+1) + " draw, dimension 1 (" + QAssert.Fail(io::ordinal(i+1) + " draw, dimension 1 (" + QL_FIXED + point[0] + ") in 3-D Faure sequence should have been " + vanderCorputSequenceModuloTwo[i] @@ -349,7 +363,7 @@ public void testSobol() point = rsg.nextSequence().value; double error = std::fabs(point[0]-vanderCorputSequenceModuloTwo[i]); if (error > tolerance) { - Assert.Fail(io::ordinal(i+1) + " draw, dimension 1 (" + QAssert.Fail(io::ordinal(i+1) + " draw, dimension 1 (" + QL_FIXED + point[0] + ") in 3-D Faure sequence should have been " + vanderCorputSequenceModuloTwo[i] @@ -358,7 +372,7 @@ public void testSobol() } error = std::fabs(point[1]-FaureDimensionTwoOfTwo[i]); if (error > tolerance) { - Assert.Fail(io::ordinal(i+1) + " draw, dimension 2 (" + QAssert.Fail(io::ordinal(i+1) + " draw, dimension 2 (" + QL_FIXED + point[1] + ") in 3-D Faure sequence should have been " + FaureDimensionTwoOfTwo[i] @@ -396,7 +410,7 @@ public void testSobol() point = rsg.nextSequence().value; double error = std::fabs(point[0]-FaureDimensionOneOfThree[i]); if (error > tolerance) { - Assert.Fail(io::ordinal(i+1) + " draw, dimension 1 (" + QAssert.Fail(io::ordinal(i+1) + " draw, dimension 1 (" + QL_FIXED + point[0] + ") in 3-D Faure sequence should have been " + FaureDimensionOneOfThree[i] @@ -405,7 +419,7 @@ public void testSobol() } error = std::fabs(point[1]-FaureDimensionTwoOfThree[i]); if (error > tolerance) { - Assert.Fail(io::ordinal(i+1) + " draw, dimension 2 (" + QAssert.Fail(io::ordinal(i+1) + " draw, dimension 2 (" + QL_FIXED + point[1] + ") in 3-D Faure sequence should have been " + FaureDimensionTwoOfThree[i] @@ -414,7 +428,7 @@ public void testSobol() } error = std::fabs(point[2]-FaureDimensionThreeOfThree[i]); if (error > tolerance) { - Assert.Fail(io::ordinal(i+1) + " draw, dimension 3 (" + QAssert.Fail(io::ordinal(i+1) + " draw, dimension 3 (" + QL_FIXED + point[2] + ") in 3-D Faure sequence should have been " + FaureDimensionThreeOfThree[i] @@ -422,9 +436,13 @@ public void testSobol() + " (error = " + error + ")"); } } -}*/ - - [TestMethod()] +}*/ + +#if QL_DOTNET_FRAMEWORK + [TestMethod()] +#else + [Fact] +#endif public void testHalton() { @@ -442,7 +460,7 @@ public void testHalton() point = rsg.nextSequence().value; if (point.Count != dimensionality) { - Assert.Fail("Halton sequence generator returns " + + QAssert.Fail("Halton sequence generator returns " + " a sequence of wrong dimensionality: " + point.Count + " instead of " + dimensionality) ; @@ -477,7 +495,7 @@ public void testHalton() double error = Math.Abs(point[0] - vanderCorputSequenceModuloTwo[i]); if (error > tolerance) { - Assert.Fail(i + 1 + " draw (" + QAssert.Fail(i + 1 + " draw (" + /*QL_FIXED*/ +point[0] + ") in 1-D Halton sequence is not in the " + "van der Corput sequence modulo two: " @@ -509,7 +527,7 @@ public void testHalton() double error = Math.Abs(point[0] - vanderCorputSequenceModuloTwo[i]); if (error > tolerance) { - Assert.Fail("First component of " + i + 1 + QAssert.Fail("First component of " + i + 1 + " draw (" + /*QL_FIXED*/ +point[0] + ") in 2-D Halton sequence is not in the " + "van der Corput sequence modulo two: " @@ -521,7 +539,7 @@ public void testHalton() error = Math.Abs(point[1] - vanderCorputSequenceModuloThree[i]); if (error > tolerance) { - Assert.Fail("Second component of " + i + 1 + QAssert.Fail("Second component of " + i + 1 + " draw (" + /*QL_FIXED*/ +point[1] + ") in 2-D Halton sequence is not in the " + "van der Corput sequence modulo three: " @@ -552,7 +570,7 @@ public void testHalton() double error = Math.Abs(mean[0] - 0.5); if (error > tolerance) { - Assert.Fail("First dimension mean (" + /*QL_FIXED*/ +mean[0] + QAssert.Fail("First dimension mean (" + /*QL_FIXED*/ +mean[0] + ") at the end of the " + j + 1 + " cycle in Halton sequence is not " + 0.5 //+ QL_SCIENTIFIC @@ -577,7 +595,7 @@ public void testHalton() double error = Math.Abs(mean[1] - 0.5); if (error > tolerance) { - Assert.Fail("Second dimension mean (" + /*QL_FIXED*/ +mean[1] + QAssert.Fail("Second dimension mean (" + /*QL_FIXED*/ +mean[1] + ") at the end of the " + j + 1 + " cycle in Halton sequence is not " + 0.5 //+ QL_SCIENTIFIC @@ -620,7 +638,7 @@ public void testGeneratorDiscrepancy(IRNGFactory generatorFactory, double[][] di if (Math.Abs(discr - discrepancy[i][j - jMin]) > tolerance*discr) { - Assert.Fail(generatorFactory.name() + QAssert.Fail(generatorFactory.name() + "discrepancy dimension " + dimensionality[i] + " at " + points + " samples is " + discr + " instead of " @@ -825,9 +843,13 @@ public void _testDiscrepancy_Sobol() testUnitSobolDiscrepancy(); } - #endregion - - [TestMethod()] + #endregion + +#if QL_DOTNET_FRAMEWORK + [TestMethod()] +#else + [Fact] +#endif public void testSobolSkipping() { @@ -868,7 +890,7 @@ public void testSobolSkipping() { if (s1[n] != s2[n]) { - Assert.Fail("Mismatch after skipping:" + QAssert.Fail("Mismatch after skipping:" + "\n size: " + dimensionality[j] + "\n integers: " + integers[i] + "\n skipped: " + skip[k] diff --git a/Test/T_Matrices.cs b/Test/T_Matrices.cs index 60d988ca8..76b92ecb6 100644 --- a/Test/T_Matrices.cs +++ b/Test/T_Matrices.cs @@ -16,14 +16,20 @@ under the terms of the QLNet license. You should have received a This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the license for more details. -*/ +*/ using System; -using System.Collections.Generic; -using Microsoft.VisualStudio.TestTools.UnitTesting; +using System.Collections.Generic; +#if QL_DOTNET_FRAMEWORK +using Microsoft.VisualStudio.TestTools.UnitTesting; +#else + using Xunit; +#endif using QLNet; -namespace TestSuite { - [TestClass()] +namespace TestSuite { +#if QL_DOTNET_FRAMEWORK + [TestClass()] +#endif public class T_Matrices { int N; @@ -85,9 +91,13 @@ void setup() { M7 = new Matrix(M1); M7[0,1] = 0.3; M7[0,2] = 0.2; M7[2,1] = 1.2; - } - - [TestMethod()] + } + +#if QL_DOTNET_FRAMEWORK + [TestMethod()] +#else + [Fact] +#endif public void testEigenvectors() { //("Testing eigenvalues and eigenvectors calculation..."); @@ -111,10 +121,10 @@ public void testEigenvectors() { Vector a = M * v; Vector b = eigenValues[i] * v; if (norm(a-b) > 1.0e-15) - Assert.Fail("Eigenvector definition not satisfied"); + QAssert.Fail("Eigenvector definition not satisfied"); // check decreasing ordering if (eigenValues[i] >= minHolder) { - Assert.Fail("Eigenvalues not ordered: " + eigenValues); + QAssert.Fail("Eigenvalues not ordered: " + eigenValues); } else minHolder = eigenValues[i]; } @@ -122,11 +132,15 @@ public void testEigenvectors() { // check normalization Matrix m = eigenVectors * Matrix.transpose(eigenVectors); if (norm(m-I) > 1.0e-15) - Assert.Fail("Eigenvector not normalized"); + QAssert.Fail("Eigenvector not normalized"); } - } - - [TestMethod()] + } + +#if QL_DOTNET_FRAMEWORK + [TestMethod()] +#else + [Fact] +#endif public void testSqrt() { //BOOST_MESSAGE("Testing matricial square root..."); @@ -138,16 +152,20 @@ public void testSqrt() { double error = norm(temp - M1); double tolerance = 1.0e-12; if (error>tolerance) { - Assert.Fail("Matrix square root calculation failed\n" + QAssert.Fail("Matrix square root calculation failed\n" + "original matrix:\n" + M1 + "pseudoSqrt:\n" + m + "pseudoSqrt*pseudoSqrt:\n" + temp + "\nerror: " + error + "\ntolerance: " + tolerance); } - } - - [TestMethod()] + } + +#if QL_DOTNET_FRAMEWORK + [TestMethod()] +#else + [Fact] +#endif public void testHighamSqrt() { //BOOST_MESSAGE("Testing Higham matricial square root..."); @@ -158,16 +176,20 @@ public void testHighamSqrt() { double error = norm(ansSqrt - tempSqrt); double tolerance = 1.0e-4; if (error>tolerance) { - Assert.Fail("Higham matrix correction failed\n" + QAssert.Fail("Higham matrix correction failed\n" + "original matrix:\n" + M5 + "pseudoSqrt:\n" + tempSqrt + "should be:\n" + ansSqrt + "\nerror: " + error + "\ntolerance: " + tolerance); } - } - - [TestMethod()] + } + +#if QL_DOTNET_FRAMEWORK + [TestMethod()] +#else + [Fact] +#endif public void testSVD() { //BOOST_MESSAGE("Testing singular value decomposition..."); @@ -192,25 +214,29 @@ public void testSVD() { for (int i=0; i < S.rows(); i++) { if (S[i,i] != s[i]) - Assert.Fail("S not consistent with s"); + QAssert.Fail("S not consistent with s"); } // tests Matrix U_Utranspose = Matrix.transpose(U)*U; if (norm(U_Utranspose-I) > tol) - Assert.Fail("U not orthogonal (norm of U^T*U-I = " + norm(U_Utranspose-I) + ")"); + QAssert.Fail("U not orthogonal (norm of U^T*U-I = " + norm(U_Utranspose-I) + ")"); Matrix V_Vtranspose = Matrix.transpose(V) * V; if (norm(V_Vtranspose-I) > tol) - Assert.Fail("V not orthogonal (norm of V^T*V-I = " + norm(V_Vtranspose-I) + ")"); + QAssert.Fail("V not orthogonal (norm of V^T*V-I = " + norm(V_Vtranspose-I) + ")"); Matrix A_reconstructed = U * S * Matrix.transpose(V); if (norm(A_reconstructed-A) > tol) - Assert.Fail("Product does not recover A: (norm of U*S*V^T-A = " + norm(A_reconstructed-A) + ")"); + QAssert.Fail("Product does not recover A: (norm of U*S*V^T-A = " + norm(A_reconstructed-A) + ")"); } - } - - [TestMethod()] + } + +#if QL_DOTNET_FRAMEWORK + [TestMethod()] +#else + [Fact] +#endif public void testQRDecomposition() { @@ -236,92 +262,96 @@ public void testQRDecomposition() } if (norm(Q*R - A*P) > tol) - Assert.Fail("Q*R does not match matrix A*P (norm = " + QAssert.Fail("Q*R does not match matrix A*P (norm = " + norm(Q*R-A*P) + ")"); pivot = false; MatrixUtilities.qrDecomposition(A, ref Q, ref R, pivot); if (norm(Q*R - A) > tol) - Assert.Fail("Q*R does not match matrix A (norm = " + QAssert.Fail("Q*R does not match matrix A (norm = " + norm(Q*R-A) + ")"); } } +#if QL_DOTNET_FRAMEWORK [TestMethod()] - public void testQRSolve() - { - // Testing QR solve... - setup(); - - double tol = 1.0e-12; - MersenneTwisterUniformRng rng = new MersenneTwisterUniformRng( 1234 ); - Matrix bigM = new Matrix( 50, 100, 0.0 ); - for ( int i = 0; i < Math.Min( bigM.rows(), bigM.columns() ); ++i ) - { - bigM[i, i] = i + 1.0; - } +#else + [Fact] +#endif + public void testQRSolve() + { + // Testing QR solve... + setup(); + + double tol = 1.0e-12; + MersenneTwisterUniformRng rng = new MersenneTwisterUniformRng( 1234 ); + Matrix bigM = new Matrix( 50, 100, 0.0 ); + for ( int i = 0; i < Math.Min( bigM.rows(), bigM.columns() ); ++i ) + { + bigM[i, i] = i + 1.0; + } Matrix[] testMatrices = { M1, M2, M3, Matrix.transpose(M3), - M4, Matrix.transpose(M4), M5, I, M7, bigM, Matrix.transpose(bigM) }; - - for ( int j = 0; j < testMatrices.Length; j++ ) - { - Matrix A = testMatrices[j]; - Vector b = new Vector( A.rows() ); - - for ( int k = 0; k < 10; ++k ) - { - for ( int i = 0; i < b.Count; ++i ) - { - b[i] = rng.next().value; - } - Vector x = MatrixUtilities.qrSolve( A, b, true ); - - if ( A.columns() >= A.rows() ) - { - if ( norm( A * x - b ) > tol ) - Assert.Fail( "A*x does not match vector b (norm = " - + norm( A * x - b ) + ")" ); - } - else - { - // use the SVD to calculate the reference values - int n = A.columns(); - Vector xr = new Vector( n, 0.0 ); - - SVD svd = new SVD( A ); - Matrix V = svd.V(); - Matrix U = svd.U(); - Vector w = svd.singularValues(); - double threshold = n * Const.QL_EPSILON; - - for ( int i = 0; i < n; ++i ) - { - if ( w[i] > threshold ) - { - double u = 0; - int zero = 0; - for ( int kk = 0; kk < U.rows(); kk++ ) - u += ( U[kk, i] * b[zero++] ) / w[i]; - - for ( int jj = 0; jj < n; ++jj ) - { - xr[jj] += u * V[jj, i]; - } - } - } - - if ( norm( xr - x ) > tol ) - { - Assert.Fail( "least square solution does not match (norm = " - + norm( x - xr ) + ")" ); - - } - } - } - } - } - + M4, Matrix.transpose(M4), M5, I, M7, bigM, Matrix.transpose(bigM) }; + + for ( int j = 0; j < testMatrices.Length; j++ ) + { + Matrix A = testMatrices[j]; + Vector b = new Vector( A.rows() ); + + for ( int k = 0; k < 10; ++k ) + { + for ( int i = 0; i < b.Count; ++i ) + { + b[i] = rng.next().value; + } + Vector x = MatrixUtilities.qrSolve( A, b, true ); + + if ( A.columns() >= A.rows() ) + { + if ( norm( A * x - b ) > tol ) + QAssert.Fail( "A*x does not match vector b (norm = " + + norm( A * x - b ) + ")" ); + } + else + { + // use the SVD to calculate the reference values + int n = A.columns(); + Vector xr = new Vector( n, 0.0 ); + + SVD svd = new SVD( A ); + Matrix V = svd.V(); + Matrix U = svd.U(); + Vector w = svd.singularValues(); + double threshold = n * Const.QL_EPSILON; + + for ( int i = 0; i < n; ++i ) + { + if ( w[i] > threshold ) + { + double u = 0; + int zero = 0; + for ( int kk = 0; kk < U.rows(); kk++ ) + u += ( U[kk, i] * b[zero++] ) / w[i]; + + for ( int jj = 0; jj < n; ++jj ) + { + xr[jj] += u * V[jj, i]; + } + } + } + + if ( norm( xr - x ) > tol ) + { + QAssert.Fail( "least square solution does not match (norm = " + + norm( x - xr ) + ")" ); + + } + } + } + } + } + } } diff --git a/Test/T_Mclongstaffschwartzengine.cs b/Test/T_Mclongstaffschwartzengine.cs index 8e8816f0f..6a3e102f8 100644 --- a/Test/T_Mclongstaffschwartzengine.cs +++ b/Test/T_Mclongstaffschwartzengine.cs @@ -15,7 +15,7 @@ under the terms of the QLNet license. You should have received a This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the license for more details. -*/ +*/ using System; using System.Collections.Generic; using System.Linq; @@ -67,11 +67,11 @@ public List> basisSystem() { // protected override LongstaffSchwartzPathPricer lsmPathPricer() { // StochasticProcessArray processArray = process_ as StochasticProcessArray; // if (processArray == null || processArray.size() == 0) - // throw new ApplicationException("Stochastic process array required"); + // throw new Exception("Stochastic process array required"); // GeneralizedBlackScholesProcess process = processArray.process(0) as GeneralizedBlackScholesProcess; // if (process == null) - // throw new ApplicationException("generalized Black-Scholes proces required"); + // throw new Exception("generalized Black-Scholes proces required"); // AmericanMaxPathPricer earlyExercisePathPricer = new AmericanMaxPathPricer(arguments_.payoff); diff --git a/Test/T_Money.cs b/Test/T_Money.cs index aa78ae351..bb5f441e7 100644 --- a/Test/T_Money.cs +++ b/Test/T_Money.cs @@ -15,17 +15,27 @@ under the terms of the QLNet license. You should have received a This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the license for more details. -*/ - -using Microsoft.VisualStudio.TestTools.UnitTesting; +*/ + +#if QL_DOTNET_FRAMEWORK +using Microsoft.VisualStudio.TestTools.UnitTesting; +#else + using Xunit; +#endif using QLNet; namespace TestSuite -{ - [TestClass()] +{ +#if QL_DOTNET_FRAMEWORK + [TestClass()] +#endif public class T_Money - { - [TestMethod()] + { +#if QL_DOTNET_FRAMEWORK + [TestMethod()] +#else + [Fact] +#endif public void testNone() { Currency EUR = new EURCurrency(); @@ -41,10 +51,14 @@ public void testNone() Money expected = new Money(x, EUR); if (calculated != expected) - Assert.Fail("Wrong result: expected: " + expected + " calculated: " + calculated); - } - - [TestMethod()] + QAssert.Fail("Wrong result: expected: " + expected + " calculated: " + calculated); + } + +#if QL_DOTNET_FRAMEWORK + [TestMethod()] +#else + [Fact] +#endif public void testBaseCurrency() { Currency EUR = new EURCurrency(), GBP = new GBPCurrency(), USD = new USDCurrency(); @@ -73,11 +87,15 @@ public void testBaseCurrency() if (calculated != expected) { - Assert.Fail("Wrong result: expected: " + expected + "calculated: " + calculated); + QAssert.Fail("Wrong result: expected: " + expected + "calculated: " + calculated); } - } - - [TestMethod()] + } + +#if QL_DOTNET_FRAMEWORK + [TestMethod()] +#else + [Fact] +#endif public void testAutomated() { Currency EUR = new EURCurrency(), GBP = new GBPCurrency(), USD = new USDCurrency(); @@ -105,7 +123,7 @@ public void testAutomated() if (calculated != expected) { - Assert.Fail("Wrong result: " + "expected: " + expected + " calculated: " + calculated); + QAssert.Fail("Wrong result: " + "expected: " + expected + " calculated: " + calculated); } } diff --git a/Test/T_Operators.cs b/Test/T_Operators.cs index 08785081b..ded5c1c86 100644 --- a/Test/T_Operators.cs +++ b/Test/T_Operators.cs @@ -16,18 +16,28 @@ under the terms of the QLNet license. You should have received a ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the license for more details. */ -using System; -using Microsoft.VisualStudio.TestTools.UnitTesting; +using System; +#if QL_DOTNET_FRAMEWORK +using Microsoft.VisualStudio.TestTools.UnitTesting; +#else + using Xunit; +#endif using QLNet; namespace TestSuite -{ - [TestClass()] +{ +#if QL_DOTNET_FRAMEWORK + [TestClass()] +#endif public class T_Operators { - public const double average = 0.0, sigma = 1.0; - - [TestMethod()] + public const double average = 0.0, sigma = 1.0; + +#if QL_DOTNET_FRAMEWORK + [TestMethod()] +#else + [Fact] +#endif public void testOperatorConsistency() { @@ -71,7 +81,7 @@ public void testOperatorConsistency() double e = Utilities.norm(diff, diff.size(), h); if (e > 1.0e-6) { - Assert.Fail("norm of 1st derivative of cum minus Gaussian: " + e + "\ntolerance exceeded"); + QAssert.Fail("norm of 1st derivative of cum minus Gaussian: " + e + "\ntolerance exceeded"); } // check that the second derivative of cum is normal.derivative @@ -83,11 +93,15 @@ public void testOperatorConsistency() e = Utilities.norm(diff, diff.size(), h); if (e > 1.0e-4) { - Assert.Fail("norm of 2nd derivative of cum minus Gaussian derivative: " + e + "\ntolerance exceeded"); + QAssert.Fail("norm of 2nd derivative of cum minus Gaussian derivative: " + e + "\ntolerance exceeded"); } - } - - [TestMethod()] + } + +#if QL_DOTNET_FRAMEWORK + [TestMethod()] +#else + [Fact] +#endif public void testBSMOperatorConsistency() { //("Testing consistency of BSM operators..."); @@ -136,7 +150,7 @@ public void testBSMOperatorConsistency() Math.Abs(derror[i]) > tolerance || Math.Abs(uderror[i]) > tolerance) { - Assert.Fail("inconsistency between BSM operators:\n" + QAssert.Fail("inconsistency between BSM operators:\n" + i + " row:\n" + "expected: " + refer.lowerDiagonal()[i] + ", " @@ -158,7 +172,7 @@ public void testBSMOperatorConsistency() Math.Abs(derror[i]) > tolerance || Math.Abs(uderror[i]) > tolerance) { - Assert.Fail("inconsistency between BSM operators:\n" + QAssert.Fail("inconsistency between BSM operators:\n" + i + " row:\n" + "expected: " + refer.lowerDiagonal()[i] + ", " diff --git a/Test/T_Optimizers.cs b/Test/T_Optimizers.cs index 4face27cd..1091d8713 100644 --- a/Test/T_Optimizers.cs +++ b/Test/T_Optimizers.cs @@ -18,12 +18,18 @@ under the terms of the QLNet license. You should have received a */ using System; using System.Collections.Generic; -using System.Linq; -using Microsoft.VisualStudio.TestTools.UnitTesting; +using System.Linq; +#if QL_DOTNET_FRAMEWORK +using Microsoft.VisualStudio.TestTools.UnitTesting; +#else + using Xunit; +#endif using QLNet; -namespace TestSuite { - [TestClass()] +namespace TestSuite { +#if QL_DOTNET_FRAMEWORK + [TestClass()] +#endif public class T_Optimizers { List costFunctions_ = new List(); List constraints_ = new List(); @@ -43,17 +49,21 @@ struct NamedOptimizationMethod { enum OptimizationMethodType { simplex, - levenbergMarquardt, + levenbergMarquardt, levenbergMarquardt2, - conjugateGradient, - conjugateGradient_goldstein, - steepestDescent, - steepestDescent_goldstein, - bfgs, + conjugateGradient, + conjugateGradient_goldstein, + steepestDescent, + steepestDescent_goldstein, + bfgs, bfgs_goldstein - } - - [TestMethod()] + } + +#if QL_DOTNET_FRAMEWORK + [TestMethod()] +#else + [Fact] +#endif public void OptimizersTest() { //("Testing optimizers..."); @@ -84,7 +94,7 @@ public void OptimizersTest() { if (endCriteriaResult==EndCriteria.Type.None || endCriteriaResult==EndCriteria.Type.MaxIterations || endCriteriaResult==EndCriteria.Type.Unknown) - Assert.Fail("function evaluations: " + problem.functionEvaluation() + + QAssert.Fail("function evaluations: " + problem.functionEvaluation() + " gradient evaluations: " + problem.gradientEvaluation() + " x expected: " + xMinExpected_[i] + " x calculated: " + xMinCalculated + @@ -98,9 +108,13 @@ public void OptimizersTest() { } } } - } - - [TestMethod()] + } + +#if QL_DOTNET_FRAMEWORK + [TestMethod()] +#else + [Fact] +#endif public void nestedOptimizationTest() { //("Testing nested optimizations..."); OptimizationBasedCostFunction optimizationBasedCostFunction = new OptimizationBasedCostFunction(); @@ -181,9 +195,9 @@ OptimizationMethod makeOptimizationMethod(OptimizationMethodType optimizationMet case OptimizationMethodType.simplex: return new Simplex(simplexLambda); case OptimizationMethodType.levenbergMarquardt: - return new LevenbergMarquardt(levenbergMarquardtEpsfcn, levenbergMarquardtXtol, levenbergMarquardtGtol); - case OptimizationMethodType.levenbergMarquardt2: - return new LevenbergMarquardt( levenbergMarquardtEpsfcn, levenbergMarquardtXtol, levenbergMarquardtGtol,true ); + return new LevenbergMarquardt(levenbergMarquardtEpsfcn, levenbergMarquardtXtol, levenbergMarquardtGtol); + case OptimizationMethodType.levenbergMarquardt2: + return new LevenbergMarquardt( levenbergMarquardtEpsfcn, levenbergMarquardtXtol, levenbergMarquardtGtol,true ); case OptimizationMethodType.conjugateGradient: return new ConjugateGradient(); case OptimizationMethodType.steepestDescent: @@ -197,7 +211,7 @@ OptimizationMethod makeOptimizationMethod(OptimizationMethodType optimizationMet case OptimizationMethodType.bfgs_goldstein: return new BFGS(new GoldsteinLineSearch()); default: - throw new ApplicationException("unknown OptimizationMethod type"); + throw new Exception("unknown OptimizationMethod type"); } } @@ -226,23 +240,23 @@ string optimizationMethodTypeToString(OptimizationMethodType type) { case OptimizationMethodType.simplex: return "Simplex"; case OptimizationMethodType.levenbergMarquardt: - return "Levenberg Marquardt"; - case OptimizationMethodType.levenbergMarquardt2: + return "Levenberg Marquardt"; + case OptimizationMethodType.levenbergMarquardt2: return "Levenberg Marquardt (cost function's jacbobian)"; case OptimizationMethodType.conjugateGradient: return "Conjugate Gradient"; case OptimizationMethodType.steepestDescent: - return "Steepest Descent"; - case OptimizationMethodType.bfgs: - return "BFGS"; - case OptimizationMethodType.conjugateGradient_goldstein: - return "Conjugate Gradient (Goldstein line search)"; - case OptimizationMethodType.steepestDescent_goldstein: - return "Steepest Descent (Goldstein line search)"; - case OptimizationMethodType.bfgs_goldstein: + return "Steepest Descent"; + case OptimizationMethodType.bfgs: + return "BFGS"; + case OptimizationMethodType.conjugateGradient_goldstein: + return "Conjugate Gradient (Goldstein line search)"; + case OptimizationMethodType.steepestDescent_goldstein: + return "Steepest Descent (Goldstein line search)"; + case OptimizationMethodType.bfgs_goldstein: return "BFGS (Goldstein line search)"; default: - throw new ApplicationException("unknown OptimizationMethod type"); + throw new Exception("unknown OptimizationMethod type"); } } } @@ -257,7 +271,7 @@ public OneDimensionalPolynomialDegreeN(Vector coefficients) { } public override double value(Vector x) { - if(x.size()!=1) throw new ApplicationException("independent variable must be 1 dimensional"); + if(x.size()!=1) throw new Exception("independent variable must be 1 dimensional"); double y = 0; for (int i=0; i<=polynomialDegree_; ++i) y += coefficients_[i]*Utils.Pow(x[0],i); @@ -265,7 +279,7 @@ public override double value(Vector x) { } public override Vector values(Vector x) { - if(x.size()!=1) throw new ApplicationException("independent variable must be 1 dimensional"); + if(x.size()!=1) throw new Exception("independent variable must be 1 dimensional"); Vector y = new Vector(1); y[0] = value(x); return y; diff --git a/Test/T_OptionletStripper.cs b/Test/T_OptionletStripper.cs index 645b28116..bfe769cae 100644 --- a/Test/T_OptionletStripper.cs +++ b/Test/T_OptionletStripper.cs @@ -1,61 +1,90 @@ -// Copyright (C) 2008-2016 Andrea Maggiulli (a.maggiulli@gmail.com) -// -// This file is part of QLNet Project https://github.com/amaggiulli/qlnet -// QLNet is free software: you can redistribute it and/or modify it -// under the terms of the QLNet license. You should have received a -// copy of the license along with this program; if not, license is -// available online at . -// -// QLNet is a based on QuantLib, a free-software/open-source library -// for financial quantitative analysts and developers - http://quantlib.org/ -// The QuantLib license is available online at http://quantlib.org/license.shtml. -// -// This program is distributed in the hope that it will be useful, but WITHOUT -// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS -// FOR A PARTICULAR PURPOSE. See the license for more details. -using System; +// Copyright (C) 2008-2016 Andrea Maggiulli (a.maggiulli@gmail.com) +// +// This file is part of QLNet Project https://github.com/amaggiulli/qlnet +// QLNet is free software: you can redistribute it and/or modify it +// under the terms of the QLNet license. You should have received a +// copy of the license along with this program; if not, license is +// available online at . +// +// QLNet is a based on QuantLib, a free-software/open-source library +// for financial quantitative analysts and developers - http://quantlib.org/ +// The QuantLib license is available online at http://quantlib.org/license.shtml. +// +// This program is distributed in the hope that it will be useful, but WITHOUT +// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +// FOR A PARTICULAR PURPOSE. See the license for more details. +using System; using System.Collections.Generic; +#if QL_DOTNET_FRAMEWORK using Microsoft.VisualStudio.TestTools.UnitTesting; -using QLNet; - -namespace TestSuite +#else + using Xunit; +#endif +using QLNet; + +namespace TestSuite { +#if QL_DOTNET_FRAMEWORK [TestClass()] - public class T_OptionletStripper - { - class CommonVars +#endif + public class T_OptionletStripper : IDisposable + { + #region Initialize&Cleanup + private SavedSettings backup; + #if QL_DOTNET_FRAMEWORK + [TestInitialize] + public void testInitialize() + { + #else + public T_OptionletStripper() + { + #endif + + backup = new SavedSettings(); + } + #if QL_DOTNET_FRAMEWORK + [TestCleanup] + #endif + public void testCleanup() + { + Dispose(); + } + public void Dispose() { - // global data - public Calendar calendar; - public DayCounter dayCounter; - - public RelinkableHandle yieldTermStructure = new RelinkableHandle(); - - public List strikes; - public List optionTenors; - public Matrix termV; - public List atmTermV; - public List> atmTermVolHandle; - - public Handle capFloorVolCurve; - public Handle flatTermVolCurve; - - public CapFloorTermVolSurface capFloorVolSurface; - public CapFloorTermVolSurface flatTermVolSurface; - - public double accuracy; - public double tolerance; - - // cleanup - public SavedSettings backup = new SavedSettings(); - - public CommonVars() - { - accuracy = 1.0e-6; - tolerance = 2.5e-8; - } - - public void setTermStructure() + backup.Dispose(); + } + #endregion + + class CommonVars + { + // global data + public Calendar calendar; + public DayCounter dayCounter; + + public RelinkableHandle yieldTermStructure = new RelinkableHandle(); + + public List strikes; + public List optionTenors; + public Matrix termV; + public List atmTermV; + public List> atmTermVolHandle; + + public Handle capFloorVolCurve; + public Handle flatTermVolCurve; + + public CapFloorTermVolSurface capFloorVolSurface; + public CapFloorTermVolSurface flatTermVolSurface; + + public double accuracy; + public double tolerance; + + public CommonVars() + { + accuracy = 1.0e-6; + tolerance = 2.5e-8; + } + + public void setTermStructure() { calendar = new TARGET(); @@ -63,8 +92,8 @@ public void setTermStructure() double flatFwdRate = 0.04; yieldTermStructure.linkTo(new FlatForward(0,calendar,flatFwdRate,dayCounter)); - } - + } + public void setFlatTermVolCurve() { setTermStructure(); @@ -82,8 +111,8 @@ public void setFlatTermVolCurve() flatTermVolCurve = new Handle(new CapFloorTermVolCurve(0, calendar, BusinessDayConvention.Following, optionTenors, curveVHandle, dayCounter)); - } - + } + public void setFlatTermVolSurface() { @@ -101,9 +130,9 @@ public void setFlatTermVolSurface() termV = new Matrix(optionTenors.Count, strikes.Count, flatVol); flatTermVolSurface = new CapFloorTermVolSurface(0, calendar, BusinessDayConvention.Following, optionTenors, strikes,termV, dayCounter); - } - - + } + + public void setCapFloorTermVolCurve() { @@ -155,8 +184,8 @@ public void setCapFloorTermVolCurve() capFloorVolCurve = new Handle(new CapFloorTermVolCurve(0, calendar, BusinessDayConvention.Following, optionTenors, atmTermVolHandle,dayCounter)); - } - + } + public void setCapFloorTermVolSurface() { setTermStructure(); @@ -215,10 +244,14 @@ public void setCapFloorTermVolSurface() capFloorVolSurface = new CapFloorTermVolSurface(0, calendar, BusinessDayConvention.Following, optionTenors, strikes, termV, dayCounter); + } } - } - - [TestMethod()] + +#if QL_DOTNET_FRAMEWORK + [TestMethod()] +#else + [Fact] +#endif public void testFlatTermVolatilityStripping1() { // Testing forward/forward vol stripping from flat term vol @@ -232,16 +265,16 @@ public void testFlatTermVolatilityStripping1() IborIndex iborIndex = new Euribor6M(vars.yieldTermStructure); OptionletStripper optionletStripper1 = new OptionletStripper1(vars.flatTermVolSurface, - iborIndex,null,vars.accuracy); - + iborIndex,null,vars.accuracy); + StrippedOptionletAdapter strippedOptionletAdapter = new StrippedOptionletAdapter(optionletStripper1); Handle vol = new Handle(strippedOptionletAdapter); vol.link.enableExtrapolation(); - BlackCapFloorEngine strippedVolEngine = new BlackCapFloorEngine(vars.yieldTermStructure,vol); - + BlackCapFloorEngine strippedVolEngine = new BlackCapFloorEngine(vars.yieldTermStructure,vol); + CapFloor cap; for (int tenorIndex=0; tenorIndexvars.tolerance) - Assert.Fail("\noption tenor: " + vars.optionTenors[tenorIndex] + + QAssert.Fail("\noption tenor: " + vars.optionTenors[tenorIndex] + "\nstrike: " + vars.strikes[strikeIndex] + "\nstripped vol price: " + priceFromStrippedVolatility + "\nconstant vol price: " + priceFromConstantVolatility + @@ -271,10 +304,13 @@ public void testFlatTermVolatilityStripping1() } } - [TestMethod()] +#if QL_DOTNET_FRAMEWORK + [TestMethod()] +#else + [Fact] +#endif public void testTermVolatilityStripping1() { - // Testing forward/forward vol stripping from non-flat term // vol surface using OptionletStripper1 class @@ -315,7 +351,7 @@ public void testTermVolatilityStripping1() double error = Math.Abs(priceFromStrippedVolatility - priceFromConstantVolatility); if (error>vars.tolerance) - Assert.Fail("\noption tenor: " + vars.optionTenors[tenorIndex] + + QAssert.Fail("\noption tenor: " + vars.optionTenors[tenorIndex] + "\nstrike: " + vars.strikes[strikeIndex] + "\nstripped vol price: " + priceFromStrippedVolatility + "\nconstant vol price: " + priceFromConstantVolatility + @@ -325,7 +361,11 @@ public void testTermVolatilityStripping1() } } - [TestMethod()] +#if QL_DOTNET_FRAMEWORK + [TestMethod()] +#else + [Fact] +#endif public void testFlatTermVolatilityStripping2() { // Testing forward/forward vol stripping from flat term vol @@ -350,8 +390,8 @@ public void testFlatTermVolatilityStripping2() vol1.link.enableExtrapolation(); // optionletstripper2 - OptionletStripper optionletStripper2 = new OptionletStripper2(optionletStripper1, vars.flatTermVolCurve); - + OptionletStripper optionletStripper2 = new OptionletStripper2(optionletStripper1, vars.flatTermVolCurve); + StrippedOptionletAdapter strippedOptionletAdapter2 = new StrippedOptionletAdapter(optionletStripper2); Handle vol2 = new Handle(strippedOptionletAdapter2); @@ -373,7 +413,7 @@ public void testFlatTermVolatilityStripping2() double error = Math.Abs(strippedVol1-strippedVol2); if (error>vars.tolerance) - Assert.Fail("\noption tenor: " + vars.optionTenors[tenorIndex] + + QAssert.Fail("\noption tenor: " + vars.optionTenors[tenorIndex] + "\nstrike: " + vars.strikes[strikeIndex] + "\nstripped vol1: " + strippedVol1 + "\nstripped vol2: " + strippedVol2 + @@ -383,9 +423,13 @@ public void testFlatTermVolatilityStripping2() } } -} +} - [TestMethod()] +#if QL_DOTNET_FRAMEWORK + [TestMethod()] +#else + [Fact] +#endif public void testTermVolatilityStripping2() { // Testing forward/forward vol stripping from non-flat term vol " @@ -424,7 +468,7 @@ public void testTermVolatilityStripping2() double error = Math.Abs(strippedVol1-strippedVol2); if (error>vars.tolerance) - Assert.Fail("\noption tenor: " + vars.optionTenors[tenorIndex] + + QAssert.Fail("\noption tenor: " + vars.optionTenors[tenorIndex] + "\nstrike: " + (vars.strikes[strikeIndex]) + "\nstripped vol1: " + (strippedVol1) + "\nstripped vol2: " + (strippedVol2) + @@ -434,8 +478,5 @@ public void testTermVolatilityStripping2() } } } - - - - } -} + } +} diff --git a/Test/T_OvernightIndexedSwap.cs b/Test/T_OvernightIndexedSwap.cs index 2e66e910a..3423980c6 100644 --- a/Test/T_OvernightIndexedSwap.cs +++ b/Test/T_OvernightIndexedSwap.cs @@ -17,15 +17,47 @@ under the terms of the QLNet license. You should have received a FOR A PARTICULAR PURPOSE. See the license for more details. */ using System; -using System.Collections.Generic; -using Microsoft.VisualStudio.TestTools.UnitTesting; +using System.Collections.Generic; +#if QL_DOTNET_FRAMEWORK +using Microsoft.VisualStudio.TestTools.UnitTesting; +#else + using Xunit; +#endif using QLNet; namespace TestSuite -{ - [TestClass()] - public class T_OvernightIndexedSwap +{ +#if QL_DOTNET_FRAMEWORK + [TestClass()] +#endif + public class T_OvernightIndexedSwap : IDisposable { + #region Initialize&Cleanup + private SavedSettings backup; + #if QL_DOTNET_FRAMEWORK + [TestInitialize] + public void testInitialize() + { + #else + public T_OvernightIndexedSwap() + { + #endif + + backup = new SavedSettings(); + } + #if QL_DOTNET_FRAMEWORK + [TestCleanup] + #endif + public void testCleanup() + { + Dispose(); + } + public void Dispose() + { + backup.Dispose(); + } + #endregion + public struct Datum { public int settlementDays; @@ -166,9 +198,6 @@ public class CommonVars public IborIndex swapIndex; public RelinkableHandle swapTermStructure = new RelinkableHandle(); - // cleanup - public SavedSettings backup; - // utilities public OvernightIndexedSwap makeSwap(Period length, double fixedRate, @@ -203,10 +232,14 @@ public CommonVars() settlement = calendar.advance(today,new Period(settlementDays,TimeUnit.Days),BusinessDayConvention.Following); eoniaTermStructure.linkTo(Utilities.flatRate(settlement, 0.05,new Actual365Fixed())); } - } - - - [TestMethod()] + } + + +#if QL_DOTNET_FRAMEWORK + [TestMethod()] +#else + [Fact] +#endif public void testFairRate() { // Testing Eonia-swap calculation of fair fixed rate... @@ -227,7 +260,7 @@ public void testFairRate() if (Math.Abs(swap.NPV()) > 1.0e-10) { - Assert.Fail("recalculating with implied rate:\n" + QAssert.Fail("recalculating with implied rate:\n" + " length: " + lengths[i] + " \n" + " floating spread: " + (spreads[j]) + "\n" @@ -236,12 +269,15 @@ public void testFairRate() } } } - } - - [TestMethod()] + } + +#if QL_DOTNET_FRAMEWORK + [TestMethod()] +#else + [Fact] +#endif public void testFairSpread() { - // Testing Eonia-swap calculation of fair floating spread... CommonVars vars = new CommonVars(); @@ -262,7 +298,7 @@ public void testFairSpread() if (Math.Abs(swap.NPV()) > 1.0e-10) { - Assert.Fail("Recalculating with implied spread:" + + QAssert.Fail("Recalculating with implied spread:" + "\n length: " + lengths[i] + "\n fixed rate: " + rates[j] + "\nfair spread: " + fairSpread + @@ -270,9 +306,13 @@ public void testFairSpread() } } } - } - - [TestMethod()] + } + +#if QL_DOTNET_FRAMEWORK + [TestMethod()] +#else + [Fact] +#endif public void testCachedValue() { // Testing Eonia-swap calculation against cached value... @@ -288,13 +328,17 @@ public void testCachedValue() double tolerance = 1.0e-11; if (Math.Abs(swap.NPV()-cachedNPV) > tolerance) - Assert.Fail("\nfailed to reproduce cached swap value:" + + QAssert.Fail("\nfailed to reproduce cached swap value:" + "\ncalculated: " + swap.NPV() + "\n expected: " + cachedNPV + "\n tolerance:" + tolerance); - } - - [TestMethod()] + } + +#if QL_DOTNET_FRAMEWORK + [TestMethod()] +#else + [Fact] +#endif public void testBootstrap() { // Testing Eonia-swap curve building... @@ -402,7 +446,7 @@ public void testBootstrap() double? calculated = 100.0 * swap.fairRate(); if (Math.Abs(expected-calculated.Value) > tolerance) - Assert.Fail("curve inconsistency:\n" + QAssert.Fail("curve inconsistency:\n" + " swap length: " + term + "\n" + " quoted rate: " + expected + "\n" + " calculated rate: " + calculated); diff --git a/Test/T_PSACurve.cs b/Test/T_PSACurve.cs index 509870983..9e535d586 100644 --- a/Test/T_PSACurve.cs +++ b/Test/T_PSACurve.cs @@ -15,16 +15,26 @@ under the terms of the QLNet license. You should have received a This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the license for more details. -*/ -using Microsoft.VisualStudio.TestTools.UnitTesting; +*/ +#if QL_DOTNET_FRAMEWORK +using Microsoft.VisualStudio.TestTools.UnitTesting; +#else + using Xunit; +#endif using QLNet; namespace TestSuite -{ - [TestClass()] +{ +#if QL_DOTNET_FRAMEWORK + [TestClass()] +#endif public class T_PSACurve - { - [TestMethod()] + { +#if QL_DOTNET_FRAMEWORK + [TestMethod()] +#else + [Fact] +#endif public void testCashedValues() { @@ -47,9 +57,9 @@ public void testCashedValues() for (int i = 0; i < schedule.Count; i++) { if ( i <= 29 ) - Assert.AreEqual(listCPR[i], psa100.getCPR(schedule[i])*100,0.001); + QAssert.AreEqual(listCPR[i], psa100.getCPR(schedule[i])*100,0.001); else - Assert.AreEqual(6.0000, psa100.getCPR(schedule[i])*100); + QAssert.AreEqual(6.0000, psa100.getCPR(schedule[i])*100); } diff --git a/Test/T_PathGenerator.cs b/Test/T_PathGenerator.cs index 1664f4240..e4a3130c4 100644 --- a/Test/T_PathGenerator.cs +++ b/Test/T_PathGenerator.cs @@ -18,15 +18,47 @@ under the terms of the QLNet license. You should have received a */ using System; -using System.Collections.Generic; -using Microsoft.VisualStudio.TestTools.UnitTesting; +using System.Collections.Generic; +#if QL_DOTNET_FRAMEWORK +using Microsoft.VisualStudio.TestTools.UnitTesting; +#else + using Xunit; +#endif using QLNet; namespace TestSuite -{ - [TestClass()] - public class T_Pathgenerator +{ +#if QL_DOTNET_FRAMEWORK + [TestClass()] +#endif + public class T_Pathgenerator : IDisposable { + #region Initialize&Cleanup + private SavedSettings backup; + #if QL_DOTNET_FRAMEWORK + [TestInitialize] + public void testInitialize() + { + #else + public T_Pathgenerator() + { + #endif + + backup = new SavedSettings(); + } + #if QL_DOTNET_FRAMEWORK + [TestCleanup] + #endif + public void testCleanup() + { + Dispose(); + } + public void Dispose() + { + backup.Dispose(); + } + #endregion + public void testSingle(StochasticProcess1D process, string tag, bool brownianBridge, @@ -60,7 +92,7 @@ public void testSingle(StochasticProcess1D process, double tolerance = 2.0e-8; if (error > tolerance) { - Assert.Fail("using " + tag + " process " + QAssert.Fail("using " + tag + " process " + (brownianBridge ? "with " : "without ") + "brownian bridge:\n" //+ std::setprecision(13) @@ -70,15 +102,15 @@ public void testSingle(StochasticProcess1D process, + " tolerance: " + tolerance); } - sample = generator.antithetic(); - value = sample.value as Path; + sample = generator.antithetic(); + value = sample.value as Path; Utils.QL_REQUIRE( value != null, () => "Invalid Path" ); calculated = value.back(); error = Math.Abs(calculated-antithetic); tolerance = 2.0e-7; if (error > tolerance) { - Assert.Fail("using " + tag + " process " + QAssert.Fail("using " + tag + " process " + (brownianBridge ? "with " : "without ") + "brownian bridge:\n" + "antithetic sample:\n" @@ -113,8 +145,8 @@ public void testMultiple(StochasticProcess process, for (i=0; i<100; i++) generator.next(); - Sample sample = generator.next(); - MultiPath value = sample.value as MultiPath; + Sample sample = generator.next(); + MultiPath value = sample.value as MultiPath; Utils.QL_REQUIRE( value != null, () => "Invalid Path" ); Vector calculated = new Vector(assets); double error, tolerance = 2.0e-7; @@ -125,7 +157,7 @@ public void testMultiple(StochasticProcess process, for (int j=0; j tolerance) { - Assert.Fail("using " + tag + " process " + QAssert.Fail("using " + tag + " process " + "(" + j+1 + " asset:)\n" //+ std::setprecision(13) + " calculated: " + calculated[j] + "\n" @@ -135,15 +167,15 @@ public void testMultiple(StochasticProcess process, } } - sample = generator.antithetic(); - value = sample.value as MultiPath; + sample = generator.antithetic(); + value = sample.value as MultiPath; Utils.QL_REQUIRE( value != null, () => "Invalid Path" ); for (int j=0; j tolerance) { - Assert.Fail("using " + tag + " process " + QAssert.Fail("using " + tag + " process " + "(" + j+1 + " asset:)\n" + "antithetic sample:\n" //+ std::setprecision(13) @@ -155,13 +187,14 @@ public void testMultiple(StochasticProcess process, } } + #if QL_DOTNET_FRAMEWORK [TestCategory( "LongRun" ), TestMethod()] - public void testPathGenerator() { - - //"Testing 1-D path generation against cached values..."); - - //SavedSettings backup; - + #else + [Fact(Skip = "LongRun")] + #endif + public void testPathGenerator() + { + // Testing 1-D path generation against cached values Settings.setEvaluationDate(new Date(26,4,2005)); Handle x0=new Handle (new SimpleQuote(100.0)); @@ -188,14 +221,14 @@ public void testPathGenerator() { "square-root", false, 1.70608664108, 6.024200546031); } + #if QL_DOTNET_FRAMEWORK [TestCategory( "LongRun" ), TestMethod()] + #else + [Fact(Skip = "LongRun")] + #endif public void testMultiPathGenerator() { - - //("Testing n-D path generation against cached values..."); - - //SavedSettings backup; - + // Testing n-D path generation against cached values Settings.setEvaluationDate(new Date(26,4,2005)); Handle x0=new Handle (new SimpleQuote(100.0)); diff --git a/Test/T_PiecewiseZeroSpreadedTermStructure.cs b/Test/T_PiecewiseZeroSpreadedTermStructure.cs index 6d8b9af19..91b22e844 100644 --- a/Test/T_PiecewiseZeroSpreadedTermStructure.cs +++ b/Test/T_PiecewiseZeroSpreadedTermStructure.cs @@ -1,31 +1,37 @@ -/* - Copyright (C) 2008-2016 Andrea Maggiulli (a.maggiulli@gmail.com) - - This file is part of QLNet Project https://github.com/amaggiulli/qlnet - - QLNet is free software: you can redistribute it and/or modify it - under the terms of the QLNet license. You should have received a - copy of the license along with this program; if not, license is - available online at . - - QLNet is a based on QuantLib, a free-software/open-source library - for financial quantitative analysts and developers - http://quantlib.org/ - The QuantLib license is available online at http://quantlib.org/license.shtml. - - This program is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS - FOR A PARTICULAR PURPOSE. See the license for more details. +/* + Copyright (C) 2008-2016 Andrea Maggiulli (a.maggiulli@gmail.com) + + This file is part of QLNet Project https://github.com/amaggiulli/qlnet + + QLNet is free software: you can redistribute it and/or modify it + under the terms of the QLNet license. You should have received a + copy of the license along with this program; if not, license is + available online at . + + QLNet is a based on QuantLib, a free-software/open-source library + for financial quantitative analysts and developers - http://quantlib.org/ + The QuantLib license is available online at http://quantlib.org/license.shtml. + + This program is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS + FOR A PARTICULAR PURPOSE. See the license for more details. */ using System; using System.Linq; using System.Collections.Generic; +#if QL_DOTNET_FRAMEWORK using Microsoft.VisualStudio.TestTools.UnitTesting; +#else + using Xunit; +#endif using QLNet; namespace TestSuite { +#if QL_DOTNET_FRAMEWORK [TestClass()] +#endif public class T_PiecewiseZeroSpreadedTermStructure { public class CommonVars @@ -72,7 +78,11 @@ public CommonVars() } } - [TestMethod()] +#if QL_DOTNET_FRAMEWORK + [TestMethod()] +#else + [Fact] +#endif public void testFlatInterpolationLeft() { // Testing flat interpolation before the first spreaded date... @@ -103,12 +113,16 @@ public void testFlatInterpolationLeft() double expectedRate = vars.termStructure.zeroRate(t, vars.compounding).value() + spread1.value(); if (Math.Abs(interpolatedZeroRate - expectedRate) > tolerance) - Assert.Fail("unable to reproduce interpolated rate\n" + QAssert.Fail("unable to reproduce interpolated rate\n" + " calculated: " + interpolatedZeroRate + "\n" + " expected: " + expectedRate); } - [TestMethod()] +#if QL_DOTNET_FRAMEWORK + [TestMethod()] +#else + [Fact] +#endif public void testFlatInterpolationRight() { // Testing flat interpolation after the last spreaded date... @@ -140,12 +154,16 @@ public void testFlatInterpolationRight() double expectedRate = vars.termStructure.zeroRate(t, vars.compounding).value() + spread2.value(); if (Math.Abs(interpolatedZeroRate - expectedRate) > tolerance) - Assert.Fail("unable to reproduce interpolated rate\n" + QAssert.Fail("unable to reproduce interpolated rate\n" + " calculated: " + interpolatedZeroRate + "\n" + " expected: " + expectedRate); } - [TestMethod()] +#if QL_DOTNET_FRAMEWORK + [TestMethod()] +#else + [Fact] +#endif public void testLinearInterpolationMultipleSpreads() { // Testing linear interpolation with more than two spreaded dates... @@ -183,14 +201,18 @@ public void testLinearInterpolationMultipleSpreads() spread1.value(); if (Math.Abs(interpolatedZeroRate - expectedRate) > tolerance) - Assert.Fail( + QAssert.Fail( "unable to reproduce interpolated rate\n" + " calculated: " + interpolatedZeroRate + "\n" + " expected: " + expectedRate); } - [TestMethod()] +#if QL_DOTNET_FRAMEWORK + [TestMethod()] +#else + [Fact] +#endif public void testLinearInterpolation() { // Testing linear interpolation between two dates... @@ -227,13 +249,17 @@ public void testLinearInterpolation() double tolerance = 1e-9; if (Math.Abs(interpolatedZeroRate - expectedRate) > tolerance) - Assert.Fail( + QAssert.Fail( "unable to reproduce interpolated rate\n" + " calculated: " + interpolatedZeroRate + "\n" + " expected: " + expectedRate); } - [TestMethod()] +#if QL_DOTNET_FRAMEWORK + [TestMethod()] +#else + [Fact] +#endif public void testForwardFlatInterpolation() { // Testing forward flat interpolation between two dates... @@ -265,13 +291,17 @@ public void testForwardFlatInterpolation() spread1.value(); if (Math.Abs(interpolatedZeroRate - expectedRate) > tolerance) - Assert.Fail( + QAssert.Fail( "unable to reproduce interpolated rate\n" + " calculated: " + interpolatedZeroRate + "\n" + " expected: " + expectedRate); } - [TestMethod()] +#if QL_DOTNET_FRAMEWORK + [TestMethod()] +#else + [Fact] +#endif public void testBackwardFlatInterpolation() { // Testing backward flat interpolation between two dates... @@ -306,14 +336,18 @@ public void testBackwardFlatInterpolation() spread2.value(); if (Math.Abs(interpolatedZeroRate - expectedRate) > tolerance) - Assert.Fail( + QAssert.Fail( "unable to reproduce interpolated rate\n" + " calculated: " + interpolatedZeroRate + "\n" + " expected: " + expectedRate); } - [TestMethod()] +#if QL_DOTNET_FRAMEWORK + [TestMethod()] +#else + [Fact] +#endif public void testDefaultInterpolation() { // Testing default interpolation between two dates... @@ -345,13 +379,17 @@ public void testDefaultInterpolation() spread1.value(); if (Math.Abs(interpolatedZeroRate - expectedRate) > tolerance) - Assert.Fail( + QAssert.Fail( "unable to reproduce interpolated rate\n" + " calculated: " + interpolatedZeroRate + "\n" + " expected: " + expectedRate); } - [TestMethod()] +#if QL_DOTNET_FRAMEWORK + [TestMethod()] +#else + [Fact] +#endif public void testSetInterpolationFactory() { // Testing factory constructor with additional parameters... @@ -396,13 +434,17 @@ public void testSetInterpolationFactory() 0.026065770863; if (Math.Abs(interpolatedZeroRate - expectedRate) > tolerance) - Assert.Fail( + QAssert.Fail( "unable to reproduce interpolated rate\n" + " calculated: " + interpolatedZeroRate + "\n" + " expected: " + expectedRate); } - [TestMethod()] +#if QL_DOTNET_FRAMEWORK + [TestMethod()] +#else + [Fact] +#endif public void testMaxDate() { // Testing term structure max date... @@ -429,13 +471,17 @@ public void testMaxDate() Date expectedDate = vars.termStructure.maxDate() < spreadDates.Last() ? vars.termStructure.maxDate() : spreadDates.Last(); if (maxDate != expectedDate) - Assert.Fail( + QAssert.Fail( "unable to reproduce max date\n" + " calculated: " + maxDate + "\n" + " expected: " + expectedDate); } - [TestMethod()] +#if QL_DOTNET_FRAMEWORK + [TestMethod()] +#else + [Fact] +#endif public void testQuoteChanging() { // Testing quote update... @@ -466,7 +512,7 @@ public void testQuoteChanging() 0.03; if (Math.Abs(interpolatedZeroRate - expectedRate) > tolerance) - Assert.Fail( + QAssert.Fail( "unable to reproduce interpolated rate\n" + " calculated: " + interpolatedZeroRate + "\n" + " expected: " + expectedRate); @@ -478,7 +524,7 @@ public void testQuoteChanging() 0.025; if (Math.Abs(interpolatedZeroRate - expectedRate) > tolerance) - Assert.Fail( + QAssert.Fail( "unable to reproduce interpolated rate\n" + " calculated: " + interpolatedZeroRate + "\n" + " expected: " + expectedRate); diff --git a/Test/T_Piecewiseyieldcurve.cs b/Test/T_Piecewiseyieldcurve.cs index e27b74d00..f55656572 100644 --- a/Test/T_Piecewiseyieldcurve.cs +++ b/Test/T_Piecewiseyieldcurve.cs @@ -1,30 +1,37 @@ /* Copyright (C) 2008 Siarhei Novik (snovik@gmail.com) Copyright (C) 2008, 2009 , 2010 Andrea Maggiulli (a.maggiulli@gmail.com) - + This file is part of QLNet Project https://github.com/amaggiulli/qlnet QLNet is free software: you can redistribute it and/or modify it under the terms of the QLNet license. You should have received a - copy of the license along with this program; if not, license is + copy of the license along with this program; if not, license is available online at . - + QLNet is a based on QuantLib, a free-software/open-source library for financial quantitative analysts and developers - http://quantlib.org/ The QuantLib license is available online at http://quantlib.org/license.shtml. - + This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the license for more details. */ using System; using System.Collections.Generic; +#if QL_DOTNET_FRAMEWORK using Microsoft.VisualStudio.TestTools.UnitTesting; +#else + using Xunit; +#endif using QLNet; namespace TestSuite { - [TestClass()] - public class T_PiecewiseyieldCurve { +#if QL_DOTNET_FRAMEWORK + [TestClass()] +#endif + public class T_PiecewiseyieldCurve : IDisposable + { public class CommonVars { #region Values public struct Datum { @@ -119,19 +126,9 @@ public struct BondDatum { public List schedules; public YieldTermStructure termStructure; - // cleanup - // SavedSettings backup = new SavedSettings(); - // IndexHistoryCleaner cleaner; - // setup public CommonVars() { - //cleaner = new IndexHistoryCleaner(); - ////GC.Collect(); - //// force garbage collection - //// garbage collection in .NET is rather weird and we do need when we run several tests in a row - //GC.Collect(); - // data calendar = new TARGET(); settlementDays = 2; @@ -222,6 +219,34 @@ public CommonVars() { } } + #region Initialize&Cleanup + private SavedSettings backup; + private IndexHistoryCleaner cleaner; + #if QL_DOTNET_FRAMEWORK + [TestInitialize] + public void testInitialize() + { + #else + public T_PiecewiseyieldCurve() + { + #endif + backup = new SavedSettings(); + cleaner = new IndexHistoryCleaner(); + } + #if QL_DOTNET_FRAMEWORK + [TestCleanup] + #endif + public void testCleanup() + { + Dispose(); + } + public void Dispose() + { + backup.Dispose(); + cleaner.Dispose(); + } + #endregion + //[TestMethod()] public void testLogCubicDiscountConsistency() { // "Testing consistency of piecewise-log-cubic discount curve..."); @@ -238,7 +263,11 @@ public void testLogCubicDiscountConsistency() { CubicInterpolation.BoundaryCondition.SecondDerivative, 0.0)); } +#if QL_DOTNET_FRAMEWORK [TestMethod()] +#else + [Fact] +#endif public void testLogLinearDiscountConsistency() { // "Testing consistency of piecewise-log-linear discount curve..."); @@ -248,7 +277,11 @@ public void testLogLinearDiscountConsistency() { testBMACurveConsistency( vars ); } +#if QL_DOTNET_FRAMEWORK [TestMethod()] +#else + [Fact] +#endif public void testLinearDiscountConsistency() { // "Testing consistency of piecewise-linear discount curve..." @@ -257,24 +290,31 @@ public void testLinearDiscountConsistency() { testCurveConsistency( vars ); testBMACurveConsistency( vars ); } - +#if QL_DOTNET_FRAMEWORK [TestMethod()] +#else + [Fact] +#endif public void testLogLinearZeroConsistency() { // "Testing consistency of piecewise-log-linear zero-yield curve..."); - + // if rates can be negative it makes no sense to interpolate loglinearly if ( Utils.is_QL_NEGATIVE_RATES() ) return; else { CommonVars vars = new CommonVars(); - + testCurveConsistency( vars ); testBMACurveConsistency( vars ); } } +#if QL_DOTNET_FRAMEWORK [TestMethod()] +#else + [Fact] +#endif public void testLinearZeroConsistency() { // "Testing consistency of piecewise-linear zero-yield curve..."); @@ -284,7 +324,11 @@ public void testLinearZeroConsistency() { testBMACurveConsistency( vars ); } +#if QL_DOTNET_FRAMEWORK [TestMethod()] +#else + [Fact] +#endif public void testSplineZeroConsistency() { //"Testing consistency of piecewise-cubic zero-yield curve..."); @@ -303,7 +347,11 @@ public void testSplineZeroConsistency() { CubicInterpolation.BoundaryCondition.SecondDerivative, 0.0)); } +#if QL_DOTNET_FRAMEWORK [TestMethod()] +#else + [Fact] +#endif public void testLinearForwardConsistency() { // "Testing consistency of piecewise-linear forward-rate curve..."); @@ -313,7 +361,11 @@ public void testLinearForwardConsistency() { testBMACurveConsistency( vars ); } +#if QL_DOTNET_FRAMEWORK [TestMethod()] +#else + [Fact] +#endif public void testFlatForwardConsistency() { //"Testing consistency of piecewise-flat forward-rate curve..."); @@ -343,7 +395,11 @@ public void testSplineForwardConsistency() { CubicInterpolation.BoundaryCondition.SecondDerivative, 0.0)); } +#if QL_DOTNET_FRAMEWORK [TestMethod()] +#else + [Fact] +#endif public void testConvexMonotoneForwardConsistency() { //"Testing consistency of convex monotone forward-rate curve..."); @@ -353,7 +409,11 @@ public void testConvexMonotoneForwardConsistency() { testBMACurveConsistency(vars); } +#if QL_DOTNET_FRAMEWORK [TestMethod()] +#else + [Fact] +#endif public void testLocalBootstrapConsistency() { //"Testing consistency of local-bootstrap algorithm..."); @@ -362,7 +422,11 @@ public void testLocalBootstrapConsistency() { testBMACurveConsistency( vars, new ConvexMonotone(), 1.0e-9 ); } +#if QL_DOTNET_FRAMEWORK [TestMethod()] +#else + [Fact] +#endif public void testObservability() { // "Testing observability of piecewise yield curve..."); @@ -379,20 +443,24 @@ public void testObservability() { f.lower(); vars.rates[i].setValue(vars.rates[i].value() * 1.01); if (!f.isUp()) - Assert.Fail("Observer was not notified of underlying rate change"); + QAssert.Fail("Observer was not notified of underlying rate change"); double discount_new = vars.termStructure.discount(testTime, true); if (discount_new == discount) - Assert.Fail("rate change did not trigger recalculation"); + QAssert.Fail("rate change did not trigger recalculation"); vars.rates[i].setValue(vars.rates[i].value() / 1.01); } f.lower(); Settings.setEvaluationDate(vars.calendar.advance(vars.today, 15, TimeUnit.Days)); if (!f.isUp()) - Assert.Fail("Observer was not notified of date change"); + QAssert.Fail("Observer was not notified of date change"); } +#if QL_DOTNET_FRAMEWORK [TestMethod()] +#else + [Fact] +#endif public void testLiborFixing() { // "Testing use of today's LIBOR fixings in swap curve..."); @@ -430,7 +498,7 @@ public void testLiborFixing() { estimatedRate = swap.fairRate(); double tolerance = 1.0e-9; if (Math.Abs(expectedRate-estimatedRate) > tolerance) { - Assert.Fail("before LIBOR fixing:\n" + QAssert.Fail("before LIBOR fixing:\n" + vars.swapData[i].n + " year(s) swap:\n" + " estimated rate: " + (estimatedRate) + "\n" @@ -446,7 +514,7 @@ public void testLiborFixing() { index.addFixing(vars.today, 0.0425); if (!f.isUp()) - Assert.Fail("Observer was not notified of rate fixing"); + QAssert.Fail("Observer was not notified of rate fixing"); for (int i=0; i tolerance) { - Assert.Fail("after LIBOR fixing:\n" + QAssert.Fail("after LIBOR fixing:\n" + vars.swapData[i].n + " year(s) swap:\n" + " estimated rate: " + (estimatedRate) + "\n" @@ -473,7 +541,11 @@ public void testLiborFixing() { } } +#if QL_DOTNET_FRAMEWORK [TestMethod()] +#else + [Fact] +#endif public void testForwardRateDayCounter() { CommonVars vars = new CommonVars(); @@ -486,14 +558,18 @@ public void testForwardRateDayCounter() { InterestRate ir = vars.termStructure.forwardRate(vars.settlement, vars.settlement + 30, d1, Compounding.Simple); if (ir.dayCounter().name() != d1.name()) - Assert.Fail("PiecewiseYieldCurve forwardRate dayCounter error" + + QAssert.Fail("PiecewiseYieldCurve forwardRate dayCounter error" + " Actual daycounter : " + vars.termStructure.dayCounter().name() + " Expetced DayCounter : " + d1.name()); } +#if QL_DOTNET_FRAMEWORK [TestMethod()] +#else + [Fact] +#endif public void testJpyLibor() { //"Testing bootstrap over JPY LIBOR swaps..."); @@ -554,7 +630,7 @@ public void testJpyLibor() { double tolerance = 1.0e-9; if (error > tolerance) { - Assert.Fail(vars.swapData[i].n + " year(s) swap:\n" + QAssert.Fail(vars.swapData[i].n + " year(s) swap:\n" + "\n estimated rate: " + (estimatedRate) + "\n expected rate: " + (expectedRate) + "\n error: " + (error) @@ -563,7 +639,11 @@ public void testJpyLibor() { } } +#if QL_DOTNET_FRAMEWORK [TestMethod()] +#else + [Fact] +#endif public void testDiscountCopy() { //BOOST_MESSAGE("Testing copying of discount curve..."); @@ -571,7 +651,11 @@ public void testDiscountCopy() { testCurveCopy(vars); } +#if QL_DOTNET_FRAMEWORK [TestMethod()] +#else + [Fact] +#endif public void testForwardCopy() { //BOOST_MESSAGE("Testing copying of forward-rate curve..."); @@ -579,7 +663,11 @@ public void testForwardCopy() { testCurveCopy(vars); } +#if QL_DOTNET_FRAMEWORK [TestMethod()] +#else + [Fact] +#endif public void testZeroCopy() { //BOOST_MESSAGE("Testing copying of zero-rate curve..."); @@ -613,13 +701,12 @@ public void testCurveConsistency(CommonVars vars, I interpolator, doubl Euribor index = new Euribor(new Period(vars.depositData[i].n, vars.depositData[i].units), curveHandle); double expectedRate = vars.depositData[i].rate / 100, estimatedRate = index.fixing(vars.today); - if (Math.Abs(expectedRate - estimatedRate) > tolerance) { - Console.WriteLine(vars.depositData[i].n + " " - + (vars.depositData[i].units == TimeUnit.Weeks ? "week(s)" : "month(s)") - + " deposit:" - + "\n estimated rate: " + estimatedRate - + "\n expected rate: " + expectedRate); - } + QAssert.IsTrue(Math.Abs(expectedRate - estimatedRate) < tolerance, + vars.depositData[i].n + " " + + (vars.depositData[i].units == TimeUnit.Weeks ? "week(s)" : "month(s)") + + " deposit:" + + "\n estimated rate: " + estimatedRate + + "\n expected rate: " + expectedRate); } // check swaps @@ -637,13 +724,12 @@ public void testCurveConsistency(CommonVars vars, I interpolator, doubl double expectedRate = vars.swapData[i].rate / 100, estimatedRate = swap.fairRate(); double error = Math.Abs(expectedRate - estimatedRate); - if (error > tolerance) { - Console.WriteLine(vars.swapData[i].n + " year(s) swap:\n" - + "\n estimated rate: " + estimatedRate - + "\n expected rate: " + expectedRate - + "\n error: " + error - + "\n tolerance: " + tolerance); - } + QAssert.IsTrue(error < tolerance, + vars.swapData[i].n + " year(s) swap:\n" + + "\n estimated rate: " + estimatedRate + + "\n expected rate: " + expectedRate + + "\n error: " + error + + "\n tolerance: " + tolerance); } // check bonds @@ -666,11 +752,10 @@ public void testCurveConsistency(CommonVars vars, I interpolator, doubl double expectedPrice = vars.bondData[i].price, estimatedPrice = bond.cleanPrice(); - if (Math.Abs(expectedPrice - estimatedPrice) > tolerance) { - Console.WriteLine(i + 1 + " bond failure:" + - "\n estimated price: " + estimatedPrice + - "\n expected price: " + expectedPrice); - } + QAssert.IsTrue(Math.Abs(expectedPrice - estimatedPrice) < tolerance, + i + 1 + " bond failure:" + + "\n estimated price: " + estimatedPrice + + "\n expected price: " + expectedPrice); } // check FRA @@ -693,11 +778,10 @@ public void testCurveConsistency(CommonVars vars, I interpolator, doubl 100.0, euribor3m, curveHandle); double expectedRate = vars.fraData[i].rate / 100, estimatedRate = fra.forwardRate().rate(); - if (Math.Abs(expectedRate - estimatedRate) > tolerance) { - Console.WriteLine(i + 1 + " FRA failure:" + - "\n estimated rate: " + estimatedRate + - "\n expected rate: " + expectedRate); - } + QAssert.IsTrue(Math.Abs(expectedRate - estimatedRate) < tolerance, + i + 1 + " FRA failure:" + + "\n estimated rate: " + estimatedRate + + "\n expected rate: " + expectedRate); } } @@ -773,7 +857,7 @@ public void testBMACurveConsistency(CommonVars vars, I interpolator, do .endOfMonth(libor3m.endOfMonth()) .backwards() .value(); - + BMASwap swap = new BMASwap(BMASwap.Type.Payer, 100.0, liborSchedule, 0.75, 0.0, libor3m, libor3m.dayCounter(), bmaSchedule, bma, vars.bmaDayCounter); swap.setPricingEngine(new DiscountingSwapEngine(libor3m.forwardingTermStructure())); @@ -781,13 +865,12 @@ public void testBMACurveConsistency(CommonVars vars, I interpolator, do double expectedFraction = vars.bmaData[i].rate / 100, estimatedFraction = swap.fairLiborFraction(); double error = Math.Abs(expectedFraction - estimatedFraction); - if (error > tolerance) { - Console.WriteLine(vars.bmaData[i].n + " year(s) BMA swap:\n" - + "\n estimated libor fraction: " + estimatedFraction - + "\n expected libor fraction: " + expectedFraction - + "\n error: " + error - + "\n tolerance: " + tolerance); - } + QAssert.IsTrue(error < tolerance, + vars.bmaData[i].n + " year(s) BMA swap:\n" + + "\n estimated libor fraction: " + estimatedFraction + + "\n expected libor fraction: " + expectedFraction + + "\n error: " + error + + "\n tolerance: " + tolerance); } // this is a workaround for grabage collection @@ -820,7 +903,7 @@ public void testCurveCopy(CommonVars vars, I interpolator) var r1 = curve.zeroRate(t, Compounding.Continuous).value(); var r2 = copiedCurve.zeroRate(t, Compounding.Continuous).value(); if (!Utils.close(r1, r2)) { - Assert.Fail("failed to link original and copied curve"); + QAssert.Fail("failed to link original and copied curve"); } for (int i=0; i(CommonVars vars, I interpolator) double r3 = curve.zeroRate(t, Compounding.Continuous).value(); double r4 = copiedCurve.zeroRate(t, Compounding.Continuous).value(); if (Utils.close(r1, r3)) { - Assert.Fail("failed to modify original curve"); + QAssert.Fail("failed to modify original curve"); } if (!Utils.close(r2,r4)) { - Assert.Fail("failed to break link between original and copied curve"); + QAssert.Fail("failed to break link between original and copied curve"); } } } diff --git a/Test/T_Quotes.cs b/Test/T_Quotes.cs index 3850161c6..b09fe1da4 100644 --- a/Test/T_Quotes.cs +++ b/Test/T_Quotes.cs @@ -17,14 +17,20 @@ under the terms of the QLNet license. You should have received a FOR A PARTICULAR PURPOSE. See the license for more details. */ -using System; -using Microsoft.VisualStudio.TestTools.UnitTesting; +using System; +#if QL_DOTNET_FRAMEWORK + using Microsoft.VisualStudio.TestTools.UnitTesting; +#else + using Xunit; +#endif using QLNet; namespace TestSuite -{ - - [TestClass()] +{ + +#if QL_DOTNET_FRAMEWORK + [TestClass()] +#endif public class T_Quotes { double add10(double x) { return x + 10; } @@ -33,9 +39,13 @@ public class T_Quotes double add(double x, double y) { return x + y; } double mul(double x, double y) { return x * y; } - double sub(double x, double y) { return x - y; } - - [TestMethod()] + double sub(double x, double y) { return x - y; } + +#if QL_DOTNET_FRAMEWORK + [TestMethod()] +#else + [Fact] +#endif public void testObservable() { // Testing observability of quotes @@ -47,10 +57,14 @@ public void testObservable() me.setValue(3.14); if (!f.isUp()) - Assert.Fail("Observer was not notified of quote change"); - - } - [TestMethod()] + QAssert.Fail("Observer was not notified of quote change"); + + } +#if QL_DOTNET_FRAMEWORK + [TestMethod()] +#else + [Fact] +#endif public void testObservableHandle() { @@ -66,18 +80,22 @@ public void testObservableHandle() me1.setValue(3.14); if (!f.isUp()) - Assert.Fail("Observer was not notified of quote change"); + QAssert.Fail("Observer was not notified of quote change"); f.lower(); SimpleQuote me2 = new SimpleQuote(0.0); h.linkTo(me2); if (!f.isUp()) - Assert.Fail("Observer was not notified of quote change"); - - } - - [TestMethod()] + QAssert.Fail("Observer was not notified of quote change"); + + } + +#if QL_DOTNET_FRAMEWORK + [TestMethod()] +#else + [Fact] +#endif public void testDerived() { @@ -94,12 +112,16 @@ public void testDerived() double x = derived.value(), y = f[i](me.value()); if (Math.Abs(x-y) > 1.0e-10) - Assert.Fail("derived quote yields " + x + "function result is " + y); + QAssert.Fail("derived quote yields " + x + "function result is " + y); } - } - - [TestMethod()] + } + +#if QL_DOTNET_FRAMEWORK + [TestMethod()] +#else + [Fact] +#endif public void testComposite() { // Testing composite quotes @@ -117,7 +139,7 @@ public void testComposite() double x = composite.value(), y = f[i](me1.value(),me2.value()); if (Math.Abs(x-y) > 1.0e-10) - Assert.Fail("composite quote yields " + x + "function result is " + y); + QAssert.Fail("composite quote yields " + x + "function result is " + y); } } diff --git a/Test/T_RNGTraits.cs b/Test/T_RNGTraits.cs index 37a271969..3277b0f3b 100644 --- a/Test/T_RNGTraits.cs +++ b/Test/T_RNGTraits.cs @@ -17,16 +17,26 @@ under the terms of the QLNet license. You should have received a FOR A PARTICULAR PURPOSE. See the license for more details. */ using System; -using System.Collections.Generic; -using Microsoft.VisualStudio.TestTools.UnitTesting; +using System.Collections.Generic; +#if QL_DOTNET_FRAMEWORK +using Microsoft.VisualStudio.TestTools.UnitTesting; +#else + using Xunit; +#endif using QLNet; namespace TestSuite -{ - [TestClass()] +{ +#if QL_DOTNET_FRAMEWORK + [TestClass()] +#endif public class T_RNGTraits - { - [TestMethod()] + { +#if QL_DOTNET_FRAMEWORK + [TestMethod()] +#else + [Fact] +#endif public void testGaussian() { //("Testing Gaussian pseudo-random number generation..."); @@ -42,12 +52,16 @@ public void testGaussian() double stored = 4.09916; double tolerance = 1.0e-5; if (Math.Abs(sum - stored) > tolerance) - Assert.Fail("the sum of the samples does not match the stored value\n" + QAssert.Fail("the sum of the samples does not match the stored value\n" + " calculated: " + sum + "\n" + " expected: " + stored); - } - - [TestMethod()] + } + +#if QL_DOTNET_FRAMEWORK + [TestMethod()] +#else + [Fact] +#endif public void testDefaultPoisson() { @@ -63,12 +77,16 @@ public void testDefaultPoisson() double stored = 108.0; if (!Utils.close(sum, stored)) - Assert.Fail("the sum of the samples does not match the stored value\n" + QAssert.Fail("the sum of the samples does not match the stored value\n" + " calculated: " + sum + "\n" + " expected: " + stored); - } - - [TestMethod()] + } + +#if QL_DOTNET_FRAMEWORK + [TestMethod()] +#else + [Fact] +#endif public void testCustomPoisson() { @@ -84,7 +102,7 @@ public void testCustomPoisson() double stored = 409.0; if (!Utils.close(sum, stored)) - Assert.Fail("the sum of the samples does not match the stored value\n" + QAssert.Fail("the sum of the samples does not match the stored value\n" + " calculated: " + sum + "\n" + " expected: " + stored); } diff --git a/Test/T_RiskStats.cs b/Test/T_RiskStats.cs index 2a1ad84e2..c8f8a2ee9 100644 --- a/Test/T_RiskStats.cs +++ b/Test/T_RiskStats.cs @@ -18,8 +18,12 @@ under the terms of the QLNet license. You should have received a */ using System; using System.Collections.Generic; -using System.Linq; -using Microsoft.VisualStudio.TestTools.UnitTesting; +using System.Linq; +#if QL_DOTNET_FRAMEWORK +using Microsoft.VisualStudio.TestTools.UnitTesting; +#else + using Xunit; +#endif using QLNet; namespace TestSuite @@ -27,12 +31,18 @@ namespace TestSuite class IncrementalGaussianStatistics : GenericGaussianStatistics { public double downsideVariance() { return ((IncrementalStatistics)impl_).downsideVariance(); } - } - - [TestClass()] + } + +#if QL_DOTNET_FRAMEWORK + [TestClass()] +#endif public class T_RiskStats - { - [TestMethod()] + { +#if QL_DOTNET_FRAMEWORK + [TestMethod()] +#else + [Fact] +#endif public void RiskStatisticsTest() { // ("Testing risk measures..."); @@ -75,12 +85,12 @@ public void RiskStatisticsTest() double tolerance; if (igs.samples() != N) - Assert.Fail("IncrementalGaussianStatistics: " + QAssert.Fail("IncrementalGaussianStatistics: " + "wrong number of samples\n" + " calculated: " + igs.samples() + "\n" + " expected: " + N); if (s.samples() != N) - Assert.Fail("RiskStatistics: wrong number of samples\n" + QAssert.Fail("RiskStatistics: wrong number of samples\n" + " calculated: " + s.samples() + "\n" + " expected: " + N); @@ -90,14 +100,14 @@ public void RiskStatisticsTest() expected = weights.Sum(); calculated = igs.weightSum(); if (Math.Abs(calculated - expected) > tolerance) - Assert.Fail("IncrementalGaussianStatistics: " + QAssert.Fail("IncrementalGaussianStatistics: " + "wrong sum of weights\n" + " calculated: " + calculated + "\n" + " expected: " + expected + "\n" + " tolerance: " + tolerance); calculated = s.weightSum(); if (Math.Abs(calculated - expected) > tolerance) - Assert.Fail("RiskStatistics: wrong sum of weights\n" + QAssert.Fail("RiskStatistics: wrong sum of weights\n" + " calculated: " + calculated + "\n" + " expected: " + expected + "\n" + " tolerance: " + tolerance); @@ -108,14 +118,14 @@ public void RiskStatisticsTest() expected = dataMin; calculated = igs.min(); if (Math.Abs(calculated - expected) > tolerance) - Assert.Fail("IncrementalGaussianStatistics: " + QAssert.Fail("IncrementalGaussianStatistics: " + "wrong minimum value\n" + " calculated: " + calculated + "\n" + " expected: " + expected + "\n" + " tolerance: " + tolerance); calculated = s.min(); if (Math.Abs(calculated - expected) > tolerance) - Assert.Fail("RiskStatistics: " + QAssert.Fail("RiskStatistics: " + "wrong minimum value\n" + " calculated: " + calculated + "\n" + " expected: " + expected + "\n" @@ -126,14 +136,14 @@ public void RiskStatisticsTest() expected = dataMax; calculated = igs.max(); if (Math.Abs(calculated - expected) > tolerance) - Assert.Fail("IncrementalGaussianStatistics: " + QAssert.Fail("IncrementalGaussianStatistics: " + "wrong maximum value\n" + " calculated: " + calculated + "\n" + " expected: " + expected + "\n" + " tolerance: " + tolerance); calculated = s.max(); if (Math.Abs(calculated - expected) > tolerance) - Assert.Fail("RiskStatistics: " + QAssert.Fail("RiskStatistics: " + "wrong maximum value\n" + " calculated: " + calculated + "\n" + " expected: " + expected + "\n" @@ -146,7 +156,7 @@ public void RiskStatisticsTest() Math.Abs(expected) * 1.0e-13); calculated = igs.mean(); if (Math.Abs(calculated - expected) > tolerance) - Assert.Fail("IncrementalGaussianStatistics: " + QAssert.Fail("IncrementalGaussianStatistics: " + "wrong mean value" + " for N(" + averages[i] + ", " + sigmas[j] + ")\n" @@ -155,7 +165,7 @@ public void RiskStatisticsTest() + " tolerance: " + tolerance); calculated = s.mean(); if (Math.Abs(calculated - expected) > tolerance) - Assert.Fail("RiskStatistics: wrong mean value" + QAssert.Fail("RiskStatistics: wrong mean value" + " for N(" + averages[i] + ", " + sigmas[j] + ")\n" + " calculated: " + calculated + "\n" @@ -168,7 +178,7 @@ public void RiskStatisticsTest() tolerance = expected * 1.0e-1; calculated = igs.variance(); if (Math.Abs(calculated - expected) > tolerance) - Assert.Fail("IncrementalGaussianStatistics: " + QAssert.Fail("IncrementalGaussianStatistics: " + "wrong variance" + " for N(" + averages[i] + ", " + sigmas[j] + ")\n" @@ -177,7 +187,7 @@ public void RiskStatisticsTest() + " tolerance: " + tolerance); calculated = s.variance(); if (Math.Abs(calculated - expected) > tolerance) - Assert.Fail("RiskStatistics: wrong variance" + QAssert.Fail("RiskStatistics: wrong variance" + " for N(" + averages[i] + ", " + sigmas[j] + ")\n" + " calculated: " + calculated + "\n" @@ -190,7 +200,7 @@ public void RiskStatisticsTest() tolerance = expected * 1.0e-1; calculated = igs.standardDeviation(); if (Math.Abs(calculated - expected) > tolerance) - Assert.Fail("IncrementalGaussianStatistics: " + QAssert.Fail("IncrementalGaussianStatistics: " + "wrong standard deviation" + " for N(" + averages[i] + ", " + sigmas[j] + ")\n" @@ -199,7 +209,7 @@ public void RiskStatisticsTest() + " tolerance: " + tolerance); calculated = s.standardDeviation(); if (Math.Abs(calculated - expected) > tolerance) - Assert.Fail("RiskStatistics: wrong standard deviation" + QAssert.Fail("RiskStatistics: wrong standard deviation" + " for N(" + averages[i] + ", " + sigmas[j] + ")\n" + " calculated: " + calculated + "\n" @@ -214,7 +224,7 @@ public void RiskStatisticsTest() tolerance = 1.0e-4; calculated = igs.skewness(); if (Math.Abs(calculated - expected) > tolerance) - Assert.Fail("IncrementalGaussianStatistics: " + QAssert.Fail("IncrementalGaussianStatistics: " + "wrong skewness" + " for N(" + averages[i] + ", " + sigmas[j] + ")\n" @@ -223,7 +233,7 @@ public void RiskStatisticsTest() + " tolerance: " + tolerance); calculated = s.skewness(); if (Math.Abs(calculated - expected) > tolerance) - Assert.Fail("RiskStatistics: wrong skewness" + QAssert.Fail("RiskStatistics: wrong skewness" + " for N(" + averages[i] + ", " + sigmas[j] + ")\n" + " calculated: " + calculated + "\n" @@ -236,7 +246,7 @@ public void RiskStatisticsTest() tolerance = 1.0e-1; calculated = igs.kurtosis(); if (Math.Abs(calculated - expected) > tolerance) - Assert.Fail("IncrementalGaussianStatistics: " + QAssert.Fail("IncrementalGaussianStatistics: " + "wrong kurtosis" + " for N(" + averages[i] + ", " + sigmas[j] + ")\n" @@ -245,7 +255,7 @@ public void RiskStatisticsTest() + " tolerance: " + tolerance); calculated = s.kurtosis(); if (Math.Abs(calculated - expected) > tolerance) - Assert.Fail("RiskStatistics: wrong kurtosis" + QAssert.Fail("RiskStatistics: wrong kurtosis" + " for N(" + averages[i] + ", " + sigmas[j] + ")\n" + " calculated: " + calculated + "\n" @@ -259,7 +269,7 @@ public void RiskStatisticsTest() Math.Abs(expected * 1.0e-3)); calculated = igs.gaussianPercentile(0.5); if (Math.Abs(calculated - expected) > tolerance) - Assert.Fail("IncrementalGaussianStatistics: " + QAssert.Fail("IncrementalGaussianStatistics: " + "wrong Gaussian percentile" + " for N(" + averages[i] + ", " + sigmas[j] + ")\n" @@ -268,7 +278,7 @@ public void RiskStatisticsTest() + " tolerance: " + tolerance); calculated = s.gaussianPercentile(0.5); if (Math.Abs(calculated - expected) > tolerance) - Assert.Fail("RiskStatistics: wrong Gaussian percentile" + QAssert.Fail("RiskStatistics: wrong Gaussian percentile" + " for N(" + averages[i] + ", " + sigmas[j] + ")\n" + " calculated: " + calculated + "\n" @@ -276,7 +286,7 @@ public void RiskStatisticsTest() + " tolerance: " + tolerance); calculated = s.percentile(0.5); if (Math.Abs(calculated - expected) > tolerance) - Assert.Fail("RiskStatistics: wrong percentile" + QAssert.Fail("RiskStatistics: wrong percentile" + " for N(" + averages[i] + ", " + sigmas[j] + ")\n" + " calculated: " + calculated + "\n" @@ -295,7 +305,7 @@ public void RiskStatisticsTest() Math.Abs(expected * 1.0e-3)); calculated = igs.gaussianPotentialUpside(twoSigma); if (Math.Abs(calculated - expected) > tolerance) - Assert.Fail("IncrementalGaussianStatistics: " + QAssert.Fail("IncrementalGaussianStatistics: " + "wrong Gaussian potential upside" + " for N(" + averages[i] + ", " + sigmas[j] + ")\n" @@ -304,7 +314,7 @@ public void RiskStatisticsTest() + " tolerance: " + tolerance); calculated = s.gaussianPotentialUpside(twoSigma); if (Math.Abs(calculated - expected) > tolerance) - Assert.Fail("RiskStatistics: wrong Gaussian potential upside" + QAssert.Fail("RiskStatistics: wrong Gaussian potential upside" + " for N(" + averages[i] + ", " + sigmas[j] + ")\n" + " calculated: " + calculated + "\n" @@ -312,7 +322,7 @@ public void RiskStatisticsTest() + " tolerance: " + tolerance); calculated = s.potentialUpside(twoSigma); if (Math.Abs(calculated - expected) > tolerance) - Assert.Fail("RiskStatistics: wrong potential upside" + QAssert.Fail("RiskStatistics: wrong potential upside" + " for N(" + averages[i] + ", " + sigmas[j] + ")\n" + " calculated: " + calculated + "\n" @@ -326,7 +336,7 @@ public void RiskStatisticsTest() expected = s.gaussianPotentialUpside(twoSigma); calculated = test.gaussianPotentialUpside(twoSigma); if (calculated != expected) - Assert.Fail("GenericGaussianStatistics fails" + QAssert.Fail("GenericGaussianStatistics fails" + "\n calculated: " + calculated + "\n expected: " + expected); @@ -337,7 +347,7 @@ public void RiskStatisticsTest() Math.Abs(expected * 1.0e-3)); calculated = igs.gaussianValueAtRisk(twoSigma); if (Math.Abs(calculated - expected) > tolerance) - Assert.Fail("IncrementalGaussianStatistics: " + QAssert.Fail("IncrementalGaussianStatistics: " + "wrong Gaussian value-at-risk" + " for N(" + averages[i] + ", " + sigmas[j] + ")\n" @@ -346,7 +356,7 @@ public void RiskStatisticsTest() + " tolerance: " + tolerance); calculated = s.gaussianValueAtRisk(twoSigma); if (Math.Abs(calculated - expected) > tolerance) - Assert.Fail("RiskStatistics: wrong Gaussian value-at-risk" + QAssert.Fail("RiskStatistics: wrong Gaussian value-at-risk" + " for N(" + averages[i] + ", " + sigmas[j] + ")\n" + " calculated: " + calculated + "\n" @@ -354,7 +364,7 @@ public void RiskStatisticsTest() + " tolerance: " + tolerance); calculated = s.valueAtRisk(twoSigma); if (Math.Abs(calculated - expected) > tolerance) - Assert.Fail("RiskStatistics: wrong value-at-risk" + QAssert.Fail("RiskStatistics: wrong value-at-risk" + " for N(" + averages[i] + ", " + sigmas[j] + ")\n" + " calculated: " + calculated + "\n" @@ -380,7 +390,7 @@ public void RiskStatisticsTest() : Math.Abs(expected) * 1.0e-2); calculated = igs.gaussianExpectedShortfall(twoSigma); if (Math.Abs(calculated - expected) > tolerance) - Assert.Fail("IncrementalGaussianStatistics: " + QAssert.Fail("IncrementalGaussianStatistics: " + "wrong Gaussian expected shortfall" + " for N(" + averages[i] + ", " + sigmas[j] + ")\n" @@ -389,7 +399,7 @@ public void RiskStatisticsTest() + " tolerance: " + tolerance); calculated = s.gaussianExpectedShortfall(twoSigma); if (Math.Abs(calculated - expected) > tolerance) - Assert.Fail("RiskStatistics: wrong Gaussian expected shortfall" + QAssert.Fail("RiskStatistics: wrong Gaussian expected shortfall" + " for N(" + averages[i] + ", " + sigmas[j] + ")\n" + " calculated: " + calculated + "\n" @@ -397,7 +407,7 @@ public void RiskStatisticsTest() + " tolerance: " + tolerance); calculated = s.expectedShortfall(twoSigma); if (Math.Abs(calculated - expected) > tolerance) - Assert.Fail("RiskStatistics: wrong expected shortfall" + QAssert.Fail("RiskStatistics: wrong expected shortfall" + " for N(" + averages[i] + ", " + sigmas[j] + ")\n" + " calculated: " + calculated + "\n" @@ -411,7 +421,7 @@ public void RiskStatisticsTest() Math.Abs(expected * 1.0e-3)); calculated = igs.gaussianShortfall(averages[i]); if (Math.Abs(calculated - expected) > tolerance) - Assert.Fail("IncrementalGaussianStatistics: " + QAssert.Fail("IncrementalGaussianStatistics: " + "wrong Gaussian shortfall" + " for N(" + averages[i] + ", " + sigmas[j] + ")\n" @@ -420,7 +430,7 @@ public void RiskStatisticsTest() + " tolerance: " + tolerance); calculated = s.gaussianShortfall(averages[i]); if (Math.Abs(calculated - expected) > tolerance) - Assert.Fail("RiskStatistics: wrong Gaussian shortfall" + QAssert.Fail("RiskStatistics: wrong Gaussian shortfall" + " for N(" + averages[i] + ", " + sigmas[j] + ")\n" + " calculated: " + calculated + "\n" @@ -428,7 +438,7 @@ public void RiskStatisticsTest() + " tolerance: " + tolerance); calculated = s.shortfall(averages[i]); if (Math.Abs(calculated - expected) > tolerance) - Assert.Fail("RiskStatistics: wrong shortfall" + QAssert.Fail("RiskStatistics: wrong shortfall" + " for N(" + averages[i] + ", " + sigmas[j] + ")\n" + " calculated: " + calculated + "\n" @@ -441,7 +451,7 @@ public void RiskStatisticsTest() tolerance = expected * 1.0e-3; calculated = igs.gaussianAverageShortfall(averages[i]); if (Math.Abs(calculated - expected) > tolerance) - Assert.Fail("IncrementalGaussianStatistics: " + QAssert.Fail("IncrementalGaussianStatistics: " + "wrong Gaussian average shortfall" + " for N(" + averages[i] + ", " + sigmas[j] + ")\n" @@ -450,7 +460,7 @@ public void RiskStatisticsTest() + " tolerance: " + tolerance); calculated = s.gaussianAverageShortfall(averages[i]); if (Math.Abs(calculated - expected) > tolerance) - Assert.Fail("RiskStatistics: wrong Gaussian average shortfall" + QAssert.Fail("RiskStatistics: wrong Gaussian average shortfall" + " for N(" + averages[i] + ", " + sigmas[j] + ")\n" + " calculated: " + calculated + "\n" @@ -458,7 +468,7 @@ public void RiskStatisticsTest() + " tolerance: " + tolerance); calculated = s.averageShortfall(averages[i]); if (Math.Abs(calculated - expected) > tolerance) - Assert.Fail("RiskStatistics: wrong average shortfall" + QAssert.Fail("RiskStatistics: wrong average shortfall" + " for N(" + averages[i] + ", " + sigmas[j] + ")\n" + " calculated: " + calculated + "\n" @@ -471,7 +481,7 @@ public void RiskStatisticsTest() tolerance = expected * 1.0e-1; calculated = igs.gaussianRegret(averages[i]); if (Math.Abs(calculated - expected) > tolerance) - Assert.Fail("IncrementalGaussianStatistics: " + QAssert.Fail("IncrementalGaussianStatistics: " + "wrong Gaussian regret(" + averages[i] + ") " + "for N(" + averages[i] + ", " + sigmas[j] + ")\n" @@ -480,7 +490,7 @@ public void RiskStatisticsTest() + " tolerance: " + tolerance); calculated = s.gaussianRegret(averages[i]); if (Math.Abs(calculated - expected) > tolerance) - Assert.Fail("RiskStatistics: " + QAssert.Fail("RiskStatistics: " + "wrong Gaussian regret(" + averages[i] + ") " + "for N(" + averages[i] + ", " + sigmas[j] + ")\n" @@ -489,7 +499,7 @@ public void RiskStatisticsTest() + " tolerance: " + tolerance); calculated = s.regret(averages[i]); if (Math.Abs(calculated - expected) > tolerance) - Assert.Fail("RiskStatistics: " + QAssert.Fail("RiskStatistics: " + "wrong regret(" + averages[i] + ") " + "for N(" + averages[i] + ", " + sigmas[j] + ")\n" @@ -504,7 +514,7 @@ public void RiskStatisticsTest() Math.Abs(expected * 1.0e-3)); calculated = igs.downsideVariance(); if (Math.Abs(calculated - expected) > tolerance) - Assert.Fail("IncrementalGaussianStatistics: " + QAssert.Fail("IncrementalGaussianStatistics: " + "wrong downside variance" + "for N(" + averages[i] + ", " + sigmas[j] + ")\n" @@ -513,7 +523,7 @@ public void RiskStatisticsTest() + " tolerance: " + tolerance); calculated = igs.gaussianDownsideVariance(); if (Math.Abs(calculated - expected) > tolerance) - Assert.Fail("IncrementalGaussianStatistics: " + QAssert.Fail("IncrementalGaussianStatistics: " + "wrong Gaussian downside variance" + "for N(" + averages[i] + ", " + sigmas[j] + ")\n" @@ -528,7 +538,7 @@ public void RiskStatisticsTest() tolerance = expected * 1.0e-3; calculated = igs.downsideVariance(); if (Math.Abs(calculated - expected) > tolerance) - Assert.Fail("IncrementalGaussianStatistics: " + QAssert.Fail("IncrementalGaussianStatistics: " + "wrong downside variance" + "for N(" + averages[i] + ", " + sigmas[j] + ")\n" @@ -537,7 +547,7 @@ public void RiskStatisticsTest() + " tolerance: " + tolerance); calculated = igs.gaussianDownsideVariance(); if (Math.Abs(calculated - expected) > tolerance) - Assert.Fail("IncrementalGaussianStatistics: " + QAssert.Fail("IncrementalGaussianStatistics: " + "wrong Gaussian downside variance" + "for N(" + averages[i] + ", " + sigmas[j] + ")\n" @@ -546,7 +556,7 @@ public void RiskStatisticsTest() + " tolerance: " + tolerance); calculated = s.downsideVariance(); if (Math.Abs(calculated - expected) > tolerance) - Assert.Fail("RiskStatistics: wrong downside variance" + QAssert.Fail("RiskStatistics: wrong downside variance" + "for N(" + averages[i] + ", " + sigmas[j] + ")\n" + " calculated: " + calculated + "\n" @@ -554,7 +564,7 @@ public void RiskStatisticsTest() + " tolerance: " + tolerance); calculated = s.gaussianDownsideVariance(); if (Math.Abs(calculated - expected) > tolerance) - Assert.Fail("RiskStatistics: wrong Gaussian downside variance" + QAssert.Fail("RiskStatistics: wrong Gaussian downside variance" + "for N(" + averages[i] + ", " + sigmas[j] + ")\n" + " calculated: " + calculated + "\n" diff --git a/Test/T_Rounding.cs b/Test/T_Rounding.cs index 67955dac0..04b4cc2c2 100644 --- a/Test/T_Rounding.cs +++ b/Test/T_Rounding.cs @@ -15,14 +15,20 @@ under the terms of the QLNet license. You should have received a This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the license for more details. -*/ - -using Microsoft.VisualStudio.TestTools.UnitTesting; +*/ + +#if QL_DOTNET_FRAMEWORK +using Microsoft.VisualStudio.TestTools.UnitTesting; +#else + using Xunit; +#endif using QLNet; namespace TestSuite -{ - [TestClass()] +{ +#if QL_DOTNET_FRAMEWORK + [TestClass()] +#endif public class T_Rounding { public struct TestCase @@ -69,9 +75,13 @@ public TestCase(double x, int precision, double closest, double up, double down, new TestCase(4.60998652, 1, 4.6, 4.7, 4.6, 4.6, 4.6 ), new TestCase(6.28794223, 3, 6.288, 6.288, 6.287, 6.288, 6.287 ), new TestCase(7.89428221, 2, 7.89, 7.90, 7.89, 7.89, 7.89 ) - }; - - [TestMethod()] + }; + +#if QL_DOTNET_FRAMEWORK + [TestMethod()] +#else + [Fact] +#endif public void testClosest() { for (int i = 0; i < testData.Length; i++) @@ -81,10 +91,14 @@ public void testClosest() double calculated = closest.Round(testData[i].x); double expected = testData[i].closest; if (!Utils.close(calculated, expected, 1)) - Assert.Fail("Original number: " + testData[i].x + "Expected: " + expected + "Calculated: " + calculated); + QAssert.Fail("Original number: " + testData[i].x + "Expected: " + expected + "Calculated: " + calculated); } - } - [TestMethod()] + } +#if QL_DOTNET_FRAMEWORK + [TestMethod()] +#else + [Fact] +#endif public void testUp() { for (int i = 0; i < testData.Length; i++) @@ -94,11 +108,15 @@ public void testUp() double calculated = up.Round(testData[i].x); double expected = testData[i].up; if (!Utils.close(calculated, expected, 1)) - Assert.Fail("Original number: " + testData[i].x + "Expected: " + expected + "Calculated: " + calculated); + QAssert.Fail("Original number: " + testData[i].x + "Expected: " + expected + "Calculated: " + calculated); } - } - - [TestMethod()] + } + +#if QL_DOTNET_FRAMEWORK + [TestMethod()] +#else + [Fact] +#endif public void testDown() { for (int i = 0; i < testData.Length; i++) @@ -108,11 +126,15 @@ public void testDown() double calculated = down.Round(testData[i].x); double expected = testData[i].down; if (!Utils.close(calculated, expected, 1)) - Assert.Fail("Original number: " + testData[i].x + "Expected: " + expected + "Calculated: " + calculated); + QAssert.Fail("Original number: " + testData[i].x + "Expected: " + expected + "Calculated: " + calculated); } - } - - [TestMethod()] + } + +#if QL_DOTNET_FRAMEWORK + [TestMethod()] +#else + [Fact] +#endif public void testFloor() { for (int i = 0; i < testData.Length; i++) @@ -122,11 +144,15 @@ public void testFloor() double calculated = floor.Round(testData[i].x); double expected = testData[i].floor; if (!Utils.close(calculated, expected, 1)) - Assert.Fail("Original number: " + testData[i].x + "Expected: " + expected + "Calculated: " + calculated); + QAssert.Fail("Original number: " + testData[i].x + "Expected: " + expected + "Calculated: " + calculated); } - } - - [TestMethod()] + } + +#if QL_DOTNET_FRAMEWORK + [TestMethod()] +#else + [Fact] +#endif public void testCeiling() { for (int i = 0; i < testData.Length; i++) @@ -136,7 +162,7 @@ public void testCeiling() double calculated = ceiling.Round(testData[i].x); double expected = testData[i].ceiling; if (!Utils.close(calculated, expected, 1)) - Assert.Fail("Original number: " + testData[i].x + "Expected: " + expected + "Calculated: " + calculated); + QAssert.Fail("Original number: " + testData[i].x + "Expected: " + expected + "Calculated: " + calculated); } } diff --git a/Test/T_SampledCurve.cs b/Test/T_SampledCurve.cs index 92b8742e3..42e2792a9 100644 --- a/Test/T_SampledCurve.cs +++ b/Test/T_SampledCurve.cs @@ -16,22 +16,32 @@ under the terms of the QLNet license. You should have received a ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the license for more details. */ -using System; -using Microsoft.VisualStudio.TestTools.UnitTesting; +using System; +#if QL_DOTNET_FRAMEWORK +using Microsoft.VisualStudio.TestTools.UnitTesting; +#else + using Xunit; +#endif using QLNet; namespace TestSuite -{ - [TestClass()] +{ +#if QL_DOTNET_FRAMEWORK + [TestClass()] +#endif public class T_SampledCurve { class FSquared { public double value(double x) { return x * x; } - } - - [TestMethod()] + } + +#if QL_DOTNET_FRAMEWORK + [TestMethod()] +#else + [Fact] +#endif public void testConstruction() { //("Testing sampled curve construction..."); @@ -42,30 +52,30 @@ public void testConstruction() double expected = 100.0; if (Math.Abs(curve.value(0) - expected) > 1e-5) { - Assert.Fail("function sampling failed"); + QAssert.Fail("function sampling failed"); } curve.setValue(0, 2.0); if (Math.Abs(curve.value(0) - 2.0) > 1e-5) { - Assert.Fail("curve value setting failed"); + QAssert.Fail("curve value setting failed"); } Vector value = curve.values(); value[1] = 3.0; if (Math.Abs(curve.value(1) - 3.0) > 1e-5) { - Assert.Fail("curve value grid failed"); + QAssert.Fail("curve value grid failed"); } curve.shiftGrid(10.0); if (Math.Abs(curve.gridValue(0) - 0.0) > 1e-5) { - Assert.Fail("sample curve shift grid failed"); + QAssert.Fail("sample curve shift grid failed"); } if (Math.Abs(curve.value(0) - 2.0) > 1e-5) { - Assert.Fail("sample curve shift grid - value failed"); + QAssert.Fail("sample curve shift grid - value failed"); } curve.sample(f2.value); @@ -78,7 +88,7 @@ public void testConstruction() double exp = f2.value(grid); if (Math.Abs(v - exp) > tolerance) { - Assert.Fail("sample curve regriding failed" + + QAssert.Fail("sample curve regriding failed" + "\n at " + (i + 1) + " point " + "(x = " + grid + ")" + "\n grid value: " + v + "\n expected: " + exp); diff --git a/Test/T_Schedule.cs b/Test/T_Schedule.cs index 701588159..039082067 100644 --- a/Test/T_Schedule.cs +++ b/Test/T_Schedule.cs @@ -17,32 +17,42 @@ under the terms of the QLNet license. You should have received a FOR A PARTICULAR PURPOSE. See the license for more details. */ using System.Collections.Generic; +#if QL_DOTNET_FRAMEWORK using Microsoft.VisualStudio.TestTools.UnitTesting; +#else + using Xunit; +#endif using QLNet; namespace TestSuite { +#if QL_DOTNET_FRAMEWORK [TestClass()] +#endif public class T_Schedule { void check_dates(Schedule s, List expected) { if (s.Count != expected.Count) { - Assert.Fail("expected " + expected.Count + " dates, " + "found " + s.Count); + QAssert.Fail("expected " + expected.Count + " dates, " + "found " + s.Count); } for (int i = 0; i < expected.Count; ++i) { if (s[i] != expected[i]) { - Assert.Fail("expected " + expected[i] + " at index " + i + ", " + "found " + s[i]); + QAssert.Fail("expected " + expected[i] + " at index " + i + ", " + "found " + s[i]); } } } - [TestMethod()] +#if QL_DOTNET_FRAMEWORK + [TestMethod()] +#else + [Fact] +#endif public void testDailySchedule() { // Testing schedule with daily frequency @@ -68,7 +78,11 @@ public void testDailySchedule() check_dates(s, expected); } - [TestMethod()] +#if QL_DOTNET_FRAMEWORK + [TestMethod()] +#else + [Fact] +#endif public void testEndDateWithEomAdjustment() { // Testing end date for schedule with end-of-month adjustment @@ -110,7 +124,11 @@ public void testEndDateWithEomAdjustment() check_dates(s, expected); } - [TestMethod()] +#if QL_DOTNET_FRAMEWORK + [TestMethod()] +#else + [Fact] +#endif public void testDatesPastEndDateWithEomAdjustment() { @@ -133,8 +151,45 @@ public void testDatesPastEndDateWithEomAdjustment() check_dates(s, expected); } +#if QL_DOTNET_FRAMEWORK + [TestMethod()] +#else + [Fact] +#endif + public void testDatesSameAsEndDateWithEomAdjustment() + { + // Testing that next-to-last date same as end date is removed... + + Schedule s = new MakeSchedule().from(new Date(28, Month.March, 2013)) + .to(new Date(31, Month.March, 2015)) + .withCalendar(new TARGET()) + .withTenor(new Period(1, TimeUnit.Years)) + .withConvention(BusinessDayConvention.Unadjusted) + .withTerminationDateConvention(BusinessDayConvention.Unadjusted) + .forwards() + .endOfMonth() + .value(); + + List expected = new List(3); + expected.Add(new Date(31, Month.March, 2013)); + expected.Add(new Date(31, Month.March, 2014)); + // March 31st 2015, coming from the EOM adjustment of March 28th, + // should be discarded as the same as the end date. + expected.Add(new Date(31, Month.March, 2015)); + + check_dates(s, expected); + + // also, the last period should be regular. + if (!s.isRegular(2)) + QAssert.Fail("last period should be regular"); + } + - [TestMethod()] +#if QL_DOTNET_FRAMEWORK + [TestMethod()] +#else + [Fact] +#endif public void testForwardDatesWithEomAdjustment() { // Testing that the last date is not adjusted for EOM when termination date convention is unadjusted @@ -148,7 +203,7 @@ public void testForwardDatesWithEomAdjustment() .forwards() .endOfMonth().value(); - List expected = new List(); + List expected = new List(); expected.Add(new Date(31, Month.August, 1996)); expected.Add(new Date(28, Month.February, 1997)); expected.Add(new Date(31, Month.August, 1997)); @@ -157,7 +212,11 @@ public void testForwardDatesWithEomAdjustment() check_dates(s, expected); } - [TestMethod()] +#if QL_DOTNET_FRAMEWORK + [TestMethod()] +#else + [Fact] +#endif public void testBackwardDatesWithEomAdjustment() { // Testing that the first date is not adjusted for EOM going backward when termination date convention is unadjusted @@ -171,7 +230,7 @@ public void testBackwardDatesWithEomAdjustment() .backwards() .endOfMonth().value(); - List expected = new List(); + List expected = new List(); expected.Add(new Date(22, Month.August, 1996)); expected.Add(new Date(31, Month.August, 1996)); expected.Add(new Date(28, Month.February, 1997)); @@ -180,7 +239,11 @@ public void testBackwardDatesWithEomAdjustment() check_dates(s, expected); } - [TestMethod()] +#if QL_DOTNET_FRAMEWORK + [TestMethod()] +#else + [Fact] +#endif public void testDoubleFirstDateWithEomAdjustment() { // Testing that the first date is not duplicated due to EOM convention when going backwards @@ -194,7 +257,7 @@ public void testDoubleFirstDateWithEomAdjustment() .backwards() .endOfMonth().value(); - List expected = new List(); + List expected = new List(); expected.Add(new Date(30, Month.August, 1996)); expected.Add(new Date(28, Month.February, 1997)); expected.Add(new Date(29, Month.August, 1997)); @@ -202,7 +265,11 @@ public void testDoubleFirstDateWithEomAdjustment() check_dates(s, expected); } - [TestMethod()] +#if QL_DOTNET_FRAMEWORK + [TestMethod()] +#else + [Fact] +#endif public void testDateConstructor() { // Testing the constructor taking a vector of dates and possibly additional meta information @@ -216,14 +283,14 @@ public void testDateConstructor() // schedule without any additional information Schedule schedule1 = new Schedule(dates); if (schedule1.Count != dates.Count) - Assert.Fail("schedule1 has size {0}, expected {1}", schedule1.Count, dates.Count); + QAssert.Fail( "schedule1 has size " + schedule1.Count + ", expected " + dates.Count ); for (int i = 0; i < dates.Count; ++i) if (schedule1[i] != dates[i]) - Assert.Fail("schedule1 has {0} at position {1}, expected {2}", schedule1[i], i, dates[i]); + QAssert.Fail("schedule1 has "+schedule1[i]+" at position "+i+", expected "+ dates[i]); if (schedule1.calendar() != new NullCalendar()) - Assert.Fail("schedule1 has calendar {0}, expected null calendar", schedule1.calendar().name()); + QAssert.Fail("schedule1 has calendar "+schedule1.calendar().name()+", expected null calendar"); if (schedule1.businessDayConvention() != BusinessDayConvention.Unadjusted) - Assert.Fail("schedule1 has convention {0}, expected unadjusted", schedule1.businessDayConvention()); + QAssert.Fail( "schedule1 has convention " + schedule1.businessDayConvention() + ", expected unadjusted" ); // schedule with metadata List regular = new List(); @@ -235,19 +302,19 @@ public void testDateConstructor() DateGeneration.Rule.Backward, true, regular); for (int i = 1; i < dates.Count; ++i) if (schedule2.isRegular(i) != regular[i - 1]) - Assert.Fail("schedule2 has a {0} period at position {1}, expected {2}", (schedule2.isRegular(i) ? "regular" : "irregular"), i, (regular[i - 1] ? "regular" : "irregular")); + QAssert.Fail( "schedule2 has a " + ( schedule2.isRegular( i ) ? "regular" : "irregular" ) + " period at position " + i + ", expected " + ( regular[i - 1] ? "regular" : "irregular" ) ); if (schedule2.calendar() != new TARGET()) - Assert.Fail("schedule1 has calendar {0}, expected TARGET", schedule2.calendar().name()); + QAssert.Fail( "schedule1 has calendar " + schedule2.calendar().name() + ", expected TARGET" ); if (schedule2.businessDayConvention() != BusinessDayConvention.Following) - Assert.Fail("schedule2 has convention {0}, expected Following", schedule2.businessDayConvention()); + QAssert.Fail( "schedule2 has convention " + schedule2.businessDayConvention() + ", expected Following" ); if (schedule2.terminationDateBusinessDayConvention() != BusinessDayConvention.ModifiedPreceding) - Assert.Fail("schedule2 has convention {0}, expected Modified Preceding", schedule2.terminationDateBusinessDayConvention()); + QAssert.Fail( "schedule2 has convention " + schedule2.terminationDateBusinessDayConvention() + ", expected Modified Preceding" ); if (schedule2.tenor() != new Period(1, TimeUnit.Years)) - Assert.Fail("schedule2 has tenor {0}, expected 1Y", schedule2.tenor()); + QAssert.Fail( "schedule2 has tenor " + schedule2.tenor() + ", expected 1Y" ); if (schedule2.rule() != DateGeneration.Rule.Backward) - Assert.Fail("schedule2 has rule {0}, expected Backward", schedule2.rule()); + QAssert.Fail( "schedule2 has rule " + schedule2.rule() + ", expected Backward" ); if (schedule2.endOfMonth() != true) - Assert.Fail("schedule2 has end of month flag false, expected true"); + QAssert.Fail("schedule2 has end of month flag false, expected true"); } } } diff --git a/Test/T_ShortRateModels.cs b/Test/T_ShortRateModels.cs index 5539b655d..0d142e371 100644 --- a/Test/T_ShortRateModels.cs +++ b/Test/T_ShortRateModels.cs @@ -20,13 +20,19 @@ under the terms of the QLNet license. You should have received a using System; using System.Collections.Generic; -using System.Linq; -using Microsoft.VisualStudio.TestTools.UnitTesting; +using System.Linq; +#if QL_DOTNET_FRAMEWORK +using Microsoft.VisualStudio.TestTools.UnitTesting; +#else + using Xunit; +#endif using QLNet; namespace TestSuite -{ - [TestClass()] +{ +#if QL_DOTNET_FRAMEWORK + [TestClass()] +#endif public class T_ShortRateModels { @@ -41,9 +47,13 @@ public CalibrationData(int s, int l, double v) length = l; volatility = v; } - } - - [TestMethod()] + } + +#if QL_DOTNET_FRAMEWORK + [TestMethod()] +#else + [Fact] +#endif public void testCachedHullWhite() { //("Testing Hull-White calibration against cached values..."); @@ -106,7 +116,7 @@ public void testCachedHullWhite() { double yMinExpected = model.value(xMinExpected, swaptions); if (Math.Abs(xMinCalculated[0]-cachedA) > tolerance || Math.Abs(xMinCalculated[1]-cachedSigma) > tolerance) { - Assert.Fail ("Failed to reproduce cached calibration results:\n" + QAssert.Fail ("Failed to reproduce cached calibration results:\n" + "calculated: a = " + xMinCalculated[0] + ", " + "sigma = " + xMinCalculated[1] + ", " + "f(a) = " + yMinCalculated + ",\n" @@ -118,9 +128,13 @@ public void testCachedHullWhite() { + "f(a) = " + (yMinCalculated - yMinExpected) + ",\n" + "end criteria = " + ecType ); } - } - - [TestMethod()] + } + +#if QL_DOTNET_FRAMEWORK + [TestMethod()] +#else + [Fact] +#endif public void testSwaps() { //BOOST_MESSAGE("Testing Hull-White swap pricing against known values..."); @@ -222,7 +236,7 @@ public void testSwaps() { double error = Math.Abs((expected-calculated)/expected); if (error > tolerance) { - Assert.Fail("Failed to reproduce swap NPV:" + QAssert.Fail("Failed to reproduce swap NPV:" //+ QL_FIXED << std::setprecision(9) + "\n calculated: " + calculated + "\n expected: " + expected @@ -232,9 +246,13 @@ public void testSwaps() { } } } - } - - [TestMethod()] + } + +#if QL_DOTNET_FRAMEWORK + [TestMethod()] +#else + [Fact] +#endif public void testFuturesConvexityBias() { //BOOST_MESSAGE("Testing Hull-White futures convexity bias..."); @@ -257,7 +275,7 @@ public void testFuturesConvexityBias() if (error > tolerance) { - Assert.Fail("Failed to reproduce convexity bias:" + QAssert.Fail("Failed to reproduce convexity bias:" + "\ncalculated: " + calculatedForward + "\n expected: " + expectedForward //+ QL_SCIENTIFIC diff --git a/Test/T_Solvers.cs b/Test/T_Solvers.cs index 5fecc7ad0..d6749becb 100644 --- a/Test/T_Solvers.cs +++ b/Test/T_Solvers.cs @@ -17,13 +17,19 @@ under the terms of the QLNet license. You should have received a FOR A PARTICULAR PURPOSE. See the license for more details. */ -using System; -using Microsoft.VisualStudio.TestTools.UnitTesting; +using System; +#if QL_DOTNET_FRAMEWORK +using Microsoft.VisualStudio.TestTools.UnitTesting; +#else + using Xunit; +#endif using QLNet; namespace TestSuite -{ - [TestClass()] +{ +#if QL_DOTNET_FRAMEWORK + [TestClass()] +#endif public class T_Solvers { class Foo : ISolver1d @@ -41,7 +47,7 @@ public void test(Solver1D solver, string name) double root = solver.solve(new Foo(), accuracy[i], 1.5, 0.1); if (Math.Abs(root - expected) > accuracy[i]) { - Assert.Fail(name + " solver:\n" + QAssert.Fail(name + " solver:\n" + " expected: " + expected + "\n" + " calculated: " + root + "\n" + " accuracy: " + accuracy[i]); @@ -49,40 +55,64 @@ public void test(Solver1D solver, string name) root = solver.solve(new Foo(), accuracy[i], 1.5, 0.0, 1.0); if (Math.Abs(root - expected) > accuracy[i]) { - Assert.Fail(name + " solver (bracketed):\n" + QAssert.Fail(name + " solver (bracketed):\n" + " expected: " + expected + "\n" + " calculated: " + root + "\n" + " accuracy: " + accuracy[i]); } } - } - - [TestMethod()] + } + +#if QL_DOTNET_FRAMEWORK + [TestMethod()] +#else + [Fact] +#endif public void testBrent() { test(new Brent(), "Brent"); - } - [TestMethod()] + } +#if QL_DOTNET_FRAMEWORK + [TestMethod()] +#else + [Fact] +#endif public void testNewton() { test(new Newton(), "Newton"); - } - [TestMethod()] + } +#if QL_DOTNET_FRAMEWORK + [TestMethod()] +#else + [Fact] +#endif public void testFalsePosition() { test(new FalsePosition(), "FalsePosition"); - } - [TestMethod()] + } +#if QL_DOTNET_FRAMEWORK + [TestMethod()] +#else + [Fact] +#endif public void testBisection() { test(new Bisection(), "Bisection"); - } - [TestMethod()] + } +#if QL_DOTNET_FRAMEWORK + [TestMethod()] +#else + [Fact] +#endif public void testRidder() { test(new Ridder(), "Ridder"); - } - [TestMethod()] + } +#if QL_DOTNET_FRAMEWORK + [TestMethod()] +#else + [Fact] +#endif public void testSecant() { test(new Secant(), "Secant"); diff --git a/Test/T_Stats.cs b/Test/T_Stats.cs index 49e8263a9..fb254907f 100644 --- a/Test/T_Stats.cs +++ b/Test/T_Stats.cs @@ -18,36 +18,54 @@ under the terms of the QLNet license. You should have received a */ using System; using System.Collections.Generic; -using System.Linq; -using Microsoft.VisualStudio.TestTools.UnitTesting; -using QLNet; - +using System.Linq; +#if QL_DOTNET_FRAMEWORK +using Microsoft.VisualStudio.TestTools.UnitTesting; +#else + using Xunit; +#endif +using QLNet; + namespace TestSuite -{ - [TestClass()] +{ +#if QL_DOTNET_FRAMEWORK + [TestClass()] +#endif public class T_Stats { double[] data = { 3.0, 4.0, 5.0, 2.0, 3.0, 4.0, 5.0, 6.0, 4.0, 7.0 }; - double[] weights = { 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0 }; - - [TestMethod()] + double[] weights = { 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0 }; + +#if QL_DOTNET_FRAMEWORK + [TestMethod()] +#else + [Fact] +#endif public void testStatistics() { check("IncrementalStatistics"); check("Statistics"); - } - - [TestMethod()] + } + +#if QL_DOTNET_FRAMEWORK + [TestMethod()] +#else + [Fact] +#endif public void testSequenceStatistics() { //("Testing sequence statistics..."); checkSequence("IncrementalStatistics", 5); checkSequence("Statistics", 5); - } - - [TestMethod()] + } + +#if QL_DOTNET_FRAMEWORK + [TestMethod()] +#else + [Fact] +#endif public void testConvergenceStatistics() { @@ -55,37 +73,41 @@ public void testConvergenceStatistics() checkConvergence("IncrementalStatistics"); checkConvergence("Statistics"); - } - - [TestMethod()] + } + +#if QL_DOTNET_FRAMEWORK + [TestMethod()] +#else + [Fact] +#endif public void testIncrementalStatistics() { // Testing incremental statistics - - MersenneTwisterUniformRng mt = new MersenneTwisterUniformRng(42); - - IncrementalStatistics stat = new IncrementalStatistics(); - - for ( int i = 0; i < 500000; ++i ) - { - double x = 2.0 * ( mt.nextReal() - 0.5 ) * 1234.0; - double w = mt.nextReal(); - stat.add( x, w ); - } - - if ( stat.samples() != 500000 ) - Assert.Fail( "stat.samples() (" + stat.samples() + ") can not be reproduced against cached result (" + 500000 + ")" ); - - TEST_INC_STAT( stat.weightSum(), 2.5003623600676749e+05 ); - TEST_INC_STAT( stat.mean(), 4.9122325964293845e-01 ); - TEST_INC_STAT( stat.variance(), 5.0706503959683329e+05 ); - TEST_INC_STAT( stat.standardDeviation(), 7.1208499464378076e+02 ); - TEST_INC_STAT( stat.errorEstimate(), 1.0070402569876076e+00 ); - TEST_INC_STAT( stat.skewness(), -1.7360169326720038e-03 ); - TEST_INC_STAT( stat.kurtosis(), -1.1990742562085395e+00 ); - TEST_INC_STAT( stat.min(), -1.2339945045639761e+03 ); - TEST_INC_STAT( stat.max(), 1.2339958308008499e+03 ); - TEST_INC_STAT( stat.downsideVariance(), 5.0786776146975247e+05 ); + + MersenneTwisterUniformRng mt = new MersenneTwisterUniformRng(42); + + IncrementalStatistics stat = new IncrementalStatistics(); + + for ( int i = 0; i < 500000; ++i ) + { + double x = 2.0 * ( mt.nextReal() - 0.5 ) * 1234.0; + double w = mt.nextReal(); + stat.add( x, w ); + } + + if ( stat.samples() != 500000 ) + QAssert.Fail( "stat.samples() (" + stat.samples() + ") can not be reproduced against cached result (" + 500000 + ")" ); + + TEST_INC_STAT( stat.weightSum(), 2.5003623600676749e+05 ); + TEST_INC_STAT( stat.mean(), 4.9122325964293845e-01 ); + TEST_INC_STAT( stat.variance(), 5.0706503959683329e+05 ); + TEST_INC_STAT( stat.standardDeviation(), 7.1208499464378076e+02 ); + TEST_INC_STAT( stat.errorEstimate(), 1.0070402569876076e+00 ); + TEST_INC_STAT( stat.skewness(), -1.7360169326720038e-03 ); + TEST_INC_STAT( stat.kurtosis(), -1.1990742562085395e+00 ); + TEST_INC_STAT( stat.min(), -1.2339945045639761e+03 ); + TEST_INC_STAT( stat.max(), 1.2339958308008499e+03 ); + TEST_INC_STAT( stat.downsideVariance(), 5.0786776146975247e+05 ); TEST_INC_STAT( stat.downsideDeviation(), 7.1264841364431061e+02 ); @@ -94,7 +116,7 @@ public void testIncrementalStatistics() //InverseCumulativeRng normal_gen = // new InverseCumulativeRng(mt); - //IncrementalStatistics stat2 = new IncrementalStatistics(); + //IncrementalStatistics stat2 = new IncrementalStatistics(); //for (int i = 0; i < 500000; ++i) //{ @@ -106,14 +128,14 @@ public void testIncrementalStatistics() //double tol = 1E-5; //if(Math.Abs( stat2.variance() - 1E-2 ) > tol) - // Assert.Fail("variance (" + stat2.variance() + ") out of expected range " + 1E-2 + " +- " + tol); + // QAssert.Fail("variance (" + stat2.variance() + ") out of expected range " + 1E-2 + " +- " + tol); } public void TEST_INC_STAT(double expr, double expected) { if (!Utils.close_enough(expr, expected)) - Assert.Fail( " (" + expr + ") can not be reproduced against cached result ("+ expected + ")"); + QAssert.Fail( " (" + expr + ") can not be reproduced against cached result ("+ expected + ")"); } void check(string name) where S : IGeneralStatistics, new() @@ -127,28 +149,28 @@ public void TEST_INC_STAT(double expr, double expected) double tolerance; if (s.samples() != data.Length) - Assert.Fail(name + ": wrong number of samples\n" + QAssert.Fail(name + ": wrong number of samples\n" + " calculated: " + s.samples() + "\n" + " expected: " + data.Length); expected = weights.Sum(); calculated = s.weightSum(); if (calculated != expected) - Assert.Fail(name + ": wrong sum of weights\n" + QAssert.Fail(name + ": wrong sum of weights\n" + " calculated: " + calculated + "\n" + " expected: " + expected); expected = data.Min(); calculated = s.min(); if (calculated != expected) - Assert.Fail(name + ": wrong minimum value\n" + QAssert.Fail(name + ": wrong minimum value\n" + " calculated: " + calculated + "\n" + " expected: " + expected); expected = data.Max(); calculated = s.max(); if (calculated != expected) - Assert.Fail(name + ": wrong maximum value\n" + QAssert.Fail(name + ": wrong maximum value\n" + " calculated: " + calculated + "\n" + " expected: " + expected); @@ -156,35 +178,35 @@ public void TEST_INC_STAT(double expr, double expected) tolerance = 1.0e-9; calculated = s.mean(); if (Math.Abs(calculated - expected) > tolerance) - Assert.Fail(name + ": wrong mean value\n" + QAssert.Fail(name + ": wrong mean value\n" + " calculated: " + calculated + "\n" + " expected: " + expected); expected = 2.23333333333; calculated = s.variance(); if (Math.Abs(calculated - expected) > tolerance) - Assert.Fail(name + ": wrong variance\n" + QAssert.Fail(name + ": wrong variance\n" + " calculated: " + calculated + "\n" + " expected: " + expected); expected = 1.4944341181; calculated = s.standardDeviation(); if (Math.Abs(calculated - expected) > tolerance) - Assert.Fail(name + ": wrong standard deviation\n" + QAssert.Fail(name + ": wrong standard deviation\n" + " calculated: " + calculated + "\n" + " expected: " + expected); expected = 0.359543071407; calculated = s.skewness(); if (Math.Abs(calculated - expected) > tolerance) - Assert.Fail(name + ": wrong skewness\n" + QAssert.Fail(name + ": wrong skewness\n" + " calculated: " + calculated + "\n" + " expected: " + expected); expected = -0.151799637209; calculated = s.kurtosis(); if (Math.Abs(calculated - expected) > tolerance) - Assert.Fail(name + ": wrong kurtosis\n" + QAssert.Fail(name + ": wrong kurtosis\n" + " calculated: " + calculated + "\n" + " expected: " + expected); } @@ -204,14 +226,14 @@ public void TEST_INC_STAT(double expr, double expected) double expected, tolerance; if (ss.samples() != data.Length) - Assert.Fail("SequenceStatistics<" + name + ">: " + QAssert.Fail("SequenceStatistics<" + name + ">: " + "wrong number of samples\n" + " calculated: " + ss.samples() + "\n" + " expected: " + data.Length); expected = weights.Sum(); if (ss.weightSum() != expected) - Assert.Fail("SequenceStatistics<" + name + ">: " + QAssert.Fail("SequenceStatistics<" + name + ">: " + "wrong sum of weights\n" + " calculated: " + ss.weightSum() + "\n" + " expected: " + expected); @@ -221,7 +243,7 @@ public void TEST_INC_STAT(double expr, double expected) for (i = 0; i < dimension; i++) { if (calculated[i] != expected) - Assert.Fail("SequenceStatistics<" + name + ">: " + QAssert.Fail("SequenceStatistics<" + name + ">: " + (i + 1) + " dimension: " + "wrong minimum value\n" + " calculated: " + calculated[i] + "\n" @@ -233,7 +255,7 @@ public void TEST_INC_STAT(double expr, double expected) for (i = 0; i < dimension; i++) { if (calculated[i] != expected) - Assert.Fail("SequenceStatistics<" + name + ">: " + QAssert.Fail("SequenceStatistics<" + name + ">: " + (i + 1) + " dimension: " + "wrong maximun value\n" + " calculated: " + calculated[i] + "\n" @@ -246,7 +268,7 @@ public void TEST_INC_STAT(double expr, double expected) for (i = 0; i < dimension; i++) { if (Math.Abs(calculated[i] - expected) > tolerance) - Assert.Fail("SequenceStatistics<" + name + ">: " + QAssert.Fail("SequenceStatistics<" + name + ">: " + (i + 1) + " dimension: " + "wrong mean value\n" + " calculated: " + calculated[i] + "\n" @@ -258,7 +280,7 @@ public void TEST_INC_STAT(double expr, double expected) for (i = 0; i < dimension; i++) { if (Math.Abs(calculated[i] - expected) > tolerance) - Assert.Fail("SequenceStatistics<" + name + ">: " + QAssert.Fail("SequenceStatistics<" + name + ">: " + (i + 1) + " dimension: " + "wrong variance\n" + " calculated: " + calculated[i] + "\n" @@ -270,7 +292,7 @@ public void TEST_INC_STAT(double expr, double expected) for (i = 0; i < dimension; i++) { if (Math.Abs(calculated[i] - expected) > tolerance) - Assert.Fail("SequenceStatistics<" + name + ">: " + QAssert.Fail("SequenceStatistics<" + name + ">: " + (i + 1) + " dimension: " + "wrong standard deviation\n" + " calculated: " + calculated[i] + "\n" @@ -282,7 +304,7 @@ public void TEST_INC_STAT(double expr, double expected) for (i = 0; i < dimension; i++) { if (Math.Abs(calculated[i] - expected) > tolerance) - Assert.Fail("SequenceStatistics<" + name + ">: " + QAssert.Fail("SequenceStatistics<" + name + ">: " + (i + 1) + " dimension: " + "wrong skewness\n" + " calculated: " + calculated[i] + "\n" @@ -294,7 +316,7 @@ public void TEST_INC_STAT(double expr, double expected) for (i = 0; i < dimension; i++) { if (Math.Abs(calculated[i] - expected) > tolerance) - Assert.Fail("SequenceStatistics<" + name + ">: " + QAssert.Fail("SequenceStatistics<" + name + ">: " + (i + 1) + " dimension: " + "wrong kurtosis\n" + " calculated: " + calculated[i] + "\n" @@ -319,7 +341,7 @@ public void TEST_INC_STAT(double expr, double expected) const int expectedSize1 = 3; int calculatedSize = stats.convergenceTable().Count; if (calculatedSize != expectedSize1) - Assert.Fail("ConvergenceStatistics<" + name + ">: " + QAssert.Fail("ConvergenceStatistics<" + name + ">: " + "\nwrong convergence-table size" + "\n calculated: " + calculatedSize + "\n expected: " + expectedSize1); @@ -328,14 +350,14 @@ public void TEST_INC_STAT(double expr, double expected) const double tolerance = 1.0e-9; double calculatedValue = stats.convergenceTable().Last().Value; if (Math.Abs(calculatedValue - expectedValue1) > tolerance) - Assert.Fail("wrong last value in convergence table" + QAssert.Fail("wrong last value in convergence table" + "\n calculated: " + calculatedValue + "\n expected: " + expectedValue1); const int expectedSampleSize1 = 7; int calculatedSamples = stats.convergenceTable().Last().Key; if (calculatedSamples != expectedSampleSize1) - Assert.Fail("wrong number of samples in convergence table" + QAssert.Fail("wrong number of samples in convergence table" + "\n calculated: " + calculatedSamples + "\n expected: " + expectedSampleSize1); @@ -348,21 +370,21 @@ public void TEST_INC_STAT(double expr, double expected) const int expectedSize2 = 2; calculatedSize = stats.convergenceTable().Count; if (calculatedSize != expectedSize2) - Assert.Fail("wrong convergence-table size" + QAssert.Fail("wrong convergence-table size" + "\n calculated: " + calculatedSize + "\n expected: " + expectedSize2); const double expectedValue2 = 2.0; calculatedValue = stats.convergenceTable().Last().Value; if (Math.Abs(calculatedValue - expectedValue2) > tolerance) - Assert.Fail("wrong last value in convergence table" + QAssert.Fail("wrong last value in convergence table" + "\n calculated: " + calculatedValue + "\n expected: " + expectedValue2); const int expectedSampleSize2 = 3; calculatedSamples = stats.convergenceTable().Last().Key; if (calculatedSamples != expectedSampleSize2) - Assert.Fail("wrong number of samples in convergence table" + QAssert.Fail("wrong number of samples in convergence table" + "\n calculated: " + calculatedSamples + "\n expected: " + expectedSampleSize2); } diff --git a/Test/T_Swaps.cs b/Test/T_Swaps.cs index d8ddd8b31..47bebd0ab 100644 --- a/Test/T_Swaps.cs +++ b/Test/T_Swaps.cs @@ -18,15 +18,46 @@ under the terms of the QLNet license. You should have received a */ using System; -using System.Collections.Generic; -using Microsoft.VisualStudio.TestTools.UnitTesting; +using System.Collections.Generic; +#if QL_DOTNET_FRAMEWORK +using Microsoft.VisualStudio.TestTools.UnitTesting; +#else + using Xunit; +#endif using QLNet; namespace TestSuite -{ - [TestClass()] - public class T_Swaps +{ +#if QL_DOTNET_FRAMEWORK + [TestClass()] +#endif + public class T_Swaps : IDisposable { + #region Initialize&Cleanup + private SavedSettings backup; + #if QL_DOTNET_FRAMEWORK + [TestInitialize] + public void testInitialize() + { + #else + public T_Swaps() + { + #endif + backup = new SavedSettings(); + } + #if QL_DOTNET_FRAMEWORK + [TestCleanup] + #endif + public void testCleanup() + { + Dispose(); + } + public void Dispose() + { + backup.Dispose(); + } + #endregion + class CommonVars { // global data @@ -41,9 +72,6 @@ class CommonVars public int settlementDays; public RelinkableHandle termStructure = new RelinkableHandle(); - // cleanup - // SavedSettings backup; - // utilities public VanillaSwap makeSwap(int length, double fixedRate, double floatingSpread) { @@ -78,12 +106,16 @@ public CommonVars() termStructure.linkTo(Utilities.flatRate(settlement, 0.05, new Actual365Fixed())); } - } - - [TestMethod()] + } + +#if QL_DOTNET_FRAMEWORK + [TestMethod()] +#else + [Fact] +#endif public void testFairRate() { - //("Testing vanilla-swap calculation of fair fixed rate..."); + // Testing vanilla-swap calculation of fair fixed rate CommonVars vars = new CommonVars(); @@ -99,7 +131,7 @@ public void testFairRate() swap = vars.makeSwap(lengths[i], swap.fairRate(), spreads[j]); if (Math.Abs(swap.NPV()) > 1.0e-10) { - Assert.Fail("recalculating with implied rate:\n" + QAssert.Fail("recalculating with implied rate:\n" + " length: " + lengths[i] + " years\n" + " floating spread: " + spreads[j] + "\n" @@ -107,12 +139,15 @@ public void testFairRate() } } } - } - [TestMethod()] + } +#if QL_DOTNET_FRAMEWORK + [TestMethod()] +#else + [Fact] +#endif public void testFairSpread() { - //("Testing vanilla-swap calculation of fair floating spread..."); - + // Testing vanilla-swap calculation of fair floating spread CommonVars vars = new CommonVars(); int[] lengths = new int[] { 1, 2, 5, 10, 20 }; @@ -127,7 +162,7 @@ public void testFairSpread() swap = vars.makeSwap(lengths[i], rates[j], swap.fairSpread()); if (Math.Abs(swap.NPV()) > 1.0e-10) { - Assert.Fail("recalculating with implied spread:\n" + QAssert.Fail("recalculating with implied spread:\n" + " length: " + lengths[i] + " years\n" + " fixed rate: " + rates[j] + "\n" @@ -135,12 +170,15 @@ public void testFairSpread() } } } - } - [TestMethod()] + } +#if QL_DOTNET_FRAMEWORK + [TestMethod()] +#else + [Fact] +#endif public void testRateDependency() { - //("Testing vanilla-swap dependency on fixed rate..."); - + // Testing vanilla-swap dependency on fixed rate CommonVars vars = new CommonVars(); int[] lengths = new int[] { 1, 2, 5, 10, 20 }; @@ -164,7 +202,7 @@ public void testRateDependency() for (int z = 0; z < swap_values.Count - 1; z++) { if (swap_values[z] < swap_values[z + 1]) - Assert.Fail( + QAssert.Fail( "NPV is increasing with the fixed rate in a swap: \n" + " length: " + lengths[i] + " years\n" + " value: " + swap_values[z] @@ -174,12 +212,15 @@ public void testRateDependency() } } } - } - [TestMethod()] + } +#if QL_DOTNET_FRAMEWORK + [TestMethod()] +#else + [Fact] +#endif public void testSpreadDependency() { - //("Testing vanilla-swap dependency on floating spread..."); - + // Testing vanilla-swap dependency on floating spread CommonVars vars = new CommonVars(); int[] lengths = new int[] { 1, 2, 5, 10, 20 }; @@ -203,7 +244,7 @@ public void testSpreadDependency() for (int z = 0; z < swap_values.Count - 1; z++) { if (swap_values[z] > swap_values[z + 1]) - Assert.Fail( + QAssert.Fail( "NPV is decreasing with the floating spread in a swap: \n" + " length: " + lengths[i] + " years\n" + " value: " + swap_values[z] @@ -213,12 +254,15 @@ public void testSpreadDependency() } } } - } - [TestMethod()] + } +#if QL_DOTNET_FRAMEWORK + [TestMethod()] +#else + [Fact] +#endif public void testInArrears() { - //("Testing in-arrears swap calculation..."); - + // Testing in-arrears swap calculation CommonVars vars = new CommonVars(); /* See Hull, 4th ed., page 550 @@ -269,15 +313,18 @@ public void testInArrears() double tolerance = 1.0; if (Math.Abs(swap.NPV() - storedValue) > tolerance) - Assert.Fail("Wrong NPV calculation:\n" + QAssert.Fail("Wrong NPV calculation:\n" + " expected: " + storedValue + "\n" + " calculated: " + swap.NPV()); - } - [TestMethod()] + } +#if QL_DOTNET_FRAMEWORK + [TestMethod()] +#else + [Fact] +#endif public void testCachedValue() { - //("Testing vanilla-swap calculation against cached value..."); - + // Testing vanilla-swap calculation against cached value CommonVars vars = new CommonVars(); vars.today = new Date(17, Month.June, 2002); @@ -293,12 +340,15 @@ public void testCachedValue() #endif if (Math.Abs(swap.NPV() - cachedNPV) > 1.0e-11) - Assert.Fail("failed to reproduce cached swap value:\n" + QAssert.Fail("failed to reproduce cached swap value:\n" + " calculated: " + swap.NPV() + "\n" + " expected: " + cachedNPV); - } - - [TestMethod()] + } +#if QL_DOTNET_FRAMEWORK + [TestMethod()] +#else + [Fact] +#endif public void testFixing() { Date tradeDate = new Date( 17, Month.April, 2015 ); @@ -343,20 +393,10 @@ public void testFixing() } catch ( Exception ex ) { - Assert.Fail( ex.Message ); - Console.WriteLine( ex ); + QAssert.Fail( ex.Message ); } } - public void suite() - { - testFairRate(); - testFairSpread(); - testRateDependency(); - testSpreadDependency(); - testInArrears(); - testCachedValue(); - } } } diff --git a/Test/T_Swaption.cs b/Test/T_Swaption.cs index ffe7b81c1..2f80348a3 100644 --- a/Test/T_Swaption.cs +++ b/Test/T_Swaption.cs @@ -17,15 +17,46 @@ under the terms of the QLNet license. You should have received a FOR A PARTICULAR PURPOSE. See the license for more details. */ using System; -using System.Collections.Generic; -using Microsoft.VisualStudio.TestTools.UnitTesting; +using System.Collections.Generic; +#if QL_DOTNET_FRAMEWORK +using Microsoft.VisualStudio.TestTools.UnitTesting; +#else + using Xunit; +#endif using QLNet; namespace TestSuite -{ - [TestClass()] - public class T_Swaption +{ +#if QL_DOTNET_FRAMEWORK + [TestClass()] +#endif + public class T_Swaption : IDisposable { + #region Initialize&Cleanup + private SavedSettings backup; + #if QL_DOTNET_FRAMEWORK + [TestInitialize] + public void testInitialize() + { + #else + public T_Swaption() + { + #endif + backup = new SavedSettings(); + } + #if QL_DOTNET_FRAMEWORK + [TestCleanup] + #endif + public void testCleanup() + { + Dispose(); + } + public void Dispose() + { + backup.Dispose(); + } + #endregion + public Period[] exercises = new Period[] { new Period(1, TimeUnit.Years), new Period(2, TimeUnit.Years), new Period(3, TimeUnit.Years), @@ -59,9 +90,6 @@ public class CommonVars public int settlementDays; public RelinkableHandle termStructure = new RelinkableHandle(); - // cleanup - // SavedSettings backup; - // utilities public Swaption makeSwaption(VanillaSwap swap,Date exercise,double volatility,Settlement.Type settlementType) { @@ -107,13 +135,16 @@ public CommonVars() termStructure.linkTo(Utilities.flatRate(settlement, 0.05, new Actual365Fixed())); } - } - - [TestMethod()] + } + +#if QL_DOTNET_FRAMEWORK + [TestMethod()] +#else + [Fact] +#endif public void testStrikeDependency() { - //("Testing swaption dependency on strike......"); - + // Testing swaption dependency on strike CommonVars vars = new CommonVars(); double[] strikes = new double[] { 0.03, 0.04, 0.05, 0.06, 0.07 }; @@ -147,7 +178,7 @@ public void testStrikeDependency() for (int z = 0; z < values.Count - 1; z++) { if( values[z] values[z+1]){ - Assert.Fail("NPV of Receiver swaption with delivery settlement" + + QAssert.Fail("NPV of Receiver swaption with delivery settlement" + "is increasing with the strike:" + "\noption tenor: " + exercises[i] + "\noption date: " + exerciseDate + @@ -189,7 +220,7 @@ public void testStrikeDependency() { if (values[z] > values[z+1]) { - Assert.Fail("NPV of Receiver swaption with cash settlement" + + QAssert.Fail("NPV of Receiver swaption with cash settlement" + "is increasing with the strike:" + "\noption tenor: " + exercises[i] + "\noption date: " + exerciseDate + @@ -203,13 +234,16 @@ public void testStrikeDependency() } } } - } - - [TestMethod()] + } + +#if QL_DOTNET_FRAMEWORK + [TestMethod()] +#else + [Fact] +#endif public void testSpreadDependency() { - //"Testing swaption dependency on spread..."; - + // Testing swaption dependency on spread CommonVars vars = new CommonVars(); double[] spreads = { -0.002, -0.001, 0.0, 0.001, 0.002 }; @@ -245,7 +279,7 @@ public void testSpreadDependency() for (int n = 0; n < spreads.Length - 1; n++) { if (values[n] > values[n + 1]) - Assert.Fail("NPV is decreasing with the spread " + + QAssert.Fail("NPV is decreasing with the spread " + "in a payer swaption (physical delivered):" + "\nexercise date: " + exerciseDate + "\nlength: " + lengths[j] + @@ -253,7 +287,7 @@ public void testSpreadDependency() "\nvalue: " + values[n + 1] + " for spread: " + spreads[n + 1]); if (values_cash[n] > values_cash[n + 1]) - Assert.Fail("NPV is decreasing with the spread " + + QAssert.Fail("NPV is decreasing with the spread " + "in a payer swaption (cash delivered):" + "\nexercise date: " + exerciseDate + "\nlength: " + lengths[j] + @@ -266,7 +300,7 @@ public void testSpreadDependency() for (int n = 0; n < spreads.Length - 1; n++) { if (values[n] < values[n + 1]) - Assert.Fail("NPV is increasing with the spread " + + QAssert.Fail("NPV is increasing with the spread " + "in a receiver swaption (physical delivered):" + "\nexercise date: " + exerciseDate + "\nlength: " + lengths[j] + @@ -274,7 +308,7 @@ public void testSpreadDependency() "\nvalue: " + values[n + 1] + " for spread: " + spreads[n + 1]); if (values_cash[n] < values_cash[n+1]) - Assert.Fail("NPV is increasing with the spread " + + QAssert.Fail("NPV is increasing with the spread " + "in a receiver swaption (cash delivered):" + "\nexercise date: " + exerciseDate + "\nlength: " + lengths[j] + @@ -285,13 +319,16 @@ public void testSpreadDependency() } } } - } - - [TestMethod()] + } + +#if QL_DOTNET_FRAMEWORK + [TestMethod()] +#else + [Fact] +#endif public void testSpreadTreatment() { - //"Testing swaption treatment of spread..."; - + // Testing swaption treatment of spread CommonVars vars = new CommonVars(); double[] spreads = { -0.002, -0.001, 0.0, 0.001, 0.002 }; @@ -330,7 +367,7 @@ public void testSpreadTreatment() vars.makeSwaption(equivalentSwap,exerciseDate,0.20, Settlement.Type.Cash); if (Math.Abs(swaption1.NPV()-swaption2.NPV()) > 1.0e-6) - Assert.Fail("wrong spread treatment:" + + QAssert.Fail("wrong spread treatment:" + "\nexercise: " + exerciseDate + "\nlength: " + lengths[j] + "\ntype " + type[k] + @@ -339,7 +376,7 @@ public void testSpreadTreatment() "\nequivalent swaption value: " + swaption2.NPV()); if (Math.Abs(swaption1_cash.NPV()-swaption2_cash.NPV()) > 1.0e-6) - Assert.Fail("wrong spread treatment:" + + QAssert.Fail("wrong spread treatment:" + "\nexercise date: " + exerciseDate + "\nlength: " + lengths[j] + //"\npay " + (type[k] ? "fixed" : "floating") + @@ -350,13 +387,16 @@ public void testSpreadTreatment() } } } - } - - [TestMethod()] + } + +#if QL_DOTNET_FRAMEWORK + [TestMethod()] +#else + [Fact] +#endif public void testCachedValue() { - //"Testing swaption value against cached value..."); - + // Testing swaption value against cached value CommonVars vars = new CommonVars(); vars.today = new Date(13, 3, 2002); @@ -380,17 +420,20 @@ public void testCachedValue() // FLOATING_POINT_EXCEPTION if (Math.Abs(swaption.NPV()-cachedNPV) > 1.0e-12) - Assert.Fail ("failed to reproduce cached swaption value:\n" + + QAssert.Fail ("failed to reproduce cached swaption value:\n" + //QL_FIXED + std::setprecision(12) + "\ncalculated: " + swaption.NPV() + "\nexpected: " + cachedNPV); - } - - [TestMethod()] + } + +#if QL_DOTNET_FRAMEWORK + [TestMethod()] +#else + [Fact] +#endif public void testVega() { - //"Testing swaption vega..."; - + // Testing swaption vega CommonVars vars = new CommonVars(); Settlement.Type[] types = { Settlement.Type.Physical, Settlement.Type.Cash }; @@ -434,7 +477,7 @@ public void testVega() discrepancy /= numericalVegaPerPoint; double tolerance = 0.015; if (discrepancy > tolerance) - Assert.Fail ("failed to compute swaption vega:" + + QAssert.Fail ("failed to compute swaption vega:" + "\n option tenor: " + exercises[i] + "\n volatility: " + vols[u] + "\n option type: " + swaption.type() + @@ -453,13 +496,16 @@ public void testVega() } } } - } - - [TestMethod()] + } + +#if QL_DOTNET_FRAMEWORK + [TestMethod()] +#else + [Fact] +#endif public void testImpliedVolatility() { - //"Testing implied volatility for swaptions..."; - + // Testing implied volatility for swaptions CommonVars vars=new CommonVars(); int maxEvaluations = 100; @@ -516,7 +562,7 @@ public void testImpliedVolatility() continue; } // otherwise, report error - Assert.Fail("implied vol failure: " + + QAssert.Fail("implied vol failure: " + exercises[i] + "x" + lengths[j] + " " + type[k] + "\nsettlement: " + types[h] + "\nstrike " + strikes[t] + @@ -532,7 +578,7 @@ public void testImpliedVolatility() double value2 = swaption.NPV(); if (Math.Abs(value - value2) > tolerance) { - Assert.Fail("implied vol failure: " + + QAssert.Fail("implied vol failure: " + exercises[i] + "x" + lengths[j] + " " + type[k] + "\nsettlement: " + types[h] + "\nstrike " + strikes[t] + @@ -550,15 +596,5 @@ public void testImpliedVolatility() } } } - - public void T_Swaption_suite() - { - testStrikeDependency(); - testSpreadDependency(); - testSpreadTreatment(); - testCachedValue(); - testVega(); - testImpliedVolatility(); - } } } diff --git a/Test/T_SwaptionVolatilitymatrix.cs b/Test/T_SwaptionVolatilitymatrix.cs index ecd6d5809..96b71ef01 100644 --- a/Test/T_SwaptionVolatilitymatrix.cs +++ b/Test/T_SwaptionVolatilitymatrix.cs @@ -19,15 +19,46 @@ under the terms of the QLNet license. You should have received a using System; using System.Collections.Generic; -using System.Linq; -using Microsoft.VisualStudio.TestTools.UnitTesting; +using System.Linq; +#if QL_DOTNET_FRAMEWORK +using Microsoft.VisualStudio.TestTools.UnitTesting; +#else + using Xunit; +#endif using QLNet; namespace TestSuite -{ - [TestClass()] - public class T_SwaptionVolatilityMatrix +{ +#if QL_DOTNET_FRAMEWORK + [TestClass()] +#endif + public class T_SwaptionVolatilityMatrix : IDisposable { + #region Initialize&Cleanup + private SavedSettings backup; + #if QL_DOTNET_FRAMEWORK + [TestInitialize] + public void testInitialize() + { + #else + public T_SwaptionVolatilityMatrix() + { + #endif + backup = new SavedSettings(); + } + #if QL_DOTNET_FRAMEWORK + [TestCleanup] + #endif + public void testCleanup() + { + Dispose(); + } + public void Dispose() + { + backup.Dispose(); + } + #endregion + public class SwaptionTenors { public List options; @@ -101,9 +132,6 @@ class CommonVars public RelinkableHandle termStructure; public RelinkableHandle atmVolMatrix; - // cleanup - //SavedSettings backup; - // setup public CommonVars() { @@ -142,10 +170,10 @@ public void makeObservabilityTest( string description, Settings.setEvaluationDate(referenceDate); if (referenceDateFloating && (initialVol == newVol)) - Assert.Fail(description + + QAssert.Fail(description + " the volatility should change when the reference date is changed !"); if (!referenceDateFloating && (initialVol != newVol)) - Assert.Fail(description + + QAssert.Fail(description + " the volatility should not change when the reference date is changed !"); // test market data change... @@ -161,7 +189,7 @@ public void makeObservabilityTest( string description, sq.setValue(initialVolatility); if (initialVol == newVol) - Assert.Fail(description + " the volatility should change when"+ + QAssert.Fail(description + " the volatility should change when"+ " the market data is changed !"); } } @@ -174,7 +202,7 @@ public void makeCoherenceTest( string description, Date optionDate = vol.optionDateFromTenor(atm.tenors.options[i]); if (optionDate!=vol.optionDates()[i]) - Assert.Fail( + QAssert.Fail( "optionDateFromTenor failure for " + description+ ":"+ "\n option tenor: " + atm.tenors.options[i] + @@ -182,7 +210,7 @@ public void makeCoherenceTest( string description, "\n exp. option date : " + vol.optionDates()[i]); double optionTime = vol.timeFromReference(optionDate); if (optionTime!=vol.optionTimes()[i]) - Assert.Fail( + QAssert.Fail( "timeFromReference failure for " + description + ":"+ "\n option tenor: " +atm.tenors.options[i] + @@ -199,7 +227,7 @@ public void makeCoherenceTest( string description, double swapLength = vol.swapLength(atm.tenors.swaps[j]); if (swapLength!= atm.tenors.swaps[j].length()) - Assert.Fail("convertSwapTenor failure for " + + QAssert.Fail("convertSwapTenor failure for " + description + ":"+ "\n swap tenor : " + atm.tenors.swaps[j] + "\n actual swap length: " + swapLength + @@ -215,7 +243,7 @@ public void makeCoherenceTest( string description, atm.tenors.swaps[j], 0.05, true); error = Math.Abs(expVol-actVol); if (error>tolerance) - Assert.Fail( + QAssert.Fail( "recovery of atm vols failed for " + description + ":"+ "\noption tenor = " + atm.tenors.options[i] + @@ -231,7 +259,7 @@ public void makeCoherenceTest( string description, atm.tenors.swaps[j], 0.05, true); error = Math.Abs(expVol-actVol); if (error>tolerance) - Assert.Fail( + QAssert.Fail( "recovery of atm vols failed for " + description + ":"+ "\noption tenor: " + atm.tenors.options[i] + @@ -247,7 +275,7 @@ public void makeCoherenceTest( string description, 0.05, true); error = Math.Abs(expVol-actVol); if (error>tolerance) - Assert.Fail( + QAssert.Fail( "recovery of atm vols failed for " + description + ":"+ "\noption tenor: " + atm.tenors.options[i] + @@ -267,7 +295,7 @@ public void makeCoherenceTest( string description, Date exerciseDate = swaption.exercise().dates().First(); if (exerciseDate!=vol.optionDates()[i]) - Assert.Fail( + QAssert.Fail( "optionDateFromTenor mismatch for " + description + ":"+ "\n option tenor: " + atm.tenors.options[i] + @@ -278,7 +306,7 @@ public void makeCoherenceTest( string description, Date end = swaption.underlyingSwap().maturityDate(); double swapLength2 = vol.swapLength(start, end); if (swapLength2!=swapLength) - Assert.Fail( + QAssert.Fail( "swapLength failure for " + description + ":"+ "\n swap tenor : " + atm.tenors.swaps[j] + @@ -292,7 +320,7 @@ public void makeCoherenceTest( string description, // TO BE FIXED // double tolerance2 = 0.000001; // if (error > tolerance2 & i != 0)//NOK for i=0 -> to debug - // Assert.Fail( + // QAssert.Fail( // "recovery of atm vols through BlackSwaptionEngine failed for " + // description + ":"+ // "\noption tenor: " + atm.tenors.options[i] + @@ -306,14 +334,16 @@ public void makeCoherenceTest( string description, } } } - } - - [TestMethod()] + } + +#if QL_DOTNET_FRAMEWORK + [TestMethod()] +#else + [Fact] +#endif public void testSwaptionVolMatrixCoherence() { - - //"Testing swaption volatility matrix..."); - + // Testing swaption volatility matrix CommonVars vars = new CommonVars(); SwaptionVolatilityMatrix vol; @@ -364,13 +394,16 @@ public void testSwaptionVolMatrixCoherence() vars.conventions.dayCounter); vars.makeCoherenceTest(description, vol); - } - - [TestMethod()] + } + +#if QL_DOTNET_FRAMEWORK + [TestMethod()] +#else + [Fact] +#endif public void testSwaptionVolMatrixObservability() { - //"Testing swaption volatility matrix observability..."); - + // Testing swaption volatility matrix observability CommonVars vars=new CommonVars(); SwaptionVolatilityMatrix vol; @@ -426,14 +459,6 @@ public void testSwaptionVolMatrixObservability() // const Matrix& volatilities, // const DayCounter& dayCounter); } - - public void suite() - { - //"Swaption Volatility Matrix tests" - testSwaptionVolMatrixCoherence(); - testSwaptionVolMatrixObservability(); - - } } } diff --git a/Test/T_TermStructures.cs b/Test/T_TermStructures.cs index 0ebe6ef28..81562b4ca 100644 --- a/Test/T_TermStructures.cs +++ b/Test/T_TermStructures.cs @@ -19,15 +19,46 @@ under the terms of the QLNet license. You should have received a */ using System; -using System.Collections.Generic; -using Microsoft.VisualStudio.TestTools.UnitTesting; +using System.Collections.Generic; +#if QL_DOTNET_FRAMEWORK +using Microsoft.VisualStudio.TestTools.UnitTesting; +#else + using Xunit; +#endif using QLNet; namespace TestSuite -{ - [TestClass()] - public class T_TermStructures +{ +#if QL_DOTNET_FRAMEWORK + [TestClass()] +#endif + public class T_TermStructures : IDisposable { + #region Initialize&Cleanup + private SavedSettings backup; + #if QL_DOTNET_FRAMEWORK + [TestInitialize] + public void testInitialize() + { + #else + public T_TermStructures() + { + #endif + backup = new SavedSettings(); + } + #if QL_DOTNET_FRAMEWORK + [TestCleanup] + #endif + public void testCleanup() + { + Dispose(); + } + public void Dispose() + { + backup.Dispose(); + } + #endregion + public class CommonVars { #region Values @@ -61,9 +92,6 @@ public struct Datum public YieldTermStructure termStructure; public YieldTermStructure dummyTermStructure; - // cleanup - // SavedSettings backup; - // setup public CommonVars() { @@ -93,13 +121,16 @@ public CommonVars() termStructure = new PiecewiseYieldCurve(settlement, instruments, new Actual360()); dummyTermStructure = new PiecewiseYieldCurve(settlement, instruments, new Actual360()); } - } - - [TestMethod()] + } + +#if QL_DOTNET_FRAMEWORK + [TestMethod()] +#else + [Fact] +#endif public void testReferenceChange() { - // ("Testing term structure against evaluation date change..."); - + // Testing term structure against evaluation date change CommonVars vars = new CommonVars(); SimpleQuote flatRate = new SimpleQuote(); @@ -122,17 +153,20 @@ public void testReferenceChange() for (int i = 0; i < days.Length; i++) { if (!Utils.close(expected[i], calculated[i])) - Console.WriteLine("\n Discount at " + days[i] + " days:\n" + QAssert.Fail("\n Discount at " + days[i] + " days:\n" + " before date change: " + expected[i] + "\n" + " after date change: " + calculated[i]); } - } - - [TestMethod()] + } + +#if QL_DOTNET_FRAMEWORK + [TestMethod()] +#else + [Fact] +#endif public void testImplied() { - // ("Testing consistency of implied term structure..."); - + // Testing consistency of implied term structure CommonVars vars = new CommonVars(); double tolerance = 1.0e-10; @@ -145,16 +179,19 @@ public void testImplied() double discount = vars.termStructure.discount(testDate); double impliedDiscount = implied.discount(testDate); if (Math.Abs(discount - baseDiscount * impliedDiscount) > tolerance) - Console.WriteLine("unable to reproduce discount from implied curve\n" + QAssert.Fail("unable to reproduce discount from implied curve\n" + " calculated: " + baseDiscount * impliedDiscount + "\n" + " expected: " + discount); - } - - [TestMethod()] + } + +#if QL_DOTNET_FRAMEWORK + [TestMethod()] +#else + [Fact] +#endif public void testImpliedObs() { - // ("Testing observability of implied term structure..."); - + // Testing observability of implied term structure CommonVars vars = new CommonVars(); Date today = Settings.evaluationDate(); @@ -166,13 +203,17 @@ public void testImpliedObs() implied.registerWith(flag.update); h.linkTo(vars.termStructure); if (!flag.isUp()) - Console.WriteLine("Observer was not notified of term structure change"); - } - - [TestMethod()] + QAssert.Fail("Observer was not notified of term structure change"); + } + +#if QL_DOTNET_FRAMEWORK + [TestMethod()] +#else + [Fact] +#endif public void testFSpreaded() { - //("Testing consistency of forward-spreaded term structure..."); + // Testing consistency of forward-spreaded term structure CommonVars vars = new CommonVars(); double tolerance = 1.0e-10; @@ -187,17 +228,20 @@ public void testFSpreaded() double spreadedForward = spreaded.forwardRate(testDate, testDate, sprdc, Compounding.Continuous, Frequency.NoFrequency).rate(); if (Math.Abs(forward - (spreadedForward - me.value())) > tolerance) - Console.WriteLine("unable to reproduce forward from spreaded curve\n" + QAssert.Fail("unable to reproduce forward from spreaded curve\n" + " calculated: " + (spreadedForward - me.value()) + "\n" + " expected: " + forward); - } - - [TestMethod()] + } + +#if QL_DOTNET_FRAMEWORK + [TestMethod()] +#else + [Fact] +#endif public void testFSpreadedObs() { - // ("Testing observability of forward-spreaded term structure..."); - + // Testing observability of forward-spreaded term structure CommonVars vars = new CommonVars(); SimpleQuote me = new SimpleQuote(0.01); @@ -208,18 +252,21 @@ public void testFSpreadedObs() spreaded.registerWith(flag.update); h.linkTo(vars.termStructure); if (!flag.isUp()) - Console.WriteLine("Observer was not notified of term structure change"); + QAssert.Fail("Observer was not notified of term structure change"); flag.lower(); me.setValue(0.005); if (!flag.isUp()) - Console.WriteLine("Observer was not notified of spread change"); - } - - [TestMethod()] + QAssert.Fail("Observer was not notified of spread change"); + } + +#if QL_DOTNET_FRAMEWORK + [TestMethod()] +#else + [Fact] +#endif public void testZSpreaded() { - // ("Testing consistency of zero-spreaded term structure..."); - + // Testing consistency of zero-spreaded term structure CommonVars vars = new CommonVars(); double tolerance = 1.0e-10; @@ -231,16 +278,19 @@ public void testZSpreaded() double zero = vars.termStructure.zeroRate(testDate, rfdc, Compounding.Continuous, Frequency.NoFrequency).rate(); double spreadedZero = spreaded.zeroRate(testDate, rfdc, Compounding.Continuous, Frequency.NoFrequency).rate(); if (Math.Abs(zero - (spreadedZero - me.value())) > tolerance) - Console.WriteLine("unable to reproduce zero yield from spreaded curve\n" - + " calculated: " + (spreadedZero - me.value()) + "\n" - + " expected: " + zero); - } - - [TestMethod()] + QAssert.Fail("unable to reproduce zero yield from spreaded curve\n" + + " calculated: " + (spreadedZero - me.value()) + "\n" + + " expected: " + zero); + } + +#if QL_DOTNET_FRAMEWORK + [TestMethod()] +#else + [Fact] +#endif public void testZSpreadedObs() { - // ("Testing observability of zero-spreaded term structure..."); - + // Testing observability of zero-spreaded term structure CommonVars vars = new CommonVars(); SimpleQuote me = new SimpleQuote(0.01); @@ -252,22 +302,11 @@ public void testZSpreadedObs() spreaded.registerWith(flag.update); h.linkTo(vars.termStructure); if (!flag.isUp()) - Console.WriteLine("Observer was not notified of term structure change"); + QAssert.Fail("Observer was not notified of term structure change"); flag.lower(); me.setValue(0.005); if (!flag.isUp()) - Console.WriteLine("Observer was not notified of spread change"); - } - - public void suite() - { - testReferenceChange(); - testImplied(); - testImpliedObs(); - testFSpreaded(); - testFSpreadedObs(); - testZSpreaded(); - testZSpreadedObs(); + QAssert.Fail("Observer was not notified of spread change"); } } } diff --git a/Test/Test.csproj b/Test/Test.csproj index e90ea0552..5b1853a65 100644 --- a/Test/Test.csproj +++ b/Test/Test.csproj @@ -39,7 +39,7 @@ full false bin\Debug\ - DEBUG;TRACE + TRACE;DEBUG;QL_DOTNET_FRAMEWORK prompt 4 AllRules.ruleset @@ -49,7 +49,7 @@ pdbonly true bin\Release\ - TRACE + TRACE;QL_DOTNET_FRAMEWORK prompt 4 AllRules.ruleset diff --git a/Test/Test.xproj b/Test/Test.xproj new file mode 100644 index 000000000..77679c217 --- /dev/null +++ b/Test/Test.xproj @@ -0,0 +1,22 @@ + + + + 14.0 + $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion) + + + + e95ec6f5-40e7-48c0-952b-d6ae1942eef9 + Test + .\obj + .\bin\ + v4.5.2 + + + 2.0 + + + + + + \ No newline at end of file diff --git a/Test/Utilities.cs b/Test/Utilities.cs index 1a1cd5971..7aa554049 100644 --- a/Test/Utilities.cs +++ b/Test/Utilities.cs @@ -19,7 +19,12 @@ under the terms of the QLNet license. You should have received a using System; using System.Collections.Generic; -using System.Linq; +using System.Linq; +#if QL_DOTNET_FRAMEWORK +using Microsoft.VisualStudio.TestTools.UnitTesting; +#else + using Xunit; +#endif using QLNet; namespace TestSuite { @@ -147,8 +152,81 @@ public static String payoffTypeToString(Payoff h) } } - // this cleans up index-fixing histories when destroyed - public class IndexHistoryCleaner { - ~IndexHistoryCleaner() { IndexManager.instance().clearHistories(); } + // this cleans up index-fixing histories when disposed + public class IndexHistoryCleaner : IDisposable + { + public void Dispose() { IndexManager.instance().clearHistories(); } }; + + public static partial class QAssert + { + public static void Fail(string message) + { + #if QL_DOTNET_FRAMEWORK + Assert.Fail(message); + #else + Assert.True(false,message); + #endif + } + + public static void AreEqual( double expected, double actual, double delta ) + { + #if QL_DOTNET_FRAMEWORK + Assert.AreEqual( expected, actual, delta ); + #else + Assert.True(Math.Abs(expected- actual) <= delta); + #endif + } + + public static void AreEqual(double expected, double actual, double delta, string message) + { + #if QL_DOTNET_FRAMEWORK + Assert.AreEqual(expected, actual, delta, message); + #else + Assert.True(Math.Abs(expected- actual) <= delta,message); + #endif + } + + public static void AreEqual( T expected, T actual ) + { + + #if QL_DOTNET_FRAMEWORK + Assert.AreEqual( expected, actual ); + #else + Assert.Equal(expected, actual); + #endif + } + + public static void AreEqual( T expected, T actual, string message ) + { + #if QL_DOTNET_FRAMEWORK + Assert.AreEqual( expected, actual, message ); + #else + Assert.Equal(expected, actual); + #endif + } + + public static void IsTrue( bool condition, string message ) + { + #if QL_DOTNET_FRAMEWORK + Assert.IsTrue( condition, message); + #else + Assert.True( condition, message); + #endif + } + + public static void IsFalse( bool condition, string message ) + { + #if QL_DOTNET_FRAMEWORK + Assert.IsFalse( condition, message ); + #else + Assert.False( condition, message); + #endif + } + //public static void IsTrue( bool condition, string message, params object[] parameters ) + //{ + // QAssert.IsTrue( condition, message, parameters ); + //} + + } } diff --git a/Test/project.json b/Test/project.json new file mode 100644 index 000000000..1ef7e48d3 --- /dev/null +++ b/Test/project.json @@ -0,0 +1,20 @@ +{ + "version": "1.8.0-*", + "testRunner": "xunit", + "dependencies": { + "dotnet-test-xunit": "2.2.0-preview2-build1029", + "xunit": "2.2.0-beta2-build3300", + "QLNet": "1.8.0-*" + }, + + "frameworks": { + "netcoreapp1.0": { + "dependencies": { + "Microsoft.NETCore.App": { + "type": "platform", + "version": "1.0.0" + } + } + } + } +} diff --git a/Test/project.lock.json b/Test/project.lock.json new file mode 100644 index 000000000..b6bcaada4 --- /dev/null +++ b/Test/project.lock.json @@ -0,0 +1,7496 @@ +{ + "locked": false, + "version": 2, + "targets": { + ".NETCoreApp,Version=v1.0": { + "dotnet-test-xunit/2.2.0-preview2-build1029": { + "type": "package", + "dependencies": { + "Microsoft.Extensions.Testing.Abstractions": "1.0.0-preview2-003121", + "Microsoft.NETCore.App": "1.0.0", + "xunit.runner.reporters": "2.2.0-beta2-build3300" + }, + "compile": { + "lib/netcoreapp1.0/dotnet-test-xunit.dll": {} + }, + "runtime": { + "lib/netcoreapp1.0/dotnet-test-xunit.dll": {} + } + }, + "Libuv/1.9.0": { + "type": "package", + "dependencies": { + "Microsoft.NETCore.Platforms": "1.0.1" + }, + "runtimeTargets": { + "runtimes/debian-x64/native/libuv.so": { + "assetType": "native", + "rid": "debian-x64" + }, + "runtimes/fedora-x64/native/libuv.so": { + "assetType": "native", + "rid": "fedora-x64" + }, + "runtimes/opensuse-x64/native/libuv.so": { + "assetType": "native", + "rid": "opensuse-x64" + }, + "runtimes/osx/native/libuv.dylib": { + "assetType": "native", + "rid": "osx" + }, + "runtimes/rhel-x64/native/libuv.so": { + "assetType": "native", + "rid": "rhel-x64" + }, + "runtimes/win7-arm/native/libuv.dll": { + "assetType": "native", + "rid": "win7-arm" + }, + "runtimes/win7-x64/native/libuv.dll": { + "assetType": "native", + "rid": "win7-x64" + }, + "runtimes/win7-x86/native/libuv.dll": { + "assetType": "native", + "rid": "win7-x86" + } + } + }, + "Microsoft.CodeAnalysis.Analyzers/1.1.0": { + "type": "package" + }, + "Microsoft.CodeAnalysis.Common/1.3.0": { + "type": "package", + "dependencies": { + "Microsoft.CodeAnalysis.Analyzers": "1.1.0", + "System.AppContext": "4.1.0", + "System.Collections": "4.0.11", + "System.Collections.Concurrent": "4.0.12", + "System.Collections.Immutable": "1.2.0", + "System.Console": "4.0.0", + "System.Diagnostics.Debug": "4.0.11", + "System.Diagnostics.FileVersionInfo": "4.0.0", + "System.Diagnostics.StackTrace": "4.0.1", + "System.Diagnostics.Tools": "4.0.1", + "System.Dynamic.Runtime": "4.0.11", + "System.Globalization": "4.0.11", + "System.IO.FileSystem": "4.0.1", + "System.IO.FileSystem.Primitives": "4.0.1", + "System.Linq": "4.1.0", + "System.Linq.Expressions": "4.1.0", + "System.Reflection": "4.1.0", + "System.Reflection.Metadata": "1.3.0", + "System.Reflection.Primitives": "4.0.1", + "System.Resources.ResourceManager": "4.0.1", + "System.Runtime": "4.1.0", + "System.Runtime.Extensions": "4.1.0", + "System.Runtime.Handles": "4.0.1", + "System.Runtime.InteropServices": "4.1.0", + "System.Runtime.Numerics": "4.0.1", + "System.Security.Cryptography.Algorithms": "4.2.0", + "System.Security.Cryptography.Encoding": "4.0.0", + "System.Security.Cryptography.X509Certificates": "4.1.0", + "System.Text.Encoding": "4.0.11", + "System.Text.Encoding.CodePages": "4.0.1", + "System.Text.Encoding.Extensions": "4.0.11", + "System.Threading": "4.0.11", + "System.Threading.Tasks": "4.0.11", + "System.Threading.Tasks.Parallel": "4.0.1", + "System.Threading.Thread": "4.0.0", + "System.Xml.ReaderWriter": "4.0.11", + "System.Xml.XDocument": "4.0.11", + "System.Xml.XPath.XDocument": "4.0.1", + "System.Xml.XmlDocument": "4.0.1" + }, + "compile": { + "lib/netstandard1.3/_._": {} + }, + "runtime": { + "lib/netstandard1.3/Microsoft.CodeAnalysis.dll": {} + } + }, + "Microsoft.CodeAnalysis.CSharp/1.3.0": { + "type": "package", + "dependencies": { + "Microsoft.CodeAnalysis.Common": "[1.3.0]" + }, + "compile": { + "lib/netstandard1.3/_._": {} + }, + "runtime": { + "lib/netstandard1.3/Microsoft.CodeAnalysis.CSharp.dll": {} + } + }, + "Microsoft.CodeAnalysis.VisualBasic/1.3.0": { + "type": "package", + "dependencies": { + "Microsoft.CodeAnalysis.Common": "1.3.0" + }, + "compile": { + "lib/netstandard1.3/_._": {} + }, + "runtime": { + "lib/netstandard1.3/Microsoft.CodeAnalysis.VisualBasic.dll": {} + } + }, + "Microsoft.CSharp/4.0.1": { + "type": "package", + "dependencies": { + "System.Collections": "4.0.11", + "System.Diagnostics.Debug": "4.0.11", + "System.Dynamic.Runtime": "4.0.11", + "System.Globalization": "4.0.11", + "System.Linq": "4.1.0", + "System.Linq.Expressions": "4.1.0", + "System.ObjectModel": "4.0.12", + "System.Reflection": "4.1.0", + "System.Reflection.Extensions": "4.0.1", + "System.Reflection.Primitives": "4.0.1", + "System.Reflection.TypeExtensions": "4.1.0", + "System.Resources.ResourceManager": "4.0.1", + "System.Runtime": "4.1.0", + "System.Runtime.Extensions": "4.1.0", + "System.Runtime.InteropServices": "4.1.0", + "System.Threading": "4.0.11" + }, + "compile": { + "ref/netstandard1.0/Microsoft.CSharp.dll": {} + }, + "runtime": { + "lib/netstandard1.3/Microsoft.CSharp.dll": {} + } + }, + "Microsoft.DiaSymReader/1.0.8": { + "type": "package", + "dependencies": { + "System.Diagnostics.Debug": "4.0.11", + "System.Runtime": "4.1.0", + "System.Runtime.InteropServices": "4.1.0" + }, + "compile": { + "lib/netstandard1.1/Microsoft.DiaSymReader.dll": {} + }, + "runtime": { + "lib/netstandard1.1/Microsoft.DiaSymReader.dll": {} + } + }, + "Microsoft.DiaSymReader.Native/1.4.0-rc2": { + "type": "package", + "runtimeTargets": { + "runtimes/win-x64/native/Microsoft.DiaSymReader.Native.amd64.dll": { + "assetType": "native", + "rid": "win-x64" + }, + "runtimes/win-x86/native/Microsoft.DiaSymReader.Native.x86.dll": { + "assetType": "native", + "rid": "win-x86" + }, + "runtimes/win/native/Microsoft.DiaSymReader.Native.amd64.dll": { + "assetType": "native", + "rid": "win" + }, + "runtimes/win/native/Microsoft.DiaSymReader.Native.arm.dll": { + "assetType": "native", + "rid": "win" + }, + "runtimes/win/native/Microsoft.DiaSymReader.Native.x86.dll": { + "assetType": "native", + "rid": "win" + }, + "runtimes/win8-arm/native/Microsoft.DiaSymReader.Native.arm.dll": { + "assetType": "native", + "rid": "win8-arm" + } + } + }, + "Microsoft.DotNet.InternalAbstractions/1.0.0": { + "type": "package", + "dependencies": { + "System.AppContext": "4.1.0", + "System.Collections": "4.0.11", + "System.IO": "4.1.0", + "System.IO.FileSystem": "4.0.1", + "System.Reflection.TypeExtensions": "4.1.0", + "System.Runtime.Extensions": "4.1.0", + "System.Runtime.InteropServices": "4.1.0", + "System.Runtime.InteropServices.RuntimeInformation": "4.0.0" + }, + "compile": { + "lib/netstandard1.3/Microsoft.DotNet.InternalAbstractions.dll": {} + }, + "runtime": { + "lib/netstandard1.3/Microsoft.DotNet.InternalAbstractions.dll": {} + } + }, + "Microsoft.DotNet.ProjectModel/1.0.0-rc3-003121": { + "type": "package", + "dependencies": { + "Microsoft.CSharp": "4.0.1", + "Microsoft.Extensions.DependencyModel": "1.0.0", + "Newtonsoft.Json": "9.0.1", + "NuGet.Packaging": "3.5.0-beta2-1484", + "NuGet.RuntimeModel": "3.5.0-beta2-1484", + "System.Dynamic.Runtime": "4.0.11", + "System.Reflection.Metadata": "1.3.0", + "System.Runtime.Loader": "4.0.0", + "System.Runtime.Serialization.Primitives": "4.1.1", + "System.Security.Cryptography.Algorithms": "4.2.0", + "System.Threading.Thread": "4.0.0", + "System.Xml.XDocument": "4.0.11" + }, + "compile": { + "lib/netstandard1.6/Microsoft.DotNet.ProjectModel.dll": {} + }, + "runtime": { + "lib/netstandard1.6/Microsoft.DotNet.ProjectModel.dll": {} + } + }, + "Microsoft.Extensions.DependencyModel/1.0.0": { + "type": "package", + "dependencies": { + "Microsoft.DotNet.InternalAbstractions": "1.0.0", + "Newtonsoft.Json": "9.0.1", + "System.Diagnostics.Debug": "4.0.11", + "System.Dynamic.Runtime": "4.0.11", + "System.Linq": "4.1.0" + }, + "compile": { + "lib/netstandard1.6/Microsoft.Extensions.DependencyModel.dll": {} + }, + "runtime": { + "lib/netstandard1.6/Microsoft.Extensions.DependencyModel.dll": {} + } + }, + "Microsoft.Extensions.Testing.Abstractions/1.0.0-preview2-003121": { + "type": "package", + "dependencies": { + "Microsoft.DiaSymReader": "1.0.8", + "Microsoft.DiaSymReader.Native": "1.4.0-rc2", + "Microsoft.DotNet.ProjectModel": "1.0.0-rc3-003121", + "Newtonsoft.Json": "9.0.1", + "System.Reflection.TypeExtensions": "4.1.0", + "System.Resources.ResourceManager": "4.0.1" + }, + "compile": { + "lib/netstandard1.6/Microsoft.Extensions.Testing.Abstractions.dll": {} + }, + "runtime": { + "lib/netstandard1.6/Microsoft.Extensions.Testing.Abstractions.dll": {} + } + }, + "Microsoft.NETCore.App/1.0.0": { + "type": "package", + "dependencies": { + "Libuv": "1.9.0", + "Microsoft.CSharp": "4.0.1", + "Microsoft.CodeAnalysis.CSharp": "1.3.0", + "Microsoft.CodeAnalysis.VisualBasic": "1.3.0", + "Microsoft.NETCore.DotNetHostPolicy": "1.0.1", + "Microsoft.NETCore.Runtime.CoreCLR": "1.0.2", + "Microsoft.VisualBasic": "10.0.1", + "NETStandard.Library": "1.6.0", + "System.Buffers": "4.0.0", + "System.Collections.Immutable": "1.2.0", + "System.ComponentModel": "4.0.1", + "System.ComponentModel.Annotations": "4.1.0", + "System.Diagnostics.DiagnosticSource": "4.0.0", + "System.Diagnostics.Process": "4.1.0", + "System.Dynamic.Runtime": "4.0.11", + "System.Globalization.Extensions": "4.0.1", + "System.IO.FileSystem.Watcher": "4.0.0", + "System.IO.MemoryMappedFiles": "4.0.0", + "System.IO.UnmanagedMemoryStream": "4.0.1", + "System.Linq.Expressions": "4.1.0", + "System.Linq.Parallel": "4.0.1", + "System.Linq.Queryable": "4.0.1", + "System.Net.NameResolution": "4.0.0", + "System.Net.Requests": "4.0.11", + "System.Net.Security": "4.0.0", + "System.Net.WebHeaderCollection": "4.0.1", + "System.Numerics.Vectors": "4.1.1", + "System.Reflection.DispatchProxy": "4.0.1", + "System.Reflection.Metadata": "1.3.0", + "System.Reflection.TypeExtensions": "4.1.0", + "System.Resources.Reader": "4.0.0", + "System.Runtime.Loader": "4.0.0", + "System.Security.Cryptography.Algorithms": "4.2.0", + "System.Security.Cryptography.Encoding": "4.0.0", + "System.Security.Cryptography.Primitives": "4.0.0", + "System.Security.Cryptography.X509Certificates": "4.1.0", + "System.Threading.Tasks.Dataflow": "4.6.0", + "System.Threading.Tasks.Extensions": "4.0.0", + "System.Threading.Tasks.Parallel": "4.0.1", + "System.Threading.Thread": "4.0.0", + "System.Threading.ThreadPool": "4.0.10" + }, + "compile": { + "lib/netcoreapp1.0/_._": {} + }, + "runtime": { + "lib/netcoreapp1.0/_._": {} + } + }, + "Microsoft.NETCore.DotNetHost/1.0.1": { + "type": "package" + }, + "Microsoft.NETCore.DotNetHostPolicy/1.0.1": { + "type": "package", + "dependencies": { + "Microsoft.NETCore.DotNetHostResolver": "1.0.1" + } + }, + "Microsoft.NETCore.DotNetHostResolver/1.0.1": { + "type": "package", + "dependencies": { + "Microsoft.NETCore.DotNetHost": "1.0.1" + } + }, + "Microsoft.NETCore.Jit/1.0.2": { + "type": "package" + }, + "Microsoft.NETCore.Platforms/1.0.1": { + "type": "package", + "compile": { + "lib/netstandard1.0/_._": {} + }, + "runtime": { + "lib/netstandard1.0/_._": {} + } + }, + "Microsoft.NETCore.Runtime.CoreCLR/1.0.2": { + "type": "package", + "dependencies": { + "Microsoft.NETCore.Jit": "1.0.2", + "Microsoft.NETCore.Windows.ApiSets": "1.0.1" + } + }, + "Microsoft.NETCore.Targets/1.0.1": { + "type": "package", + "compile": { + "lib/netstandard1.0/_._": {} + }, + "runtime": { + "lib/netstandard1.0/_._": {} + } + }, + "Microsoft.NETCore.Windows.ApiSets/1.0.1": { + "type": "package" + }, + "Microsoft.VisualBasic/10.0.1": { + "type": "package", + "dependencies": { + "System.Collections": "4.0.11", + "System.Diagnostics.Debug": "4.0.11", + "System.Dynamic.Runtime": "4.0.11", + "System.Globalization": "4.0.11", + "System.Linq": "4.1.0", + "System.Linq.Expressions": "4.1.0", + "System.ObjectModel": "4.0.12", + "System.Reflection": "4.1.0", + "System.Reflection.Extensions": "4.0.1", + "System.Reflection.Primitives": "4.0.1", + "System.Reflection.TypeExtensions": "4.1.0", + "System.Resources.ResourceManager": "4.0.1", + "System.Runtime": "4.1.0", + "System.Runtime.Extensions": "4.1.0", + "System.Runtime.InteropServices": "4.1.0", + "System.Threading": "4.0.11" + }, + "compile": { + "ref/netstandard1.1/Microsoft.VisualBasic.dll": {} + }, + "runtime": { + "lib/netstandard1.3/Microsoft.VisualBasic.dll": {} + } + }, + "Microsoft.Win32.Primitives/4.0.1": { + "type": "package", + "dependencies": { + "Microsoft.NETCore.Platforms": "1.0.1", + "Microsoft.NETCore.Targets": "1.0.1", + "System.Runtime": "4.1.0" + }, + "compile": { + "ref/netstandard1.3/Microsoft.Win32.Primitives.dll": {} + } + }, + "Microsoft.Win32.Registry/4.0.0": { + "type": "package", + "dependencies": { + "Microsoft.NETCore.Platforms": "1.0.1", + "System.Collections": "4.0.11", + "System.Globalization": "4.0.11", + "System.Resources.ResourceManager": "4.0.1", + "System.Runtime": "4.1.0", + "System.Runtime.Extensions": "4.1.0", + "System.Runtime.Handles": "4.0.1", + "System.Runtime.InteropServices": "4.1.0" + }, + "compile": { + "ref/netstandard1.3/_._": {} + }, + "runtimeTargets": { + "runtimes/unix/lib/netstandard1.3/Microsoft.Win32.Registry.dll": { + "assetType": "runtime", + "rid": "unix" + }, + "runtimes/win/lib/netstandard1.3/Microsoft.Win32.Registry.dll": { + "assetType": "runtime", + "rid": "win" + } + } + }, + "NETStandard.Library/1.6.0": { + "type": "package", + "dependencies": { + "Microsoft.NETCore.Platforms": "1.0.1", + "Microsoft.Win32.Primitives": "4.0.1", + "System.AppContext": "4.1.0", + "System.Collections": "4.0.11", + "System.Collections.Concurrent": "4.0.12", + "System.Console": "4.0.0", + "System.Diagnostics.Debug": "4.0.11", + "System.Diagnostics.Tools": "4.0.1", + "System.Diagnostics.Tracing": "4.1.0", + "System.Globalization": "4.0.11", + "System.Globalization.Calendars": "4.0.1", + "System.IO": "4.1.0", + "System.IO.Compression": "4.1.0", + "System.IO.Compression.ZipFile": "4.0.1", + "System.IO.FileSystem": "4.0.1", + "System.IO.FileSystem.Primitives": "4.0.1", + "System.Linq": "4.1.0", + "System.Linq.Expressions": "4.1.0", + "System.Net.Http": "4.1.0", + "System.Net.Primitives": "4.0.11", + "System.Net.Sockets": "4.1.0", + "System.ObjectModel": "4.0.12", + "System.Reflection": "4.1.0", + "System.Reflection.Extensions": "4.0.1", + "System.Reflection.Primitives": "4.0.1", + "System.Resources.ResourceManager": "4.0.1", + "System.Runtime": "4.1.0", + "System.Runtime.Extensions": "4.1.0", + "System.Runtime.Handles": "4.0.1", + "System.Runtime.InteropServices": "4.1.0", + "System.Runtime.InteropServices.RuntimeInformation": "4.0.0", + "System.Runtime.Numerics": "4.0.1", + "System.Security.Cryptography.Algorithms": "4.2.0", + "System.Security.Cryptography.Encoding": "4.0.0", + "System.Security.Cryptography.Primitives": "4.0.0", + "System.Security.Cryptography.X509Certificates": "4.1.0", + "System.Text.Encoding": "4.0.11", + "System.Text.Encoding.Extensions": "4.0.11", + "System.Text.RegularExpressions": "4.1.0", + "System.Threading": "4.0.11", + "System.Threading.Tasks": "4.0.11", + "System.Threading.Timer": "4.0.1", + "System.Xml.ReaderWriter": "4.0.11", + "System.Xml.XDocument": "4.0.11" + } + }, + "Newtonsoft.Json/9.0.1": { + "type": "package", + "dependencies": { + "Microsoft.CSharp": "4.0.1", + "System.Collections": "4.0.11", + "System.Diagnostics.Debug": "4.0.11", + "System.Dynamic.Runtime": "4.0.11", + "System.Globalization": "4.0.11", + "System.IO": "4.1.0", + "System.Linq": "4.1.0", + "System.Linq.Expressions": "4.1.0", + "System.ObjectModel": "4.0.12", + "System.Reflection": "4.1.0", + "System.Reflection.Extensions": "4.0.1", + "System.Resources.ResourceManager": "4.0.1", + "System.Runtime": "4.1.0", + "System.Runtime.Extensions": "4.1.0", + "System.Runtime.Serialization.Primitives": "4.1.1", + "System.Text.Encoding": "4.0.11", + "System.Text.Encoding.Extensions": "4.0.11", + "System.Text.RegularExpressions": "4.1.0", + "System.Threading": "4.0.11", + "System.Threading.Tasks": "4.0.11", + "System.Xml.ReaderWriter": "4.0.11", + "System.Xml.XDocument": "4.0.11" + }, + "compile": { + "lib/netstandard1.0/Newtonsoft.Json.dll": {} + }, + "runtime": { + "lib/netstandard1.0/Newtonsoft.Json.dll": {} + } + }, + "NuGet.Common/3.5.0-beta2-1484": { + "type": "package", + "dependencies": { + "NETStandard.Library": "1.6.0", + "System.Diagnostics.Process": "4.1.0", + "System.Security.Cryptography.Algorithms": "4.2.0", + "System.Threading.Thread": "4.0.0" + }, + "compile": { + "lib/netstandard1.3/NuGet.Common.dll": {} + }, + "runtime": { + "lib/netstandard1.3/NuGet.Common.dll": {} + } + }, + "NuGet.Frameworks/3.5.0-beta2-1484": { + "type": "package", + "dependencies": { + "NETStandard.Library": "1.6.0" + }, + "compile": { + "lib/netstandard1.3/NuGet.Frameworks.dll": {} + }, + "runtime": { + "lib/netstandard1.3/NuGet.Frameworks.dll": {} + } + }, + "NuGet.Packaging/3.5.0-beta2-1484": { + "type": "package", + "dependencies": { + "NETStandard.Library": "1.6.0", + "NuGet.Common": "3.5.0-beta2-1484", + "NuGet.Packaging.Core": "3.5.0-beta2-1484", + "System.IO.Compression": "4.1.0" + }, + "compile": { + "lib/netstandard1.3/NuGet.Packaging.dll": {} + }, + "runtime": { + "lib/netstandard1.3/NuGet.Packaging.dll": {} + } + }, + "NuGet.Packaging.Core/3.5.0-beta2-1484": { + "type": "package", + "dependencies": { + "NETStandard.Library": "1.6.0", + "NuGet.Common": "3.5.0-beta2-1484", + "NuGet.Packaging.Core.Types": "3.5.0-beta2-1484", + "System.Xml.XDocument": "4.0.11" + }, + "compile": { + "lib/netstandard1.3/NuGet.Packaging.Core.dll": {} + }, + "runtime": { + "lib/netstandard1.3/NuGet.Packaging.Core.dll": {} + } + }, + "NuGet.Packaging.Core.Types/3.5.0-beta2-1484": { + "type": "package", + "dependencies": { + "NETStandard.Library": "1.6.0", + "NuGet.Frameworks": "3.5.0-beta2-1484", + "NuGet.Versioning": "3.5.0-beta2-1484" + }, + "compile": { + "lib/netstandard1.3/NuGet.Packaging.Core.Types.dll": {} + }, + "runtime": { + "lib/netstandard1.3/NuGet.Packaging.Core.Types.dll": {} + } + }, + "NuGet.RuntimeModel/3.5.0-beta2-1484": { + "type": "package", + "dependencies": { + "NETStandard.Library": "1.6.0", + "Newtonsoft.Json": "6.0.4", + "NuGet.Frameworks": "3.5.0-beta2-1484", + "NuGet.Versioning": "3.5.0-beta2-1484", + "System.Dynamic.Runtime": "4.0.11", + "System.ObjectModel": "4.0.12" + }, + "compile": { + "lib/netstandard1.3/NuGet.RuntimeModel.dll": {} + }, + "runtime": { + "lib/netstandard1.3/NuGet.RuntimeModel.dll": {} + } + }, + "NuGet.Versioning/3.5.0-beta2-1484": { + "type": "package", + "dependencies": { + "NETStandard.Library": "1.6.0" + }, + "compile": { + "lib/netstandard1.0/NuGet.Versioning.dll": {} + }, + "runtime": { + "lib/netstandard1.0/NuGet.Versioning.dll": {} + } + }, + "runtime.native.System/4.0.0": { + "type": "package", + "dependencies": { + "Microsoft.NETCore.Platforms": "1.0.1", + "Microsoft.NETCore.Targets": "1.0.1" + }, + "compile": { + "lib/netstandard1.0/_._": {} + }, + "runtime": { + "lib/netstandard1.0/_._": {} + } + }, + "runtime.native.System.IO.Compression/4.1.0": { + "type": "package", + "dependencies": { + "Microsoft.NETCore.Platforms": "1.0.1", + "Microsoft.NETCore.Targets": "1.0.1" + }, + "compile": { + "lib/netstandard1.0/_._": {} + }, + "runtime": { + "lib/netstandard1.0/_._": {} + } + }, + "runtime.native.System.Net.Http/4.0.1": { + "type": "package", + "dependencies": { + "Microsoft.NETCore.Platforms": "1.0.1", + "Microsoft.NETCore.Targets": "1.0.1" + }, + "compile": { + "lib/netstandard1.0/_._": {} + }, + "runtime": { + "lib/netstandard1.0/_._": {} + } + }, + "runtime.native.System.Net.Security/4.0.1": { + "type": "package", + "dependencies": { + "Microsoft.NETCore.Platforms": "1.0.1", + "Microsoft.NETCore.Targets": "1.0.1" + }, + "compile": { + "lib/netstandard1.0/_._": {} + }, + "runtime": { + "lib/netstandard1.0/_._": {} + } + }, + "runtime.native.System.Security.Cryptography/4.0.0": { + "type": "package", + "dependencies": { + "Microsoft.NETCore.Platforms": "1.0.1", + "Microsoft.NETCore.Targets": "1.0.1" + }, + "compile": { + "lib/netstandard1.0/_._": {} + }, + "runtime": { + "lib/netstandard1.0/_._": {} + } + }, + "System.AppContext/4.1.0": { + "type": "package", + "dependencies": { + "System.Runtime": "4.1.0" + }, + "compile": { + "ref/netstandard1.6/System.AppContext.dll": {} + }, + "runtime": { + "lib/netstandard1.6/System.AppContext.dll": {} + } + }, + "System.Buffers/4.0.0": { + "type": "package", + "dependencies": { + "System.Diagnostics.Debug": "4.0.11", + "System.Diagnostics.Tracing": "4.1.0", + "System.Resources.ResourceManager": "4.0.1", + "System.Runtime": "4.1.0", + "System.Threading": "4.0.11" + }, + "compile": { + "lib/netstandard1.1/System.Buffers.dll": {} + }, + "runtime": { + "lib/netstandard1.1/System.Buffers.dll": {} + } + }, + "System.Collections/4.0.11": { + "type": "package", + "dependencies": { + "Microsoft.NETCore.Platforms": "1.0.1", + "Microsoft.NETCore.Targets": "1.0.1", + "System.Runtime": "4.1.0" + }, + "compile": { + "ref/netstandard1.3/System.Collections.dll": {} + } + }, + "System.Collections.Concurrent/4.0.12": { + "type": "package", + "dependencies": { + "System.Collections": "4.0.11", + "System.Diagnostics.Debug": "4.0.11", + "System.Diagnostics.Tracing": "4.1.0", + "System.Globalization": "4.0.11", + "System.Reflection": "4.1.0", + "System.Resources.ResourceManager": "4.0.1", + "System.Runtime": "4.1.0", + "System.Runtime.Extensions": "4.1.0", + "System.Threading": "4.0.11", + "System.Threading.Tasks": "4.0.11" + }, + "compile": { + "ref/netstandard1.3/System.Collections.Concurrent.dll": {} + }, + "runtime": { + "lib/netstandard1.3/System.Collections.Concurrent.dll": {} + } + }, + "System.Collections.Immutable/1.2.0": { + "type": "package", + "dependencies": { + "System.Collections": "4.0.11", + "System.Diagnostics.Debug": "4.0.11", + "System.Globalization": "4.0.11", + "System.Linq": "4.1.0", + "System.Resources.ResourceManager": "4.0.1", + "System.Runtime": "4.1.0", + "System.Runtime.Extensions": "4.1.0", + "System.Threading": "4.0.11" + }, + "compile": { + "lib/netstandard1.0/System.Collections.Immutable.dll": {} + }, + "runtime": { + "lib/netstandard1.0/System.Collections.Immutable.dll": {} + } + }, + "System.ComponentModel/4.0.1": { + "type": "package", + "dependencies": { + "System.Runtime": "4.1.0" + }, + "compile": { + "ref/netstandard1.0/System.ComponentModel.dll": {} + }, + "runtime": { + "lib/netstandard1.3/System.ComponentModel.dll": {} + } + }, + "System.ComponentModel.Annotations/4.1.0": { + "type": "package", + "dependencies": { + "System.Collections": "4.0.11", + "System.ComponentModel": "4.0.1", + "System.Globalization": "4.0.11", + "System.Linq": "4.1.0", + "System.Reflection": "4.1.0", + "System.Reflection.Extensions": "4.0.1", + "System.Resources.ResourceManager": "4.0.1", + "System.Runtime": "4.1.0", + "System.Runtime.Extensions": "4.1.0", + "System.Text.RegularExpressions": "4.1.0", + "System.Threading": "4.0.11" + }, + "compile": { + "ref/netstandard1.4/System.ComponentModel.Annotations.dll": {} + }, + "runtime": { + "lib/netstandard1.4/System.ComponentModel.Annotations.dll": {} + } + }, + "System.Console/4.0.0": { + "type": "package", + "dependencies": { + "Microsoft.NETCore.Platforms": "1.0.1", + "Microsoft.NETCore.Targets": "1.0.1", + "System.IO": "4.1.0", + "System.Runtime": "4.1.0", + "System.Text.Encoding": "4.0.11" + }, + "compile": { + "ref/netstandard1.3/System.Console.dll": {} + } + }, + "System.Diagnostics.Debug/4.0.11": { + "type": "package", + "dependencies": { + "Microsoft.NETCore.Platforms": "1.0.1", + "Microsoft.NETCore.Targets": "1.0.1", + "System.Runtime": "4.1.0" + }, + "compile": { + "ref/netstandard1.3/System.Diagnostics.Debug.dll": {} + } + }, + "System.Diagnostics.DiagnosticSource/4.0.0": { + "type": "package", + "dependencies": { + "System.Collections": "4.0.11", + "System.Diagnostics.Tracing": "4.1.0", + "System.Reflection": "4.1.0", + "System.Runtime": "4.1.0", + "System.Threading": "4.0.11" + }, + "compile": { + "lib/netstandard1.3/System.Diagnostics.DiagnosticSource.dll": {} + }, + "runtime": { + "lib/netstandard1.3/System.Diagnostics.DiagnosticSource.dll": {} + } + }, + "System.Diagnostics.FileVersionInfo/4.0.0": { + "type": "package", + "dependencies": { + "Microsoft.NETCore.Platforms": "1.0.1", + "System.Globalization": "4.0.11", + "System.IO": "4.1.0", + "System.IO.FileSystem": "4.0.1", + "System.IO.FileSystem.Primitives": "4.0.1", + "System.Reflection.Metadata": "1.3.0", + "System.Runtime": "4.1.0", + "System.Runtime.Extensions": "4.1.0", + "System.Runtime.InteropServices": "4.1.0" + }, + "compile": { + "ref/netstandard1.3/_._": {} + }, + "runtimeTargets": { + "runtimes/unix/lib/netstandard1.3/System.Diagnostics.FileVersionInfo.dll": { + "assetType": "runtime", + "rid": "unix" + }, + "runtimes/win/lib/netstandard1.3/System.Diagnostics.FileVersionInfo.dll": { + "assetType": "runtime", + "rid": "win" + } + } + }, + "System.Diagnostics.Process/4.1.0": { + "type": "package", + "dependencies": { + "Microsoft.NETCore.Platforms": "1.0.1", + "Microsoft.Win32.Primitives": "4.0.1", + "Microsoft.Win32.Registry": "4.0.0", + "System.Collections": "4.0.11", + "System.Diagnostics.Debug": "4.0.11", + "System.Globalization": "4.0.11", + "System.IO": "4.1.0", + "System.IO.FileSystem": "4.0.1", + "System.IO.FileSystem.Primitives": "4.0.1", + "System.Resources.ResourceManager": "4.0.1", + "System.Runtime": "4.1.0", + "System.Runtime.Extensions": "4.1.0", + "System.Runtime.Handles": "4.0.1", + "System.Runtime.InteropServices": "4.1.0", + "System.Text.Encoding": "4.0.11", + "System.Text.Encoding.Extensions": "4.0.11", + "System.Threading": "4.0.11", + "System.Threading.Tasks": "4.0.11", + "System.Threading.Thread": "4.0.0", + "System.Threading.ThreadPool": "4.0.10", + "runtime.native.System": "4.0.0" + }, + "compile": { + "ref/netstandard1.4/System.Diagnostics.Process.dll": {} + }, + "runtimeTargets": { + "runtimes/linux/lib/netstandard1.4/System.Diagnostics.Process.dll": { + "assetType": "runtime", + "rid": "linux" + }, + "runtimes/osx/lib/netstandard1.4/System.Diagnostics.Process.dll": { + "assetType": "runtime", + "rid": "osx" + }, + "runtimes/win/lib/netstandard1.4/System.Diagnostics.Process.dll": { + "assetType": "runtime", + "rid": "win" + } + } + }, + "System.Diagnostics.StackTrace/4.0.1": { + "type": "package", + "dependencies": { + "System.Collections.Immutable": "1.2.0", + "System.IO.FileSystem": "4.0.1", + "System.Reflection": "4.1.0", + "System.Reflection.Metadata": "1.3.0", + "System.Runtime": "4.1.0", + "System.Runtime.Extensions": "4.1.0" + }, + "compile": { + "ref/netstandard1.3/_._": {} + }, + "runtime": { + "lib/netstandard1.3/System.Diagnostics.StackTrace.dll": {} + } + }, + "System.Diagnostics.Tools/4.0.1": { + "type": "package", + "dependencies": { + "Microsoft.NETCore.Platforms": "1.0.1", + "Microsoft.NETCore.Targets": "1.0.1", + "System.Runtime": "4.1.0" + }, + "compile": { + "ref/netstandard1.0/System.Diagnostics.Tools.dll": {} + } + }, + "System.Diagnostics.Tracing/4.1.0": { + "type": "package", + "dependencies": { + "Microsoft.NETCore.Platforms": "1.0.1", + "Microsoft.NETCore.Targets": "1.0.1", + "System.Runtime": "4.1.0" + }, + "compile": { + "ref/netstandard1.5/System.Diagnostics.Tracing.dll": {} + } + }, + "System.Dynamic.Runtime/4.0.11": { + "type": "package", + "dependencies": { + "System.Collections": "4.0.11", + "System.Diagnostics.Debug": "4.0.11", + "System.Globalization": "4.0.11", + "System.Linq": "4.1.0", + "System.Linq.Expressions": "4.1.0", + "System.ObjectModel": "4.0.12", + "System.Reflection": "4.1.0", + "System.Reflection.Emit": "4.0.1", + "System.Reflection.Emit.ILGeneration": "4.0.1", + "System.Reflection.Primitives": "4.0.1", + "System.Reflection.TypeExtensions": "4.1.0", + "System.Resources.ResourceManager": "4.0.1", + "System.Runtime": "4.1.0", + "System.Runtime.Extensions": "4.1.0", + "System.Threading": "4.0.11" + }, + "compile": { + "ref/netstandard1.3/System.Dynamic.Runtime.dll": {} + }, + "runtime": { + "lib/netstandard1.3/System.Dynamic.Runtime.dll": {} + } + }, + "System.Globalization/4.0.11": { + "type": "package", + "dependencies": { + "Microsoft.NETCore.Platforms": "1.0.1", + "Microsoft.NETCore.Targets": "1.0.1", + "System.Runtime": "4.1.0" + }, + "compile": { + "ref/netstandard1.3/System.Globalization.dll": {} + } + }, + "System.Globalization.Calendars/4.0.1": { + "type": "package", + "dependencies": { + "Microsoft.NETCore.Platforms": "1.0.1", + "Microsoft.NETCore.Targets": "1.0.1", + "System.Globalization": "4.0.11", + "System.Runtime": "4.1.0" + }, + "compile": { + "ref/netstandard1.3/System.Globalization.Calendars.dll": {} + } + }, + "System.Globalization.Extensions/4.0.1": { + "type": "package", + "dependencies": { + "Microsoft.NETCore.Platforms": "1.0.1", + "System.Globalization": "4.0.11", + "System.Resources.ResourceManager": "4.0.1", + "System.Runtime": "4.1.0", + "System.Runtime.Extensions": "4.1.0", + "System.Runtime.InteropServices": "4.1.0" + }, + "compile": { + "ref/netstandard1.3/System.Globalization.Extensions.dll": {} + }, + "runtimeTargets": { + "runtimes/unix/lib/netstandard1.3/System.Globalization.Extensions.dll": { + "assetType": "runtime", + "rid": "unix" + }, + "runtimes/win/lib/netstandard1.3/System.Globalization.Extensions.dll": { + "assetType": "runtime", + "rid": "win" + } + } + }, + "System.IO/4.1.0": { + "type": "package", + "dependencies": { + "Microsoft.NETCore.Platforms": "1.0.1", + "Microsoft.NETCore.Targets": "1.0.1", + "System.Runtime": "4.1.0", + "System.Text.Encoding": "4.0.11", + "System.Threading.Tasks": "4.0.11" + }, + "compile": { + "ref/netstandard1.5/System.IO.dll": {} + } + }, + "System.IO.Compression/4.1.0": { + "type": "package", + "dependencies": { + "Microsoft.NETCore.Platforms": "1.0.1", + "System.Collections": "4.0.11", + "System.Diagnostics.Debug": "4.0.11", + "System.IO": "4.1.0", + "System.Resources.ResourceManager": "4.0.1", + "System.Runtime": "4.1.0", + "System.Runtime.Extensions": "4.1.0", + "System.Runtime.Handles": "4.0.1", + "System.Runtime.InteropServices": "4.1.0", + "System.Text.Encoding": "4.0.11", + "System.Threading": "4.0.11", + "System.Threading.Tasks": "4.0.11", + "runtime.native.System": "4.0.0", + "runtime.native.System.IO.Compression": "4.1.0" + }, + "compile": { + "ref/netstandard1.3/System.IO.Compression.dll": {} + }, + "runtimeTargets": { + "runtimes/unix/lib/netstandard1.3/System.IO.Compression.dll": { + "assetType": "runtime", + "rid": "unix" + }, + "runtimes/win/lib/netstandard1.3/System.IO.Compression.dll": { + "assetType": "runtime", + "rid": "win" + } + } + }, + "System.IO.Compression.ZipFile/4.0.1": { + "type": "package", + "dependencies": { + "System.Buffers": "4.0.0", + "System.IO": "4.1.0", + "System.IO.Compression": "4.1.0", + "System.IO.FileSystem": "4.0.1", + "System.IO.FileSystem.Primitives": "4.0.1", + "System.Resources.ResourceManager": "4.0.1", + "System.Runtime": "4.1.0", + "System.Runtime.Extensions": "4.1.0", + "System.Text.Encoding": "4.0.11" + }, + "compile": { + "ref/netstandard1.3/System.IO.Compression.ZipFile.dll": {} + }, + "runtime": { + "lib/netstandard1.3/System.IO.Compression.ZipFile.dll": {} + } + }, + "System.IO.FileSystem/4.0.1": { + "type": "package", + "dependencies": { + "Microsoft.NETCore.Platforms": "1.0.1", + "Microsoft.NETCore.Targets": "1.0.1", + "System.IO": "4.1.0", + "System.IO.FileSystem.Primitives": "4.0.1", + "System.Runtime": "4.1.0", + "System.Runtime.Handles": "4.0.1", + "System.Text.Encoding": "4.0.11", + "System.Threading.Tasks": "4.0.11" + }, + "compile": { + "ref/netstandard1.3/System.IO.FileSystem.dll": {} + } + }, + "System.IO.FileSystem.Primitives/4.0.1": { + "type": "package", + "dependencies": { + "System.Runtime": "4.1.0" + }, + "compile": { + "ref/netstandard1.3/System.IO.FileSystem.Primitives.dll": {} + }, + "runtime": { + "lib/netstandard1.3/System.IO.FileSystem.Primitives.dll": {} + } + }, + "System.IO.FileSystem.Watcher/4.0.0": { + "type": "package", + "dependencies": { + "Microsoft.NETCore.Platforms": "1.0.1", + "Microsoft.Win32.Primitives": "4.0.1", + "System.Collections": "4.0.11", + "System.IO.FileSystem": "4.0.1", + "System.IO.FileSystem.Primitives": "4.0.1", + "System.Resources.ResourceManager": "4.0.1", + "System.Runtime": "4.1.0", + "System.Runtime.Extensions": "4.1.0", + "System.Runtime.Handles": "4.0.1", + "System.Runtime.InteropServices": "4.1.0", + "System.Text.Encoding": "4.0.11", + "System.Threading": "4.0.11", + "System.Threading.Overlapped": "4.0.1", + "System.Threading.Tasks": "4.0.11", + "System.Threading.Thread": "4.0.0", + "runtime.native.System": "4.0.0" + }, + "compile": { + "ref/netstandard1.3/System.IO.FileSystem.Watcher.dll": {} + }, + "runtimeTargets": { + "runtimes/linux/lib/netstandard1.3/System.IO.FileSystem.Watcher.dll": { + "assetType": "runtime", + "rid": "linux" + }, + "runtimes/osx/lib/netstandard1.3/System.IO.FileSystem.Watcher.dll": { + "assetType": "runtime", + "rid": "osx" + }, + "runtimes/win/lib/netstandard1.3/System.IO.FileSystem.Watcher.dll": { + "assetType": "runtime", + "rid": "win" + } + } + }, + "System.IO.MemoryMappedFiles/4.0.0": { + "type": "package", + "dependencies": { + "Microsoft.NETCore.Platforms": "1.0.1", + "System.IO": "4.1.0", + "System.IO.FileSystem": "4.0.1", + "System.IO.FileSystem.Primitives": "4.0.1", + "System.IO.UnmanagedMemoryStream": "4.0.1", + "System.Resources.ResourceManager": "4.0.1", + "System.Runtime": "4.1.0", + "System.Runtime.Extensions": "4.1.0", + "System.Runtime.Handles": "4.0.1", + "System.Runtime.InteropServices": "4.1.0", + "System.Threading": "4.0.11", + "System.Threading.Tasks": "4.0.11", + "runtime.native.System": "4.0.0" + }, + "compile": { + "ref/netstandard1.3/System.IO.MemoryMappedFiles.dll": {} + }, + "runtimeTargets": { + "runtimes/unix/lib/netstandard1.3/System.IO.MemoryMappedFiles.dll": { + "assetType": "runtime", + "rid": "unix" + }, + "runtimes/win/lib/netstandard1.3/System.IO.MemoryMappedFiles.dll": { + "assetType": "runtime", + "rid": "win" + } + } + }, + "System.IO.UnmanagedMemoryStream/4.0.1": { + "type": "package", + "dependencies": { + "System.IO": "4.1.0", + "System.IO.FileSystem.Primitives": "4.0.1", + "System.Resources.ResourceManager": "4.0.1", + "System.Runtime": "4.1.0", + "System.Runtime.InteropServices": "4.1.0", + "System.Threading": "4.0.11", + "System.Threading.Tasks": "4.0.11" + }, + "compile": { + "ref/netstandard1.3/System.IO.UnmanagedMemoryStream.dll": {} + }, + "runtime": { + "lib/netstandard1.3/System.IO.UnmanagedMemoryStream.dll": {} + } + }, + "System.Linq/4.1.0": { + "type": "package", + "dependencies": { + "System.Collections": "4.0.11", + "System.Diagnostics.Debug": "4.0.11", + "System.Resources.ResourceManager": "4.0.1", + "System.Runtime": "4.1.0", + "System.Runtime.Extensions": "4.1.0" + }, + "compile": { + "ref/netstandard1.6/System.Linq.dll": {} + }, + "runtime": { + "lib/netstandard1.6/System.Linq.dll": {} + } + }, + "System.Linq.Expressions/4.1.0": { + "type": "package", + "dependencies": { + "System.Collections": "4.0.11", + "System.Diagnostics.Debug": "4.0.11", + "System.Globalization": "4.0.11", + "System.IO": "4.1.0", + "System.Linq": "4.1.0", + "System.ObjectModel": "4.0.12", + "System.Reflection": "4.1.0", + "System.Reflection.Emit": "4.0.1", + "System.Reflection.Emit.ILGeneration": "4.0.1", + "System.Reflection.Emit.Lightweight": "4.0.1", + "System.Reflection.Extensions": "4.0.1", + "System.Reflection.Primitives": "4.0.1", + "System.Reflection.TypeExtensions": "4.1.0", + "System.Resources.ResourceManager": "4.0.1", + "System.Runtime": "4.1.0", + "System.Runtime.Extensions": "4.1.0", + "System.Threading": "4.0.11" + }, + "compile": { + "ref/netstandard1.6/System.Linq.Expressions.dll": {} + }, + "runtime": { + "lib/netstandard1.6/System.Linq.Expressions.dll": {} + } + }, + "System.Linq.Parallel/4.0.1": { + "type": "package", + "dependencies": { + "System.Collections": "4.0.11", + "System.Collections.Concurrent": "4.0.12", + "System.Diagnostics.Debug": "4.0.11", + "System.Diagnostics.Tracing": "4.1.0", + "System.Linq": "4.1.0", + "System.Resources.ResourceManager": "4.0.1", + "System.Runtime": "4.1.0", + "System.Runtime.Extensions": "4.1.0", + "System.Threading": "4.0.11", + "System.Threading.Tasks": "4.0.11" + }, + "compile": { + "ref/netstandard1.1/System.Linq.Parallel.dll": {} + }, + "runtime": { + "lib/netstandard1.3/System.Linq.Parallel.dll": {} + } + }, + "System.Linq.Queryable/4.0.1": { + "type": "package", + "dependencies": { + "System.Collections": "4.0.11", + "System.Diagnostics.Debug": "4.0.11", + "System.Linq": "4.1.0", + "System.Linq.Expressions": "4.1.0", + "System.Reflection": "4.1.0", + "System.Reflection.Extensions": "4.0.1", + "System.Resources.ResourceManager": "4.0.1", + "System.Runtime": "4.1.0" + }, + "compile": { + "ref/netstandard1.0/System.Linq.Queryable.dll": {} + }, + "runtime": { + "lib/netstandard1.3/System.Linq.Queryable.dll": {} + } + }, + "System.Net.Http/4.1.0": { + "type": "package", + "dependencies": { + "Microsoft.NETCore.Platforms": "1.0.1", + "System.Collections": "4.0.11", + "System.Diagnostics.Debug": "4.0.11", + "System.Diagnostics.DiagnosticSource": "4.0.0", + "System.Diagnostics.Tracing": "4.1.0", + "System.Globalization": "4.0.11", + "System.Globalization.Extensions": "4.0.1", + "System.IO": "4.1.0", + "System.IO.FileSystem": "4.0.1", + "System.Net.Primitives": "4.0.11", + "System.Resources.ResourceManager": "4.0.1", + "System.Runtime": "4.1.0", + "System.Runtime.Extensions": "4.1.0", + "System.Runtime.Handles": "4.0.1", + "System.Runtime.InteropServices": "4.1.0", + "System.Security.Cryptography.Algorithms": "4.2.0", + "System.Security.Cryptography.Encoding": "4.0.0", + "System.Security.Cryptography.OpenSsl": "4.0.0", + "System.Security.Cryptography.Primitives": "4.0.0", + "System.Security.Cryptography.X509Certificates": "4.1.0", + "System.Text.Encoding": "4.0.11", + "System.Threading": "4.0.11", + "System.Threading.Tasks": "4.0.11", + "runtime.native.System": "4.0.0", + "runtime.native.System.Net.Http": "4.0.1", + "runtime.native.System.Security.Cryptography": "4.0.0" + }, + "compile": { + "ref/netstandard1.3/System.Net.Http.dll": {} + }, + "runtimeTargets": { + "runtimes/unix/lib/netstandard1.6/System.Net.Http.dll": { + "assetType": "runtime", + "rid": "unix" + }, + "runtimes/win/lib/netstandard1.3/System.Net.Http.dll": { + "assetType": "runtime", + "rid": "win" + } + } + }, + "System.Net.NameResolution/4.0.0": { + "type": "package", + "dependencies": { + "Microsoft.NETCore.Platforms": "1.0.1", + "System.Collections": "4.0.11", + "System.Diagnostics.Tracing": "4.1.0", + "System.Globalization": "4.0.11", + "System.Net.Primitives": "4.0.11", + "System.Resources.ResourceManager": "4.0.1", + "System.Runtime": "4.1.0", + "System.Runtime.Extensions": "4.1.0", + "System.Runtime.Handles": "4.0.1", + "System.Runtime.InteropServices": "4.1.0", + "System.Security.Principal.Windows": "4.0.0", + "System.Threading": "4.0.11", + "System.Threading.Tasks": "4.0.11", + "runtime.native.System": "4.0.0" + }, + "compile": { + "ref/netstandard1.3/System.Net.NameResolution.dll": {} + }, + "runtimeTargets": { + "runtimes/unix/lib/netstandard1.3/System.Net.NameResolution.dll": { + "assetType": "runtime", + "rid": "unix" + }, + "runtimes/win/lib/netstandard1.3/System.Net.NameResolution.dll": { + "assetType": "runtime", + "rid": "win" + } + } + }, + "System.Net.Primitives/4.0.11": { + "type": "package", + "dependencies": { + "Microsoft.NETCore.Platforms": "1.0.1", + "Microsoft.NETCore.Targets": "1.0.1", + "System.Runtime": "4.1.0", + "System.Runtime.Handles": "4.0.1" + }, + "compile": { + "ref/netstandard1.3/System.Net.Primitives.dll": {} + } + }, + "System.Net.Requests/4.0.11": { + "type": "package", + "dependencies": { + "Microsoft.NETCore.Platforms": "1.0.1", + "System.Collections": "4.0.11", + "System.Diagnostics.Debug": "4.0.11", + "System.Diagnostics.Tracing": "4.1.0", + "System.Globalization": "4.0.11", + "System.IO": "4.1.0", + "System.Net.Http": "4.1.0", + "System.Net.Primitives": "4.0.11", + "System.Net.WebHeaderCollection": "4.0.1", + "System.Resources.ResourceManager": "4.0.1", + "System.Runtime": "4.1.0", + "System.Threading": "4.0.11", + "System.Threading.Tasks": "4.0.11" + }, + "compile": { + "ref/netstandard1.3/System.Net.Requests.dll": {} + }, + "runtimeTargets": { + "runtimes/unix/lib/netstandard1.3/System.Net.Requests.dll": { + "assetType": "runtime", + "rid": "unix" + }, + "runtimes/win/lib/netstandard1.3/System.Net.Requests.dll": { + "assetType": "runtime", + "rid": "win" + } + } + }, + "System.Net.Security/4.0.0": { + "type": "package", + "dependencies": { + "Microsoft.NETCore.Platforms": "1.0.1", + "Microsoft.Win32.Primitives": "4.0.1", + "System.Collections": "4.0.11", + "System.Collections.Concurrent": "4.0.12", + "System.Diagnostics.Tracing": "4.1.0", + "System.Globalization": "4.0.11", + "System.Globalization.Extensions": "4.0.1", + "System.IO": "4.1.0", + "System.Net.Primitives": "4.0.11", + "System.Resources.ResourceManager": "4.0.1", + "System.Runtime": "4.1.0", + "System.Runtime.Extensions": "4.1.0", + "System.Runtime.Handles": "4.0.1", + "System.Runtime.InteropServices": "4.1.0", + "System.Security.Claims": "4.0.1", + "System.Security.Cryptography.Algorithms": "4.2.0", + "System.Security.Cryptography.Encoding": "4.0.0", + "System.Security.Cryptography.OpenSsl": "4.0.0", + "System.Security.Cryptography.Primitives": "4.0.0", + "System.Security.Cryptography.X509Certificates": "4.1.0", + "System.Security.Principal": "4.0.1", + "System.Text.Encoding": "4.0.11", + "System.Threading": "4.0.11", + "System.Threading.Tasks": "4.0.11", + "System.Threading.ThreadPool": "4.0.10", + "runtime.native.System": "4.0.0", + "runtime.native.System.Net.Security": "4.0.1", + "runtime.native.System.Security.Cryptography": "4.0.0" + }, + "compile": { + "ref/netstandard1.3/System.Net.Security.dll": {} + }, + "runtimeTargets": { + "runtimes/unix/lib/netstandard1.6/System.Net.Security.dll": { + "assetType": "runtime", + "rid": "unix" + }, + "runtimes/win/lib/netstandard1.3/System.Net.Security.dll": { + "assetType": "runtime", + "rid": "win" + } + } + }, + "System.Net.Sockets/4.1.0": { + "type": "package", + "dependencies": { + "Microsoft.NETCore.Platforms": "1.0.1", + "Microsoft.NETCore.Targets": "1.0.1", + "System.IO": "4.1.0", + "System.Net.Primitives": "4.0.11", + "System.Runtime": "4.1.0", + "System.Threading.Tasks": "4.0.11" + }, + "compile": { + "ref/netstandard1.3/System.Net.Sockets.dll": {} + } + }, + "System.Net.WebHeaderCollection/4.0.1": { + "type": "package", + "dependencies": { + "System.Collections": "4.0.11", + "System.Resources.ResourceManager": "4.0.1", + "System.Runtime": "4.1.0", + "System.Runtime.Extensions": "4.1.0" + }, + "compile": { + "ref/netstandard1.3/System.Net.WebHeaderCollection.dll": {} + }, + "runtime": { + "lib/netstandard1.3/System.Net.WebHeaderCollection.dll": {} + } + }, + "System.Numerics.Vectors/4.1.1": { + "type": "package", + "dependencies": { + "System.Globalization": "4.0.11", + "System.Resources.ResourceManager": "4.0.1", + "System.Runtime": "4.1.0", + "System.Runtime.Extensions": "4.1.0" + }, + "compile": { + "ref/netstandard1.0/System.Numerics.Vectors.dll": {} + }, + "runtime": { + "lib/netstandard1.0/System.Numerics.Vectors.dll": {} + } + }, + "System.ObjectModel/4.0.12": { + "type": "package", + "dependencies": { + "System.Collections": "4.0.11", + "System.Diagnostics.Debug": "4.0.11", + "System.Resources.ResourceManager": "4.0.1", + "System.Runtime": "4.1.0", + "System.Threading": "4.0.11" + }, + "compile": { + "ref/netstandard1.3/System.ObjectModel.dll": {} + }, + "runtime": { + "lib/netstandard1.3/System.ObjectModel.dll": {} + } + }, + "System.Reflection/4.1.0": { + "type": "package", + "dependencies": { + "Microsoft.NETCore.Platforms": "1.0.1", + "Microsoft.NETCore.Targets": "1.0.1", + "System.IO": "4.1.0", + "System.Reflection.Primitives": "4.0.1", + "System.Runtime": "4.1.0" + }, + "compile": { + "ref/netstandard1.5/System.Reflection.dll": {} + } + }, + "System.Reflection.DispatchProxy/4.0.1": { + "type": "package", + "dependencies": { + "System.Collections": "4.0.11", + "System.Linq": "4.1.0", + "System.Reflection": "4.1.0", + "System.Reflection.Emit": "4.0.1", + "System.Reflection.Emit.ILGeneration": "4.0.1", + "System.Reflection.Extensions": "4.0.1", + "System.Reflection.Primitives": "4.0.1", + "System.Resources.ResourceManager": "4.0.1", + "System.Runtime": "4.1.0", + "System.Threading": "4.0.11" + }, + "compile": { + "ref/netstandard1.3/System.Reflection.DispatchProxy.dll": {} + }, + "runtime": { + "lib/netstandard1.3/System.Reflection.DispatchProxy.dll": {} + } + }, + "System.Reflection.Emit/4.0.1": { + "type": "package", + "dependencies": { + "System.IO": "4.1.0", + "System.Reflection": "4.1.0", + "System.Reflection.Emit.ILGeneration": "4.0.1", + "System.Reflection.Primitives": "4.0.1", + "System.Runtime": "4.1.0" + }, + "compile": { + "ref/netstandard1.1/_._": {} + }, + "runtime": { + "lib/netstandard1.3/System.Reflection.Emit.dll": {} + } + }, + "System.Reflection.Emit.ILGeneration/4.0.1": { + "type": "package", + "dependencies": { + "System.Reflection": "4.1.0", + "System.Reflection.Primitives": "4.0.1", + "System.Runtime": "4.1.0" + }, + "compile": { + "ref/netstandard1.0/_._": {} + }, + "runtime": { + "lib/netstandard1.3/System.Reflection.Emit.ILGeneration.dll": {} + } + }, + "System.Reflection.Emit.Lightweight/4.0.1": { + "type": "package", + "dependencies": { + "System.Reflection": "4.1.0", + "System.Reflection.Emit.ILGeneration": "4.0.1", + "System.Reflection.Primitives": "4.0.1", + "System.Runtime": "4.1.0" + }, + "compile": { + "ref/netstandard1.0/_._": {} + }, + "runtime": { + "lib/netstandard1.3/System.Reflection.Emit.Lightweight.dll": {} + } + }, + "System.Reflection.Extensions/4.0.1": { + "type": "package", + "dependencies": { + "Microsoft.NETCore.Platforms": "1.0.1", + "Microsoft.NETCore.Targets": "1.0.1", + "System.Reflection": "4.1.0", + "System.Runtime": "4.1.0" + }, + "compile": { + "ref/netstandard1.0/System.Reflection.Extensions.dll": {} + } + }, + "System.Reflection.Metadata/1.3.0": { + "type": "package", + "dependencies": { + "System.Collections": "4.0.11", + "System.Collections.Immutable": "1.2.0", + "System.Diagnostics.Debug": "4.0.11", + "System.IO": "4.1.0", + "System.Linq": "4.1.0", + "System.Reflection": "4.1.0", + "System.Reflection.Extensions": "4.0.1", + "System.Reflection.Primitives": "4.0.1", + "System.Resources.ResourceManager": "4.0.1", + "System.Runtime": "4.1.0", + "System.Runtime.Extensions": "4.1.0", + "System.Runtime.InteropServices": "4.1.0", + "System.Text.Encoding": "4.0.11", + "System.Text.Encoding.Extensions": "4.0.11", + "System.Threading": "4.0.11" + }, + "compile": { + "lib/netstandard1.1/System.Reflection.Metadata.dll": {} + }, + "runtime": { + "lib/netstandard1.1/System.Reflection.Metadata.dll": {} + } + }, + "System.Reflection.Primitives/4.0.1": { + "type": "package", + "dependencies": { + "Microsoft.NETCore.Platforms": "1.0.1", + "Microsoft.NETCore.Targets": "1.0.1", + "System.Runtime": "4.1.0" + }, + "compile": { + "ref/netstandard1.0/System.Reflection.Primitives.dll": {} + } + }, + "System.Reflection.TypeExtensions/4.1.0": { + "type": "package", + "dependencies": { + "System.Reflection": "4.1.0", + "System.Runtime": "4.1.0" + }, + "compile": { + "ref/netstandard1.5/System.Reflection.TypeExtensions.dll": {} + }, + "runtime": { + "lib/netstandard1.5/System.Reflection.TypeExtensions.dll": {} + } + }, + "System.Resources.Reader/4.0.0": { + "type": "package", + "dependencies": { + "System.IO": "4.1.0", + "System.Resources.ResourceManager": "4.0.1", + "System.Runtime": "4.1.0", + "System.Text.Encoding": "4.0.11", + "System.Threading": "4.0.11" + }, + "compile": { + "lib/netstandard1.0/System.Resources.Reader.dll": {} + }, + "runtime": { + "lib/netstandard1.0/System.Resources.Reader.dll": {} + } + }, + "System.Resources.ResourceManager/4.0.1": { + "type": "package", + "dependencies": { + "Microsoft.NETCore.Platforms": "1.0.1", + "Microsoft.NETCore.Targets": "1.0.1", + "System.Globalization": "4.0.11", + "System.Reflection": "4.1.0", + "System.Runtime": "4.1.0" + }, + "compile": { + "ref/netstandard1.0/System.Resources.ResourceManager.dll": {} + } + }, + "System.Runtime/4.1.0": { + "type": "package", + "dependencies": { + "Microsoft.NETCore.Platforms": "1.0.1", + "Microsoft.NETCore.Targets": "1.0.1" + }, + "compile": { + "ref/netstandard1.5/System.Runtime.dll": {} + } + }, + "System.Runtime.Extensions/4.1.0": { + "type": "package", + "dependencies": { + "Microsoft.NETCore.Platforms": "1.0.1", + "Microsoft.NETCore.Targets": "1.0.1", + "System.Runtime": "4.1.0" + }, + "compile": { + "ref/netstandard1.5/System.Runtime.Extensions.dll": {} + } + }, + "System.Runtime.Handles/4.0.1": { + "type": "package", + "dependencies": { + "Microsoft.NETCore.Platforms": "1.0.1", + "Microsoft.NETCore.Targets": "1.0.1", + "System.Runtime": "4.1.0" + }, + "compile": { + "ref/netstandard1.3/System.Runtime.Handles.dll": {} + } + }, + "System.Runtime.InteropServices/4.1.0": { + "type": "package", + "dependencies": { + "Microsoft.NETCore.Platforms": "1.0.1", + "Microsoft.NETCore.Targets": "1.0.1", + "System.Reflection": "4.1.0", + "System.Reflection.Primitives": "4.0.1", + "System.Runtime": "4.1.0", + "System.Runtime.Handles": "4.0.1" + }, + "compile": { + "ref/netstandard1.5/System.Runtime.InteropServices.dll": {} + } + }, + "System.Runtime.InteropServices.RuntimeInformation/4.0.0": { + "type": "package", + "dependencies": { + "Microsoft.NETCore.Platforms": "1.0.1", + "System.Reflection": "4.1.0", + "System.Resources.ResourceManager": "4.0.1", + "System.Runtime": "4.1.0", + "System.Runtime.InteropServices": "4.1.0", + "System.Threading": "4.0.11", + "runtime.native.System": "4.0.0" + }, + "compile": { + "ref/netstandard1.1/System.Runtime.InteropServices.RuntimeInformation.dll": {} + }, + "runtimeTargets": { + "runtimes/unix/lib/netstandard1.1/System.Runtime.InteropServices.RuntimeInformation.dll": { + "assetType": "runtime", + "rid": "unix" + }, + "runtimes/win/lib/netstandard1.1/System.Runtime.InteropServices.RuntimeInformation.dll": { + "assetType": "runtime", + "rid": "win" + } + } + }, + "System.Runtime.Loader/4.0.0": { + "type": "package", + "dependencies": { + "System.IO": "4.1.0", + "System.Reflection": "4.1.0", + "System.Runtime": "4.1.0" + }, + "compile": { + "ref/netstandard1.5/System.Runtime.Loader.dll": {} + }, + "runtime": { + "lib/netstandard1.5/System.Runtime.Loader.dll": {} + } + }, + "System.Runtime.Numerics/4.0.1": { + "type": "package", + "dependencies": { + "System.Globalization": "4.0.11", + "System.Resources.ResourceManager": "4.0.1", + "System.Runtime": "4.1.0", + "System.Runtime.Extensions": "4.1.0" + }, + "compile": { + "ref/netstandard1.1/System.Runtime.Numerics.dll": {} + }, + "runtime": { + "lib/netstandard1.3/System.Runtime.Numerics.dll": {} + } + }, + "System.Runtime.Serialization.Primitives/4.1.1": { + "type": "package", + "dependencies": { + "System.Resources.ResourceManager": "4.0.1", + "System.Runtime": "4.1.0" + }, + "compile": { + "ref/netstandard1.3/System.Runtime.Serialization.Primitives.dll": {} + }, + "runtime": { + "lib/netstandard1.3/System.Runtime.Serialization.Primitives.dll": {} + } + }, + "System.Security.Claims/4.0.1": { + "type": "package", + "dependencies": { + "System.Collections": "4.0.11", + "System.Globalization": "4.0.11", + "System.IO": "4.1.0", + "System.Resources.ResourceManager": "4.0.1", + "System.Runtime": "4.1.0", + "System.Runtime.Extensions": "4.1.0", + "System.Security.Principal": "4.0.1" + }, + "compile": { + "ref/netstandard1.3/_._": {} + }, + "runtime": { + "lib/netstandard1.3/System.Security.Claims.dll": {} + } + }, + "System.Security.Cryptography.Algorithms/4.2.0": { + "type": "package", + "dependencies": { + "Microsoft.NETCore.Platforms": "1.0.1", + "System.Collections": "4.0.11", + "System.IO": "4.1.0", + "System.Resources.ResourceManager": "4.0.1", + "System.Runtime": "4.1.0", + "System.Runtime.Extensions": "4.1.0", + "System.Runtime.Handles": "4.0.1", + "System.Runtime.InteropServices": "4.1.0", + "System.Runtime.Numerics": "4.0.1", + "System.Security.Cryptography.Encoding": "4.0.0", + "System.Security.Cryptography.Primitives": "4.0.0", + "System.Text.Encoding": "4.0.11", + "runtime.native.System.Security.Cryptography": "4.0.0" + }, + "compile": { + "ref/netstandard1.6/System.Security.Cryptography.Algorithms.dll": {} + }, + "runtimeTargets": { + "runtimes/unix/lib/netstandard1.6/System.Security.Cryptography.Algorithms.dll": { + "assetType": "runtime", + "rid": "unix" + }, + "runtimes/win/lib/netstandard1.6/System.Security.Cryptography.Algorithms.dll": { + "assetType": "runtime", + "rid": "win" + } + } + }, + "System.Security.Cryptography.Cng/4.2.0": { + "type": "package", + "dependencies": { + "Microsoft.NETCore.Platforms": "1.0.1", + "System.IO": "4.1.0", + "System.Resources.ResourceManager": "4.0.1", + "System.Runtime": "4.1.0", + "System.Runtime.Extensions": "4.1.0", + "System.Runtime.Handles": "4.0.1", + "System.Runtime.InteropServices": "4.1.0", + "System.Security.Cryptography.Algorithms": "4.2.0", + "System.Security.Cryptography.Encoding": "4.0.0", + "System.Security.Cryptography.Primitives": "4.0.0", + "System.Text.Encoding": "4.0.11" + }, + "compile": { + "ref/netstandard1.6/_._": {} + }, + "runtimeTargets": { + "runtimes/unix/lib/netstandard1.6/System.Security.Cryptography.Cng.dll": { + "assetType": "runtime", + "rid": "unix" + }, + "runtimes/win/lib/netstandard1.6/System.Security.Cryptography.Cng.dll": { + "assetType": "runtime", + "rid": "win" + } + } + }, + "System.Security.Cryptography.Csp/4.0.0": { + "type": "package", + "dependencies": { + "Microsoft.NETCore.Platforms": "1.0.1", + "System.IO": "4.1.0", + "System.Reflection": "4.1.0", + "System.Resources.ResourceManager": "4.0.1", + "System.Runtime": "4.1.0", + "System.Runtime.Extensions": "4.1.0", + "System.Runtime.Handles": "4.0.1", + "System.Runtime.InteropServices": "4.1.0", + "System.Security.Cryptography.Algorithms": "4.2.0", + "System.Security.Cryptography.Encoding": "4.0.0", + "System.Security.Cryptography.Primitives": "4.0.0", + "System.Text.Encoding": "4.0.11", + "System.Threading": "4.0.11" + }, + "compile": { + "ref/netstandard1.3/_._": {} + }, + "runtimeTargets": { + "runtimes/unix/lib/netstandard1.3/System.Security.Cryptography.Csp.dll": { + "assetType": "runtime", + "rid": "unix" + }, + "runtimes/win/lib/netstandard1.3/System.Security.Cryptography.Csp.dll": { + "assetType": "runtime", + "rid": "win" + } + } + }, + "System.Security.Cryptography.Encoding/4.0.0": { + "type": "package", + "dependencies": { + "Microsoft.NETCore.Platforms": "1.0.1", + "System.Collections": "4.0.11", + "System.Collections.Concurrent": "4.0.12", + "System.Linq": "4.1.0", + "System.Resources.ResourceManager": "4.0.1", + "System.Runtime": "4.1.0", + "System.Runtime.Extensions": "4.1.0", + "System.Runtime.Handles": "4.0.1", + "System.Runtime.InteropServices": "4.1.0", + "System.Security.Cryptography.Primitives": "4.0.0", + "System.Text.Encoding": "4.0.11", + "runtime.native.System.Security.Cryptography": "4.0.0" + }, + "compile": { + "ref/netstandard1.3/System.Security.Cryptography.Encoding.dll": {} + }, + "runtimeTargets": { + "runtimes/unix/lib/netstandard1.3/System.Security.Cryptography.Encoding.dll": { + "assetType": "runtime", + "rid": "unix" + }, + "runtimes/win/lib/netstandard1.3/System.Security.Cryptography.Encoding.dll": { + "assetType": "runtime", + "rid": "win" + } + } + }, + "System.Security.Cryptography.OpenSsl/4.0.0": { + "type": "package", + "dependencies": { + "System.Collections": "4.0.11", + "System.IO": "4.1.0", + "System.Resources.ResourceManager": "4.0.1", + "System.Runtime": "4.1.0", + "System.Runtime.Extensions": "4.1.0", + "System.Runtime.Handles": "4.0.1", + "System.Runtime.InteropServices": "4.1.0", + "System.Runtime.Numerics": "4.0.1", + "System.Security.Cryptography.Algorithms": "4.2.0", + "System.Security.Cryptography.Encoding": "4.0.0", + "System.Security.Cryptography.Primitives": "4.0.0", + "System.Text.Encoding": "4.0.11", + "runtime.native.System.Security.Cryptography": "4.0.0" + }, + "compile": { + "ref/netstandard1.6/_._": {} + }, + "runtime": { + "lib/netstandard1.6/System.Security.Cryptography.OpenSsl.dll": {} + }, + "runtimeTargets": { + "runtimes/unix/lib/netstandard1.6/System.Security.Cryptography.OpenSsl.dll": { + "assetType": "runtime", + "rid": "unix" + } + } + }, + "System.Security.Cryptography.Primitives/4.0.0": { + "type": "package", + "dependencies": { + "System.Diagnostics.Debug": "4.0.11", + "System.Globalization": "4.0.11", + "System.IO": "4.1.0", + "System.Resources.ResourceManager": "4.0.1", + "System.Runtime": "4.1.0", + "System.Threading": "4.0.11", + "System.Threading.Tasks": "4.0.11" + }, + "compile": { + "ref/netstandard1.3/System.Security.Cryptography.Primitives.dll": {} + }, + "runtime": { + "lib/netstandard1.3/System.Security.Cryptography.Primitives.dll": {} + } + }, + "System.Security.Cryptography.X509Certificates/4.1.0": { + "type": "package", + "dependencies": { + "Microsoft.NETCore.Platforms": "1.0.1", + "System.Collections": "4.0.11", + "System.Diagnostics.Debug": "4.0.11", + "System.Globalization": "4.0.11", + "System.Globalization.Calendars": "4.0.1", + "System.IO": "4.1.0", + "System.IO.FileSystem": "4.0.1", + "System.IO.FileSystem.Primitives": "4.0.1", + "System.Resources.ResourceManager": "4.0.1", + "System.Runtime": "4.1.0", + "System.Runtime.Extensions": "4.1.0", + "System.Runtime.Handles": "4.0.1", + "System.Runtime.InteropServices": "4.1.0", + "System.Runtime.Numerics": "4.0.1", + "System.Security.Cryptography.Algorithms": "4.2.0", + "System.Security.Cryptography.Cng": "4.2.0", + "System.Security.Cryptography.Csp": "4.0.0", + "System.Security.Cryptography.Encoding": "4.0.0", + "System.Security.Cryptography.OpenSsl": "4.0.0", + "System.Security.Cryptography.Primitives": "4.0.0", + "System.Text.Encoding": "4.0.11", + "System.Threading": "4.0.11", + "runtime.native.System": "4.0.0", + "runtime.native.System.Net.Http": "4.0.1", + "runtime.native.System.Security.Cryptography": "4.0.0" + }, + "compile": { + "ref/netstandard1.4/System.Security.Cryptography.X509Certificates.dll": {} + }, + "runtimeTargets": { + "runtimes/unix/lib/netstandard1.6/System.Security.Cryptography.X509Certificates.dll": { + "assetType": "runtime", + "rid": "unix" + }, + "runtimes/win/lib/netstandard1.6/System.Security.Cryptography.X509Certificates.dll": { + "assetType": "runtime", + "rid": "win" + } + } + }, + "System.Security.Principal/4.0.1": { + "type": "package", + "dependencies": { + "System.Runtime": "4.1.0" + }, + "compile": { + "ref/netstandard1.0/System.Security.Principal.dll": {} + }, + "runtime": { + "lib/netstandard1.0/System.Security.Principal.dll": {} + } + }, + "System.Security.Principal.Windows/4.0.0": { + "type": "package", + "dependencies": { + "Microsoft.NETCore.Platforms": "1.0.1", + "Microsoft.Win32.Primitives": "4.0.1", + "System.Collections": "4.0.11", + "System.Diagnostics.Debug": "4.0.11", + "System.Reflection": "4.1.0", + "System.Resources.ResourceManager": "4.0.1", + "System.Runtime": "4.1.0", + "System.Runtime.Extensions": "4.1.0", + "System.Runtime.Handles": "4.0.1", + "System.Runtime.InteropServices": "4.1.0", + "System.Security.Claims": "4.0.1", + "System.Security.Principal": "4.0.1", + "System.Text.Encoding": "4.0.11", + "System.Threading": "4.0.11" + }, + "compile": { + "ref/netstandard1.3/_._": {} + }, + "runtimeTargets": { + "runtimes/unix/lib/netstandard1.3/System.Security.Principal.Windows.dll": { + "assetType": "runtime", + "rid": "unix" + }, + "runtimes/win/lib/netstandard1.3/System.Security.Principal.Windows.dll": { + "assetType": "runtime", + "rid": "win" + } + } + }, + "System.Text.Encoding/4.0.11": { + "type": "package", + "dependencies": { + "Microsoft.NETCore.Platforms": "1.0.1", + "Microsoft.NETCore.Targets": "1.0.1", + "System.Runtime": "4.1.0" + }, + "compile": { + "ref/netstandard1.3/System.Text.Encoding.dll": {} + } + }, + "System.Text.Encoding.CodePages/4.0.1": { + "type": "package", + "dependencies": { + "Microsoft.NETCore.Platforms": "1.0.1", + "System.Collections": "4.0.11", + "System.Globalization": "4.0.11", + "System.IO": "4.1.0", + "System.Reflection": "4.1.0", + "System.Resources.ResourceManager": "4.0.1", + "System.Runtime": "4.1.0", + "System.Runtime.Extensions": "4.1.0", + "System.Runtime.Handles": "4.0.1", + "System.Runtime.InteropServices": "4.1.0", + "System.Text.Encoding": "4.0.11", + "System.Threading": "4.0.11" + }, + "compile": { + "ref/netstandard1.3/_._": {} + }, + "runtimeTargets": { + "runtimes/unix/lib/netstandard1.3/System.Text.Encoding.CodePages.dll": { + "assetType": "runtime", + "rid": "unix" + }, + "runtimes/win/lib/netstandard1.3/System.Text.Encoding.CodePages.dll": { + "assetType": "runtime", + "rid": "win" + } + } + }, + "System.Text.Encoding.Extensions/4.0.11": { + "type": "package", + "dependencies": { + "Microsoft.NETCore.Platforms": "1.0.1", + "Microsoft.NETCore.Targets": "1.0.1", + "System.Runtime": "4.1.0", + "System.Text.Encoding": "4.0.11" + }, + "compile": { + "ref/netstandard1.3/System.Text.Encoding.Extensions.dll": {} + } + }, + "System.Text.RegularExpressions/4.1.0": { + "type": "package", + "dependencies": { + "System.Collections": "4.0.11", + "System.Globalization": "4.0.11", + "System.Resources.ResourceManager": "4.0.1", + "System.Runtime": "4.1.0", + "System.Runtime.Extensions": "4.1.0", + "System.Threading": "4.0.11" + }, + "compile": { + "ref/netstandard1.6/System.Text.RegularExpressions.dll": {} + }, + "runtime": { + "lib/netstandard1.6/System.Text.RegularExpressions.dll": {} + } + }, + "System.Threading/4.0.11": { + "type": "package", + "dependencies": { + "System.Runtime": "4.1.0", + "System.Threading.Tasks": "4.0.11" + }, + "compile": { + "ref/netstandard1.3/System.Threading.dll": {} + }, + "runtime": { + "lib/netstandard1.3/System.Threading.dll": {} + } + }, + "System.Threading.Overlapped/4.0.1": { + "type": "package", + "dependencies": { + "Microsoft.NETCore.Platforms": "1.0.1", + "System.Resources.ResourceManager": "4.0.1", + "System.Runtime": "4.1.0", + "System.Runtime.Handles": "4.0.1" + }, + "compile": { + "ref/netstandard1.3/_._": {} + }, + "runtimeTargets": { + "runtimes/unix/lib/netstandard1.3/System.Threading.Overlapped.dll": { + "assetType": "runtime", + "rid": "unix" + }, + "runtimes/win/lib/netstandard1.3/System.Threading.Overlapped.dll": { + "assetType": "runtime", + "rid": "win" + } + } + }, + "System.Threading.Tasks/4.0.11": { + "type": "package", + "dependencies": { + "Microsoft.NETCore.Platforms": "1.0.1", + "Microsoft.NETCore.Targets": "1.0.1", + "System.Runtime": "4.1.0" + }, + "compile": { + "ref/netstandard1.3/System.Threading.Tasks.dll": {} + } + }, + "System.Threading.Tasks.Dataflow/4.6.0": { + "type": "package", + "dependencies": { + "System.Collections": "4.0.11", + "System.Collections.Concurrent": "4.0.12", + "System.Diagnostics.Debug": "4.0.11", + "System.Diagnostics.Tracing": "4.1.0", + "System.Dynamic.Runtime": "4.0.11", + "System.Linq": "4.1.0", + "System.Resources.ResourceManager": "4.0.1", + "System.Runtime": "4.1.0", + "System.Runtime.Extensions": "4.1.0", + "System.Threading": "4.0.11", + "System.Threading.Tasks": "4.0.11" + }, + "compile": { + "lib/netstandard1.1/System.Threading.Tasks.Dataflow.dll": {} + }, + "runtime": { + "lib/netstandard1.1/System.Threading.Tasks.Dataflow.dll": {} + } + }, + "System.Threading.Tasks.Extensions/4.0.0": { + "type": "package", + "dependencies": { + "System.Collections": "4.0.11", + "System.Runtime": "4.1.0", + "System.Threading.Tasks": "4.0.11" + }, + "compile": { + "lib/netstandard1.0/System.Threading.Tasks.Extensions.dll": {} + }, + "runtime": { + "lib/netstandard1.0/System.Threading.Tasks.Extensions.dll": {} + } + }, + "System.Threading.Tasks.Parallel/4.0.1": { + "type": "package", + "dependencies": { + "System.Collections.Concurrent": "4.0.12", + "System.Diagnostics.Debug": "4.0.11", + "System.Diagnostics.Tracing": "4.1.0", + "System.Resources.ResourceManager": "4.0.1", + "System.Runtime": "4.1.0", + "System.Runtime.Extensions": "4.1.0", + "System.Threading": "4.0.11", + "System.Threading.Tasks": "4.0.11" + }, + "compile": { + "ref/netstandard1.1/System.Threading.Tasks.Parallel.dll": {} + }, + "runtime": { + "lib/netstandard1.3/System.Threading.Tasks.Parallel.dll": {} + } + }, + "System.Threading.Thread/4.0.0": { + "type": "package", + "dependencies": { + "System.Runtime": "4.1.0" + }, + "compile": { + "ref/netstandard1.3/System.Threading.Thread.dll": {} + }, + "runtime": { + "lib/netstandard1.3/System.Threading.Thread.dll": {} + } + }, + "System.Threading.ThreadPool/4.0.10": { + "type": "package", + "dependencies": { + "System.Runtime": "4.1.0", + "System.Runtime.Handles": "4.0.1" + }, + "compile": { + "ref/netstandard1.3/System.Threading.ThreadPool.dll": {} + }, + "runtime": { + "lib/netstandard1.3/System.Threading.ThreadPool.dll": {} + } + }, + "System.Threading.Timer/4.0.1": { + "type": "package", + "dependencies": { + "Microsoft.NETCore.Platforms": "1.0.1", + "Microsoft.NETCore.Targets": "1.0.1", + "System.Runtime": "4.1.0" + }, + "compile": { + "ref/netstandard1.2/System.Threading.Timer.dll": {} + } + }, + "System.Xml.ReaderWriter/4.0.11": { + "type": "package", + "dependencies": { + "System.Collections": "4.0.11", + "System.Diagnostics.Debug": "4.0.11", + "System.Globalization": "4.0.11", + "System.IO": "4.1.0", + "System.IO.FileSystem": "4.0.1", + "System.IO.FileSystem.Primitives": "4.0.1", + "System.Resources.ResourceManager": "4.0.1", + "System.Runtime": "4.1.0", + "System.Runtime.Extensions": "4.1.0", + "System.Runtime.InteropServices": "4.1.0", + "System.Text.Encoding": "4.0.11", + "System.Text.Encoding.Extensions": "4.0.11", + "System.Text.RegularExpressions": "4.1.0", + "System.Threading.Tasks": "4.0.11", + "System.Threading.Tasks.Extensions": "4.0.0" + }, + "compile": { + "ref/netstandard1.3/System.Xml.ReaderWriter.dll": {} + }, + "runtime": { + "lib/netstandard1.3/System.Xml.ReaderWriter.dll": {} + } + }, + "System.Xml.XDocument/4.0.11": { + "type": "package", + "dependencies": { + "System.Collections": "4.0.11", + "System.Diagnostics.Debug": "4.0.11", + "System.Diagnostics.Tools": "4.0.1", + "System.Globalization": "4.0.11", + "System.IO": "4.1.0", + "System.Reflection": "4.1.0", + "System.Resources.ResourceManager": "4.0.1", + "System.Runtime": "4.1.0", + "System.Runtime.Extensions": "4.1.0", + "System.Text.Encoding": "4.0.11", + "System.Threading": "4.0.11", + "System.Xml.ReaderWriter": "4.0.11" + }, + "compile": { + "ref/netstandard1.3/System.Xml.XDocument.dll": {} + }, + "runtime": { + "lib/netstandard1.3/System.Xml.XDocument.dll": {} + } + }, + "System.Xml.XmlDocument/4.0.1": { + "type": "package", + "dependencies": { + "System.Collections": "4.0.11", + "System.Diagnostics.Debug": "4.0.11", + "System.Globalization": "4.0.11", + "System.IO": "4.1.0", + "System.Resources.ResourceManager": "4.0.1", + "System.Runtime": "4.1.0", + "System.Runtime.Extensions": "4.1.0", + "System.Text.Encoding": "4.0.11", + "System.Threading": "4.0.11", + "System.Xml.ReaderWriter": "4.0.11" + }, + "compile": { + "ref/netstandard1.3/_._": {} + }, + "runtime": { + "lib/netstandard1.3/System.Xml.XmlDocument.dll": {} + } + }, + "System.Xml.XPath/4.0.1": { + "type": "package", + "dependencies": { + "System.Collections": "4.0.11", + "System.Diagnostics.Debug": "4.0.11", + "System.Globalization": "4.0.11", + "System.IO": "4.1.0", + "System.Resources.ResourceManager": "4.0.1", + "System.Runtime": "4.1.0", + "System.Runtime.Extensions": "4.1.0", + "System.Threading": "4.0.11", + "System.Xml.ReaderWriter": "4.0.11" + }, + "compile": { + "ref/netstandard1.3/_._": {} + }, + "runtime": { + "lib/netstandard1.3/System.Xml.XPath.dll": {} + } + }, + "System.Xml.XPath.XDocument/4.0.1": { + "type": "package", + "dependencies": { + "System.Diagnostics.Debug": "4.0.11", + "System.Linq": "4.1.0", + "System.Resources.ResourceManager": "4.0.1", + "System.Runtime": "4.1.0", + "System.Runtime.Extensions": "4.1.0", + "System.Threading": "4.0.11", + "System.Xml.ReaderWriter": "4.0.11", + "System.Xml.XDocument": "4.0.11", + "System.Xml.XPath": "4.0.1" + }, + "compile": { + "ref/netstandard1.3/_._": {} + }, + "runtime": { + "lib/netstandard1.3/System.Xml.XPath.XDocument.dll": {} + } + }, + "xunit/2.2.0-beta2-build3300": { + "type": "package", + "dependencies": { + "xunit.assert": "[2.2.0-beta2-build3300]", + "xunit.core": "[2.2.0-beta2-build3300]" + } + }, + "xunit.abstractions/2.0.1-rc2": { + "type": "package", + "dependencies": { + "System.Collections": "4.0.11-rc2-24027", + "System.Diagnostics.Tools": "4.0.1-rc2-24027", + "System.Reflection": "4.1.0-rc2-24027", + "System.Runtime": "4.1.0-rc2-24027" + }, + "compile": { + "lib/netstandard1.0/xunit.abstractions.dll": {} + }, + "runtime": { + "lib/netstandard1.0/xunit.abstractions.dll": {} + } + }, + "xunit.assert/2.2.0-beta2-build3300": { + "type": "package", + "dependencies": { + "NETStandard.Library": "1.6.0" + }, + "compile": { + "lib/netstandard1.0/xunit.assert.dll": {} + }, + "runtime": { + "lib/netstandard1.0/xunit.assert.dll": {} + } + }, + "xunit.core/2.2.0-beta2-build3300": { + "type": "package", + "dependencies": { + "xunit.extensibility.core": "[2.2.0-beta2-build3300]", + "xunit.extensibility.execution": "[2.2.0-beta2-build3300]" + } + }, + "xunit.extensibility.core/2.2.0-beta2-build3300": { + "type": "package", + "dependencies": { + "NETStandard.Library": "1.6.0", + "xunit.abstractions": "2.0.1-rc2" + }, + "compile": { + "lib/netstandard1.0/xunit.core.dll": {} + }, + "runtime": { + "lib/netstandard1.0/xunit.core.dll": {} + } + }, + "xunit.extensibility.execution/2.2.0-beta2-build3300": { + "type": "package", + "dependencies": { + "NETStandard.Library": "1.6.0", + "xunit.extensibility.core": "[2.2.0-beta2-build3300]" + }, + "compile": { + "lib/netstandard1.0/xunit.execution.dotnet.dll": {} + }, + "runtime": { + "lib/netstandard1.0/xunit.execution.dotnet.dll": {} + } + }, + "xunit.runner.reporters/2.2.0-beta2-build3300": { + "type": "package", + "dependencies": { + "NETStandard.Library": "1.6.0", + "Newtonsoft.Json": "9.0.1", + "xunit.runner.utility": "[2.2.0-beta2-build3300]" + }, + "compile": { + "lib/netstandard1.1/xunit.runner.reporters.dotnet.dll": {} + }, + "runtime": { + "lib/netstandard1.1/xunit.runner.reporters.dotnet.dll": {} + } + }, + "xunit.runner.utility/2.2.0-beta2-build3300": { + "type": "package", + "dependencies": { + "NETStandard.Library": "1.6.0", + "xunit.abstractions": "2.0.1-rc2" + }, + "compile": { + "lib/netstandard1.1/xunit.runner.utility.dotnet.dll": {} + }, + "runtime": { + "lib/netstandard1.1/xunit.runner.utility.dotnet.dll": {} + } + }, + "QLNet/1.8.0": { + "type": "project", + "framework": ".NETStandard,Version=v1.1", + "dependencies": { + "NETStandard.Library": "1.6.0" + }, + "compile": { + "netstandard1.1/QLNet.dll": {} + }, + "runtime": { + "netstandard1.1/QLNet.dll": {} + } + } + } + }, + "libraries": { + "dotnet-test-xunit/2.2.0-preview2-build1029": { + "sha512": "mPl4HHGcXsE4ljw3sHCOUvlyhXHDpfFO6qz0HbTQrhrFT8Tgm/HFLfz6TpMXUfch7rRL23kR8i0yjQPYdsl6EQ==", + "type": "package", + "path": "dotnet-test-xunit/2.2.0-preview2-build1029", + "files": [ + "dotnet-test-xunit.2.2.0-preview2-build1029.nupkg.sha512", + "dotnet-test-xunit.nuspec", + "lib/net451/dotnet-test-xunit.exe", + "lib/netcoreapp1.0/dotnet-test-xunit.dll", + "lib/netcoreapp1.0/dotnet-test-xunit.runtimeconfig.json", + "runtimes/unix-x64/lib/net451/dotnet-test-xunit.exe", + "runtimes/win7-x64/lib/net451/dotnet-test-xunit.exe", + "runtimes/win7-x86/lib/net451/dotnet-test-xunit.exe" + ] + }, + "Libuv/1.9.0": { + "sha512": "iaEPGhPLwNTRiLP5hwXbfx6HJonoFE08DM4AdtbftbnFCqGnY9m7lKIfBQlo8e8HRNHPBFuzVIzsX3VPgkC12g==", + "type": "package", + "path": "Libuv/1.9.0", + "files": [ + "Libuv.1.9.0.nupkg.sha512", + "Libuv.nuspec", + "License.txt", + "runtimes/debian-x64/native/libuv.so", + "runtimes/fedora-x64/native/libuv.so", + "runtimes/opensuse-x64/native/libuv.so", + "runtimes/osx/native/libuv.dylib", + "runtimes/rhel-x64/native/libuv.so", + "runtimes/win7-arm/native/libuv.dll", + "runtimes/win7-x64/native/libuv.dll", + "runtimes/win7-x86/native/libuv.dll" + ] + }, + "Microsoft.CodeAnalysis.Analyzers/1.1.0": { + "sha512": "HS3iRWZKcUw/8eZ/08GXKY2Bn7xNzQPzf8gRPHGSowX7u7XXu9i9YEaBeBNKUXWfI7qjvT2zXtLUvbN0hds8vg==", + "type": "package", + "path": "Microsoft.CodeAnalysis.Analyzers/1.1.0", + "files": [ + "Microsoft.CodeAnalysis.Analyzers.1.1.0.nupkg.sha512", + "Microsoft.CodeAnalysis.Analyzers.nuspec", + "ThirdPartyNotices.rtf", + "analyzers/dotnet/cs/Microsoft.CodeAnalysis.Analyzers.dll", + "analyzers/dotnet/cs/Microsoft.CodeAnalysis.CSharp.Analyzers.dll", + "analyzers/dotnet/vb/Microsoft.CodeAnalysis.Analyzers.dll", + "analyzers/dotnet/vb/Microsoft.CodeAnalysis.VisualBasic.Analyzers.dll", + "tools/install.ps1", + "tools/uninstall.ps1" + ] + }, + "Microsoft.CodeAnalysis.Common/1.3.0": { + "sha512": "dd3k6dDKWeWXFN5GnimfUylSgo1mTMgtNeYcIOqsmdktF2XQFvQ18dgrhbrkn0gN7Tgeu3b5GFizAhI/VA2Wtw==", + "type": "package", + "path": "Microsoft.CodeAnalysis.Common/1.3.0", + "files": [ + "Microsoft.CodeAnalysis.Common.1.3.0.nupkg.sha512", + "Microsoft.CodeAnalysis.Common.nuspec", + "ThirdPartyNotices.rtf", + "lib/net45/Microsoft.CodeAnalysis.dll", + "lib/net45/Microsoft.CodeAnalysis.xml", + "lib/netstandard1.3/Microsoft.CodeAnalysis.dll", + "lib/netstandard1.3/Microsoft.CodeAnalysis.xml", + "lib/portable-net45+win8/Microsoft.CodeAnalysis.dll", + "lib/portable-net45+win8/Microsoft.CodeAnalysis.xml" + ] + }, + "Microsoft.CodeAnalysis.CSharp/1.3.0": { + "sha512": "L3qy5RtyjUE4xk7fylnM3VDHHhYCPSiHdy1i9atu2ZpXonFDT+BBx4G6K3quBuBUox7t2bEzXOVB4GheScg/8Q==", + "type": "package", + "path": "Microsoft.CodeAnalysis.CSharp/1.3.0", + "files": [ + "Microsoft.CodeAnalysis.CSharp.1.3.0.nupkg.sha512", + "Microsoft.CodeAnalysis.CSharp.nuspec", + "ThirdPartyNotices.rtf", + "lib/net45/Microsoft.CodeAnalysis.CSharp.dll", + "lib/net45/Microsoft.CodeAnalysis.CSharp.xml", + "lib/netstandard1.3/Microsoft.CodeAnalysis.CSharp.dll", + "lib/netstandard1.3/Microsoft.CodeAnalysis.CSharp.xml", + "lib/portable-net45+win8/Microsoft.CodeAnalysis.CSharp.dll", + "lib/portable-net45+win8/Microsoft.CodeAnalysis.CSharp.xml" + ] + }, + "Microsoft.CodeAnalysis.VisualBasic/1.3.0": { + "sha512": "kzaNLAsYTiUrN01nCkh/Vc0REpb69ugmL/10vf4xMtoFjdRGTQd7kOW/jLKF7Q6JRd9G+7tO8+A3Df/pP5PYlg==", + "type": "package", + "path": "Microsoft.CodeAnalysis.VisualBasic/1.3.0", + "files": [ + "Microsoft.CodeAnalysis.VisualBasic.1.3.0.nupkg.sha512", + "Microsoft.CodeAnalysis.VisualBasic.nuspec", + "ThirdPartyNotices.rtf", + "lib/net45/Microsoft.CodeAnalysis.VisualBasic.dll", + "lib/net45/Microsoft.CodeAnalysis.VisualBasic.xml", + "lib/netstandard1.3/Microsoft.CodeAnalysis.VisualBasic.dll", + "lib/netstandard1.3/Microsoft.CodeAnalysis.VisualBasic.xml", + "lib/portable-net45+win8/Microsoft.CodeAnalysis.VisualBasic.dll", + "lib/portable-net45+win8/Microsoft.CodeAnalysis.VisualBasic.xml" + ] + }, + "Microsoft.CSharp/4.0.1": { + "sha512": "17h8b5mXa87XYKrrVqdgZ38JefSUqLChUQpXgSnpzsM0nDOhE40FTeNWOJ/YmySGV6tG6T8+hjz6vxbknHJr6A==", + "type": "package", + "path": "Microsoft.CSharp/4.0.1", + "files": [ + "Microsoft.CSharp.4.0.1.nupkg.sha512", + "Microsoft.CSharp.nuspec", + "ThirdPartyNotices.txt", + "dotnet_library_license.txt", + "lib/MonoAndroid10/_._", + "lib/MonoTouch10/_._", + "lib/net45/_._", + "lib/netcore50/Microsoft.CSharp.dll", + "lib/netstandard1.3/Microsoft.CSharp.dll", + "lib/portable-net45+win8+wp8+wpa81/_._", + "lib/win8/_._", + "lib/wp80/_._", + "lib/wpa81/_._", + "lib/xamarinios10/_._", + "lib/xamarinmac20/_._", + "lib/xamarintvos10/_._", + "lib/xamarinwatchos10/_._", + "ref/MonoAndroid10/_._", + "ref/MonoTouch10/_._", + "ref/net45/_._", + "ref/netcore50/Microsoft.CSharp.dll", + "ref/netcore50/Microsoft.CSharp.xml", + "ref/netcore50/de/Microsoft.CSharp.xml", + "ref/netcore50/es/Microsoft.CSharp.xml", + "ref/netcore50/fr/Microsoft.CSharp.xml", + "ref/netcore50/it/Microsoft.CSharp.xml", + "ref/netcore50/ja/Microsoft.CSharp.xml", + "ref/netcore50/ko/Microsoft.CSharp.xml", + "ref/netcore50/ru/Microsoft.CSharp.xml", + "ref/netcore50/zh-hans/Microsoft.CSharp.xml", + "ref/netcore50/zh-hant/Microsoft.CSharp.xml", + "ref/netstandard1.0/Microsoft.CSharp.dll", + "ref/netstandard1.0/Microsoft.CSharp.xml", + "ref/netstandard1.0/de/Microsoft.CSharp.xml", + "ref/netstandard1.0/es/Microsoft.CSharp.xml", + "ref/netstandard1.0/fr/Microsoft.CSharp.xml", + "ref/netstandard1.0/it/Microsoft.CSharp.xml", + "ref/netstandard1.0/ja/Microsoft.CSharp.xml", + "ref/netstandard1.0/ko/Microsoft.CSharp.xml", + "ref/netstandard1.0/ru/Microsoft.CSharp.xml", + "ref/netstandard1.0/zh-hans/Microsoft.CSharp.xml", + "ref/netstandard1.0/zh-hant/Microsoft.CSharp.xml", + "ref/portable-net45+win8+wp8+wpa81/_._", + "ref/win8/_._", + "ref/wp80/_._", + "ref/wpa81/_._", + "ref/xamarinios10/_._", + "ref/xamarinmac20/_._", + "ref/xamarintvos10/_._", + "ref/xamarinwatchos10/_._" + ] + }, + "Microsoft.DiaSymReader/1.0.8": { + "sha512": "ABLULVhCAiyBFLBT5xX6vB4NhZDgwUylGRQK+zW5nZn2rbh1f8LOnFZ9gVSxzL6qOzPNb32Nu3QZ43iZerHOxA==", + "type": "package", + "path": "Microsoft.DiaSymReader/1.0.8", + "files": [ + "Microsoft.DiaSymReader.1.0.8.nupkg.sha512", + "Microsoft.DiaSymReader.nuspec", + "lib/net20/Microsoft.DiaSymReader.dll", + "lib/net20/Microsoft.DiaSymReader.xml", + "lib/netstandard1.1/Microsoft.DiaSymReader.dll", + "lib/netstandard1.1/Microsoft.DiaSymReader.xml", + "lib/portable-net45+win8/Microsoft.DiaSymReader.dll", + "lib/portable-net45+win8/Microsoft.DiaSymReader.xml" + ] + }, + "Microsoft.DiaSymReader.Native/1.4.0-rc2": { + "sha512": "KIQOG+U6btTHL5KkXYofMpyCzVx+6EcDPS9GBRGGhlrTjJqcqAM6a6a0D0Dur/HPnAdmGLtSHVjCDZijGJFCAA==", + "type": "package", + "path": "Microsoft.DiaSymReader.Native/1.4.0-rc2", + "files": [ + "Microsoft.DiaSymReader.Native.1.4.0-rc2.nupkg.sha512", + "Microsoft.DiaSymReader.Native.nuspec", + "build/Microsoft.DiaSymReader.Native.props", + "runtimes/win-x64/native/Microsoft.DiaSymReader.Native.amd64.dll", + "runtimes/win-x86/native/Microsoft.DiaSymReader.Native.x86.dll", + "runtimes/win/native/Microsoft.DiaSymReader.Native.amd64.dll", + "runtimes/win/native/Microsoft.DiaSymReader.Native.arm.dll", + "runtimes/win/native/Microsoft.DiaSymReader.Native.x86.dll", + "runtimes/win8-arm/native/Microsoft.DiaSymReader.Native.arm.dll" + ] + }, + "Microsoft.DotNet.InternalAbstractions/1.0.0": { + "sha512": "AAguUq7YyKk3yDWPoWA8DrLZvURxB/LrDdTn1h5lmPeznkFUpfC3p459w5mQYQE0qpquf/CkSQZ0etiV5vRHFA==", + "type": "package", + "path": "Microsoft.DotNet.InternalAbstractions/1.0.0", + "files": [ + "Microsoft.DotNet.InternalAbstractions.1.0.0.nupkg.sha512", + "Microsoft.DotNet.InternalAbstractions.nuspec", + "lib/net451/Microsoft.DotNet.InternalAbstractions.dll", + "lib/netstandard1.3/Microsoft.DotNet.InternalAbstractions.dll" + ] + }, + "Microsoft.DotNet.ProjectModel/1.0.0-rc3-003121": { + "sha512": "wnWw5KsKinG2wWxdoQIJXZlMFvPNhL7WmIyW9q6xrZFUi/uld5PC3ksq2QDZepF148FUjCIyTP+TnRwU3RJqUg==", + "type": "package", + "path": "Microsoft.DotNet.ProjectModel/1.0.0-rc3-003121", + "files": [ + "Microsoft.DotNet.ProjectModel.1.0.0-rc3-003121.nupkg.sha512", + "Microsoft.DotNet.ProjectModel.nuspec", + "lib/net451/Microsoft.DotNet.ProjectModel.dll", + "lib/netstandard1.6/Microsoft.DotNet.ProjectModel.dll" + ] + }, + "Microsoft.Extensions.DependencyModel/1.0.0": { + "sha512": "n55Y2T4qMgCNMrJaqAN+nlG2EH4XL+e9uxIg4vdFsQeF+L8UKxRdD3C35Bt+xk3vO3Zwp3g+6KFq2VPH2COSmg==", + "type": "package", + "path": "Microsoft.Extensions.DependencyModel/1.0.0", + "files": [ + "Microsoft.Extensions.DependencyModel.1.0.0.nupkg.sha512", + "Microsoft.Extensions.DependencyModel.nuspec", + "lib/net451/Microsoft.Extensions.DependencyModel.dll", + "lib/netstandard1.6/Microsoft.Extensions.DependencyModel.dll" + ] + }, + "Microsoft.Extensions.Testing.Abstractions/1.0.0-preview2-003121": { + "sha512": "q3Uq07d6LbYr0NiX5Dz9GCbXJv4vkmSbUvFEmov3Vo4prZWjhFzF+byk2tWAEEqtZ6ereMYXBUt99wCTtANk6Q==", + "type": "package", + "path": "Microsoft.Extensions.Testing.Abstractions/1.0.0-preview2-003121", + "files": [ + "Microsoft.Extensions.Testing.Abstractions.1.0.0-preview2-003121.nupkg.sha512", + "Microsoft.Extensions.Testing.Abstractions.nuspec", + "lib/net451/Microsoft.Extensions.Testing.Abstractions.dll", + "lib/netstandard1.6/Microsoft.Extensions.Testing.Abstractions.dll" + ] + }, + "Microsoft.NETCore.App/1.0.0": { + "sha512": "7OqhRJnBbuiiNyPtlejl8HoHbrGweXZqrdb0obrSAWZie9pFKTmaKoNcU1tVFGDGkp+53E0cMIlJp2aUC8S9Mw==", + "type": "package", + "path": "Microsoft.NETCore.App/1.0.0", + "files": [ + "Microsoft.NETCore.App.1.0.0.nupkg.sha512", + "Microsoft.NETCore.App.nuspec", + "ThirdPartyNotices.txt", + "dotnet_library_license.txt", + "lib/netcoreapp1.0/_._" + ] + }, + "Microsoft.NETCore.DotNetHost/1.0.1": { + "sha512": "Uy9jMG2qYAoKVbHSVP65eh49vysKaVH36Pnd+ktUwRszl+IA1QRvKQNq4vU11IpVYERSyml5TU+G8WNSPAzjlQ==", + "type": "package", + "path": "Microsoft.NETCore.DotNetHost/1.0.1", + "files": [ + "Microsoft.NETCore.DotNetHost.1.0.1.nupkg.sha512", + "Microsoft.NETCore.DotNetHost.nuspec", + "ThirdPartyNotices.txt", + "dotnet_library_license.txt", + "runtime.json" + ] + }, + "Microsoft.NETCore.DotNetHostPolicy/1.0.1": { + "sha512": "4+tCHe6o53mhYkISEEVKLcFVeQaHT1fRPjaYD+7NRyD+lCuG18UW880LiLA33mOVPKr+7J8WDXXPLTBMk3LWzA==", + "type": "package", + "path": "Microsoft.NETCore.DotNetHostPolicy/1.0.1", + "files": [ + "Microsoft.NETCore.DotNetHostPolicy.1.0.1.nupkg.sha512", + "Microsoft.NETCore.DotNetHostPolicy.nuspec", + "ThirdPartyNotices.txt", + "dotnet_library_license.txt", + "runtime.json" + ] + }, + "Microsoft.NETCore.DotNetHostResolver/1.0.1": { + "sha512": "7lslwV1XAHe0eL3oJMTLqznr84rjdFqFrnxkP7QSmkRdQ9ts18/6GwyvSW8Mqjc1aR8dwZo2bONOAxmyqJtxcw==", + "type": "package", + "path": "Microsoft.NETCore.DotNetHostResolver/1.0.1", + "files": [ + "Microsoft.NETCore.DotNetHostResolver.1.0.1.nupkg.sha512", + "Microsoft.NETCore.DotNetHostResolver.nuspec", + "ThirdPartyNotices.txt", + "dotnet_library_license.txt", + "runtime.json" + ] + }, + "Microsoft.NETCore.Jit/1.0.2": { + "sha512": "Ok2vWofa6X8WD9vc4pfLHwvJz1/B6t3gOAoZcjrjrQf7lQOlNIuZIZtLn3wnWX28DuQGpPJkRlBxFj7Z5txNqw==", + "type": "package", + "path": "Microsoft.NETCore.Jit/1.0.2", + "files": [ + "Microsoft.NETCore.Jit.1.0.2.nupkg.sha512", + "Microsoft.NETCore.Jit.nuspec", + "ThirdPartyNotices.txt", + "dotnet_library_license.txt", + "runtime.json" + ] + }, + "Microsoft.NETCore.Platforms/1.0.1": { + "sha512": "2G6OjjJzwBfNOO8myRV/nFrbTw5iA+DEm0N+qUqhrOmaVtn4pC77h38I1jsXGw5VH55+dPfQsqHD0We9sCl9FQ==", + "type": "package", + "path": "Microsoft.NETCore.Platforms/1.0.1", + "files": [ + "Microsoft.NETCore.Platforms.1.0.1.nupkg.sha512", + "Microsoft.NETCore.Platforms.nuspec", + "ThirdPartyNotices.txt", + "dotnet_library_license.txt", + "lib/netstandard1.0/_._", + "runtime.json" + ] + }, + "Microsoft.NETCore.Runtime.CoreCLR/1.0.2": { + "sha512": "A0x1xtTjYJWZr2DRzgfCOXgB0JkQg8twnmtTJ79wFje+IihlLbXtx6Z2AxyVokBM5ruwTedR6YdCmHk39QJdtQ==", + "type": "package", + "path": "Microsoft.NETCore.Runtime.CoreCLR/1.0.2", + "files": [ + "Microsoft.NETCore.Runtime.CoreCLR.1.0.2.nupkg.sha512", + "Microsoft.NETCore.Runtime.CoreCLR.nuspec", + "ThirdPartyNotices.txt", + "dotnet_library_license.txt", + "runtime.json" + ] + }, + "Microsoft.NETCore.Targets/1.0.1": { + "sha512": "rkn+fKobF/cbWfnnfBOQHKVKIOpxMZBvlSHkqDWgBpwGDcLRduvs3D9OLGeV6GWGvVwNlVi2CBbTjuPmtHvyNw==", + "type": "package", + "path": "Microsoft.NETCore.Targets/1.0.1", + "files": [ + "Microsoft.NETCore.Targets.1.0.1.nupkg.sha512", + "Microsoft.NETCore.Targets.nuspec", + "ThirdPartyNotices.txt", + "dotnet_library_license.txt", + "lib/netstandard1.0/_._", + "runtime.json" + ] + }, + "Microsoft.NETCore.Windows.ApiSets/1.0.1": { + "sha512": "SaToCvvsGMxTgtLv/BrFQ5IFMPRE1zpWbnqbpwykJa8W5XiX82CXI6K2o7yf5xS7EP6t/JzFLV0SIDuWpvBZVw==", + "type": "package", + "path": "Microsoft.NETCore.Windows.ApiSets/1.0.1", + "files": [ + "Microsoft.NETCore.Windows.ApiSets.1.0.1.nupkg.sha512", + "Microsoft.NETCore.Windows.ApiSets.nuspec", + "ThirdPartyNotices.txt", + "dotnet_library_license.txt", + "runtime.json" + ] + }, + "Microsoft.VisualBasic/10.0.1": { + "sha512": "HpNyOf/4Tp2lh4FyywB55VITk0SqVxEjDzsVDDyF1yafDN6Bq18xcHowzCPINyYHUTgGcEtmpYiRsFdSo0KKdQ==", + "type": "package", + "path": "Microsoft.VisualBasic/10.0.1", + "files": [ + "Microsoft.VisualBasic.10.0.1.nupkg.sha512", + "Microsoft.VisualBasic.nuspec", + "ThirdPartyNotices.txt", + "dotnet_library_license.txt", + "lib/net45/_._", + "lib/netcore50/Microsoft.VisualBasic.dll", + "lib/netstandard1.3/Microsoft.VisualBasic.dll", + "lib/portable-net45+win8+wpa81/_._", + "lib/win8/_._", + "lib/wpa81/_._", + "ref/net45/_._", + "ref/netcore50/Microsoft.VisualBasic.dll", + "ref/netcore50/Microsoft.VisualBasic.xml", + "ref/netcore50/de/Microsoft.VisualBasic.xml", + "ref/netcore50/es/Microsoft.VisualBasic.xml", + "ref/netcore50/fr/Microsoft.VisualBasic.xml", + "ref/netcore50/it/Microsoft.VisualBasic.xml", + "ref/netcore50/ja/Microsoft.VisualBasic.xml", + "ref/netcore50/ko/Microsoft.VisualBasic.xml", + "ref/netcore50/ru/Microsoft.VisualBasic.xml", + "ref/netcore50/zh-hans/Microsoft.VisualBasic.xml", + "ref/netcore50/zh-hant/Microsoft.VisualBasic.xml", + "ref/netstandard1.1/Microsoft.VisualBasic.dll", + "ref/netstandard1.1/Microsoft.VisualBasic.xml", + "ref/netstandard1.1/de/Microsoft.VisualBasic.xml", + "ref/netstandard1.1/es/Microsoft.VisualBasic.xml", + "ref/netstandard1.1/fr/Microsoft.VisualBasic.xml", + "ref/netstandard1.1/it/Microsoft.VisualBasic.xml", + "ref/netstandard1.1/ja/Microsoft.VisualBasic.xml", + "ref/netstandard1.1/ko/Microsoft.VisualBasic.xml", + "ref/netstandard1.1/ru/Microsoft.VisualBasic.xml", + "ref/netstandard1.1/zh-hans/Microsoft.VisualBasic.xml", + "ref/netstandard1.1/zh-hant/Microsoft.VisualBasic.xml", + "ref/portable-net45+win8+wpa81/_._", + "ref/win8/_._", + "ref/wpa81/_._" + ] + }, + "Microsoft.Win32.Primitives/4.0.1": { + "sha512": "fQnBHO9DgcmkC9dYSJoBqo6sH1VJwJprUHh8F3hbcRlxiQiBUuTntdk8tUwV490OqC2kQUrinGwZyQHTieuXRA==", + "type": "package", + "path": "Microsoft.Win32.Primitives/4.0.1", + "files": [ + "Microsoft.Win32.Primitives.4.0.1.nupkg.sha512", + "Microsoft.Win32.Primitives.nuspec", + "ThirdPartyNotices.txt", + "dotnet_library_license.txt", + "lib/MonoAndroid10/_._", + "lib/MonoTouch10/_._", + "lib/net46/Microsoft.Win32.Primitives.dll", + "lib/xamarinios10/_._", + "lib/xamarinmac20/_._", + "lib/xamarintvos10/_._", + "lib/xamarinwatchos10/_._", + "ref/MonoAndroid10/_._", + "ref/MonoTouch10/_._", + "ref/net46/Microsoft.Win32.Primitives.dll", + "ref/netstandard1.3/Microsoft.Win32.Primitives.dll", + "ref/netstandard1.3/Microsoft.Win32.Primitives.xml", + "ref/netstandard1.3/de/Microsoft.Win32.Primitives.xml", + "ref/netstandard1.3/es/Microsoft.Win32.Primitives.xml", + "ref/netstandard1.3/fr/Microsoft.Win32.Primitives.xml", + "ref/netstandard1.3/it/Microsoft.Win32.Primitives.xml", + "ref/netstandard1.3/ja/Microsoft.Win32.Primitives.xml", + "ref/netstandard1.3/ko/Microsoft.Win32.Primitives.xml", + "ref/netstandard1.3/ru/Microsoft.Win32.Primitives.xml", + "ref/netstandard1.3/zh-hans/Microsoft.Win32.Primitives.xml", + "ref/netstandard1.3/zh-hant/Microsoft.Win32.Primitives.xml", + "ref/xamarinios10/_._", + "ref/xamarinmac20/_._", + "ref/xamarintvos10/_._", + "ref/xamarinwatchos10/_._" + ] + }, + "Microsoft.Win32.Registry/4.0.0": { + "sha512": "q+eLtROUAQ3OxYA5mpQrgyFgzLQxIyrfT2eLpYX5IEPlHmIio2nh4F5bgOaQoGOV865kFKZZso9Oq9RlazvXtg==", + "type": "package", + "path": "Microsoft.Win32.Registry/4.0.0", + "files": [ + "Microsoft.Win32.Registry.4.0.0.nupkg.sha512", + "Microsoft.Win32.Registry.nuspec", + "ThirdPartyNotices.txt", + "dotnet_library_license.txt", + "lib/net46/Microsoft.Win32.Registry.dll", + "ref/net46/Microsoft.Win32.Registry.dll", + "ref/netstandard1.3/Microsoft.Win32.Registry.dll", + "ref/netstandard1.3/Microsoft.Win32.Registry.xml", + "ref/netstandard1.3/de/Microsoft.Win32.Registry.xml", + "ref/netstandard1.3/es/Microsoft.Win32.Registry.xml", + "ref/netstandard1.3/fr/Microsoft.Win32.Registry.xml", + "ref/netstandard1.3/it/Microsoft.Win32.Registry.xml", + "ref/netstandard1.3/ja/Microsoft.Win32.Registry.xml", + "ref/netstandard1.3/ko/Microsoft.Win32.Registry.xml", + "ref/netstandard1.3/ru/Microsoft.Win32.Registry.xml", + "ref/netstandard1.3/zh-hans/Microsoft.Win32.Registry.xml", + "ref/netstandard1.3/zh-hant/Microsoft.Win32.Registry.xml", + "runtimes/unix/lib/netstandard1.3/Microsoft.Win32.Registry.dll", + "runtimes/win/lib/net46/Microsoft.Win32.Registry.dll", + "runtimes/win/lib/netcore50/_._", + "runtimes/win/lib/netstandard1.3/Microsoft.Win32.Registry.dll" + ] + }, + "NETStandard.Library/1.6.0": { + "sha512": "ypsCvIdCZ4IoYASJHt6tF2fMo7N30NLgV1EbmC+snO490OMl9FvVxmumw14rhReWU3j3g7BYudG6YCrchwHJlA==", + "type": "package", + "path": "NETStandard.Library/1.6.0", + "files": [ + "NETStandard.Library.1.6.0.nupkg.sha512", + "NETStandard.Library.nuspec", + "ThirdPartyNotices.txt", + "dotnet_library_license.txt" + ] + }, + "Newtonsoft.Json/9.0.1": { + "sha512": "U82mHQSKaIk+lpSVCbWYKNavmNH1i5xrExDEquU1i6I5pV6UMOqRnJRSlKO3cMPfcpp0RgDY+8jUXHdQ4IfXvw==", + "type": "package", + "path": "Newtonsoft.Json/9.0.1", + "files": [ + "Newtonsoft.Json.9.0.1.nupkg.sha512", + "Newtonsoft.Json.nuspec", + "lib/net20/Newtonsoft.Json.dll", + "lib/net20/Newtonsoft.Json.xml", + "lib/net35/Newtonsoft.Json.dll", + "lib/net35/Newtonsoft.Json.xml", + "lib/net40/Newtonsoft.Json.dll", + "lib/net40/Newtonsoft.Json.xml", + "lib/net45/Newtonsoft.Json.dll", + "lib/net45/Newtonsoft.Json.xml", + "lib/netstandard1.0/Newtonsoft.Json.dll", + "lib/netstandard1.0/Newtonsoft.Json.xml", + "lib/portable-net40+sl5+wp80+win8+wpa81/Newtonsoft.Json.dll", + "lib/portable-net40+sl5+wp80+win8+wpa81/Newtonsoft.Json.xml", + "lib/portable-net45+wp80+win8+wpa81/Newtonsoft.Json.dll", + "lib/portable-net45+wp80+win8+wpa81/Newtonsoft.Json.xml", + "tools/install.ps1" + ] + }, + "NuGet.Common/3.5.0-beta2-1484": { + "sha512": "rLBmcZOPVF7Mne/LumDNACZZyI5B67hjylt+Z/WSEUQ/IXE9nLv8IVL0+T9xljIaSSQCjO8cOtmJ6ztqrsQKcQ==", + "type": "package", + "path": "NuGet.Common/3.5.0-beta2-1484", + "files": [ + "NuGet.Common.3.5.0-beta2-1484.nupkg.sha512", + "NuGet.Common.nuspec", + "lib/net45/NuGet.Common.dll", + "lib/net45/NuGet.Common.xml", + "lib/netstandard1.3/NuGet.Common.dll", + "lib/netstandard1.3/NuGet.Common.xml" + ] + }, + "NuGet.Frameworks/3.5.0-beta2-1484": { + "sha512": "AZoX0c05qgSfx0IOGTbLXa2fD7eM2WUqKP3osMMvSxK+tOGmctHuFlvjXxMHBv9yg0/13KdH0osV/zI7+SjzOA==", + "type": "package", + "path": "NuGet.Frameworks/3.5.0-beta2-1484", + "files": [ + "NuGet.Frameworks.3.5.0-beta2-1484.nupkg.sha512", + "NuGet.Frameworks.nuspec", + "lib/net40-client/NuGet.Frameworks.dll", + "lib/net40-client/NuGet.Frameworks.xml", + "lib/net45/NuGet.Frameworks.dll", + "lib/net45/NuGet.Frameworks.xml", + "lib/netstandard1.3/NuGet.Frameworks.dll", + "lib/netstandard1.3/NuGet.Frameworks.xml" + ] + }, + "NuGet.Packaging/3.5.0-beta2-1484": { + "sha512": "/+7d3vvCel4KhJo6AyOneg07fbAkUsy/ORgIaxW3nNdJubCXSrAdg1wfQpwzBygmErjrPcdYzzk2y2Sc6m7hwQ==", + "type": "package", + "path": "NuGet.Packaging/3.5.0-beta2-1484", + "files": [ + "NuGet.Packaging.3.5.0-beta2-1484.nupkg.sha512", + "NuGet.Packaging.nuspec", + "lib/net45/NuGet.Packaging.dll", + "lib/net45/NuGet.Packaging.xml", + "lib/netstandard1.3/NuGet.Packaging.dll", + "lib/netstandard1.3/NuGet.Packaging.xml" + ] + }, + "NuGet.Packaging.Core/3.5.0-beta2-1484": { + "sha512": "Lsz2lgYH0mdOvuL8C3G4XLm9EaAheBOqrgLgnBNxCeLGLU+n+Zu8Lt6K1bpzgkeKyTyAhJdWbv/3lS4w7s04gw==", + "type": "package", + "path": "NuGet.Packaging.Core/3.5.0-beta2-1484", + "files": [ + "NuGet.Packaging.Core.3.5.0-beta2-1484.nupkg.sha512", + "NuGet.Packaging.Core.nuspec", + "lib/net45/NuGet.Packaging.Core.dll", + "lib/net45/NuGet.Packaging.Core.xml", + "lib/netstandard1.3/NuGet.Packaging.Core.dll", + "lib/netstandard1.3/NuGet.Packaging.Core.xml" + ] + }, + "NuGet.Packaging.Core.Types/3.5.0-beta2-1484": { + "sha512": "4mEXZBoe/RKTDVQGwdrl/f5gqolU2d1JWjpbGdQv5EG/xQCC8IQ8FTNYzk0+ydV/vuRM1yaNe+6UQ90nGE+1kQ==", + "type": "package", + "path": "NuGet.Packaging.Core.Types/3.5.0-beta2-1484", + "files": [ + "NuGet.Packaging.Core.Types.3.5.0-beta2-1484.nupkg.sha512", + "NuGet.Packaging.Core.Types.nuspec", + "lib/net45/NuGet.Packaging.Core.Types.dll", + "lib/net45/NuGet.Packaging.Core.Types.xml", + "lib/netstandard1.3/NuGet.Packaging.Core.Types.dll", + "lib/netstandard1.3/NuGet.Packaging.Core.Types.xml" + ] + }, + "NuGet.RuntimeModel/3.5.0-beta2-1484": { + "sha512": "vg29WbKcExD9AJrKMr7NB9pnp+0MTAcDHB6gFHCqRynSo6jgjC8q+ZPAlxC115rQiO8fqzOEP59Q8hx20anUtA==", + "type": "package", + "path": "NuGet.RuntimeModel/3.5.0-beta2-1484", + "files": [ + "NuGet.RuntimeModel.3.5.0-beta2-1484.nupkg.sha512", + "NuGet.RuntimeModel.nuspec", + "lib/net45/NuGet.RuntimeModel.dll", + "lib/net45/NuGet.RuntimeModel.xml", + "lib/netstandard1.3/NuGet.RuntimeModel.dll", + "lib/netstandard1.3/NuGet.RuntimeModel.xml" + ] + }, + "NuGet.Versioning/3.5.0-beta2-1484": { + "sha512": "Stok+SI5lWxOkTgZZM7jT4xuAZogm5+j85mKJeHSXb8o0OAbB+qDX9jkdM2wIEnjoR8R29J0nQYwk2Kl2lWFpA==", + "type": "package", + "path": "NuGet.Versioning/3.5.0-beta2-1484", + "files": [ + "NuGet.Versioning.3.5.0-beta2-1484.nupkg.sha512", + "NuGet.Versioning.nuspec", + "lib/net45/NuGet.Versioning.dll", + "lib/net45/NuGet.Versioning.xml", + "lib/netstandard1.0/NuGet.Versioning.dll", + "lib/netstandard1.0/NuGet.Versioning.xml" + ] + }, + "runtime.native.System/4.0.0": { + "sha512": "QfS/nQI7k/BLgmLrw7qm7YBoULEvgWnPI+cYsbfCVFTW8Aj+i8JhccxcFMu1RWms0YZzF+UHguNBK4Qn89e2Sg==", + "type": "package", + "path": "runtime.native.System/4.0.0", + "files": [ + "ThirdPartyNotices.txt", + "dotnet_library_license.txt", + "lib/netstandard1.0/_._", + "runtime.native.System.4.0.0.nupkg.sha512", + "runtime.native.System.nuspec" + ] + }, + "runtime.native.System.IO.Compression/4.1.0": { + "sha512": "Ob7nvnJBox1aaB222zSVZSkf4WrebPG4qFscfK7vmD7P7NxoSxACQLtO7ytWpqXDn2wcd/+45+EAZ7xjaPip8A==", + "type": "package", + "path": "runtime.native.System.IO.Compression/4.1.0", + "files": [ + "ThirdPartyNotices.txt", + "dotnet_library_license.txt", + "lib/netstandard1.0/_._", + "runtime.native.System.IO.Compression.4.1.0.nupkg.sha512", + "runtime.native.System.IO.Compression.nuspec" + ] + }, + "runtime.native.System.Net.Http/4.0.1": { + "sha512": "Nh0UPZx2Vifh8r+J+H2jxifZUD3sBrmolgiFWJd2yiNrxO0xTa6bAw3YwRn1VOiSen/tUXMS31ttNItCZ6lKuA==", + "type": "package", + "path": "runtime.native.System.Net.Http/4.0.1", + "files": [ + "ThirdPartyNotices.txt", + "dotnet_library_license.txt", + "lib/netstandard1.0/_._", + "runtime.native.System.Net.Http.4.0.1.nupkg.sha512", + "runtime.native.System.Net.Http.nuspec" + ] + }, + "runtime.native.System.Net.Security/4.0.1": { + "sha512": "ZLOslJbCClPpf2hwAVSl4niNcAWB477RQJT+Hcs897jFbT1qiDhHAJXP2K2PnPKDOQD7me3JE5T/yKEgQdYNYw==", + "type": "package", + "path": "runtime.native.System.Net.Security/4.0.1", + "files": [ + "ThirdPartyNotices.txt", + "dotnet_library_license.txt", + "lib/netstandard1.0/_._", + "runtime.native.System.Net.Security.4.0.1.nupkg.sha512", + "runtime.native.System.Net.Security.nuspec" + ] + }, + "runtime.native.System.Security.Cryptography/4.0.0": { + "sha512": "2CQK0jmO6Eu7ZeMgD+LOFbNJSXHFVQbCJJkEyEwowh1SCgYnrn9W9RykMfpeeVGw7h4IBvYikzpGUlmZTUafJw==", + "type": "package", + "path": "runtime.native.System.Security.Cryptography/4.0.0", + "files": [ + "ThirdPartyNotices.txt", + "dotnet_library_license.txt", + "lib/netstandard1.0/_._", + "runtime.native.System.Security.Cryptography.4.0.0.nupkg.sha512", + "runtime.native.System.Security.Cryptography.nuspec" + ] + }, + "System.AppContext/4.1.0": { + "sha512": "3QjO4jNV7PdKkmQAVp9atA+usVnKRwI3Kx1nMwJ93T0LcQfx7pKAYk0nKz5wn1oP5iqlhZuy6RXOFdhr7rDwow==", + "type": "package", + "path": "System.AppContext/4.1.0", + "files": [ + "System.AppContext.4.1.0.nupkg.sha512", + "System.AppContext.nuspec", + "ThirdPartyNotices.txt", + "dotnet_library_license.txt", + "lib/MonoAndroid10/_._", + "lib/MonoTouch10/_._", + "lib/net46/System.AppContext.dll", + "lib/net463/System.AppContext.dll", + "lib/netcore50/System.AppContext.dll", + "lib/netstandard1.6/System.AppContext.dll", + "lib/xamarinios10/_._", + "lib/xamarinmac20/_._", + "lib/xamarintvos10/_._", + "lib/xamarinwatchos10/_._", + "ref/MonoAndroid10/_._", + "ref/MonoTouch10/_._", + "ref/net46/System.AppContext.dll", + "ref/net463/System.AppContext.dll", + "ref/netstandard/_._", + "ref/netstandard1.3/System.AppContext.dll", + "ref/netstandard1.3/System.AppContext.xml", + "ref/netstandard1.3/de/System.AppContext.xml", + "ref/netstandard1.3/es/System.AppContext.xml", + "ref/netstandard1.3/fr/System.AppContext.xml", + "ref/netstandard1.3/it/System.AppContext.xml", + "ref/netstandard1.3/ja/System.AppContext.xml", + "ref/netstandard1.3/ko/System.AppContext.xml", + "ref/netstandard1.3/ru/System.AppContext.xml", + "ref/netstandard1.3/zh-hans/System.AppContext.xml", + "ref/netstandard1.3/zh-hant/System.AppContext.xml", + "ref/netstandard1.6/System.AppContext.dll", + "ref/netstandard1.6/System.AppContext.xml", + "ref/netstandard1.6/de/System.AppContext.xml", + "ref/netstandard1.6/es/System.AppContext.xml", + "ref/netstandard1.6/fr/System.AppContext.xml", + "ref/netstandard1.6/it/System.AppContext.xml", + "ref/netstandard1.6/ja/System.AppContext.xml", + "ref/netstandard1.6/ko/System.AppContext.xml", + "ref/netstandard1.6/ru/System.AppContext.xml", + "ref/netstandard1.6/zh-hans/System.AppContext.xml", + "ref/netstandard1.6/zh-hant/System.AppContext.xml", + "ref/xamarinios10/_._", + "ref/xamarinmac20/_._", + "ref/xamarintvos10/_._", + "ref/xamarinwatchos10/_._", + "runtimes/aot/lib/netcore50/System.AppContext.dll" + ] + }, + "System.Buffers/4.0.0": { + "sha512": "msXumHfjjURSkvxUjYuq4N2ghHoRi2VpXcKMA7gK6ujQfU3vGpl+B6ld0ATRg+FZFpRyA6PgEPA+VlIkTeNf2w==", + "type": "package", + "path": "System.Buffers/4.0.0", + "files": [ + "System.Buffers.4.0.0.nupkg.sha512", + "System.Buffers.nuspec", + "ThirdPartyNotices.txt", + "dotnet_library_license.txt", + "lib/netstandard1.1/.xml", + "lib/netstandard1.1/System.Buffers.dll" + ] + }, + "System.Collections/4.0.11": { + "sha512": "YUJGz6eFKqS0V//mLt25vFGrrCvOnsXjlvFQs+KimpwNxug9x0Pzy4PlFMU3Q2IzqAa9G2L4LsK3+9vCBK7oTg==", + "type": "package", + "path": "System.Collections/4.0.11", + "files": [ + "System.Collections.4.0.11.nupkg.sha512", + "System.Collections.nuspec", + "ThirdPartyNotices.txt", + "dotnet_library_license.txt", + "lib/MonoAndroid10/_._", + "lib/MonoTouch10/_._", + "lib/net45/_._", + "lib/portable-net45+win8+wp8+wpa81/_._", + "lib/win8/_._", + "lib/wp80/_._", + "lib/wpa81/_._", + "lib/xamarinios10/_._", + "lib/xamarinmac20/_._", + "lib/xamarintvos10/_._", + "lib/xamarinwatchos10/_._", + "ref/MonoAndroid10/_._", + "ref/MonoTouch10/_._", + "ref/net45/_._", + "ref/netcore50/System.Collections.dll", + "ref/netcore50/System.Collections.xml", + "ref/netcore50/de/System.Collections.xml", + "ref/netcore50/es/System.Collections.xml", + "ref/netcore50/fr/System.Collections.xml", + "ref/netcore50/it/System.Collections.xml", + "ref/netcore50/ja/System.Collections.xml", + "ref/netcore50/ko/System.Collections.xml", + "ref/netcore50/ru/System.Collections.xml", + "ref/netcore50/zh-hans/System.Collections.xml", + "ref/netcore50/zh-hant/System.Collections.xml", + "ref/netstandard1.0/System.Collections.dll", + "ref/netstandard1.0/System.Collections.xml", + "ref/netstandard1.0/de/System.Collections.xml", + "ref/netstandard1.0/es/System.Collections.xml", + "ref/netstandard1.0/fr/System.Collections.xml", + "ref/netstandard1.0/it/System.Collections.xml", + "ref/netstandard1.0/ja/System.Collections.xml", + "ref/netstandard1.0/ko/System.Collections.xml", + "ref/netstandard1.0/ru/System.Collections.xml", + "ref/netstandard1.0/zh-hans/System.Collections.xml", + "ref/netstandard1.0/zh-hant/System.Collections.xml", + "ref/netstandard1.3/System.Collections.dll", + "ref/netstandard1.3/System.Collections.xml", + "ref/netstandard1.3/de/System.Collections.xml", + "ref/netstandard1.3/es/System.Collections.xml", + "ref/netstandard1.3/fr/System.Collections.xml", + "ref/netstandard1.3/it/System.Collections.xml", + "ref/netstandard1.3/ja/System.Collections.xml", + "ref/netstandard1.3/ko/System.Collections.xml", + "ref/netstandard1.3/ru/System.Collections.xml", + "ref/netstandard1.3/zh-hans/System.Collections.xml", + "ref/netstandard1.3/zh-hant/System.Collections.xml", + "ref/portable-net45+win8+wp8+wpa81/_._", + "ref/win8/_._", + "ref/wp80/_._", + "ref/wpa81/_._", + "ref/xamarinios10/_._", + "ref/xamarinmac20/_._", + "ref/xamarintvos10/_._", + "ref/xamarinwatchos10/_._" + ] + }, + "System.Collections.Concurrent/4.0.12": { + "sha512": "2gBcbb3drMLgxlI0fBfxMA31ec6AEyYCHygGse4vxceJan8mRIWeKJ24BFzN7+bi/NFTgdIgufzb94LWO5EERQ==", + "type": "package", + "path": "System.Collections.Concurrent/4.0.12", + "files": [ + "System.Collections.Concurrent.4.0.12.nupkg.sha512", + "System.Collections.Concurrent.nuspec", + "ThirdPartyNotices.txt", + "dotnet_library_license.txt", + "lib/MonoAndroid10/_._", + "lib/MonoTouch10/_._", + "lib/net45/_._", + "lib/netcore50/System.Collections.Concurrent.dll", + "lib/netstandard1.3/System.Collections.Concurrent.dll", + "lib/portable-net45+win8+wpa81/_._", + "lib/win8/_._", + "lib/wpa81/_._", + "lib/xamarinios10/_._", + "lib/xamarinmac20/_._", + "lib/xamarintvos10/_._", + "lib/xamarinwatchos10/_._", + "ref/MonoAndroid10/_._", + "ref/MonoTouch10/_._", + "ref/net45/_._", + "ref/netcore50/System.Collections.Concurrent.dll", + "ref/netcore50/System.Collections.Concurrent.xml", + "ref/netcore50/de/System.Collections.Concurrent.xml", + "ref/netcore50/es/System.Collections.Concurrent.xml", + "ref/netcore50/fr/System.Collections.Concurrent.xml", + "ref/netcore50/it/System.Collections.Concurrent.xml", + "ref/netcore50/ja/System.Collections.Concurrent.xml", + "ref/netcore50/ko/System.Collections.Concurrent.xml", + "ref/netcore50/ru/System.Collections.Concurrent.xml", + "ref/netcore50/zh-hans/System.Collections.Concurrent.xml", + "ref/netcore50/zh-hant/System.Collections.Concurrent.xml", + "ref/netstandard1.1/System.Collections.Concurrent.dll", + "ref/netstandard1.1/System.Collections.Concurrent.xml", + "ref/netstandard1.1/de/System.Collections.Concurrent.xml", + "ref/netstandard1.1/es/System.Collections.Concurrent.xml", + "ref/netstandard1.1/fr/System.Collections.Concurrent.xml", + "ref/netstandard1.1/it/System.Collections.Concurrent.xml", + "ref/netstandard1.1/ja/System.Collections.Concurrent.xml", + "ref/netstandard1.1/ko/System.Collections.Concurrent.xml", + "ref/netstandard1.1/ru/System.Collections.Concurrent.xml", + "ref/netstandard1.1/zh-hans/System.Collections.Concurrent.xml", + "ref/netstandard1.1/zh-hant/System.Collections.Concurrent.xml", + "ref/netstandard1.3/System.Collections.Concurrent.dll", + "ref/netstandard1.3/System.Collections.Concurrent.xml", + "ref/netstandard1.3/de/System.Collections.Concurrent.xml", + "ref/netstandard1.3/es/System.Collections.Concurrent.xml", + "ref/netstandard1.3/fr/System.Collections.Concurrent.xml", + "ref/netstandard1.3/it/System.Collections.Concurrent.xml", + "ref/netstandard1.3/ja/System.Collections.Concurrent.xml", + "ref/netstandard1.3/ko/System.Collections.Concurrent.xml", + "ref/netstandard1.3/ru/System.Collections.Concurrent.xml", + "ref/netstandard1.3/zh-hans/System.Collections.Concurrent.xml", + "ref/netstandard1.3/zh-hant/System.Collections.Concurrent.xml", + "ref/portable-net45+win8+wpa81/_._", + "ref/win8/_._", + "ref/wpa81/_._", + "ref/xamarinios10/_._", + "ref/xamarinmac20/_._", + "ref/xamarintvos10/_._", + "ref/xamarinwatchos10/_._" + ] + }, + "System.Collections.Immutable/1.2.0": { + "sha512": "Cma8cBW6di16ZLibL8LYQ+cLjGzoKxpOTu/faZfDcx94ZjAGq6Nv5RO7+T1YZXqEXTZP9rt1wLVEONVpURtUqw==", + "type": "package", + "path": "System.Collections.Immutable/1.2.0", + "files": [ + "System.Collections.Immutable.1.2.0.nupkg.sha512", + "System.Collections.Immutable.nuspec", + "ThirdPartyNotices.txt", + "dotnet_library_license.txt", + "lib/netstandard1.0/System.Collections.Immutable.dll", + "lib/netstandard1.0/System.Collections.Immutable.xml", + "lib/portable-net45+win8+wp8+wpa81/System.Collections.Immutable.dll", + "lib/portable-net45+win8+wp8+wpa81/System.Collections.Immutable.xml" + ] + }, + "System.ComponentModel/4.0.1": { + "sha512": "1/jcKEP64gBv2EOzhgoiuSwssrzJz3DThFqI2XQseomxiCunWg3USdmYMjknHVAVtk24K2RKScv2iAvHhArR+Q==", + "type": "package", + "path": "System.ComponentModel/4.0.1", + "files": [ + "System.ComponentModel.4.0.1.nupkg.sha512", + "System.ComponentModel.nuspec", + "ThirdPartyNotices.txt", + "dotnet_library_license.txt", + "lib/MonoAndroid10/_._", + "lib/MonoTouch10/_._", + "lib/net45/_._", + "lib/netcore50/System.ComponentModel.dll", + "lib/netstandard1.3/System.ComponentModel.dll", + "lib/portable-net45+win8+wp8+wpa81/_._", + "lib/win8/_._", + "lib/wp80/_._", + "lib/wpa81/_._", + "lib/xamarinios10/_._", + "lib/xamarinmac20/_._", + "lib/xamarintvos10/_._", + "lib/xamarinwatchos10/_._", + "ref/MonoAndroid10/_._", + "ref/MonoTouch10/_._", + "ref/net45/_._", + "ref/netcore50/System.ComponentModel.dll", + "ref/netcore50/System.ComponentModel.xml", + "ref/netcore50/de/System.ComponentModel.xml", + "ref/netcore50/es/System.ComponentModel.xml", + "ref/netcore50/fr/System.ComponentModel.xml", + "ref/netcore50/it/System.ComponentModel.xml", + "ref/netcore50/ja/System.ComponentModel.xml", + "ref/netcore50/ko/System.ComponentModel.xml", + "ref/netcore50/ru/System.ComponentModel.xml", + "ref/netcore50/zh-hans/System.ComponentModel.xml", + "ref/netcore50/zh-hant/System.ComponentModel.xml", + "ref/netstandard1.0/System.ComponentModel.dll", + "ref/netstandard1.0/System.ComponentModel.xml", + "ref/netstandard1.0/de/System.ComponentModel.xml", + "ref/netstandard1.0/es/System.ComponentModel.xml", + "ref/netstandard1.0/fr/System.ComponentModel.xml", + "ref/netstandard1.0/it/System.ComponentModel.xml", + "ref/netstandard1.0/ja/System.ComponentModel.xml", + "ref/netstandard1.0/ko/System.ComponentModel.xml", + "ref/netstandard1.0/ru/System.ComponentModel.xml", + "ref/netstandard1.0/zh-hans/System.ComponentModel.xml", + "ref/netstandard1.0/zh-hant/System.ComponentModel.xml", + "ref/portable-net45+win8+wp8+wpa81/_._", + "ref/win8/_._", + "ref/wp80/_._", + "ref/wpa81/_._", + "ref/xamarinios10/_._", + "ref/xamarinmac20/_._", + "ref/xamarintvos10/_._", + "ref/xamarinwatchos10/_._" + ] + }, + "System.ComponentModel.Annotations/4.1.0": { + "sha512": "NIQa1tqd9LtQfPtO6zXfFOJUPm74jJVeHbFh4LM14OBorPS4i1Zn/FmBYB5iB/rQ8cTdmzzy9NwekdPzZSrB+A==", + "type": "package", + "path": "System.ComponentModel.Annotations/4.1.0", + "files": [ + "System.ComponentModel.Annotations.4.1.0.nupkg.sha512", + "System.ComponentModel.Annotations.nuspec", + "ThirdPartyNotices.txt", + "dotnet_library_license.txt", + "lib/MonoAndroid10/_._", + "lib/MonoTouch10/_._", + "lib/net45/_._", + "lib/net461/System.ComponentModel.Annotations.dll", + "lib/netcore50/System.ComponentModel.Annotations.dll", + "lib/netstandard1.4/System.ComponentModel.Annotations.dll", + "lib/portable-net45+win8/_._", + "lib/win8/_._", + "lib/xamarinios10/_._", + "lib/xamarinmac20/_._", + "lib/xamarintvos10/_._", + "lib/xamarinwatchos10/_._", + "ref/MonoAndroid10/_._", + "ref/MonoTouch10/_._", + "ref/net45/_._", + "ref/net461/System.ComponentModel.Annotations.dll", + "ref/netcore50/System.ComponentModel.Annotations.dll", + "ref/netcore50/System.ComponentModel.Annotations.xml", + "ref/netcore50/de/System.ComponentModel.Annotations.xml", + "ref/netcore50/es/System.ComponentModel.Annotations.xml", + "ref/netcore50/fr/System.ComponentModel.Annotations.xml", + "ref/netcore50/it/System.ComponentModel.Annotations.xml", + "ref/netcore50/ja/System.ComponentModel.Annotations.xml", + "ref/netcore50/ko/System.ComponentModel.Annotations.xml", + "ref/netcore50/ru/System.ComponentModel.Annotations.xml", + "ref/netcore50/zh-hans/System.ComponentModel.Annotations.xml", + "ref/netcore50/zh-hant/System.ComponentModel.Annotations.xml", + "ref/netstandard1.1/System.ComponentModel.Annotations.dll", + "ref/netstandard1.1/System.ComponentModel.Annotations.xml", + "ref/netstandard1.1/de/System.ComponentModel.Annotations.xml", + "ref/netstandard1.1/es/System.ComponentModel.Annotations.xml", + "ref/netstandard1.1/fr/System.ComponentModel.Annotations.xml", + "ref/netstandard1.1/it/System.ComponentModel.Annotations.xml", + "ref/netstandard1.1/ja/System.ComponentModel.Annotations.xml", + "ref/netstandard1.1/ko/System.ComponentModel.Annotations.xml", + "ref/netstandard1.1/ru/System.ComponentModel.Annotations.xml", + "ref/netstandard1.1/zh-hans/System.ComponentModel.Annotations.xml", + "ref/netstandard1.1/zh-hant/System.ComponentModel.Annotations.xml", + "ref/netstandard1.3/System.ComponentModel.Annotations.dll", + "ref/netstandard1.3/System.ComponentModel.Annotations.xml", + "ref/netstandard1.3/de/System.ComponentModel.Annotations.xml", + "ref/netstandard1.3/es/System.ComponentModel.Annotations.xml", + "ref/netstandard1.3/fr/System.ComponentModel.Annotations.xml", + "ref/netstandard1.3/it/System.ComponentModel.Annotations.xml", + "ref/netstandard1.3/ja/System.ComponentModel.Annotations.xml", + "ref/netstandard1.3/ko/System.ComponentModel.Annotations.xml", + "ref/netstandard1.3/ru/System.ComponentModel.Annotations.xml", + "ref/netstandard1.3/zh-hans/System.ComponentModel.Annotations.xml", + "ref/netstandard1.3/zh-hant/System.ComponentModel.Annotations.xml", + "ref/netstandard1.4/System.ComponentModel.Annotations.dll", + "ref/netstandard1.4/System.ComponentModel.Annotations.xml", + "ref/netstandard1.4/de/System.ComponentModel.Annotations.xml", + "ref/netstandard1.4/es/System.ComponentModel.Annotations.xml", + "ref/netstandard1.4/fr/System.ComponentModel.Annotations.xml", + "ref/netstandard1.4/it/System.ComponentModel.Annotations.xml", + "ref/netstandard1.4/ja/System.ComponentModel.Annotations.xml", + "ref/netstandard1.4/ko/System.ComponentModel.Annotations.xml", + "ref/netstandard1.4/ru/System.ComponentModel.Annotations.xml", + "ref/netstandard1.4/zh-hans/System.ComponentModel.Annotations.xml", + "ref/netstandard1.4/zh-hant/System.ComponentModel.Annotations.xml", + "ref/portable-net45+win8/_._", + "ref/win8/_._", + "ref/xamarinios10/_._", + "ref/xamarinmac20/_._", + "ref/xamarintvos10/_._", + "ref/xamarinwatchos10/_._" + ] + }, + "System.Console/4.0.0": { + "sha512": "qSKUSOIiYA/a0g5XXdxFcUFmv1hNICBD7QZ0QhGYVipPIhvpiydY8VZqr1thmCXvmn8aipMg64zuanB4eotK9A==", + "type": "package", + "path": "System.Console/4.0.0", + "files": [ + "System.Console.4.0.0.nupkg.sha512", + "System.Console.nuspec", + "ThirdPartyNotices.txt", + "dotnet_library_license.txt", + "lib/MonoAndroid10/_._", + "lib/MonoTouch10/_._", + "lib/net46/System.Console.dll", + "lib/xamarinios10/_._", + "lib/xamarinmac20/_._", + "lib/xamarintvos10/_._", + "lib/xamarinwatchos10/_._", + "ref/MonoAndroid10/_._", + "ref/MonoTouch10/_._", + "ref/net46/System.Console.dll", + "ref/netstandard1.3/System.Console.dll", + "ref/netstandard1.3/System.Console.xml", + "ref/netstandard1.3/de/System.Console.xml", + "ref/netstandard1.3/es/System.Console.xml", + "ref/netstandard1.3/fr/System.Console.xml", + "ref/netstandard1.3/it/System.Console.xml", + "ref/netstandard1.3/ja/System.Console.xml", + "ref/netstandard1.3/ko/System.Console.xml", + "ref/netstandard1.3/ru/System.Console.xml", + "ref/netstandard1.3/zh-hans/System.Console.xml", + "ref/netstandard1.3/zh-hant/System.Console.xml", + "ref/xamarinios10/_._", + "ref/xamarinmac20/_._", + "ref/xamarintvos10/_._", + "ref/xamarinwatchos10/_._" + ] + }, + "System.Diagnostics.Debug/4.0.11": { + "sha512": "w5U95fVKHY4G8ASs/K5iK3J5LY+/dLFd4vKejsnI/ZhBsWS9hQakfx3Zr7lRWKg4tAw9r4iktyvsTagWkqYCiw==", + "type": "package", + "path": "System.Diagnostics.Debug/4.0.11", + "files": [ + "System.Diagnostics.Debug.4.0.11.nupkg.sha512", + "System.Diagnostics.Debug.nuspec", + "ThirdPartyNotices.txt", + "dotnet_library_license.txt", + "lib/MonoAndroid10/_._", + "lib/MonoTouch10/_._", + "lib/net45/_._", + "lib/portable-net45+win8+wp8+wpa81/_._", + "lib/win8/_._", + "lib/wp80/_._", + "lib/wpa81/_._", + "lib/xamarinios10/_._", + "lib/xamarinmac20/_._", + "lib/xamarintvos10/_._", + "lib/xamarinwatchos10/_._", + "ref/MonoAndroid10/_._", + "ref/MonoTouch10/_._", + "ref/net45/_._", + "ref/netcore50/System.Diagnostics.Debug.dll", + "ref/netcore50/System.Diagnostics.Debug.xml", + "ref/netcore50/de/System.Diagnostics.Debug.xml", + "ref/netcore50/es/System.Diagnostics.Debug.xml", + "ref/netcore50/fr/System.Diagnostics.Debug.xml", + "ref/netcore50/it/System.Diagnostics.Debug.xml", + "ref/netcore50/ja/System.Diagnostics.Debug.xml", + "ref/netcore50/ko/System.Diagnostics.Debug.xml", + "ref/netcore50/ru/System.Diagnostics.Debug.xml", + "ref/netcore50/zh-hans/System.Diagnostics.Debug.xml", + "ref/netcore50/zh-hant/System.Diagnostics.Debug.xml", + "ref/netstandard1.0/System.Diagnostics.Debug.dll", + "ref/netstandard1.0/System.Diagnostics.Debug.xml", + "ref/netstandard1.0/de/System.Diagnostics.Debug.xml", + "ref/netstandard1.0/es/System.Diagnostics.Debug.xml", + "ref/netstandard1.0/fr/System.Diagnostics.Debug.xml", + "ref/netstandard1.0/it/System.Diagnostics.Debug.xml", + "ref/netstandard1.0/ja/System.Diagnostics.Debug.xml", + "ref/netstandard1.0/ko/System.Diagnostics.Debug.xml", + "ref/netstandard1.0/ru/System.Diagnostics.Debug.xml", + "ref/netstandard1.0/zh-hans/System.Diagnostics.Debug.xml", + "ref/netstandard1.0/zh-hant/System.Diagnostics.Debug.xml", + "ref/netstandard1.3/System.Diagnostics.Debug.dll", + "ref/netstandard1.3/System.Diagnostics.Debug.xml", + "ref/netstandard1.3/de/System.Diagnostics.Debug.xml", + "ref/netstandard1.3/es/System.Diagnostics.Debug.xml", + "ref/netstandard1.3/fr/System.Diagnostics.Debug.xml", + "ref/netstandard1.3/it/System.Diagnostics.Debug.xml", + "ref/netstandard1.3/ja/System.Diagnostics.Debug.xml", + "ref/netstandard1.3/ko/System.Diagnostics.Debug.xml", + "ref/netstandard1.3/ru/System.Diagnostics.Debug.xml", + "ref/netstandard1.3/zh-hans/System.Diagnostics.Debug.xml", + "ref/netstandard1.3/zh-hant/System.Diagnostics.Debug.xml", + "ref/portable-net45+win8+wp8+wpa81/_._", + "ref/win8/_._", + "ref/wp80/_._", + "ref/wpa81/_._", + "ref/xamarinios10/_._", + "ref/xamarinmac20/_._", + "ref/xamarintvos10/_._", + "ref/xamarinwatchos10/_._" + ] + }, + "System.Diagnostics.DiagnosticSource/4.0.0": { + "sha512": "YKglnq4BMTJxfcr6nuT08g+yJ0UxdePIHxosiLuljuHIUR6t4KhFsyaHOaOc1Ofqp0PUvJ0EmcgiEz6T7vEx3w==", + "type": "package", + "path": "System.Diagnostics.DiagnosticSource/4.0.0", + "files": [ + "System.Diagnostics.DiagnosticSource.4.0.0.nupkg.sha512", + "System.Diagnostics.DiagnosticSource.nuspec", + "ThirdPartyNotices.txt", + "dotnet_library_license.txt", + "lib/net46/System.Diagnostics.DiagnosticSource.dll", + "lib/net46/System.Diagnostics.DiagnosticSource.xml", + "lib/netstandard1.1/System.Diagnostics.DiagnosticSource.dll", + "lib/netstandard1.1/System.Diagnostics.DiagnosticSource.xml", + "lib/netstandard1.3/System.Diagnostics.DiagnosticSource.dll", + "lib/netstandard1.3/System.Diagnostics.DiagnosticSource.xml", + "lib/portable-net45+win8+wpa81/System.Diagnostics.DiagnosticSource.dll", + "lib/portable-net45+win8+wpa81/System.Diagnostics.DiagnosticSource.xml" + ] + }, + "System.Diagnostics.FileVersionInfo/4.0.0": { + "sha512": "qjF74OTAU+mRhLaL4YSfiWy3vj6T3AOz8AW37l5zCwfbBfj0k7E94XnEsRaf2TnhE/7QaV6Hvqakoy2LoV8MVg==", + "type": "package", + "path": "System.Diagnostics.FileVersionInfo/4.0.0", + "files": [ + "System.Diagnostics.FileVersionInfo.4.0.0.nupkg.sha512", + "System.Diagnostics.FileVersionInfo.nuspec", + "ThirdPartyNotices.txt", + "dotnet_library_license.txt", + "lib/MonoAndroid10/_._", + "lib/MonoTouch10/_._", + "lib/net46/System.Diagnostics.FileVersionInfo.dll", + "lib/xamarinios10/_._", + "lib/xamarinmac20/_._", + "lib/xamarintvos10/_._", + "lib/xamarinwatchos10/_._", + "ref/MonoAndroid10/_._", + "ref/MonoTouch10/_._", + "ref/net46/System.Diagnostics.FileVersionInfo.dll", + "ref/netstandard1.3/System.Diagnostics.FileVersionInfo.dll", + "ref/netstandard1.3/System.Diagnostics.FileVersionInfo.xml", + "ref/netstandard1.3/de/System.Diagnostics.FileVersionInfo.xml", + "ref/netstandard1.3/es/System.Diagnostics.FileVersionInfo.xml", + "ref/netstandard1.3/fr/System.Diagnostics.FileVersionInfo.xml", + "ref/netstandard1.3/it/System.Diagnostics.FileVersionInfo.xml", + "ref/netstandard1.3/ja/System.Diagnostics.FileVersionInfo.xml", + "ref/netstandard1.3/ko/System.Diagnostics.FileVersionInfo.xml", + "ref/netstandard1.3/ru/System.Diagnostics.FileVersionInfo.xml", + "ref/netstandard1.3/zh-hans/System.Diagnostics.FileVersionInfo.xml", + "ref/netstandard1.3/zh-hant/System.Diagnostics.FileVersionInfo.xml", + "ref/xamarinios10/_._", + "ref/xamarinmac20/_._", + "ref/xamarintvos10/_._", + "ref/xamarinwatchos10/_._", + "runtimes/unix/lib/netstandard1.3/System.Diagnostics.FileVersionInfo.dll", + "runtimes/win/lib/net46/System.Diagnostics.FileVersionInfo.dll", + "runtimes/win/lib/netcore50/System.Diagnostics.FileVersionInfo.dll", + "runtimes/win/lib/netstandard1.3/System.Diagnostics.FileVersionInfo.dll" + ] + }, + "System.Diagnostics.Process/4.1.0": { + "sha512": "mpVZ5bnlSs3tTeJ6jYyDJEIa6tavhAd88lxq1zbYhkkCu0Pno2+gHXcvZcoygq2d8JxW3gojXqNJMTAshduqZA==", + "type": "package", + "path": "System.Diagnostics.Process/4.1.0", + "files": [ + "System.Diagnostics.Process.4.1.0.nupkg.sha512", + "System.Diagnostics.Process.nuspec", + "ThirdPartyNotices.txt", + "dotnet_library_license.txt", + "lib/MonoAndroid10/_._", + "lib/MonoTouch10/_._", + "lib/net46/System.Diagnostics.Process.dll", + "lib/net461/System.Diagnostics.Process.dll", + "lib/xamarinios10/_._", + "lib/xamarinmac20/_._", + "lib/xamarintvos10/_._", + "lib/xamarinwatchos10/_._", + "ref/MonoAndroid10/_._", + "ref/MonoTouch10/_._", + "ref/net46/System.Diagnostics.Process.dll", + "ref/net461/System.Diagnostics.Process.dll", + "ref/netstandard1.3/System.Diagnostics.Process.dll", + "ref/netstandard1.3/System.Diagnostics.Process.xml", + "ref/netstandard1.3/de/System.Diagnostics.Process.xml", + "ref/netstandard1.3/es/System.Diagnostics.Process.xml", + "ref/netstandard1.3/fr/System.Diagnostics.Process.xml", + "ref/netstandard1.3/it/System.Diagnostics.Process.xml", + "ref/netstandard1.3/ja/System.Diagnostics.Process.xml", + "ref/netstandard1.3/ko/System.Diagnostics.Process.xml", + "ref/netstandard1.3/ru/System.Diagnostics.Process.xml", + "ref/netstandard1.3/zh-hans/System.Diagnostics.Process.xml", + "ref/netstandard1.3/zh-hant/System.Diagnostics.Process.xml", + "ref/netstandard1.4/System.Diagnostics.Process.dll", + "ref/netstandard1.4/System.Diagnostics.Process.xml", + "ref/netstandard1.4/de/System.Diagnostics.Process.xml", + "ref/netstandard1.4/es/System.Diagnostics.Process.xml", + "ref/netstandard1.4/fr/System.Diagnostics.Process.xml", + "ref/netstandard1.4/it/System.Diagnostics.Process.xml", + "ref/netstandard1.4/ja/System.Diagnostics.Process.xml", + "ref/netstandard1.4/ko/System.Diagnostics.Process.xml", + "ref/netstandard1.4/ru/System.Diagnostics.Process.xml", + "ref/netstandard1.4/zh-hans/System.Diagnostics.Process.xml", + "ref/netstandard1.4/zh-hant/System.Diagnostics.Process.xml", + "ref/xamarinios10/_._", + "ref/xamarinmac20/_._", + "ref/xamarintvos10/_._", + "ref/xamarinwatchos10/_._", + "runtimes/linux/lib/netstandard1.4/System.Diagnostics.Process.dll", + "runtimes/osx/lib/netstandard1.4/System.Diagnostics.Process.dll", + "runtimes/win/lib/net46/System.Diagnostics.Process.dll", + "runtimes/win/lib/net461/System.Diagnostics.Process.dll", + "runtimes/win/lib/netstandard1.4/System.Diagnostics.Process.dll", + "runtimes/win7/lib/netcore50/_._" + ] + }, + "System.Diagnostics.StackTrace/4.0.1": { + "sha512": "6i2EbRq0lgGfiZ+FDf0gVaw9qeEU+7IS2+wbZJmFVpvVzVOgZEt0ScZtyenuBvs6iDYbGiF51bMAa0oDP/tujQ==", + "type": "package", + "path": "System.Diagnostics.StackTrace/4.0.1", + "files": [ + "System.Diagnostics.StackTrace.4.0.1.nupkg.sha512", + "System.Diagnostics.StackTrace.nuspec", + "ThirdPartyNotices.txt", + "dotnet_library_license.txt", + "lib/MonoAndroid10/_._", + "lib/MonoTouch10/_._", + "lib/net46/System.Diagnostics.StackTrace.dll", + "lib/netstandard1.3/System.Diagnostics.StackTrace.dll", + "lib/xamarinios10/_._", + "lib/xamarinmac20/_._", + "lib/xamarintvos10/_._", + "lib/xamarinwatchos10/_._", + "ref/MonoAndroid10/_._", + "ref/MonoTouch10/_._", + "ref/net46/System.Diagnostics.StackTrace.dll", + "ref/netstandard1.3/System.Diagnostics.StackTrace.dll", + "ref/netstandard1.3/System.Diagnostics.StackTrace.xml", + "ref/netstandard1.3/de/System.Diagnostics.StackTrace.xml", + "ref/netstandard1.3/es/System.Diagnostics.StackTrace.xml", + "ref/netstandard1.3/fr/System.Diagnostics.StackTrace.xml", + "ref/netstandard1.3/it/System.Diagnostics.StackTrace.xml", + "ref/netstandard1.3/ja/System.Diagnostics.StackTrace.xml", + "ref/netstandard1.3/ko/System.Diagnostics.StackTrace.xml", + "ref/netstandard1.3/ru/System.Diagnostics.StackTrace.xml", + "ref/netstandard1.3/zh-hans/System.Diagnostics.StackTrace.xml", + "ref/netstandard1.3/zh-hant/System.Diagnostics.StackTrace.xml", + "ref/xamarinios10/_._", + "ref/xamarinmac20/_._", + "ref/xamarintvos10/_._", + "ref/xamarinwatchos10/_._", + "runtimes/aot/lib/netcore50/System.Diagnostics.StackTrace.dll" + ] + }, + "System.Diagnostics.Tools/4.0.1": { + "sha512": "xBfJ8pnd4C17dWaC9FM6aShzbJcRNMChUMD42I6772KGGrqaFdumwhn9OdM68erj1ueNo3xdQ1EwiFjK5k8p0g==", + "type": "package", + "path": "System.Diagnostics.Tools/4.0.1", + "files": [ + "System.Diagnostics.Tools.4.0.1.nupkg.sha512", + "System.Diagnostics.Tools.nuspec", + "ThirdPartyNotices.txt", + "dotnet_library_license.txt", + "lib/MonoAndroid10/_._", + "lib/MonoTouch10/_._", + "lib/net45/_._", + "lib/portable-net45+win8+wp8+wpa81/_._", + "lib/win8/_._", + "lib/wp80/_._", + "lib/wpa81/_._", + "lib/xamarinios10/_._", + "lib/xamarinmac20/_._", + "lib/xamarintvos10/_._", + "lib/xamarinwatchos10/_._", + "ref/MonoAndroid10/_._", + "ref/MonoTouch10/_._", + "ref/net45/_._", + "ref/netcore50/System.Diagnostics.Tools.dll", + "ref/netcore50/System.Diagnostics.Tools.xml", + "ref/netcore50/de/System.Diagnostics.Tools.xml", + "ref/netcore50/es/System.Diagnostics.Tools.xml", + "ref/netcore50/fr/System.Diagnostics.Tools.xml", + "ref/netcore50/it/System.Diagnostics.Tools.xml", + "ref/netcore50/ja/System.Diagnostics.Tools.xml", + "ref/netcore50/ko/System.Diagnostics.Tools.xml", + "ref/netcore50/ru/System.Diagnostics.Tools.xml", + "ref/netcore50/zh-hans/System.Diagnostics.Tools.xml", + "ref/netcore50/zh-hant/System.Diagnostics.Tools.xml", + "ref/netstandard1.0/System.Diagnostics.Tools.dll", + "ref/netstandard1.0/System.Diagnostics.Tools.xml", + "ref/netstandard1.0/de/System.Diagnostics.Tools.xml", + "ref/netstandard1.0/es/System.Diagnostics.Tools.xml", + "ref/netstandard1.0/fr/System.Diagnostics.Tools.xml", + "ref/netstandard1.0/it/System.Diagnostics.Tools.xml", + "ref/netstandard1.0/ja/System.Diagnostics.Tools.xml", + "ref/netstandard1.0/ko/System.Diagnostics.Tools.xml", + "ref/netstandard1.0/ru/System.Diagnostics.Tools.xml", + "ref/netstandard1.0/zh-hans/System.Diagnostics.Tools.xml", + "ref/netstandard1.0/zh-hant/System.Diagnostics.Tools.xml", + "ref/portable-net45+win8+wp8+wpa81/_._", + "ref/win8/_._", + "ref/wp80/_._", + "ref/wpa81/_._", + "ref/xamarinios10/_._", + "ref/xamarinmac20/_._", + "ref/xamarintvos10/_._", + "ref/xamarinwatchos10/_._" + ] + }, + "System.Diagnostics.Tracing/4.1.0": { + "sha512": "vDN1PoMZCkkdNjvZLql592oYJZgS7URcJzJ7bxeBgGtx5UtR5leNm49VmfHGqIffX4FKacHbI3H6UyNSHQknBg==", + "type": "package", + "path": "System.Diagnostics.Tracing/4.1.0", + "files": [ + "System.Diagnostics.Tracing.4.1.0.nupkg.sha512", + "System.Diagnostics.Tracing.nuspec", + "ThirdPartyNotices.txt", + "dotnet_library_license.txt", + "lib/MonoAndroid10/_._", + "lib/MonoTouch10/_._", + "lib/net45/_._", + "lib/net462/System.Diagnostics.Tracing.dll", + "lib/portable-net45+win8+wpa81/_._", + "lib/win8/_._", + "lib/wpa81/_._", + "lib/xamarinios10/_._", + "lib/xamarinmac20/_._", + "lib/xamarintvos10/_._", + "lib/xamarinwatchos10/_._", + "ref/MonoAndroid10/_._", + "ref/MonoTouch10/_._", + "ref/net45/_._", + "ref/net462/System.Diagnostics.Tracing.dll", + "ref/netcore50/System.Diagnostics.Tracing.dll", + "ref/netcore50/System.Diagnostics.Tracing.xml", + "ref/netcore50/de/System.Diagnostics.Tracing.xml", + "ref/netcore50/es/System.Diagnostics.Tracing.xml", + "ref/netcore50/fr/System.Diagnostics.Tracing.xml", + "ref/netcore50/it/System.Diagnostics.Tracing.xml", + "ref/netcore50/ja/System.Diagnostics.Tracing.xml", + "ref/netcore50/ko/System.Diagnostics.Tracing.xml", + "ref/netcore50/ru/System.Diagnostics.Tracing.xml", + "ref/netcore50/zh-hans/System.Diagnostics.Tracing.xml", + "ref/netcore50/zh-hant/System.Diagnostics.Tracing.xml", + "ref/netstandard1.1/System.Diagnostics.Tracing.dll", + "ref/netstandard1.1/System.Diagnostics.Tracing.xml", + "ref/netstandard1.1/de/System.Diagnostics.Tracing.xml", + "ref/netstandard1.1/es/System.Diagnostics.Tracing.xml", + "ref/netstandard1.1/fr/System.Diagnostics.Tracing.xml", + "ref/netstandard1.1/it/System.Diagnostics.Tracing.xml", + "ref/netstandard1.1/ja/System.Diagnostics.Tracing.xml", + "ref/netstandard1.1/ko/System.Diagnostics.Tracing.xml", + "ref/netstandard1.1/ru/System.Diagnostics.Tracing.xml", + "ref/netstandard1.1/zh-hans/System.Diagnostics.Tracing.xml", + "ref/netstandard1.1/zh-hant/System.Diagnostics.Tracing.xml", + "ref/netstandard1.2/System.Diagnostics.Tracing.dll", + "ref/netstandard1.2/System.Diagnostics.Tracing.xml", + "ref/netstandard1.2/de/System.Diagnostics.Tracing.xml", + "ref/netstandard1.2/es/System.Diagnostics.Tracing.xml", + "ref/netstandard1.2/fr/System.Diagnostics.Tracing.xml", + "ref/netstandard1.2/it/System.Diagnostics.Tracing.xml", + "ref/netstandard1.2/ja/System.Diagnostics.Tracing.xml", + "ref/netstandard1.2/ko/System.Diagnostics.Tracing.xml", + "ref/netstandard1.2/ru/System.Diagnostics.Tracing.xml", + "ref/netstandard1.2/zh-hans/System.Diagnostics.Tracing.xml", + "ref/netstandard1.2/zh-hant/System.Diagnostics.Tracing.xml", + "ref/netstandard1.3/System.Diagnostics.Tracing.dll", + "ref/netstandard1.3/System.Diagnostics.Tracing.xml", + "ref/netstandard1.3/de/System.Diagnostics.Tracing.xml", + "ref/netstandard1.3/es/System.Diagnostics.Tracing.xml", + "ref/netstandard1.3/fr/System.Diagnostics.Tracing.xml", + "ref/netstandard1.3/it/System.Diagnostics.Tracing.xml", + "ref/netstandard1.3/ja/System.Diagnostics.Tracing.xml", + "ref/netstandard1.3/ko/System.Diagnostics.Tracing.xml", + "ref/netstandard1.3/ru/System.Diagnostics.Tracing.xml", + "ref/netstandard1.3/zh-hans/System.Diagnostics.Tracing.xml", + "ref/netstandard1.3/zh-hant/System.Diagnostics.Tracing.xml", + "ref/netstandard1.5/System.Diagnostics.Tracing.dll", + "ref/netstandard1.5/System.Diagnostics.Tracing.xml", + "ref/netstandard1.5/de/System.Diagnostics.Tracing.xml", + "ref/netstandard1.5/es/System.Diagnostics.Tracing.xml", + "ref/netstandard1.5/fr/System.Diagnostics.Tracing.xml", + "ref/netstandard1.5/it/System.Diagnostics.Tracing.xml", + "ref/netstandard1.5/ja/System.Diagnostics.Tracing.xml", + "ref/netstandard1.5/ko/System.Diagnostics.Tracing.xml", + "ref/netstandard1.5/ru/System.Diagnostics.Tracing.xml", + "ref/netstandard1.5/zh-hans/System.Diagnostics.Tracing.xml", + "ref/netstandard1.5/zh-hant/System.Diagnostics.Tracing.xml", + "ref/portable-net45+win8+wpa81/_._", + "ref/win8/_._", + "ref/wpa81/_._", + "ref/xamarinios10/_._", + "ref/xamarinmac20/_._", + "ref/xamarintvos10/_._", + "ref/xamarinwatchos10/_._" + ] + }, + "System.Dynamic.Runtime/4.0.11": { + "sha512": "db34f6LHYM0U0JpE+sOmjar27BnqTVkbLJhgfwMpTdgTigG/Hna3m2MYVwnFzGGKnEJk2UXFuoVTr8WUbU91/A==", + "type": "package", + "path": "System.Dynamic.Runtime/4.0.11", + "files": [ + "System.Dynamic.Runtime.4.0.11.nupkg.sha512", + "System.Dynamic.Runtime.nuspec", + "ThirdPartyNotices.txt", + "dotnet_library_license.txt", + "lib/MonoAndroid10/_._", + "lib/MonoTouch10/_._", + "lib/net45/_._", + "lib/netcore50/System.Dynamic.Runtime.dll", + "lib/netstandard1.3/System.Dynamic.Runtime.dll", + "lib/portable-net45+win8+wp8+wpa81/_._", + "lib/win8/_._", + "lib/wp80/_._", + "lib/wpa81/_._", + "lib/xamarinios10/_._", + "lib/xamarinmac20/_._", + "lib/xamarintvos10/_._", + "lib/xamarinwatchos10/_._", + "ref/MonoAndroid10/_._", + "ref/MonoTouch10/_._", + "ref/net45/_._", + "ref/netcore50/System.Dynamic.Runtime.dll", + "ref/netcore50/System.Dynamic.Runtime.xml", + "ref/netcore50/de/System.Dynamic.Runtime.xml", + "ref/netcore50/es/System.Dynamic.Runtime.xml", + "ref/netcore50/fr/System.Dynamic.Runtime.xml", + "ref/netcore50/it/System.Dynamic.Runtime.xml", + "ref/netcore50/ja/System.Dynamic.Runtime.xml", + "ref/netcore50/ko/System.Dynamic.Runtime.xml", + "ref/netcore50/ru/System.Dynamic.Runtime.xml", + "ref/netcore50/zh-hans/System.Dynamic.Runtime.xml", + "ref/netcore50/zh-hant/System.Dynamic.Runtime.xml", + "ref/netstandard1.0/System.Dynamic.Runtime.dll", + "ref/netstandard1.0/System.Dynamic.Runtime.xml", + "ref/netstandard1.0/de/System.Dynamic.Runtime.xml", + "ref/netstandard1.0/es/System.Dynamic.Runtime.xml", + "ref/netstandard1.0/fr/System.Dynamic.Runtime.xml", + "ref/netstandard1.0/it/System.Dynamic.Runtime.xml", + "ref/netstandard1.0/ja/System.Dynamic.Runtime.xml", + "ref/netstandard1.0/ko/System.Dynamic.Runtime.xml", + "ref/netstandard1.0/ru/System.Dynamic.Runtime.xml", + "ref/netstandard1.0/zh-hans/System.Dynamic.Runtime.xml", + "ref/netstandard1.0/zh-hant/System.Dynamic.Runtime.xml", + "ref/netstandard1.3/System.Dynamic.Runtime.dll", + "ref/netstandard1.3/System.Dynamic.Runtime.xml", + "ref/netstandard1.3/de/System.Dynamic.Runtime.xml", + "ref/netstandard1.3/es/System.Dynamic.Runtime.xml", + "ref/netstandard1.3/fr/System.Dynamic.Runtime.xml", + "ref/netstandard1.3/it/System.Dynamic.Runtime.xml", + "ref/netstandard1.3/ja/System.Dynamic.Runtime.xml", + "ref/netstandard1.3/ko/System.Dynamic.Runtime.xml", + "ref/netstandard1.3/ru/System.Dynamic.Runtime.xml", + "ref/netstandard1.3/zh-hans/System.Dynamic.Runtime.xml", + "ref/netstandard1.3/zh-hant/System.Dynamic.Runtime.xml", + "ref/portable-net45+win8+wp8+wpa81/_._", + "ref/win8/_._", + "ref/wp80/_._", + "ref/wpa81/_._", + "ref/xamarinios10/_._", + "ref/xamarinmac20/_._", + "ref/xamarintvos10/_._", + "ref/xamarinwatchos10/_._", + "runtimes/aot/lib/netcore50/System.Dynamic.Runtime.dll" + ] + }, + "System.Globalization/4.0.11": { + "sha512": "B95h0YLEL2oSnwF/XjqSWKnwKOy/01VWkNlsCeMTFJLLabflpGV26nK164eRs5GiaRSBGpOxQ3pKoSnnyZN5pg==", + "type": "package", + "path": "System.Globalization/4.0.11", + "files": [ + "System.Globalization.4.0.11.nupkg.sha512", + "System.Globalization.nuspec", + "ThirdPartyNotices.txt", + "dotnet_library_license.txt", + "lib/MonoAndroid10/_._", + "lib/MonoTouch10/_._", + "lib/net45/_._", + "lib/portable-net45+win8+wp8+wpa81/_._", + "lib/win8/_._", + "lib/wp80/_._", + "lib/wpa81/_._", + "lib/xamarinios10/_._", + "lib/xamarinmac20/_._", + "lib/xamarintvos10/_._", + "lib/xamarinwatchos10/_._", + "ref/MonoAndroid10/_._", + "ref/MonoTouch10/_._", + "ref/net45/_._", + "ref/netcore50/System.Globalization.dll", + "ref/netcore50/System.Globalization.xml", + "ref/netcore50/de/System.Globalization.xml", + "ref/netcore50/es/System.Globalization.xml", + "ref/netcore50/fr/System.Globalization.xml", + "ref/netcore50/it/System.Globalization.xml", + "ref/netcore50/ja/System.Globalization.xml", + "ref/netcore50/ko/System.Globalization.xml", + "ref/netcore50/ru/System.Globalization.xml", + "ref/netcore50/zh-hans/System.Globalization.xml", + "ref/netcore50/zh-hant/System.Globalization.xml", + "ref/netstandard1.0/System.Globalization.dll", + "ref/netstandard1.0/System.Globalization.xml", + "ref/netstandard1.0/de/System.Globalization.xml", + "ref/netstandard1.0/es/System.Globalization.xml", + "ref/netstandard1.0/fr/System.Globalization.xml", + "ref/netstandard1.0/it/System.Globalization.xml", + "ref/netstandard1.0/ja/System.Globalization.xml", + "ref/netstandard1.0/ko/System.Globalization.xml", + "ref/netstandard1.0/ru/System.Globalization.xml", + "ref/netstandard1.0/zh-hans/System.Globalization.xml", + "ref/netstandard1.0/zh-hant/System.Globalization.xml", + "ref/netstandard1.3/System.Globalization.dll", + "ref/netstandard1.3/System.Globalization.xml", + "ref/netstandard1.3/de/System.Globalization.xml", + "ref/netstandard1.3/es/System.Globalization.xml", + "ref/netstandard1.3/fr/System.Globalization.xml", + "ref/netstandard1.3/it/System.Globalization.xml", + "ref/netstandard1.3/ja/System.Globalization.xml", + "ref/netstandard1.3/ko/System.Globalization.xml", + "ref/netstandard1.3/ru/System.Globalization.xml", + "ref/netstandard1.3/zh-hans/System.Globalization.xml", + "ref/netstandard1.3/zh-hant/System.Globalization.xml", + "ref/portable-net45+win8+wp8+wpa81/_._", + "ref/win8/_._", + "ref/wp80/_._", + "ref/wpa81/_._", + "ref/xamarinios10/_._", + "ref/xamarinmac20/_._", + "ref/xamarintvos10/_._", + "ref/xamarinwatchos10/_._" + ] + }, + "System.Globalization.Calendars/4.0.1": { + "sha512": "L1c6IqeQ88vuzC1P81JeHmHA8mxq8a18NUBNXnIY/BVb+TCyAaGIFbhpZt60h9FJNmisymoQkHEFSE9Vslja1Q==", + "type": "package", + "path": "System.Globalization.Calendars/4.0.1", + "files": [ + "System.Globalization.Calendars.4.0.1.nupkg.sha512", + "System.Globalization.Calendars.nuspec", + "ThirdPartyNotices.txt", + "dotnet_library_license.txt", + "lib/MonoAndroid10/_._", + "lib/MonoTouch10/_._", + "lib/net46/System.Globalization.Calendars.dll", + "lib/xamarinios10/_._", + "lib/xamarinmac20/_._", + "lib/xamarintvos10/_._", + "lib/xamarinwatchos10/_._", + "ref/MonoAndroid10/_._", + "ref/MonoTouch10/_._", + "ref/net46/System.Globalization.Calendars.dll", + "ref/netstandard1.3/System.Globalization.Calendars.dll", + "ref/netstandard1.3/System.Globalization.Calendars.xml", + "ref/netstandard1.3/de/System.Globalization.Calendars.xml", + "ref/netstandard1.3/es/System.Globalization.Calendars.xml", + "ref/netstandard1.3/fr/System.Globalization.Calendars.xml", + "ref/netstandard1.3/it/System.Globalization.Calendars.xml", + "ref/netstandard1.3/ja/System.Globalization.Calendars.xml", + "ref/netstandard1.3/ko/System.Globalization.Calendars.xml", + "ref/netstandard1.3/ru/System.Globalization.Calendars.xml", + "ref/netstandard1.3/zh-hans/System.Globalization.Calendars.xml", + "ref/netstandard1.3/zh-hant/System.Globalization.Calendars.xml", + "ref/xamarinios10/_._", + "ref/xamarinmac20/_._", + "ref/xamarintvos10/_._", + "ref/xamarinwatchos10/_._" + ] + }, + "System.Globalization.Extensions/4.0.1": { + "sha512": "KKo23iKeOaIg61SSXwjANN7QYDr/3op3OWGGzDzz7mypx0Za0fZSeG0l6cco8Ntp8YMYkIQcAqlk8yhm5/Uhcg==", + "type": "package", + "path": "System.Globalization.Extensions/4.0.1", + "files": [ + "System.Globalization.Extensions.4.0.1.nupkg.sha512", + "System.Globalization.Extensions.nuspec", + "ThirdPartyNotices.txt", + "dotnet_library_license.txt", + "lib/MonoAndroid10/_._", + "lib/MonoTouch10/_._", + "lib/net46/System.Globalization.Extensions.dll", + "lib/xamarinios10/_._", + "lib/xamarinmac20/_._", + "lib/xamarintvos10/_._", + "lib/xamarinwatchos10/_._", + "ref/MonoAndroid10/_._", + "ref/MonoTouch10/_._", + "ref/net46/System.Globalization.Extensions.dll", + "ref/netstandard1.3/System.Globalization.Extensions.dll", + "ref/netstandard1.3/System.Globalization.Extensions.xml", + "ref/netstandard1.3/de/System.Globalization.Extensions.xml", + "ref/netstandard1.3/es/System.Globalization.Extensions.xml", + "ref/netstandard1.3/fr/System.Globalization.Extensions.xml", + "ref/netstandard1.3/it/System.Globalization.Extensions.xml", + "ref/netstandard1.3/ja/System.Globalization.Extensions.xml", + "ref/netstandard1.3/ko/System.Globalization.Extensions.xml", + "ref/netstandard1.3/ru/System.Globalization.Extensions.xml", + "ref/netstandard1.3/zh-hans/System.Globalization.Extensions.xml", + "ref/netstandard1.3/zh-hant/System.Globalization.Extensions.xml", + "ref/xamarinios10/_._", + "ref/xamarinmac20/_._", + "ref/xamarintvos10/_._", + "ref/xamarinwatchos10/_._", + "runtimes/unix/lib/netstandard1.3/System.Globalization.Extensions.dll", + "runtimes/win/lib/net46/System.Globalization.Extensions.dll", + "runtimes/win/lib/netstandard1.3/System.Globalization.Extensions.dll" + ] + }, + "System.IO/4.1.0": { + "sha512": "3KlTJceQc3gnGIaHZ7UBZO26SHL1SHE4ddrmiwumFnId+CEHP+O8r386tZKaE6zlk5/mF8vifMBzHj9SaXN+mQ==", + "type": "package", + "path": "System.IO/4.1.0", + "files": [ + "System.IO.4.1.0.nupkg.sha512", + "System.IO.nuspec", + "ThirdPartyNotices.txt", + "dotnet_library_license.txt", + "lib/MonoAndroid10/_._", + "lib/MonoTouch10/_._", + "lib/net45/_._", + "lib/net462/System.IO.dll", + "lib/portable-net45+win8+wp8+wpa81/_._", + "lib/win8/_._", + "lib/wp80/_._", + "lib/wpa81/_._", + "lib/xamarinios10/_._", + "lib/xamarinmac20/_._", + "lib/xamarintvos10/_._", + "lib/xamarinwatchos10/_._", + "ref/MonoAndroid10/_._", + "ref/MonoTouch10/_._", + "ref/net45/_._", + "ref/net462/System.IO.dll", + "ref/netcore50/System.IO.dll", + "ref/netcore50/System.IO.xml", + "ref/netcore50/de/System.IO.xml", + "ref/netcore50/es/System.IO.xml", + "ref/netcore50/fr/System.IO.xml", + "ref/netcore50/it/System.IO.xml", + "ref/netcore50/ja/System.IO.xml", + "ref/netcore50/ko/System.IO.xml", + "ref/netcore50/ru/System.IO.xml", + "ref/netcore50/zh-hans/System.IO.xml", + "ref/netcore50/zh-hant/System.IO.xml", + "ref/netstandard1.0/System.IO.dll", + "ref/netstandard1.0/System.IO.xml", + "ref/netstandard1.0/de/System.IO.xml", + "ref/netstandard1.0/es/System.IO.xml", + "ref/netstandard1.0/fr/System.IO.xml", + "ref/netstandard1.0/it/System.IO.xml", + "ref/netstandard1.0/ja/System.IO.xml", + "ref/netstandard1.0/ko/System.IO.xml", + "ref/netstandard1.0/ru/System.IO.xml", + "ref/netstandard1.0/zh-hans/System.IO.xml", + "ref/netstandard1.0/zh-hant/System.IO.xml", + "ref/netstandard1.3/System.IO.dll", + "ref/netstandard1.3/System.IO.xml", + "ref/netstandard1.3/de/System.IO.xml", + "ref/netstandard1.3/es/System.IO.xml", + "ref/netstandard1.3/fr/System.IO.xml", + "ref/netstandard1.3/it/System.IO.xml", + "ref/netstandard1.3/ja/System.IO.xml", + "ref/netstandard1.3/ko/System.IO.xml", + "ref/netstandard1.3/ru/System.IO.xml", + "ref/netstandard1.3/zh-hans/System.IO.xml", + "ref/netstandard1.3/zh-hant/System.IO.xml", + "ref/netstandard1.5/System.IO.dll", + "ref/netstandard1.5/System.IO.xml", + "ref/netstandard1.5/de/System.IO.xml", + "ref/netstandard1.5/es/System.IO.xml", + "ref/netstandard1.5/fr/System.IO.xml", + "ref/netstandard1.5/it/System.IO.xml", + "ref/netstandard1.5/ja/System.IO.xml", + "ref/netstandard1.5/ko/System.IO.xml", + "ref/netstandard1.5/ru/System.IO.xml", + "ref/netstandard1.5/zh-hans/System.IO.xml", + "ref/netstandard1.5/zh-hant/System.IO.xml", + "ref/portable-net45+win8+wp8+wpa81/_._", + "ref/win8/_._", + "ref/wp80/_._", + "ref/wpa81/_._", + "ref/xamarinios10/_._", + "ref/xamarinmac20/_._", + "ref/xamarintvos10/_._", + "ref/xamarinwatchos10/_._" + ] + }, + "System.IO.Compression/4.1.0": { + "sha512": "TjnBS6eztThSzeSib+WyVbLzEdLKUcEHN69VtS3u8aAsSc18FU6xCZlNWWsEd8SKcXAE+y1sOu7VbU8sUeM0sg==", + "type": "package", + "path": "System.IO.Compression/4.1.0", + "files": [ + "System.IO.Compression.4.1.0.nupkg.sha512", + "System.IO.Compression.nuspec", + "ThirdPartyNotices.txt", + "dotnet_library_license.txt", + "lib/MonoAndroid10/_._", + "lib/MonoTouch10/_._", + "lib/net45/_._", + "lib/net46/System.IO.Compression.dll", + "lib/portable-net45+win8+wpa81/_._", + "lib/win8/_._", + "lib/wpa81/_._", + "lib/xamarinios10/_._", + "lib/xamarinmac20/_._", + "lib/xamarintvos10/_._", + "lib/xamarinwatchos10/_._", + "ref/MonoAndroid10/_._", + "ref/MonoTouch10/_._", + "ref/net45/_._", + "ref/net46/System.IO.Compression.dll", + "ref/netcore50/System.IO.Compression.dll", + "ref/netcore50/System.IO.Compression.xml", + "ref/netcore50/de/System.IO.Compression.xml", + "ref/netcore50/es/System.IO.Compression.xml", + "ref/netcore50/fr/System.IO.Compression.xml", + "ref/netcore50/it/System.IO.Compression.xml", + "ref/netcore50/ja/System.IO.Compression.xml", + "ref/netcore50/ko/System.IO.Compression.xml", + "ref/netcore50/ru/System.IO.Compression.xml", + "ref/netcore50/zh-hans/System.IO.Compression.xml", + "ref/netcore50/zh-hant/System.IO.Compression.xml", + "ref/netstandard1.1/System.IO.Compression.dll", + "ref/netstandard1.1/System.IO.Compression.xml", + "ref/netstandard1.1/de/System.IO.Compression.xml", + "ref/netstandard1.1/es/System.IO.Compression.xml", + "ref/netstandard1.1/fr/System.IO.Compression.xml", + "ref/netstandard1.1/it/System.IO.Compression.xml", + "ref/netstandard1.1/ja/System.IO.Compression.xml", + "ref/netstandard1.1/ko/System.IO.Compression.xml", + "ref/netstandard1.1/ru/System.IO.Compression.xml", + "ref/netstandard1.1/zh-hans/System.IO.Compression.xml", + "ref/netstandard1.1/zh-hant/System.IO.Compression.xml", + "ref/netstandard1.3/System.IO.Compression.dll", + "ref/netstandard1.3/System.IO.Compression.xml", + "ref/netstandard1.3/de/System.IO.Compression.xml", + "ref/netstandard1.3/es/System.IO.Compression.xml", + "ref/netstandard1.3/fr/System.IO.Compression.xml", + "ref/netstandard1.3/it/System.IO.Compression.xml", + "ref/netstandard1.3/ja/System.IO.Compression.xml", + "ref/netstandard1.3/ko/System.IO.Compression.xml", + "ref/netstandard1.3/ru/System.IO.Compression.xml", + "ref/netstandard1.3/zh-hans/System.IO.Compression.xml", + "ref/netstandard1.3/zh-hant/System.IO.Compression.xml", + "ref/portable-net45+win8+wpa81/_._", + "ref/win8/_._", + "ref/wpa81/_._", + "ref/xamarinios10/_._", + "ref/xamarinmac20/_._", + "ref/xamarintvos10/_._", + "ref/xamarinwatchos10/_._", + "runtimes/unix/lib/netstandard1.3/System.IO.Compression.dll", + "runtimes/win/lib/net46/System.IO.Compression.dll", + "runtimes/win/lib/netstandard1.3/System.IO.Compression.dll" + ] + }, + "System.IO.Compression.ZipFile/4.0.1": { + "sha512": "hBQYJzfTbQURF10nLhd+az2NHxsU6MU7AB8RUf4IolBP5lOAm4Luho851xl+CqslmhI5ZH/el8BlngEk4lBkaQ==", + "type": "package", + "path": "System.IO.Compression.ZipFile/4.0.1", + "files": [ + "System.IO.Compression.ZipFile.4.0.1.nupkg.sha512", + "System.IO.Compression.ZipFile.nuspec", + "ThirdPartyNotices.txt", + "dotnet_library_license.txt", + "lib/MonoAndroid10/_._", + "lib/MonoTouch10/_._", + "lib/net46/System.IO.Compression.ZipFile.dll", + "lib/netstandard1.3/System.IO.Compression.ZipFile.dll", + "lib/xamarinios10/_._", + "lib/xamarinmac20/_._", + "lib/xamarintvos10/_._", + "lib/xamarinwatchos10/_._", + "ref/MonoAndroid10/_._", + "ref/MonoTouch10/_._", + "ref/net46/System.IO.Compression.ZipFile.dll", + "ref/netstandard1.3/System.IO.Compression.ZipFile.dll", + "ref/netstandard1.3/System.IO.Compression.ZipFile.xml", + "ref/netstandard1.3/de/System.IO.Compression.ZipFile.xml", + "ref/netstandard1.3/es/System.IO.Compression.ZipFile.xml", + "ref/netstandard1.3/fr/System.IO.Compression.ZipFile.xml", + "ref/netstandard1.3/it/System.IO.Compression.ZipFile.xml", + "ref/netstandard1.3/ja/System.IO.Compression.ZipFile.xml", + "ref/netstandard1.3/ko/System.IO.Compression.ZipFile.xml", + "ref/netstandard1.3/ru/System.IO.Compression.ZipFile.xml", + "ref/netstandard1.3/zh-hans/System.IO.Compression.ZipFile.xml", + "ref/netstandard1.3/zh-hant/System.IO.Compression.ZipFile.xml", + "ref/xamarinios10/_._", + "ref/xamarinmac20/_._", + "ref/xamarintvos10/_._", + "ref/xamarinwatchos10/_._" + ] + }, + "System.IO.FileSystem/4.0.1": { + "sha512": "IBErlVq5jOggAD69bg1t0pJcHaDbJbWNUZTPI96fkYWzwYbN6D9wRHMULLDd9dHsl7C2YsxXL31LMfPI1SWt8w==", + "type": "package", + "path": "System.IO.FileSystem/4.0.1", + "files": [ + "System.IO.FileSystem.4.0.1.nupkg.sha512", + "System.IO.FileSystem.nuspec", + "ThirdPartyNotices.txt", + "dotnet_library_license.txt", + "lib/MonoAndroid10/_._", + "lib/MonoTouch10/_._", + "lib/net46/System.IO.FileSystem.dll", + "lib/xamarinios10/_._", + "lib/xamarinmac20/_._", + "lib/xamarintvos10/_._", + "lib/xamarinwatchos10/_._", + "ref/MonoAndroid10/_._", + "ref/MonoTouch10/_._", + "ref/net46/System.IO.FileSystem.dll", + "ref/netstandard1.3/System.IO.FileSystem.dll", + "ref/netstandard1.3/System.IO.FileSystem.xml", + "ref/netstandard1.3/de/System.IO.FileSystem.xml", + "ref/netstandard1.3/es/System.IO.FileSystem.xml", + "ref/netstandard1.3/fr/System.IO.FileSystem.xml", + "ref/netstandard1.3/it/System.IO.FileSystem.xml", + "ref/netstandard1.3/ja/System.IO.FileSystem.xml", + "ref/netstandard1.3/ko/System.IO.FileSystem.xml", + "ref/netstandard1.3/ru/System.IO.FileSystem.xml", + "ref/netstandard1.3/zh-hans/System.IO.FileSystem.xml", + "ref/netstandard1.3/zh-hant/System.IO.FileSystem.xml", + "ref/xamarinios10/_._", + "ref/xamarinmac20/_._", + "ref/xamarintvos10/_._", + "ref/xamarinwatchos10/_._" + ] + }, + "System.IO.FileSystem.Primitives/4.0.1": { + "sha512": "kWkKD203JJKxJeE74p8aF8y4Qc9r9WQx4C0cHzHPrY3fv/L/IhWnyCHaFJ3H1QPOH6A93whlQ2vG5nHlBDvzWQ==", + "type": "package", + "path": "System.IO.FileSystem.Primitives/4.0.1", + "files": [ + "System.IO.FileSystem.Primitives.4.0.1.nupkg.sha512", + "System.IO.FileSystem.Primitives.nuspec", + "ThirdPartyNotices.txt", + "dotnet_library_license.txt", + "lib/MonoAndroid10/_._", + "lib/MonoTouch10/_._", + "lib/net46/System.IO.FileSystem.Primitives.dll", + "lib/netstandard1.3/System.IO.FileSystem.Primitives.dll", + "lib/xamarinios10/_._", + "lib/xamarinmac20/_._", + "lib/xamarintvos10/_._", + "lib/xamarinwatchos10/_._", + "ref/MonoAndroid10/_._", + "ref/MonoTouch10/_._", + "ref/net46/System.IO.FileSystem.Primitives.dll", + "ref/netstandard1.3/System.IO.FileSystem.Primitives.dll", + "ref/netstandard1.3/System.IO.FileSystem.Primitives.xml", + "ref/netstandard1.3/de/System.IO.FileSystem.Primitives.xml", + "ref/netstandard1.3/es/System.IO.FileSystem.Primitives.xml", + "ref/netstandard1.3/fr/System.IO.FileSystem.Primitives.xml", + "ref/netstandard1.3/it/System.IO.FileSystem.Primitives.xml", + "ref/netstandard1.3/ja/System.IO.FileSystem.Primitives.xml", + "ref/netstandard1.3/ko/System.IO.FileSystem.Primitives.xml", + "ref/netstandard1.3/ru/System.IO.FileSystem.Primitives.xml", + "ref/netstandard1.3/zh-hans/System.IO.FileSystem.Primitives.xml", + "ref/netstandard1.3/zh-hant/System.IO.FileSystem.Primitives.xml", + "ref/xamarinios10/_._", + "ref/xamarinmac20/_._", + "ref/xamarintvos10/_._", + "ref/xamarinwatchos10/_._" + ] + }, + "System.IO.FileSystem.Watcher/4.0.0": { + "sha512": "qM4Wr3La+RYb/03B0mZZjbA7tHsGzDffnuXP8Sl48HW2JwCjn3kfD5qdw0sqyNNowUipcJMi9/q6sMUrOIJ6UQ==", + "type": "package", + "path": "System.IO.FileSystem.Watcher/4.0.0", + "files": [ + "System.IO.FileSystem.Watcher.4.0.0.nupkg.sha512", + "System.IO.FileSystem.Watcher.nuspec", + "ThirdPartyNotices.txt", + "dotnet_library_license.txt", + "lib/MonoAndroid10/_._", + "lib/MonoTouch10/_._", + "lib/net46/System.IO.FileSystem.Watcher.dll", + "lib/xamarinios10/_._", + "lib/xamarinmac20/_._", + "lib/xamarintvos10/_._", + "lib/xamarinwatchos10/_._", + "ref/MonoAndroid10/_._", + "ref/MonoTouch10/_._", + "ref/net46/System.IO.FileSystem.Watcher.dll", + "ref/netstandard1.3/System.IO.FileSystem.Watcher.dll", + "ref/netstandard1.3/System.IO.FileSystem.Watcher.xml", + "ref/netstandard1.3/de/System.IO.FileSystem.Watcher.xml", + "ref/netstandard1.3/es/System.IO.FileSystem.Watcher.xml", + "ref/netstandard1.3/fr/System.IO.FileSystem.Watcher.xml", + "ref/netstandard1.3/it/System.IO.FileSystem.Watcher.xml", + "ref/netstandard1.3/ja/System.IO.FileSystem.Watcher.xml", + "ref/netstandard1.3/ko/System.IO.FileSystem.Watcher.xml", + "ref/netstandard1.3/ru/System.IO.FileSystem.Watcher.xml", + "ref/netstandard1.3/zh-hans/System.IO.FileSystem.Watcher.xml", + "ref/netstandard1.3/zh-hant/System.IO.FileSystem.Watcher.xml", + "ref/xamarinios10/_._", + "ref/xamarinmac20/_._", + "ref/xamarintvos10/_._", + "ref/xamarinwatchos10/_._", + "runtimes/linux/lib/netstandard1.3/System.IO.FileSystem.Watcher.dll", + "runtimes/osx/lib/netstandard1.3/System.IO.FileSystem.Watcher.dll", + "runtimes/win/lib/net46/System.IO.FileSystem.Watcher.dll", + "runtimes/win/lib/netstandard1.3/System.IO.FileSystem.Watcher.dll", + "runtimes/win7/lib/netcore50/_._" + ] + }, + "System.IO.MemoryMappedFiles/4.0.0": { + "sha512": "kdtr1LyxvXDhaNuq3xJ8DwkxWZphx7EPwOt2pmqn0NkbAJoWTPinD/CztojuVC/e1DEP/4MEiOSySBb6fKIr5A==", + "type": "package", + "path": "System.IO.MemoryMappedFiles/4.0.0", + "files": [ + "System.IO.MemoryMappedFiles.4.0.0.nupkg.sha512", + "System.IO.MemoryMappedFiles.nuspec", + "ThirdPartyNotices.txt", + "dotnet_library_license.txt", + "lib/MonoAndroid10/_._", + "lib/MonoTouch10/_._", + "lib/net46/System.IO.MemoryMappedFiles.dll", + "lib/xamarinios10/_._", + "lib/xamarinmac20/_._", + "lib/xamarintvos10/_._", + "lib/xamarinwatchos10/_._", + "ref/MonoAndroid10/_._", + "ref/MonoTouch10/_._", + "ref/net46/System.IO.MemoryMappedFiles.dll", + "ref/netstandard1.3/System.IO.MemoryMappedFiles.dll", + "ref/netstandard1.3/System.IO.MemoryMappedFiles.xml", + "ref/netstandard1.3/de/System.IO.MemoryMappedFiles.xml", + "ref/netstandard1.3/es/System.IO.MemoryMappedFiles.xml", + "ref/netstandard1.3/fr/System.IO.MemoryMappedFiles.xml", + "ref/netstandard1.3/it/System.IO.MemoryMappedFiles.xml", + "ref/netstandard1.3/ja/System.IO.MemoryMappedFiles.xml", + "ref/netstandard1.3/ko/System.IO.MemoryMappedFiles.xml", + "ref/netstandard1.3/ru/System.IO.MemoryMappedFiles.xml", + "ref/netstandard1.3/zh-hans/System.IO.MemoryMappedFiles.xml", + "ref/netstandard1.3/zh-hant/System.IO.MemoryMappedFiles.xml", + "ref/xamarinios10/_._", + "ref/xamarinmac20/_._", + "ref/xamarintvos10/_._", + "ref/xamarinwatchos10/_._", + "runtimes/unix/lib/netstandard1.3/System.IO.MemoryMappedFiles.dll", + "runtimes/win/lib/net46/System.IO.MemoryMappedFiles.dll", + "runtimes/win/lib/netcore50/System.IO.MemoryMappedFiles.dll", + "runtimes/win/lib/netstandard1.3/System.IO.MemoryMappedFiles.dll" + ] + }, + "System.IO.UnmanagedMemoryStream/4.0.1": { + "sha512": "cAHzctNmveIdCmh4KjVfgwSidsILIOQ4jkzBRZy0Vd9RRm97e3ehB9BrDXi9u7FHuNOb96+0ub1afmyPJZyvfw==", + "type": "package", + "path": "System.IO.UnmanagedMemoryStream/4.0.1", + "files": [ + "System.IO.UnmanagedMemoryStream.4.0.1.nupkg.sha512", + "System.IO.UnmanagedMemoryStream.nuspec", + "ThirdPartyNotices.txt", + "dotnet_library_license.txt", + "lib/MonoAndroid10/_._", + "lib/MonoTouch10/_._", + "lib/net46/System.IO.UnmanagedMemoryStream.dll", + "lib/netstandard1.3/System.IO.UnmanagedMemoryStream.dll", + "lib/xamarinios10/_._", + "lib/xamarinmac20/_._", + "lib/xamarintvos10/_._", + "lib/xamarinwatchos10/_._", + "ref/MonoAndroid10/_._", + "ref/MonoTouch10/_._", + "ref/net46/System.IO.UnmanagedMemoryStream.dll", + "ref/netstandard1.3/System.IO.UnmanagedMemoryStream.dll", + "ref/netstandard1.3/System.IO.UnmanagedMemoryStream.xml", + "ref/netstandard1.3/de/System.IO.UnmanagedMemoryStream.xml", + "ref/netstandard1.3/es/System.IO.UnmanagedMemoryStream.xml", + "ref/netstandard1.3/fr/System.IO.UnmanagedMemoryStream.xml", + "ref/netstandard1.3/it/System.IO.UnmanagedMemoryStream.xml", + "ref/netstandard1.3/ja/System.IO.UnmanagedMemoryStream.xml", + "ref/netstandard1.3/ko/System.IO.UnmanagedMemoryStream.xml", + "ref/netstandard1.3/ru/System.IO.UnmanagedMemoryStream.xml", + "ref/netstandard1.3/zh-hans/System.IO.UnmanagedMemoryStream.xml", + "ref/netstandard1.3/zh-hant/System.IO.UnmanagedMemoryStream.xml", + "ref/xamarinios10/_._", + "ref/xamarinmac20/_._", + "ref/xamarintvos10/_._", + "ref/xamarinwatchos10/_._" + ] + }, + "System.Linq/4.1.0": { + "sha512": "bQ0iYFOQI0nuTnt+NQADns6ucV4DUvMdwN6CbkB1yj8i7arTGiTN5eok1kQwdnnNWSDZfIUySQY+J3d5KjWn0g==", + "type": "package", + "path": "System.Linq/4.1.0", + "files": [ + "System.Linq.4.1.0.nupkg.sha512", + "System.Linq.nuspec", + "ThirdPartyNotices.txt", + "dotnet_library_license.txt", + "lib/MonoAndroid10/_._", + "lib/MonoTouch10/_._", + "lib/net45/_._", + "lib/net463/System.Linq.dll", + "lib/netcore50/System.Linq.dll", + "lib/netstandard1.6/System.Linq.dll", + "lib/portable-net45+win8+wp8+wpa81/_._", + "lib/win8/_._", + "lib/wp80/_._", + "lib/wpa81/_._", + "lib/xamarinios10/_._", + "lib/xamarinmac20/_._", + "lib/xamarintvos10/_._", + "lib/xamarinwatchos10/_._", + "ref/MonoAndroid10/_._", + "ref/MonoTouch10/_._", + "ref/net45/_._", + "ref/net463/System.Linq.dll", + "ref/netcore50/System.Linq.dll", + "ref/netcore50/System.Linq.xml", + "ref/netcore50/de/System.Linq.xml", + "ref/netcore50/es/System.Linq.xml", + "ref/netcore50/fr/System.Linq.xml", + "ref/netcore50/it/System.Linq.xml", + "ref/netcore50/ja/System.Linq.xml", + "ref/netcore50/ko/System.Linq.xml", + "ref/netcore50/ru/System.Linq.xml", + "ref/netcore50/zh-hans/System.Linq.xml", + "ref/netcore50/zh-hant/System.Linq.xml", + "ref/netstandard1.0/System.Linq.dll", + "ref/netstandard1.0/System.Linq.xml", + "ref/netstandard1.0/de/System.Linq.xml", + "ref/netstandard1.0/es/System.Linq.xml", + "ref/netstandard1.0/fr/System.Linq.xml", + "ref/netstandard1.0/it/System.Linq.xml", + "ref/netstandard1.0/ja/System.Linq.xml", + "ref/netstandard1.0/ko/System.Linq.xml", + "ref/netstandard1.0/ru/System.Linq.xml", + "ref/netstandard1.0/zh-hans/System.Linq.xml", + "ref/netstandard1.0/zh-hant/System.Linq.xml", + "ref/netstandard1.6/System.Linq.dll", + "ref/netstandard1.6/System.Linq.xml", + "ref/netstandard1.6/de/System.Linq.xml", + "ref/netstandard1.6/es/System.Linq.xml", + "ref/netstandard1.6/fr/System.Linq.xml", + "ref/netstandard1.6/it/System.Linq.xml", + "ref/netstandard1.6/ja/System.Linq.xml", + "ref/netstandard1.6/ko/System.Linq.xml", + "ref/netstandard1.6/ru/System.Linq.xml", + "ref/netstandard1.6/zh-hans/System.Linq.xml", + "ref/netstandard1.6/zh-hant/System.Linq.xml", + "ref/portable-net45+win8+wp8+wpa81/_._", + "ref/win8/_._", + "ref/wp80/_._", + "ref/wpa81/_._", + "ref/xamarinios10/_._", + "ref/xamarinmac20/_._", + "ref/xamarintvos10/_._", + "ref/xamarinwatchos10/_._" + ] + }, + "System.Linq.Expressions/4.1.0": { + "sha512": "I+y02iqkgmCAyfbqOmSDOgqdZQ5tTj80Akm5BPSS8EeB0VGWdy6X1KCoYe8Pk6pwDoAKZUOdLVxnTJcExiv5zw==", + "type": "package", + "path": "System.Linq.Expressions/4.1.0", + "files": [ + "System.Linq.Expressions.4.1.0.nupkg.sha512", + "System.Linq.Expressions.nuspec", + "ThirdPartyNotices.txt", + "dotnet_library_license.txt", + "lib/MonoAndroid10/_._", + "lib/MonoTouch10/_._", + "lib/net45/_._", + "lib/net463/System.Linq.Expressions.dll", + "lib/netcore50/System.Linq.Expressions.dll", + "lib/netstandard1.6/System.Linq.Expressions.dll", + "lib/portable-net45+win8+wp8+wpa81/_._", + "lib/win8/_._", + "lib/wp80/_._", + "lib/wpa81/_._", + "lib/xamarinios10/_._", + "lib/xamarinmac20/_._", + "lib/xamarintvos10/_._", + "lib/xamarinwatchos10/_._", + "ref/MonoAndroid10/_._", + "ref/MonoTouch10/_._", + "ref/net45/_._", + "ref/net463/System.Linq.Expressions.dll", + "ref/netcore50/System.Linq.Expressions.dll", + "ref/netcore50/System.Linq.Expressions.xml", + "ref/netcore50/de/System.Linq.Expressions.xml", + "ref/netcore50/es/System.Linq.Expressions.xml", + "ref/netcore50/fr/System.Linq.Expressions.xml", + "ref/netcore50/it/System.Linq.Expressions.xml", + "ref/netcore50/ja/System.Linq.Expressions.xml", + "ref/netcore50/ko/System.Linq.Expressions.xml", + "ref/netcore50/ru/System.Linq.Expressions.xml", + "ref/netcore50/zh-hans/System.Linq.Expressions.xml", + "ref/netcore50/zh-hant/System.Linq.Expressions.xml", + "ref/netstandard1.0/System.Linq.Expressions.dll", + "ref/netstandard1.0/System.Linq.Expressions.xml", + "ref/netstandard1.0/de/System.Linq.Expressions.xml", + "ref/netstandard1.0/es/System.Linq.Expressions.xml", + "ref/netstandard1.0/fr/System.Linq.Expressions.xml", + "ref/netstandard1.0/it/System.Linq.Expressions.xml", + "ref/netstandard1.0/ja/System.Linq.Expressions.xml", + "ref/netstandard1.0/ko/System.Linq.Expressions.xml", + "ref/netstandard1.0/ru/System.Linq.Expressions.xml", + "ref/netstandard1.0/zh-hans/System.Linq.Expressions.xml", + "ref/netstandard1.0/zh-hant/System.Linq.Expressions.xml", + "ref/netstandard1.3/System.Linq.Expressions.dll", + "ref/netstandard1.3/System.Linq.Expressions.xml", + "ref/netstandard1.3/de/System.Linq.Expressions.xml", + "ref/netstandard1.3/es/System.Linq.Expressions.xml", + "ref/netstandard1.3/fr/System.Linq.Expressions.xml", + "ref/netstandard1.3/it/System.Linq.Expressions.xml", + "ref/netstandard1.3/ja/System.Linq.Expressions.xml", + "ref/netstandard1.3/ko/System.Linq.Expressions.xml", + "ref/netstandard1.3/ru/System.Linq.Expressions.xml", + "ref/netstandard1.3/zh-hans/System.Linq.Expressions.xml", + "ref/netstandard1.3/zh-hant/System.Linq.Expressions.xml", + "ref/netstandard1.6/System.Linq.Expressions.dll", + "ref/netstandard1.6/System.Linq.Expressions.xml", + "ref/netstandard1.6/de/System.Linq.Expressions.xml", + "ref/netstandard1.6/es/System.Linq.Expressions.xml", + "ref/netstandard1.6/fr/System.Linq.Expressions.xml", + "ref/netstandard1.6/it/System.Linq.Expressions.xml", + "ref/netstandard1.6/ja/System.Linq.Expressions.xml", + "ref/netstandard1.6/ko/System.Linq.Expressions.xml", + "ref/netstandard1.6/ru/System.Linq.Expressions.xml", + "ref/netstandard1.6/zh-hans/System.Linq.Expressions.xml", + "ref/netstandard1.6/zh-hant/System.Linq.Expressions.xml", + "ref/portable-net45+win8+wp8+wpa81/_._", + "ref/win8/_._", + "ref/wp80/_._", + "ref/wpa81/_._", + "ref/xamarinios10/_._", + "ref/xamarinmac20/_._", + "ref/xamarintvos10/_._", + "ref/xamarinwatchos10/_._", + "runtimes/aot/lib/netcore50/System.Linq.Expressions.dll" + ] + }, + "System.Linq.Parallel/4.0.1": { + "sha512": "kylfcgGwjSmRYQCThitfnnB1RUJ+VeVbuqKMU22koJUejjFLmnx2l68HrJZz9pxsnTN07chf9HUMyhNMt3U4vg==", + "type": "package", + "path": "System.Linq.Parallel/4.0.1", + "files": [ + "System.Linq.Parallel.4.0.1.nupkg.sha512", + "System.Linq.Parallel.nuspec", + "ThirdPartyNotices.txt", + "dotnet_library_license.txt", + "lib/MonoAndroid10/_._", + "lib/MonoTouch10/_._", + "lib/net45/_._", + "lib/netcore50/System.Linq.Parallel.dll", + "lib/netstandard1.3/System.Linq.Parallel.dll", + "lib/portable-net45+win8+wpa81/_._", + "lib/win8/_._", + "lib/wpa81/_._", + "lib/xamarinios10/_._", + "lib/xamarinmac20/_._", + "lib/xamarintvos10/_._", + "lib/xamarinwatchos10/_._", + "ref/MonoAndroid10/_._", + "ref/MonoTouch10/_._", + "ref/net45/_._", + "ref/netcore50/System.Linq.Parallel.dll", + "ref/netcore50/System.Linq.Parallel.xml", + "ref/netcore50/de/System.Linq.Parallel.xml", + "ref/netcore50/es/System.Linq.Parallel.xml", + "ref/netcore50/fr/System.Linq.Parallel.xml", + "ref/netcore50/it/System.Linq.Parallel.xml", + "ref/netcore50/ja/System.Linq.Parallel.xml", + "ref/netcore50/ko/System.Linq.Parallel.xml", + "ref/netcore50/ru/System.Linq.Parallel.xml", + "ref/netcore50/zh-hans/System.Linq.Parallel.xml", + "ref/netcore50/zh-hant/System.Linq.Parallel.xml", + "ref/netstandard1.1/System.Linq.Parallel.dll", + "ref/netstandard1.1/System.Linq.Parallel.xml", + "ref/netstandard1.1/de/System.Linq.Parallel.xml", + "ref/netstandard1.1/es/System.Linq.Parallel.xml", + "ref/netstandard1.1/fr/System.Linq.Parallel.xml", + "ref/netstandard1.1/it/System.Linq.Parallel.xml", + "ref/netstandard1.1/ja/System.Linq.Parallel.xml", + "ref/netstandard1.1/ko/System.Linq.Parallel.xml", + "ref/netstandard1.1/ru/System.Linq.Parallel.xml", + "ref/netstandard1.1/zh-hans/System.Linq.Parallel.xml", + "ref/netstandard1.1/zh-hant/System.Linq.Parallel.xml", + "ref/portable-net45+win8+wpa81/_._", + "ref/win8/_._", + "ref/wpa81/_._", + "ref/xamarinios10/_._", + "ref/xamarinmac20/_._", + "ref/xamarintvos10/_._", + "ref/xamarinwatchos10/_._" + ] + }, + "System.Linq.Queryable/4.0.1": { + "sha512": "RjJ50G+6Ub+HLI3iHZF3KzPbUz84k4chfjDP6GCthZyBUeJlrQ67Ji4DQ96/XzwKLKwWGoiejbys9P3eXlNMFQ==", + "type": "package", + "path": "System.Linq.Queryable/4.0.1", + "files": [ + "System.Linq.Queryable.4.0.1.nupkg.sha512", + "System.Linq.Queryable.nuspec", + "ThirdPartyNotices.txt", + "dotnet_library_license.txt", + "lib/monoandroid10/_._", + "lib/monotouch10/_._", + "lib/net45/_._", + "lib/netcore50/System.Linq.Queryable.dll", + "lib/netstandard1.3/System.Linq.Queryable.dll", + "lib/portable-net45+win8+wp8+wpa81/_._", + "lib/win8/_._", + "lib/wp80/_._", + "lib/wpa81/_._", + "lib/xamarinios10/_._", + "lib/xamarinmac20/_._", + "lib/xamarintvos10/_._", + "lib/xamarinwatchos10/_._", + "ref/monoandroid10/_._", + "ref/monotouch10/_._", + "ref/net45/_._", + "ref/netcore50/System.Linq.Queryable.dll", + "ref/netcore50/System.Linq.Queryable.xml", + "ref/netcore50/de/System.Linq.Queryable.xml", + "ref/netcore50/es/System.Linq.Queryable.xml", + "ref/netcore50/fr/System.Linq.Queryable.xml", + "ref/netcore50/it/System.Linq.Queryable.xml", + "ref/netcore50/ja/System.Linq.Queryable.xml", + "ref/netcore50/ko/System.Linq.Queryable.xml", + "ref/netcore50/ru/System.Linq.Queryable.xml", + "ref/netcore50/zh-hans/System.Linq.Queryable.xml", + "ref/netcore50/zh-hant/System.Linq.Queryable.xml", + "ref/netstandard1.0/System.Linq.Queryable.dll", + "ref/netstandard1.0/System.Linq.Queryable.xml", + "ref/netstandard1.0/de/System.Linq.Queryable.xml", + "ref/netstandard1.0/es/System.Linq.Queryable.xml", + "ref/netstandard1.0/fr/System.Linq.Queryable.xml", + "ref/netstandard1.0/it/System.Linq.Queryable.xml", + "ref/netstandard1.0/ja/System.Linq.Queryable.xml", + "ref/netstandard1.0/ko/System.Linq.Queryable.xml", + "ref/netstandard1.0/ru/System.Linq.Queryable.xml", + "ref/netstandard1.0/zh-hans/System.Linq.Queryable.xml", + "ref/netstandard1.0/zh-hant/System.Linq.Queryable.xml", + "ref/portable-net45+win8+wp8+wpa81/_._", + "ref/win8/_._", + "ref/wp80/_._", + "ref/wpa81/_._", + "ref/xamarinios10/_._", + "ref/xamarinmac20/_._", + "ref/xamarintvos10/_._", + "ref/xamarinwatchos10/_._" + ] + }, + "System.Net.Http/4.1.0": { + "sha512": "ULq9g3SOPVuupt+Y3U+A37coXzdNisB1neFCSKzBwo182u0RDddKJF8I5+HfyXqK6OhJPgeoAwWXrbiUXuRDsg==", + "type": "package", + "path": "System.Net.Http/4.1.0", + "files": [ + "System.Net.Http.4.1.0.nupkg.sha512", + "System.Net.Http.nuspec", + "ThirdPartyNotices.txt", + "dotnet_library_license.txt", + "lib/Xamarinmac20/_._", + "lib/monoandroid10/_._", + "lib/monotouch10/_._", + "lib/net45/_._", + "lib/net46/System.Net.Http.dll", + "lib/portable-net45+win8+wpa81/_._", + "lib/win8/_._", + "lib/wpa81/_._", + "lib/xamarinios10/_._", + "lib/xamarintvos10/_._", + "lib/xamarinwatchos10/_._", + "ref/Xamarinmac20/_._", + "ref/monoandroid10/_._", + "ref/monotouch10/_._", + "ref/net45/_._", + "ref/net46/System.Net.Http.dll", + "ref/net46/System.Net.Http.xml", + "ref/net46/de/System.Net.Http.xml", + "ref/net46/es/System.Net.Http.xml", + "ref/net46/fr/System.Net.Http.xml", + "ref/net46/it/System.Net.Http.xml", + "ref/net46/ja/System.Net.Http.xml", + "ref/net46/ko/System.Net.Http.xml", + "ref/net46/ru/System.Net.Http.xml", + "ref/net46/zh-hans/System.Net.Http.xml", + "ref/net46/zh-hant/System.Net.Http.xml", + "ref/netcore50/System.Net.Http.dll", + "ref/netcore50/System.Net.Http.xml", + "ref/netcore50/de/System.Net.Http.xml", + "ref/netcore50/es/System.Net.Http.xml", + "ref/netcore50/fr/System.Net.Http.xml", + "ref/netcore50/it/System.Net.Http.xml", + "ref/netcore50/ja/System.Net.Http.xml", + "ref/netcore50/ko/System.Net.Http.xml", + "ref/netcore50/ru/System.Net.Http.xml", + "ref/netcore50/zh-hans/System.Net.Http.xml", + "ref/netcore50/zh-hant/System.Net.Http.xml", + "ref/netstandard1.1/System.Net.Http.dll", + "ref/netstandard1.1/System.Net.Http.xml", + "ref/netstandard1.1/de/System.Net.Http.xml", + "ref/netstandard1.1/es/System.Net.Http.xml", + "ref/netstandard1.1/fr/System.Net.Http.xml", + "ref/netstandard1.1/it/System.Net.Http.xml", + "ref/netstandard1.1/ja/System.Net.Http.xml", + "ref/netstandard1.1/ko/System.Net.Http.xml", + "ref/netstandard1.1/ru/System.Net.Http.xml", + "ref/netstandard1.1/zh-hans/System.Net.Http.xml", + "ref/netstandard1.1/zh-hant/System.Net.Http.xml", + "ref/netstandard1.3/System.Net.Http.dll", + "ref/netstandard1.3/System.Net.Http.xml", + "ref/netstandard1.3/de/System.Net.Http.xml", + "ref/netstandard1.3/es/System.Net.Http.xml", + "ref/netstandard1.3/fr/System.Net.Http.xml", + "ref/netstandard1.3/it/System.Net.Http.xml", + "ref/netstandard1.3/ja/System.Net.Http.xml", + "ref/netstandard1.3/ko/System.Net.Http.xml", + "ref/netstandard1.3/ru/System.Net.Http.xml", + "ref/netstandard1.3/zh-hans/System.Net.Http.xml", + "ref/netstandard1.3/zh-hant/System.Net.Http.xml", + "ref/portable-net45+win8+wpa81/_._", + "ref/win8/_._", + "ref/wpa81/_._", + "ref/xamarinios10/_._", + "ref/xamarintvos10/_._", + "ref/xamarinwatchos10/_._", + "runtimes/unix/lib/netstandard1.6/System.Net.Http.dll", + "runtimes/win/lib/net46/System.Net.Http.dll", + "runtimes/win/lib/netcore50/System.Net.Http.dll", + "runtimes/win/lib/netstandard1.3/System.Net.Http.dll" + ] + }, + "System.Net.NameResolution/4.0.0": { + "sha512": "JdqRdM1Qym3YehqdKIi5LHrpypP4JMfxKQSNCJ2z4WawkG0il+N3XfNeJOxll2XrTnG7WgYYPoeiu/KOwg0DQw==", + "type": "package", + "path": "System.Net.NameResolution/4.0.0", + "files": [ + "System.Net.NameResolution.4.0.0.nupkg.sha512", + "System.Net.NameResolution.nuspec", + "ThirdPartyNotices.txt", + "dotnet_library_license.txt", + "lib/MonoAndroid10/_._", + "lib/MonoTouch10/_._", + "lib/net46/System.Net.NameResolution.dll", + "lib/xamarinios10/_._", + "lib/xamarinmac20/_._", + "lib/xamarintvos10/_._", + "lib/xamarinwatchos10/_._", + "ref/MonoAndroid10/_._", + "ref/MonoTouch10/_._", + "ref/net46/System.Net.NameResolution.dll", + "ref/netstandard1.3/System.Net.NameResolution.dll", + "ref/netstandard1.3/System.Net.NameResolution.xml", + "ref/netstandard1.3/de/System.Net.NameResolution.xml", + "ref/netstandard1.3/es/System.Net.NameResolution.xml", + "ref/netstandard1.3/fr/System.Net.NameResolution.xml", + "ref/netstandard1.3/it/System.Net.NameResolution.xml", + "ref/netstandard1.3/ja/System.Net.NameResolution.xml", + "ref/netstandard1.3/ko/System.Net.NameResolution.xml", + "ref/netstandard1.3/ru/System.Net.NameResolution.xml", + "ref/netstandard1.3/zh-hans/System.Net.NameResolution.xml", + "ref/netstandard1.3/zh-hant/System.Net.NameResolution.xml", + "ref/xamarinios10/_._", + "ref/xamarinmac20/_._", + "ref/xamarintvos10/_._", + "ref/xamarinwatchos10/_._", + "runtimes/unix/lib/netstandard1.3/System.Net.NameResolution.dll", + "runtimes/win/lib/net46/System.Net.NameResolution.dll", + "runtimes/win/lib/netcore50/System.Net.NameResolution.dll", + "runtimes/win/lib/netstandard1.3/System.Net.NameResolution.dll" + ] + }, + "System.Net.Primitives/4.0.11": { + "sha512": "hVvfl4405DRjA2408luZekbPhplJK03j2Y2lSfMlny7GHXlkByw1iLnc9mgKW0GdQn73vvMcWrWewAhylXA4Nw==", + "type": "package", + "path": "System.Net.Primitives/4.0.11", + "files": [ + "System.Net.Primitives.4.0.11.nupkg.sha512", + "System.Net.Primitives.nuspec", + "ThirdPartyNotices.txt", + "dotnet_library_license.txt", + "lib/MonoAndroid10/_._", + "lib/MonoTouch10/_._", + "lib/net45/_._", + "lib/portable-net45+win8+wp8+wpa81/_._", + "lib/win8/_._", + "lib/wp80/_._", + "lib/wpa81/_._", + "lib/xamarinios10/_._", + "lib/xamarinmac20/_._", + "lib/xamarintvos10/_._", + "lib/xamarinwatchos10/_._", + "ref/MonoAndroid10/_._", + "ref/MonoTouch10/_._", + "ref/net45/_._", + "ref/netcore50/System.Net.Primitives.dll", + "ref/netcore50/System.Net.Primitives.xml", + "ref/netcore50/de/System.Net.Primitives.xml", + "ref/netcore50/es/System.Net.Primitives.xml", + "ref/netcore50/fr/System.Net.Primitives.xml", + "ref/netcore50/it/System.Net.Primitives.xml", + "ref/netcore50/ja/System.Net.Primitives.xml", + "ref/netcore50/ko/System.Net.Primitives.xml", + "ref/netcore50/ru/System.Net.Primitives.xml", + "ref/netcore50/zh-hans/System.Net.Primitives.xml", + "ref/netcore50/zh-hant/System.Net.Primitives.xml", + "ref/netstandard1.0/System.Net.Primitives.dll", + "ref/netstandard1.0/System.Net.Primitives.xml", + "ref/netstandard1.0/de/System.Net.Primitives.xml", + "ref/netstandard1.0/es/System.Net.Primitives.xml", + "ref/netstandard1.0/fr/System.Net.Primitives.xml", + "ref/netstandard1.0/it/System.Net.Primitives.xml", + "ref/netstandard1.0/ja/System.Net.Primitives.xml", + "ref/netstandard1.0/ko/System.Net.Primitives.xml", + "ref/netstandard1.0/ru/System.Net.Primitives.xml", + "ref/netstandard1.0/zh-hans/System.Net.Primitives.xml", + "ref/netstandard1.0/zh-hant/System.Net.Primitives.xml", + "ref/netstandard1.1/System.Net.Primitives.dll", + "ref/netstandard1.1/System.Net.Primitives.xml", + "ref/netstandard1.1/de/System.Net.Primitives.xml", + "ref/netstandard1.1/es/System.Net.Primitives.xml", + "ref/netstandard1.1/fr/System.Net.Primitives.xml", + "ref/netstandard1.1/it/System.Net.Primitives.xml", + "ref/netstandard1.1/ja/System.Net.Primitives.xml", + "ref/netstandard1.1/ko/System.Net.Primitives.xml", + "ref/netstandard1.1/ru/System.Net.Primitives.xml", + "ref/netstandard1.1/zh-hans/System.Net.Primitives.xml", + "ref/netstandard1.1/zh-hant/System.Net.Primitives.xml", + "ref/netstandard1.3/System.Net.Primitives.dll", + "ref/netstandard1.3/System.Net.Primitives.xml", + "ref/netstandard1.3/de/System.Net.Primitives.xml", + "ref/netstandard1.3/es/System.Net.Primitives.xml", + "ref/netstandard1.3/fr/System.Net.Primitives.xml", + "ref/netstandard1.3/it/System.Net.Primitives.xml", + "ref/netstandard1.3/ja/System.Net.Primitives.xml", + "ref/netstandard1.3/ko/System.Net.Primitives.xml", + "ref/netstandard1.3/ru/System.Net.Primitives.xml", + "ref/netstandard1.3/zh-hans/System.Net.Primitives.xml", + "ref/netstandard1.3/zh-hant/System.Net.Primitives.xml", + "ref/portable-net45+win8+wp8+wpa81/_._", + "ref/win8/_._", + "ref/wp80/_._", + "ref/wpa81/_._", + "ref/xamarinios10/_._", + "ref/xamarinmac20/_._", + "ref/xamarintvos10/_._", + "ref/xamarinwatchos10/_._" + ] + }, + "System.Net.Requests/4.0.11": { + "sha512": "vcJrc5ubYgPTK7JZe1A9h9gsuRVUtz7nvSbiCe6CHCobfaino0/c/0VG+eB9XQk8kLWa9UvXpq4iJcjJJy+D5w==", + "type": "package", + "path": "System.Net.Requests/4.0.11", + "files": [ + "System.Net.Requests.4.0.11.nupkg.sha512", + "System.Net.Requests.nuspec", + "ThirdPartyNotices.txt", + "dotnet_library_license.txt", + "lib/MonoAndroid10/_._", + "lib/MonoTouch10/_._", + "lib/net45/_._", + "lib/portable-net45+win8+wp8+wpa81/_._", + "lib/win8/_._", + "lib/wp80/_._", + "lib/wpa81/_._", + "lib/xamarinios10/_._", + "lib/xamarinmac20/_._", + "lib/xamarintvos10/_._", + "lib/xamarinwatchos10/_._", + "ref/MonoAndroid10/_._", + "ref/MonoTouch10/_._", + "ref/net45/_._", + "ref/net46/_._", + "ref/netcore50/System.Net.Requests.dll", + "ref/netcore50/System.Net.Requests.xml", + "ref/netcore50/de/System.Net.Requests.xml", + "ref/netcore50/es/System.Net.Requests.xml", + "ref/netcore50/fr/System.Net.Requests.xml", + "ref/netcore50/it/System.Net.Requests.xml", + "ref/netcore50/ja/System.Net.Requests.xml", + "ref/netcore50/ko/System.Net.Requests.xml", + "ref/netcore50/ru/System.Net.Requests.xml", + "ref/netcore50/zh-hans/System.Net.Requests.xml", + "ref/netcore50/zh-hant/System.Net.Requests.xml", + "ref/netstandard1.0/System.Net.Requests.dll", + "ref/netstandard1.0/System.Net.Requests.xml", + "ref/netstandard1.0/de/System.Net.Requests.xml", + "ref/netstandard1.0/es/System.Net.Requests.xml", + "ref/netstandard1.0/fr/System.Net.Requests.xml", + "ref/netstandard1.0/it/System.Net.Requests.xml", + "ref/netstandard1.0/ja/System.Net.Requests.xml", + "ref/netstandard1.0/ko/System.Net.Requests.xml", + "ref/netstandard1.0/ru/System.Net.Requests.xml", + "ref/netstandard1.0/zh-hans/System.Net.Requests.xml", + "ref/netstandard1.0/zh-hant/System.Net.Requests.xml", + "ref/netstandard1.1/System.Net.Requests.dll", + "ref/netstandard1.1/System.Net.Requests.xml", + "ref/netstandard1.1/de/System.Net.Requests.xml", + "ref/netstandard1.1/es/System.Net.Requests.xml", + "ref/netstandard1.1/fr/System.Net.Requests.xml", + "ref/netstandard1.1/it/System.Net.Requests.xml", + "ref/netstandard1.1/ja/System.Net.Requests.xml", + "ref/netstandard1.1/ko/System.Net.Requests.xml", + "ref/netstandard1.1/ru/System.Net.Requests.xml", + "ref/netstandard1.1/zh-hans/System.Net.Requests.xml", + "ref/netstandard1.1/zh-hant/System.Net.Requests.xml", + "ref/netstandard1.3/System.Net.Requests.dll", + "ref/netstandard1.3/System.Net.Requests.xml", + "ref/netstandard1.3/de/System.Net.Requests.xml", + "ref/netstandard1.3/es/System.Net.Requests.xml", + "ref/netstandard1.3/fr/System.Net.Requests.xml", + "ref/netstandard1.3/it/System.Net.Requests.xml", + "ref/netstandard1.3/ja/System.Net.Requests.xml", + "ref/netstandard1.3/ko/System.Net.Requests.xml", + "ref/netstandard1.3/ru/System.Net.Requests.xml", + "ref/netstandard1.3/zh-hans/System.Net.Requests.xml", + "ref/netstandard1.3/zh-hant/System.Net.Requests.xml", + "ref/portable-net45+win8+wp8+wpa81/_._", + "ref/win8/_._", + "ref/wp80/_._", + "ref/wpa81/_._", + "ref/xamarinios10/_._", + "ref/xamarinmac20/_._", + "ref/xamarintvos10/_._", + "ref/xamarinwatchos10/_._", + "runtimes/unix/lib/netstandard1.3/System.Net.Requests.dll", + "runtimes/win/lib/net46/_._", + "runtimes/win/lib/netstandard1.3/System.Net.Requests.dll" + ] + }, + "System.Net.Security/4.0.0": { + "sha512": "CjgN/P+Ust9TNVsnjKm/+0F/vuFpCDRxSq0AHNxvcDlRdbtOiKamVkZLCOEEzUUe0F0LHE0jzrLWmRYPhOFpnA==", + "type": "package", + "path": "System.Net.Security/4.0.0", + "files": [ + "System.Net.Security.4.0.0.nupkg.sha512", + "System.Net.Security.nuspec", + "ThirdPartyNotices.txt", + "dotnet_library_license.txt", + "lib/MonoAndroid10/_._", + "lib/MonoTouch10/_._", + "lib/net46/System.Net.Security.dll", + "lib/xamarinios10/_._", + "lib/xamarinmac20/_._", + "lib/xamarintvos10/_._", + "lib/xamarinwatchos10/_._", + "ref/MonoAndroid10/_._", + "ref/MonoTouch10/_._", + "ref/net46/System.Net.Security.dll", + "ref/netstandard1.3/System.Net.Security.dll", + "ref/netstandard1.3/System.Net.Security.xml", + "ref/netstandard1.3/de/System.Net.Security.xml", + "ref/netstandard1.3/es/System.Net.Security.xml", + "ref/netstandard1.3/fr/System.Net.Security.xml", + "ref/netstandard1.3/it/System.Net.Security.xml", + "ref/netstandard1.3/ja/System.Net.Security.xml", + "ref/netstandard1.3/ko/System.Net.Security.xml", + "ref/netstandard1.3/ru/System.Net.Security.xml", + "ref/netstandard1.3/zh-hans/System.Net.Security.xml", + "ref/netstandard1.3/zh-hant/System.Net.Security.xml", + "ref/xamarinios10/_._", + "ref/xamarinmac20/_._", + "ref/xamarintvos10/_._", + "ref/xamarinwatchos10/_._", + "runtimes/unix/lib/netstandard1.6/System.Net.Security.dll", + "runtimes/win/lib/net46/System.Net.Security.dll", + "runtimes/win/lib/netstandard1.3/System.Net.Security.dll", + "runtimes/win7/lib/netcore50/_._" + ] + }, + "System.Net.Sockets/4.1.0": { + "sha512": "xAz0N3dAV/aR/9g8r0Y5oEqU1JRsz29F5EGb/WVHmX3jVSLqi2/92M5hTad2aNWovruXrJpJtgZ9fccPMG9uSw==", + "type": "package", + "path": "System.Net.Sockets/4.1.0", + "files": [ + "System.Net.Sockets.4.1.0.nupkg.sha512", + "System.Net.Sockets.nuspec", + "ThirdPartyNotices.txt", + "dotnet_library_license.txt", + "lib/MonoAndroid10/_._", + "lib/MonoTouch10/_._", + "lib/net46/System.Net.Sockets.dll", + "lib/xamarinios10/_._", + "lib/xamarinmac20/_._", + "lib/xamarintvos10/_._", + "lib/xamarinwatchos10/_._", + "ref/MonoAndroid10/_._", + "ref/MonoTouch10/_._", + "ref/net46/System.Net.Sockets.dll", + "ref/netstandard1.3/System.Net.Sockets.dll", + "ref/netstandard1.3/System.Net.Sockets.xml", + "ref/netstandard1.3/de/System.Net.Sockets.xml", + "ref/netstandard1.3/es/System.Net.Sockets.xml", + "ref/netstandard1.3/fr/System.Net.Sockets.xml", + "ref/netstandard1.3/it/System.Net.Sockets.xml", + "ref/netstandard1.3/ja/System.Net.Sockets.xml", + "ref/netstandard1.3/ko/System.Net.Sockets.xml", + "ref/netstandard1.3/ru/System.Net.Sockets.xml", + "ref/netstandard1.3/zh-hans/System.Net.Sockets.xml", + "ref/netstandard1.3/zh-hant/System.Net.Sockets.xml", + "ref/xamarinios10/_._", + "ref/xamarinmac20/_._", + "ref/xamarintvos10/_._", + "ref/xamarinwatchos10/_._" + ] + }, + "System.Net.WebHeaderCollection/4.0.1": { + "sha512": "BlL48XHR1cflHpSeOximCAwaStM9fNRYte0vgGCCnuWTJx5x5MpBPlS1R8KVzDRuRzV7zhhLr7BJ+x1Q6O4dHA==", + "type": "package", + "path": "System.Net.WebHeaderCollection/4.0.1", + "files": [ + "System.Net.WebHeaderCollection.4.0.1.nupkg.sha512", + "System.Net.WebHeaderCollection.nuspec", + "ThirdPartyNotices.txt", + "dotnet_library_license.txt", + "lib/MonoAndroid10/_._", + "lib/MonoTouch10/_._", + "lib/net46/_._", + "lib/netstandard1.3/System.Net.WebHeaderCollection.dll", + "lib/xamarinios10/_._", + "lib/xamarinmac20/_._", + "lib/xamarintvos10/_._", + "lib/xamarinwatchos10/_._", + "ref/MonoAndroid10/_._", + "ref/MonoTouch10/_._", + "ref/net46/_._", + "ref/netstandard1.3/System.Net.WebHeaderCollection.dll", + "ref/netstandard1.3/System.Net.WebHeaderCollection.xml", + "ref/netstandard1.3/de/System.Net.WebHeaderCollection.xml", + "ref/netstandard1.3/es/System.Net.WebHeaderCollection.xml", + "ref/netstandard1.3/fr/System.Net.WebHeaderCollection.xml", + "ref/netstandard1.3/it/System.Net.WebHeaderCollection.xml", + "ref/netstandard1.3/ja/System.Net.WebHeaderCollection.xml", + "ref/netstandard1.3/ko/System.Net.WebHeaderCollection.xml", + "ref/netstandard1.3/ru/System.Net.WebHeaderCollection.xml", + "ref/netstandard1.3/zh-hans/System.Net.WebHeaderCollection.xml", + "ref/netstandard1.3/zh-hant/System.Net.WebHeaderCollection.xml", + "ref/xamarinios10/_._", + "ref/xamarinmac20/_._", + "ref/xamarintvos10/_._", + "ref/xamarinwatchos10/_._" + ] + }, + "System.Numerics.Vectors/4.1.1": { + "sha512": "MgtDgVOTSH6Nc4oTmRQe2FuoKqk6giGz/V15MCCHOy0WXUxPXY1S4Hi8NSv07JUQBrrt/VO/gjHthXDfn9uKtw==", + "type": "package", + "path": "System.Numerics.Vectors/4.1.1", + "files": [ + "System.Numerics.Vectors.4.1.1.nupkg.sha512", + "System.Numerics.Vectors.nuspec", + "ThirdPartyNotices.txt", + "dotnet_library_license.txt", + "lib/MonoAndroid10/_._", + "lib/MonoTouch10/_._", + "lib/net46/System.Numerics.Vectors.dll", + "lib/net46/System.Numerics.Vectors.xml", + "lib/netstandard1.0/System.Numerics.Vectors.dll", + "lib/netstandard1.0/System.Numerics.Vectors.xml", + "lib/portable-net45+win8+wp8+wpa81/System.Numerics.Vectors.dll", + "lib/portable-net45+win8+wp8+wpa81/System.Numerics.Vectors.xml", + "lib/xamarinios10/_._", + "lib/xamarinmac20/_._", + "lib/xamarintvos10/_._", + "lib/xamarinwatchos10/_._", + "ref/MonoAndroid10/_._", + "ref/MonoTouch10/_._", + "ref/net46/System.Numerics.Vectors.dll", + "ref/net46/System.Numerics.Vectors.xml", + "ref/netstandard1.0/System.Numerics.Vectors.dll", + "ref/netstandard1.0/System.Numerics.Vectors.xml", + "ref/xamarinios10/_._", + "ref/xamarinmac20/_._", + "ref/xamarintvos10/_._", + "ref/xamarinwatchos10/_._" + ] + }, + "System.ObjectModel/4.0.12": { + "sha512": "tAgJM1xt3ytyMoW4qn4wIqgJYm7L7TShRZG4+Q4Qsi2PCcj96pXN7nRywS9KkB3p/xDUjc2HSwP9SROyPYDYKQ==", + "type": "package", + "path": "System.ObjectModel/4.0.12", + "files": [ + "System.ObjectModel.4.0.12.nupkg.sha512", + "System.ObjectModel.nuspec", + "ThirdPartyNotices.txt", + "dotnet_library_license.txt", + "lib/MonoAndroid10/_._", + "lib/MonoTouch10/_._", + "lib/net45/_._", + "lib/netcore50/System.ObjectModel.dll", + "lib/netstandard1.3/System.ObjectModel.dll", + "lib/portable-net45+win8+wp8+wpa81/_._", + "lib/win8/_._", + "lib/wp80/_._", + "lib/wpa81/_._", + "lib/xamarinios10/_._", + "lib/xamarinmac20/_._", + "lib/xamarintvos10/_._", + "lib/xamarinwatchos10/_._", + "ref/MonoAndroid10/_._", + "ref/MonoTouch10/_._", + "ref/net45/_._", + "ref/netcore50/System.ObjectModel.dll", + "ref/netcore50/System.ObjectModel.xml", + "ref/netcore50/de/System.ObjectModel.xml", + "ref/netcore50/es/System.ObjectModel.xml", + "ref/netcore50/fr/System.ObjectModel.xml", + "ref/netcore50/it/System.ObjectModel.xml", + "ref/netcore50/ja/System.ObjectModel.xml", + "ref/netcore50/ko/System.ObjectModel.xml", + "ref/netcore50/ru/System.ObjectModel.xml", + "ref/netcore50/zh-hans/System.ObjectModel.xml", + "ref/netcore50/zh-hant/System.ObjectModel.xml", + "ref/netstandard1.0/System.ObjectModel.dll", + "ref/netstandard1.0/System.ObjectModel.xml", + "ref/netstandard1.0/de/System.ObjectModel.xml", + "ref/netstandard1.0/es/System.ObjectModel.xml", + "ref/netstandard1.0/fr/System.ObjectModel.xml", + "ref/netstandard1.0/it/System.ObjectModel.xml", + "ref/netstandard1.0/ja/System.ObjectModel.xml", + "ref/netstandard1.0/ko/System.ObjectModel.xml", + "ref/netstandard1.0/ru/System.ObjectModel.xml", + "ref/netstandard1.0/zh-hans/System.ObjectModel.xml", + "ref/netstandard1.0/zh-hant/System.ObjectModel.xml", + "ref/netstandard1.3/System.ObjectModel.dll", + "ref/netstandard1.3/System.ObjectModel.xml", + "ref/netstandard1.3/de/System.ObjectModel.xml", + "ref/netstandard1.3/es/System.ObjectModel.xml", + "ref/netstandard1.3/fr/System.ObjectModel.xml", + "ref/netstandard1.3/it/System.ObjectModel.xml", + "ref/netstandard1.3/ja/System.ObjectModel.xml", + "ref/netstandard1.3/ko/System.ObjectModel.xml", + "ref/netstandard1.3/ru/System.ObjectModel.xml", + "ref/netstandard1.3/zh-hans/System.ObjectModel.xml", + "ref/netstandard1.3/zh-hant/System.ObjectModel.xml", + "ref/portable-net45+win8+wp8+wpa81/_._", + "ref/win8/_._", + "ref/wp80/_._", + "ref/wpa81/_._", + "ref/xamarinios10/_._", + "ref/xamarinmac20/_._", + "ref/xamarintvos10/_._", + "ref/xamarinwatchos10/_._" + ] + }, + "System.Reflection/4.1.0": { + "sha512": "JCKANJ0TI7kzoQzuwB/OoJANy1Lg338B6+JVacPl4TpUwi3cReg3nMLplMq2uqYfHFQpKIlHAUVAJlImZz/4ng==", + "type": "package", + "path": "System.Reflection/4.1.0", + "files": [ + "System.Reflection.4.1.0.nupkg.sha512", + "System.Reflection.nuspec", + "ThirdPartyNotices.txt", + "dotnet_library_license.txt", + "lib/MonoAndroid10/_._", + "lib/MonoTouch10/_._", + "lib/net45/_._", + "lib/net462/System.Reflection.dll", + "lib/portable-net45+win8+wp8+wpa81/_._", + "lib/win8/_._", + "lib/wp80/_._", + "lib/wpa81/_._", + "lib/xamarinios10/_._", + "lib/xamarinmac20/_._", + "lib/xamarintvos10/_._", + "lib/xamarinwatchos10/_._", + "ref/MonoAndroid10/_._", + "ref/MonoTouch10/_._", + "ref/net45/_._", + "ref/net462/System.Reflection.dll", + "ref/netcore50/System.Reflection.dll", + "ref/netcore50/System.Reflection.xml", + "ref/netcore50/de/System.Reflection.xml", + "ref/netcore50/es/System.Reflection.xml", + "ref/netcore50/fr/System.Reflection.xml", + "ref/netcore50/it/System.Reflection.xml", + "ref/netcore50/ja/System.Reflection.xml", + "ref/netcore50/ko/System.Reflection.xml", + "ref/netcore50/ru/System.Reflection.xml", + "ref/netcore50/zh-hans/System.Reflection.xml", + "ref/netcore50/zh-hant/System.Reflection.xml", + "ref/netstandard1.0/System.Reflection.dll", + "ref/netstandard1.0/System.Reflection.xml", + "ref/netstandard1.0/de/System.Reflection.xml", + "ref/netstandard1.0/es/System.Reflection.xml", + "ref/netstandard1.0/fr/System.Reflection.xml", + "ref/netstandard1.0/it/System.Reflection.xml", + "ref/netstandard1.0/ja/System.Reflection.xml", + "ref/netstandard1.0/ko/System.Reflection.xml", + "ref/netstandard1.0/ru/System.Reflection.xml", + "ref/netstandard1.0/zh-hans/System.Reflection.xml", + "ref/netstandard1.0/zh-hant/System.Reflection.xml", + "ref/netstandard1.3/System.Reflection.dll", + "ref/netstandard1.3/System.Reflection.xml", + "ref/netstandard1.3/de/System.Reflection.xml", + "ref/netstandard1.3/es/System.Reflection.xml", + "ref/netstandard1.3/fr/System.Reflection.xml", + "ref/netstandard1.3/it/System.Reflection.xml", + "ref/netstandard1.3/ja/System.Reflection.xml", + "ref/netstandard1.3/ko/System.Reflection.xml", + "ref/netstandard1.3/ru/System.Reflection.xml", + "ref/netstandard1.3/zh-hans/System.Reflection.xml", + "ref/netstandard1.3/zh-hant/System.Reflection.xml", + "ref/netstandard1.5/System.Reflection.dll", + "ref/netstandard1.5/System.Reflection.xml", + "ref/netstandard1.5/de/System.Reflection.xml", + "ref/netstandard1.5/es/System.Reflection.xml", + "ref/netstandard1.5/fr/System.Reflection.xml", + "ref/netstandard1.5/it/System.Reflection.xml", + "ref/netstandard1.5/ja/System.Reflection.xml", + "ref/netstandard1.5/ko/System.Reflection.xml", + "ref/netstandard1.5/ru/System.Reflection.xml", + "ref/netstandard1.5/zh-hans/System.Reflection.xml", + "ref/netstandard1.5/zh-hant/System.Reflection.xml", + "ref/portable-net45+win8+wp8+wpa81/_._", + "ref/win8/_._", + "ref/wp80/_._", + "ref/wpa81/_._", + "ref/xamarinios10/_._", + "ref/xamarinmac20/_._", + "ref/xamarintvos10/_._", + "ref/xamarinwatchos10/_._" + ] + }, + "System.Reflection.DispatchProxy/4.0.1": { + "sha512": "RcVD9f2e5NNlmpeuuJTyFc1SxCAMvUCFpGpoGe2GAoKxm8ELFSvpDlVd6OEKDH8a8lVBPlgXe1+fEO9PSTN3BQ==", + "type": "package", + "path": "System.Reflection.DispatchProxy/4.0.1", + "files": [ + "System.Reflection.DispatchProxy.4.0.1.nupkg.sha512", + "System.Reflection.DispatchProxy.nuspec", + "ThirdPartyNotices.txt", + "dotnet_library_license.txt", + "lib/MonoAndroid10/_._", + "lib/MonoTouch10/_._", + "lib/netstandard1.3/System.Reflection.DispatchProxy.dll", + "lib/xamarinios10/_._", + "lib/xamarinmac20/_._", + "lib/xamarintvos10/_._", + "lib/xamarinwatchos10/_._", + "ref/MonoAndroid10/_._", + "ref/MonoTouch10/_._", + "ref/netstandard1.3/System.Reflection.DispatchProxy.dll", + "ref/netstandard1.3/System.Reflection.DispatchProxy.xml", + "ref/netstandard1.3/de/System.Reflection.DispatchProxy.xml", + "ref/netstandard1.3/es/System.Reflection.DispatchProxy.xml", + "ref/netstandard1.3/fr/System.Reflection.DispatchProxy.xml", + "ref/netstandard1.3/it/System.Reflection.DispatchProxy.xml", + "ref/netstandard1.3/ja/System.Reflection.DispatchProxy.xml", + "ref/netstandard1.3/ko/System.Reflection.DispatchProxy.xml", + "ref/netstandard1.3/ru/System.Reflection.DispatchProxy.xml", + "ref/netstandard1.3/zh-hans/System.Reflection.DispatchProxy.xml", + "ref/netstandard1.3/zh-hant/System.Reflection.DispatchProxy.xml", + "ref/xamarinios10/_._", + "ref/xamarinmac20/_._", + "ref/xamarintvos10/_._", + "ref/xamarinwatchos10/_._", + "runtimes/aot/lib/netcore50/System.Reflection.DispatchProxy.dll" + ] + }, + "System.Reflection.Emit/4.0.1": { + "sha512": "P2wqAj72fFjpP6wb9nSfDqNBMab+2ovzSDzUZK7MVIm54tBJEPr9jWfSjjoTpPwj1LeKcmX3vr0ttyjSSFM47g==", + "type": "package", + "path": "System.Reflection.Emit/4.0.1", + "files": [ + "System.Reflection.Emit.4.0.1.nupkg.sha512", + "System.Reflection.Emit.nuspec", + "ThirdPartyNotices.txt", + "dotnet_library_license.txt", + "lib/MonoAndroid10/_._", + "lib/net45/_._", + "lib/netcore50/System.Reflection.Emit.dll", + "lib/netstandard1.3/System.Reflection.Emit.dll", + "lib/xamarinmac20/_._", + "ref/MonoAndroid10/_._", + "ref/net45/_._", + "ref/netstandard1.1/System.Reflection.Emit.dll", + "ref/netstandard1.1/System.Reflection.Emit.xml", + "ref/netstandard1.1/de/System.Reflection.Emit.xml", + "ref/netstandard1.1/es/System.Reflection.Emit.xml", + "ref/netstandard1.1/fr/System.Reflection.Emit.xml", + "ref/netstandard1.1/it/System.Reflection.Emit.xml", + "ref/netstandard1.1/ja/System.Reflection.Emit.xml", + "ref/netstandard1.1/ko/System.Reflection.Emit.xml", + "ref/netstandard1.1/ru/System.Reflection.Emit.xml", + "ref/netstandard1.1/zh-hans/System.Reflection.Emit.xml", + "ref/netstandard1.1/zh-hant/System.Reflection.Emit.xml", + "ref/xamarinmac20/_._" + ] + }, + "System.Reflection.Emit.ILGeneration/4.0.1": { + "sha512": "Ov6dU8Bu15Bc7zuqttgHF12J5lwSWyTf1S+FJouUXVMSqImLZzYaQ+vRr1rQ0OZ0HqsrwWl4dsKHELckQkVpgA==", + "type": "package", + "path": "System.Reflection.Emit.ILGeneration/4.0.1", + "files": [ + "System.Reflection.Emit.ILGeneration.4.0.1.nupkg.sha512", + "System.Reflection.Emit.ILGeneration.nuspec", + "ThirdPartyNotices.txt", + "dotnet_library_license.txt", + "lib/net45/_._", + "lib/netcore50/System.Reflection.Emit.ILGeneration.dll", + "lib/netstandard1.3/System.Reflection.Emit.ILGeneration.dll", + "lib/portable-net45+wp8/_._", + "lib/wp80/_._", + "ref/net45/_._", + "ref/netstandard1.0/System.Reflection.Emit.ILGeneration.dll", + "ref/netstandard1.0/System.Reflection.Emit.ILGeneration.xml", + "ref/netstandard1.0/de/System.Reflection.Emit.ILGeneration.xml", + "ref/netstandard1.0/es/System.Reflection.Emit.ILGeneration.xml", + "ref/netstandard1.0/fr/System.Reflection.Emit.ILGeneration.xml", + "ref/netstandard1.0/it/System.Reflection.Emit.ILGeneration.xml", + "ref/netstandard1.0/ja/System.Reflection.Emit.ILGeneration.xml", + "ref/netstandard1.0/ko/System.Reflection.Emit.ILGeneration.xml", + "ref/netstandard1.0/ru/System.Reflection.Emit.ILGeneration.xml", + "ref/netstandard1.0/zh-hans/System.Reflection.Emit.ILGeneration.xml", + "ref/netstandard1.0/zh-hant/System.Reflection.Emit.ILGeneration.xml", + "ref/portable-net45+wp8/_._", + "ref/wp80/_._", + "runtimes/aot/lib/netcore50/_._" + ] + }, + "System.Reflection.Emit.Lightweight/4.0.1": { + "sha512": "sSzHHXueZ5Uh0OLpUQprhr+ZYJrLPA2Cmr4gn0wj9+FftNKXx8RIMKvO9qnjk2ebPYUjZ+F2ulGdPOsvj+MEjA==", + "type": "package", + "path": "System.Reflection.Emit.Lightweight/4.0.1", + "files": [ + "System.Reflection.Emit.Lightweight.4.0.1.nupkg.sha512", + "System.Reflection.Emit.Lightweight.nuspec", + "ThirdPartyNotices.txt", + "dotnet_library_license.txt", + "lib/net45/_._", + "lib/netcore50/System.Reflection.Emit.Lightweight.dll", + "lib/netstandard1.3/System.Reflection.Emit.Lightweight.dll", + "lib/portable-net45+wp8/_._", + "lib/wp80/_._", + "ref/net45/_._", + "ref/netstandard1.0/System.Reflection.Emit.Lightweight.dll", + "ref/netstandard1.0/System.Reflection.Emit.Lightweight.xml", + "ref/netstandard1.0/de/System.Reflection.Emit.Lightweight.xml", + "ref/netstandard1.0/es/System.Reflection.Emit.Lightweight.xml", + "ref/netstandard1.0/fr/System.Reflection.Emit.Lightweight.xml", + "ref/netstandard1.0/it/System.Reflection.Emit.Lightweight.xml", + "ref/netstandard1.0/ja/System.Reflection.Emit.Lightweight.xml", + "ref/netstandard1.0/ko/System.Reflection.Emit.Lightweight.xml", + "ref/netstandard1.0/ru/System.Reflection.Emit.Lightweight.xml", + "ref/netstandard1.0/zh-hans/System.Reflection.Emit.Lightweight.xml", + "ref/netstandard1.0/zh-hant/System.Reflection.Emit.Lightweight.xml", + "ref/portable-net45+wp8/_._", + "ref/wp80/_._", + "runtimes/aot/lib/netcore50/_._" + ] + }, + "System.Reflection.Extensions/4.0.1": { + "sha512": "GYrtRsZcMuHF3sbmRHfMYpvxZoIN2bQGrYGerUiWLEkqdEUQZhH3TRSaC/oI4wO0II1RKBPlpIa1TOMxIcOOzQ==", + "type": "package", + "path": "System.Reflection.Extensions/4.0.1", + "files": [ + "System.Reflection.Extensions.4.0.1.nupkg.sha512", + "System.Reflection.Extensions.nuspec", + "ThirdPartyNotices.txt", + "dotnet_library_license.txt", + "lib/MonoAndroid10/_._", + "lib/MonoTouch10/_._", + "lib/net45/_._", + "lib/portable-net45+win8+wp8+wpa81/_._", + "lib/win8/_._", + "lib/wp80/_._", + "lib/wpa81/_._", + "lib/xamarinios10/_._", + "lib/xamarinmac20/_._", + "lib/xamarintvos10/_._", + "lib/xamarinwatchos10/_._", + "ref/MonoAndroid10/_._", + "ref/MonoTouch10/_._", + "ref/net45/_._", + "ref/netcore50/System.Reflection.Extensions.dll", + "ref/netcore50/System.Reflection.Extensions.xml", + "ref/netcore50/de/System.Reflection.Extensions.xml", + "ref/netcore50/es/System.Reflection.Extensions.xml", + "ref/netcore50/fr/System.Reflection.Extensions.xml", + "ref/netcore50/it/System.Reflection.Extensions.xml", + "ref/netcore50/ja/System.Reflection.Extensions.xml", + "ref/netcore50/ko/System.Reflection.Extensions.xml", + "ref/netcore50/ru/System.Reflection.Extensions.xml", + "ref/netcore50/zh-hans/System.Reflection.Extensions.xml", + "ref/netcore50/zh-hant/System.Reflection.Extensions.xml", + "ref/netstandard1.0/System.Reflection.Extensions.dll", + "ref/netstandard1.0/System.Reflection.Extensions.xml", + "ref/netstandard1.0/de/System.Reflection.Extensions.xml", + "ref/netstandard1.0/es/System.Reflection.Extensions.xml", + "ref/netstandard1.0/fr/System.Reflection.Extensions.xml", + "ref/netstandard1.0/it/System.Reflection.Extensions.xml", + "ref/netstandard1.0/ja/System.Reflection.Extensions.xml", + "ref/netstandard1.0/ko/System.Reflection.Extensions.xml", + "ref/netstandard1.0/ru/System.Reflection.Extensions.xml", + "ref/netstandard1.0/zh-hans/System.Reflection.Extensions.xml", + "ref/netstandard1.0/zh-hant/System.Reflection.Extensions.xml", + "ref/portable-net45+win8+wp8+wpa81/_._", + "ref/win8/_._", + "ref/wp80/_._", + "ref/wpa81/_._", + "ref/xamarinios10/_._", + "ref/xamarinmac20/_._", + "ref/xamarintvos10/_._", + "ref/xamarinwatchos10/_._" + ] + }, + "System.Reflection.Metadata/1.3.0": { + "sha512": "jMSCxA4LSyKBGRDm/WtfkO03FkcgRzHxwvQRib1bm2GZ8ifKM1MX1al6breGCEQK280mdl9uQS7JNPXRYk90jw==", + "type": "package", + "path": "System.Reflection.Metadata/1.3.0", + "files": [ + "System.Reflection.Metadata.1.3.0.nupkg.sha512", + "System.Reflection.Metadata.nuspec", + "ThirdPartyNotices.txt", + "dotnet_library_license.txt", + "lib/netstandard1.1/System.Reflection.Metadata.dll", + "lib/netstandard1.1/System.Reflection.Metadata.xml", + "lib/portable-net45+win8/System.Reflection.Metadata.dll", + "lib/portable-net45+win8/System.Reflection.Metadata.xml" + ] + }, + "System.Reflection.Primitives/4.0.1": { + "sha512": "4inTox4wTBaDhB7V3mPvp9XlCbeGYWVEM9/fXALd52vNEAVisc1BoVWQPuUuD0Ga//dNbA/WeMy9u9mzLxGTHQ==", + "type": "package", + "path": "System.Reflection.Primitives/4.0.1", + "files": [ + "System.Reflection.Primitives.4.0.1.nupkg.sha512", + "System.Reflection.Primitives.nuspec", + "ThirdPartyNotices.txt", + "dotnet_library_license.txt", + "lib/MonoAndroid10/_._", + "lib/MonoTouch10/_._", + "lib/net45/_._", + "lib/portable-net45+win8+wp8+wpa81/_._", + "lib/win8/_._", + "lib/wp80/_._", + "lib/wpa81/_._", + "lib/xamarinios10/_._", + "lib/xamarinmac20/_._", + "lib/xamarintvos10/_._", + "lib/xamarinwatchos10/_._", + "ref/MonoAndroid10/_._", + "ref/MonoTouch10/_._", + "ref/net45/_._", + "ref/netcore50/System.Reflection.Primitives.dll", + "ref/netcore50/System.Reflection.Primitives.xml", + "ref/netcore50/de/System.Reflection.Primitives.xml", + "ref/netcore50/es/System.Reflection.Primitives.xml", + "ref/netcore50/fr/System.Reflection.Primitives.xml", + "ref/netcore50/it/System.Reflection.Primitives.xml", + "ref/netcore50/ja/System.Reflection.Primitives.xml", + "ref/netcore50/ko/System.Reflection.Primitives.xml", + "ref/netcore50/ru/System.Reflection.Primitives.xml", + "ref/netcore50/zh-hans/System.Reflection.Primitives.xml", + "ref/netcore50/zh-hant/System.Reflection.Primitives.xml", + "ref/netstandard1.0/System.Reflection.Primitives.dll", + "ref/netstandard1.0/System.Reflection.Primitives.xml", + "ref/netstandard1.0/de/System.Reflection.Primitives.xml", + "ref/netstandard1.0/es/System.Reflection.Primitives.xml", + "ref/netstandard1.0/fr/System.Reflection.Primitives.xml", + "ref/netstandard1.0/it/System.Reflection.Primitives.xml", + "ref/netstandard1.0/ja/System.Reflection.Primitives.xml", + "ref/netstandard1.0/ko/System.Reflection.Primitives.xml", + "ref/netstandard1.0/ru/System.Reflection.Primitives.xml", + "ref/netstandard1.0/zh-hans/System.Reflection.Primitives.xml", + "ref/netstandard1.0/zh-hant/System.Reflection.Primitives.xml", + "ref/portable-net45+win8+wp8+wpa81/_._", + "ref/win8/_._", + "ref/wp80/_._", + "ref/wpa81/_._", + "ref/xamarinios10/_._", + "ref/xamarinmac20/_._", + "ref/xamarintvos10/_._", + "ref/xamarinwatchos10/_._" + ] + }, + "System.Reflection.TypeExtensions/4.1.0": { + "sha512": "tsQ/ptQ3H5FYfON8lL4MxRk/8kFyE0A+tGPXmVP967cT/gzLHYxIejIYSxp4JmIeFHVP78g/F2FE1mUUTbDtrg==", + "type": "package", + "path": "System.Reflection.TypeExtensions/4.1.0", + "files": [ + "System.Reflection.TypeExtensions.4.1.0.nupkg.sha512", + "System.Reflection.TypeExtensions.nuspec", + "ThirdPartyNotices.txt", + "dotnet_library_license.txt", + "lib/MonoAndroid10/_._", + "lib/MonoTouch10/_._", + "lib/net46/System.Reflection.TypeExtensions.dll", + "lib/net462/System.Reflection.TypeExtensions.dll", + "lib/netcore50/System.Reflection.TypeExtensions.dll", + "lib/netstandard1.5/System.Reflection.TypeExtensions.dll", + "lib/xamarinios10/_._", + "lib/xamarinmac20/_._", + "lib/xamarintvos10/_._", + "lib/xamarinwatchos10/_._", + "ref/MonoAndroid10/_._", + "ref/MonoTouch10/_._", + "ref/net46/System.Reflection.TypeExtensions.dll", + "ref/net462/System.Reflection.TypeExtensions.dll", + "ref/netstandard1.3/System.Reflection.TypeExtensions.dll", + "ref/netstandard1.3/System.Reflection.TypeExtensions.xml", + "ref/netstandard1.3/de/System.Reflection.TypeExtensions.xml", + "ref/netstandard1.3/es/System.Reflection.TypeExtensions.xml", + "ref/netstandard1.3/fr/System.Reflection.TypeExtensions.xml", + "ref/netstandard1.3/it/System.Reflection.TypeExtensions.xml", + "ref/netstandard1.3/ja/System.Reflection.TypeExtensions.xml", + "ref/netstandard1.3/ko/System.Reflection.TypeExtensions.xml", + "ref/netstandard1.3/ru/System.Reflection.TypeExtensions.xml", + "ref/netstandard1.3/zh-hans/System.Reflection.TypeExtensions.xml", + "ref/netstandard1.3/zh-hant/System.Reflection.TypeExtensions.xml", + "ref/netstandard1.5/System.Reflection.TypeExtensions.dll", + "ref/netstandard1.5/System.Reflection.TypeExtensions.xml", + "ref/netstandard1.5/de/System.Reflection.TypeExtensions.xml", + "ref/netstandard1.5/es/System.Reflection.TypeExtensions.xml", + "ref/netstandard1.5/fr/System.Reflection.TypeExtensions.xml", + "ref/netstandard1.5/it/System.Reflection.TypeExtensions.xml", + "ref/netstandard1.5/ja/System.Reflection.TypeExtensions.xml", + "ref/netstandard1.5/ko/System.Reflection.TypeExtensions.xml", + "ref/netstandard1.5/ru/System.Reflection.TypeExtensions.xml", + "ref/netstandard1.5/zh-hans/System.Reflection.TypeExtensions.xml", + "ref/netstandard1.5/zh-hant/System.Reflection.TypeExtensions.xml", + "ref/xamarinios10/_._", + "ref/xamarinmac20/_._", + "ref/xamarintvos10/_._", + "ref/xamarinwatchos10/_._", + "runtimes/aot/lib/netcore50/System.Reflection.TypeExtensions.dll" + ] + }, + "System.Resources.Reader/4.0.0": { + "sha512": "wWI7BbV8TCsNScDFaOKy6Ew9y1IvkDsG0TR5LTV3KUM9ukir7NchQw6d9v7a3WVFxZW569vZlcI9mr5cFb5Prw==", + "type": "package", + "path": "System.Resources.Reader/4.0.0", + "files": [ + "System.Resources.Reader.4.0.0.nupkg.sha512", + "System.Resources.Reader.nuspec", + "ThirdPartyNotices.txt", + "dotnet_library_license.txt", + "lib/netstandard1.0/System.Resources.Reader.dll" + ] + }, + "System.Resources.ResourceManager/4.0.1": { + "sha512": "TxwVeUNoTgUOdQ09gfTjvW411MF+w9MBYL7AtNVc+HtBCFlutPLhUCdZjNkjbhj3bNQWMdHboF0KIWEOjJssbA==", + "type": "package", + "path": "System.Resources.ResourceManager/4.0.1", + "files": [ + "System.Resources.ResourceManager.4.0.1.nupkg.sha512", + "System.Resources.ResourceManager.nuspec", + "ThirdPartyNotices.txt", + "dotnet_library_license.txt", + "lib/MonoAndroid10/_._", + "lib/MonoTouch10/_._", + "lib/net45/_._", + "lib/portable-net45+win8+wp8+wpa81/_._", + "lib/win8/_._", + "lib/wp80/_._", + "lib/wpa81/_._", + "lib/xamarinios10/_._", + "lib/xamarinmac20/_._", + "lib/xamarintvos10/_._", + "lib/xamarinwatchos10/_._", + "ref/MonoAndroid10/_._", + "ref/MonoTouch10/_._", + "ref/net45/_._", + "ref/netcore50/System.Resources.ResourceManager.dll", + "ref/netcore50/System.Resources.ResourceManager.xml", + "ref/netcore50/de/System.Resources.ResourceManager.xml", + "ref/netcore50/es/System.Resources.ResourceManager.xml", + "ref/netcore50/fr/System.Resources.ResourceManager.xml", + "ref/netcore50/it/System.Resources.ResourceManager.xml", + "ref/netcore50/ja/System.Resources.ResourceManager.xml", + "ref/netcore50/ko/System.Resources.ResourceManager.xml", + "ref/netcore50/ru/System.Resources.ResourceManager.xml", + "ref/netcore50/zh-hans/System.Resources.ResourceManager.xml", + "ref/netcore50/zh-hant/System.Resources.ResourceManager.xml", + "ref/netstandard1.0/System.Resources.ResourceManager.dll", + "ref/netstandard1.0/System.Resources.ResourceManager.xml", + "ref/netstandard1.0/de/System.Resources.ResourceManager.xml", + "ref/netstandard1.0/es/System.Resources.ResourceManager.xml", + "ref/netstandard1.0/fr/System.Resources.ResourceManager.xml", + "ref/netstandard1.0/it/System.Resources.ResourceManager.xml", + "ref/netstandard1.0/ja/System.Resources.ResourceManager.xml", + "ref/netstandard1.0/ko/System.Resources.ResourceManager.xml", + "ref/netstandard1.0/ru/System.Resources.ResourceManager.xml", + "ref/netstandard1.0/zh-hans/System.Resources.ResourceManager.xml", + "ref/netstandard1.0/zh-hant/System.Resources.ResourceManager.xml", + "ref/portable-net45+win8+wp8+wpa81/_._", + "ref/win8/_._", + "ref/wp80/_._", + "ref/wpa81/_._", + "ref/xamarinios10/_._", + "ref/xamarinmac20/_._", + "ref/xamarintvos10/_._", + "ref/xamarinwatchos10/_._" + ] + }, + "System.Runtime/4.1.0": { + "sha512": "v6c/4Yaa9uWsq+JMhnOFewrYkgdNHNG2eMKuNqRn8P733rNXeRCGvV5FkkjBXn2dbVkPXOsO0xjsEeM1q2zC0g==", + "type": "package", + "path": "System.Runtime/4.1.0", + "files": [ + "System.Runtime.4.1.0.nupkg.sha512", + "System.Runtime.nuspec", + "ThirdPartyNotices.txt", + "dotnet_library_license.txt", + "lib/MonoAndroid10/_._", + "lib/MonoTouch10/_._", + "lib/net45/_._", + "lib/net462/System.Runtime.dll", + "lib/portable-net45+win8+wp80+wpa81/_._", + "lib/win8/_._", + "lib/wp80/_._", + "lib/wpa81/_._", + "lib/xamarinios10/_._", + "lib/xamarinmac20/_._", + "lib/xamarintvos10/_._", + "lib/xamarinwatchos10/_._", + "ref/MonoAndroid10/_._", + "ref/MonoTouch10/_._", + "ref/net45/_._", + "ref/net462/System.Runtime.dll", + "ref/netcore50/System.Runtime.dll", + "ref/netcore50/System.Runtime.xml", + "ref/netcore50/de/System.Runtime.xml", + "ref/netcore50/es/System.Runtime.xml", + "ref/netcore50/fr/System.Runtime.xml", + "ref/netcore50/it/System.Runtime.xml", + "ref/netcore50/ja/System.Runtime.xml", + "ref/netcore50/ko/System.Runtime.xml", + "ref/netcore50/ru/System.Runtime.xml", + "ref/netcore50/zh-hans/System.Runtime.xml", + "ref/netcore50/zh-hant/System.Runtime.xml", + "ref/netstandard1.0/System.Runtime.dll", + "ref/netstandard1.0/System.Runtime.xml", + "ref/netstandard1.0/de/System.Runtime.xml", + "ref/netstandard1.0/es/System.Runtime.xml", + "ref/netstandard1.0/fr/System.Runtime.xml", + "ref/netstandard1.0/it/System.Runtime.xml", + "ref/netstandard1.0/ja/System.Runtime.xml", + "ref/netstandard1.0/ko/System.Runtime.xml", + "ref/netstandard1.0/ru/System.Runtime.xml", + "ref/netstandard1.0/zh-hans/System.Runtime.xml", + "ref/netstandard1.0/zh-hant/System.Runtime.xml", + "ref/netstandard1.2/System.Runtime.dll", + "ref/netstandard1.2/System.Runtime.xml", + "ref/netstandard1.2/de/System.Runtime.xml", + "ref/netstandard1.2/es/System.Runtime.xml", + "ref/netstandard1.2/fr/System.Runtime.xml", + "ref/netstandard1.2/it/System.Runtime.xml", + "ref/netstandard1.2/ja/System.Runtime.xml", + "ref/netstandard1.2/ko/System.Runtime.xml", + "ref/netstandard1.2/ru/System.Runtime.xml", + "ref/netstandard1.2/zh-hans/System.Runtime.xml", + "ref/netstandard1.2/zh-hant/System.Runtime.xml", + "ref/netstandard1.3/System.Runtime.dll", + "ref/netstandard1.3/System.Runtime.xml", + "ref/netstandard1.3/de/System.Runtime.xml", + "ref/netstandard1.3/es/System.Runtime.xml", + "ref/netstandard1.3/fr/System.Runtime.xml", + "ref/netstandard1.3/it/System.Runtime.xml", + "ref/netstandard1.3/ja/System.Runtime.xml", + "ref/netstandard1.3/ko/System.Runtime.xml", + "ref/netstandard1.3/ru/System.Runtime.xml", + "ref/netstandard1.3/zh-hans/System.Runtime.xml", + "ref/netstandard1.3/zh-hant/System.Runtime.xml", + "ref/netstandard1.5/System.Runtime.dll", + "ref/netstandard1.5/System.Runtime.xml", + "ref/netstandard1.5/de/System.Runtime.xml", + "ref/netstandard1.5/es/System.Runtime.xml", + "ref/netstandard1.5/fr/System.Runtime.xml", + "ref/netstandard1.5/it/System.Runtime.xml", + "ref/netstandard1.5/ja/System.Runtime.xml", + "ref/netstandard1.5/ko/System.Runtime.xml", + "ref/netstandard1.5/ru/System.Runtime.xml", + "ref/netstandard1.5/zh-hans/System.Runtime.xml", + "ref/netstandard1.5/zh-hant/System.Runtime.xml", + "ref/portable-net45+win8+wp80+wpa81/_._", + "ref/win8/_._", + "ref/wp80/_._", + "ref/wpa81/_._", + "ref/xamarinios10/_._", + "ref/xamarinmac20/_._", + "ref/xamarintvos10/_._", + "ref/xamarinwatchos10/_._" + ] + }, + "System.Runtime.Extensions/4.1.0": { + "sha512": "CUOHjTT/vgP0qGW22U4/hDlOqXmcPq5YicBaXdUR2UiUoLwBT+olO6we4DVbq57jeX5uXH2uerVZhf0qGj+sVQ==", + "type": "package", + "path": "System.Runtime.Extensions/4.1.0", + "files": [ + "System.Runtime.Extensions.4.1.0.nupkg.sha512", + "System.Runtime.Extensions.nuspec", + "ThirdPartyNotices.txt", + "dotnet_library_license.txt", + "lib/MonoAndroid10/_._", + "lib/MonoTouch10/_._", + "lib/net45/_._", + "lib/net462/System.Runtime.Extensions.dll", + "lib/portable-net45+win8+wp8+wpa81/_._", + "lib/win8/_._", + "lib/wp80/_._", + "lib/wpa81/_._", + "lib/xamarinios10/_._", + "lib/xamarinmac20/_._", + "lib/xamarintvos10/_._", + "lib/xamarinwatchos10/_._", + "ref/MonoAndroid10/_._", + "ref/MonoTouch10/_._", + "ref/net45/_._", + "ref/net462/System.Runtime.Extensions.dll", + "ref/netcore50/System.Runtime.Extensions.dll", + "ref/netcore50/System.Runtime.Extensions.xml", + "ref/netcore50/de/System.Runtime.Extensions.xml", + "ref/netcore50/es/System.Runtime.Extensions.xml", + "ref/netcore50/fr/System.Runtime.Extensions.xml", + "ref/netcore50/it/System.Runtime.Extensions.xml", + "ref/netcore50/ja/System.Runtime.Extensions.xml", + "ref/netcore50/ko/System.Runtime.Extensions.xml", + "ref/netcore50/ru/System.Runtime.Extensions.xml", + "ref/netcore50/zh-hans/System.Runtime.Extensions.xml", + "ref/netcore50/zh-hant/System.Runtime.Extensions.xml", + "ref/netstandard1.0/System.Runtime.Extensions.dll", + "ref/netstandard1.0/System.Runtime.Extensions.xml", + "ref/netstandard1.0/de/System.Runtime.Extensions.xml", + "ref/netstandard1.0/es/System.Runtime.Extensions.xml", + "ref/netstandard1.0/fr/System.Runtime.Extensions.xml", + "ref/netstandard1.0/it/System.Runtime.Extensions.xml", + "ref/netstandard1.0/ja/System.Runtime.Extensions.xml", + "ref/netstandard1.0/ko/System.Runtime.Extensions.xml", + "ref/netstandard1.0/ru/System.Runtime.Extensions.xml", + "ref/netstandard1.0/zh-hans/System.Runtime.Extensions.xml", + "ref/netstandard1.0/zh-hant/System.Runtime.Extensions.xml", + "ref/netstandard1.3/System.Runtime.Extensions.dll", + "ref/netstandard1.3/System.Runtime.Extensions.xml", + "ref/netstandard1.3/de/System.Runtime.Extensions.xml", + "ref/netstandard1.3/es/System.Runtime.Extensions.xml", + "ref/netstandard1.3/fr/System.Runtime.Extensions.xml", + "ref/netstandard1.3/it/System.Runtime.Extensions.xml", + "ref/netstandard1.3/ja/System.Runtime.Extensions.xml", + "ref/netstandard1.3/ko/System.Runtime.Extensions.xml", + "ref/netstandard1.3/ru/System.Runtime.Extensions.xml", + "ref/netstandard1.3/zh-hans/System.Runtime.Extensions.xml", + "ref/netstandard1.3/zh-hant/System.Runtime.Extensions.xml", + "ref/netstandard1.5/System.Runtime.Extensions.dll", + "ref/netstandard1.5/System.Runtime.Extensions.xml", + "ref/netstandard1.5/de/System.Runtime.Extensions.xml", + "ref/netstandard1.5/es/System.Runtime.Extensions.xml", + "ref/netstandard1.5/fr/System.Runtime.Extensions.xml", + "ref/netstandard1.5/it/System.Runtime.Extensions.xml", + "ref/netstandard1.5/ja/System.Runtime.Extensions.xml", + "ref/netstandard1.5/ko/System.Runtime.Extensions.xml", + "ref/netstandard1.5/ru/System.Runtime.Extensions.xml", + "ref/netstandard1.5/zh-hans/System.Runtime.Extensions.xml", + "ref/netstandard1.5/zh-hant/System.Runtime.Extensions.xml", + "ref/portable-net45+win8+wp8+wpa81/_._", + "ref/win8/_._", + "ref/wp80/_._", + "ref/wpa81/_._", + "ref/xamarinios10/_._", + "ref/xamarinmac20/_._", + "ref/xamarintvos10/_._", + "ref/xamarinwatchos10/_._" + ] + }, + "System.Runtime.Handles/4.0.1": { + "sha512": "nCJvEKguXEvk2ymk1gqj625vVnlK3/xdGzx0vOKicQkoquaTBJTP13AIYkocSUwHCLNBwUbXTqTWGDxBTWpt7g==", + "type": "package", + "path": "System.Runtime.Handles/4.0.1", + "files": [ + "System.Runtime.Handles.4.0.1.nupkg.sha512", + "System.Runtime.Handles.nuspec", + "ThirdPartyNotices.txt", + "dotnet_library_license.txt", + "lib/MonoAndroid10/_._", + "lib/MonoTouch10/_._", + "lib/net46/_._", + "lib/xamarinios10/_._", + "lib/xamarinmac20/_._", + "lib/xamarintvos10/_._", + "lib/xamarinwatchos10/_._", + "ref/MonoAndroid10/_._", + "ref/MonoTouch10/_._", + "ref/net46/_._", + "ref/netstandard1.3/System.Runtime.Handles.dll", + "ref/netstandard1.3/System.Runtime.Handles.xml", + "ref/netstandard1.3/de/System.Runtime.Handles.xml", + "ref/netstandard1.3/es/System.Runtime.Handles.xml", + "ref/netstandard1.3/fr/System.Runtime.Handles.xml", + "ref/netstandard1.3/it/System.Runtime.Handles.xml", + "ref/netstandard1.3/ja/System.Runtime.Handles.xml", + "ref/netstandard1.3/ko/System.Runtime.Handles.xml", + "ref/netstandard1.3/ru/System.Runtime.Handles.xml", + "ref/netstandard1.3/zh-hans/System.Runtime.Handles.xml", + "ref/netstandard1.3/zh-hant/System.Runtime.Handles.xml", + "ref/xamarinios10/_._", + "ref/xamarinmac20/_._", + "ref/xamarintvos10/_._", + "ref/xamarinwatchos10/_._" + ] + }, + "System.Runtime.InteropServices/4.1.0": { + "sha512": "16eu3kjHS633yYdkjwShDHZLRNMKVi/s0bY8ODiqJ2RfMhDMAwxZaUaWVnZ2P71kr/or+X9o/xFWtNqz8ivieQ==", + "type": "package", + "path": "System.Runtime.InteropServices/4.1.0", + "files": [ + "System.Runtime.InteropServices.4.1.0.nupkg.sha512", + "System.Runtime.InteropServices.nuspec", + "ThirdPartyNotices.txt", + "dotnet_library_license.txt", + "lib/MonoAndroid10/_._", + "lib/MonoTouch10/_._", + "lib/net45/_._", + "lib/net462/System.Runtime.InteropServices.dll", + "lib/portable-net45+win8+wpa81/_._", + "lib/win8/_._", + "lib/wpa81/_._", + "lib/xamarinios10/_._", + "lib/xamarinmac20/_._", + "lib/xamarintvos10/_._", + "lib/xamarinwatchos10/_._", + "ref/MonoAndroid10/_._", + "ref/MonoTouch10/_._", + "ref/net45/_._", + "ref/net462/System.Runtime.InteropServices.dll", + "ref/netcore50/System.Runtime.InteropServices.dll", + "ref/netcore50/System.Runtime.InteropServices.xml", + "ref/netcore50/de/System.Runtime.InteropServices.xml", + "ref/netcore50/es/System.Runtime.InteropServices.xml", + "ref/netcore50/fr/System.Runtime.InteropServices.xml", + "ref/netcore50/it/System.Runtime.InteropServices.xml", + "ref/netcore50/ja/System.Runtime.InteropServices.xml", + "ref/netcore50/ko/System.Runtime.InteropServices.xml", + "ref/netcore50/ru/System.Runtime.InteropServices.xml", + "ref/netcore50/zh-hans/System.Runtime.InteropServices.xml", + "ref/netcore50/zh-hant/System.Runtime.InteropServices.xml", + "ref/netstandard1.1/System.Runtime.InteropServices.dll", + "ref/netstandard1.1/System.Runtime.InteropServices.xml", + "ref/netstandard1.1/de/System.Runtime.InteropServices.xml", + "ref/netstandard1.1/es/System.Runtime.InteropServices.xml", + "ref/netstandard1.1/fr/System.Runtime.InteropServices.xml", + "ref/netstandard1.1/it/System.Runtime.InteropServices.xml", + "ref/netstandard1.1/ja/System.Runtime.InteropServices.xml", + "ref/netstandard1.1/ko/System.Runtime.InteropServices.xml", + "ref/netstandard1.1/ru/System.Runtime.InteropServices.xml", + "ref/netstandard1.1/zh-hans/System.Runtime.InteropServices.xml", + "ref/netstandard1.1/zh-hant/System.Runtime.InteropServices.xml", + "ref/netstandard1.2/System.Runtime.InteropServices.dll", + "ref/netstandard1.2/System.Runtime.InteropServices.xml", + "ref/netstandard1.2/de/System.Runtime.InteropServices.xml", + "ref/netstandard1.2/es/System.Runtime.InteropServices.xml", + "ref/netstandard1.2/fr/System.Runtime.InteropServices.xml", + "ref/netstandard1.2/it/System.Runtime.InteropServices.xml", + "ref/netstandard1.2/ja/System.Runtime.InteropServices.xml", + "ref/netstandard1.2/ko/System.Runtime.InteropServices.xml", + "ref/netstandard1.2/ru/System.Runtime.InteropServices.xml", + "ref/netstandard1.2/zh-hans/System.Runtime.InteropServices.xml", + "ref/netstandard1.2/zh-hant/System.Runtime.InteropServices.xml", + "ref/netstandard1.3/System.Runtime.InteropServices.dll", + "ref/netstandard1.3/System.Runtime.InteropServices.xml", + "ref/netstandard1.3/de/System.Runtime.InteropServices.xml", + "ref/netstandard1.3/es/System.Runtime.InteropServices.xml", + "ref/netstandard1.3/fr/System.Runtime.InteropServices.xml", + "ref/netstandard1.3/it/System.Runtime.InteropServices.xml", + "ref/netstandard1.3/ja/System.Runtime.InteropServices.xml", + "ref/netstandard1.3/ko/System.Runtime.InteropServices.xml", + "ref/netstandard1.3/ru/System.Runtime.InteropServices.xml", + "ref/netstandard1.3/zh-hans/System.Runtime.InteropServices.xml", + "ref/netstandard1.3/zh-hant/System.Runtime.InteropServices.xml", + "ref/netstandard1.5/System.Runtime.InteropServices.dll", + "ref/netstandard1.5/System.Runtime.InteropServices.xml", + "ref/netstandard1.5/de/System.Runtime.InteropServices.xml", + "ref/netstandard1.5/es/System.Runtime.InteropServices.xml", + "ref/netstandard1.5/fr/System.Runtime.InteropServices.xml", + "ref/netstandard1.5/it/System.Runtime.InteropServices.xml", + "ref/netstandard1.5/ja/System.Runtime.InteropServices.xml", + "ref/netstandard1.5/ko/System.Runtime.InteropServices.xml", + "ref/netstandard1.5/ru/System.Runtime.InteropServices.xml", + "ref/netstandard1.5/zh-hans/System.Runtime.InteropServices.xml", + "ref/netstandard1.5/zh-hant/System.Runtime.InteropServices.xml", + "ref/portable-net45+win8+wpa81/_._", + "ref/win8/_._", + "ref/wpa81/_._", + "ref/xamarinios10/_._", + "ref/xamarinmac20/_._", + "ref/xamarintvos10/_._", + "ref/xamarinwatchos10/_._" + ] + }, + "System.Runtime.InteropServices.RuntimeInformation/4.0.0": { + "sha512": "hWPhJxc453RCa8Z29O91EmfGeZIHX1ZH2A8L6lYQVSaKzku2DfArSfMEb1/MYYzPQRJZeu0c9dmYeJKxW5Fgng==", + "type": "package", + "path": "System.Runtime.InteropServices.RuntimeInformation/4.0.0", + "files": [ + "System.Runtime.InteropServices.RuntimeInformation.4.0.0.nupkg.sha512", + "System.Runtime.InteropServices.RuntimeInformation.nuspec", + "ThirdPartyNotices.txt", + "dotnet_library_license.txt", + "lib/MonoAndroid10/_._", + "lib/MonoTouch10/_._", + "lib/net45/System.Runtime.InteropServices.RuntimeInformation.dll", + "lib/win8/System.Runtime.InteropServices.RuntimeInformation.dll", + "lib/wpa81/System.Runtime.InteropServices.RuntimeInformation.dll", + "lib/xamarinios10/_._", + "lib/xamarinmac20/_._", + "lib/xamarintvos10/_._", + "lib/xamarinwatchos10/_._", + "ref/MonoAndroid10/_._", + "ref/MonoTouch10/_._", + "ref/netstandard1.1/System.Runtime.InteropServices.RuntimeInformation.dll", + "ref/xamarinios10/_._", + "ref/xamarinmac20/_._", + "ref/xamarintvos10/_._", + "ref/xamarinwatchos10/_._", + "runtimes/aot/lib/netcore50/System.Runtime.InteropServices.RuntimeInformation.dll", + "runtimes/unix/lib/netstandard1.1/System.Runtime.InteropServices.RuntimeInformation.dll", + "runtimes/win/lib/net45/System.Runtime.InteropServices.RuntimeInformation.dll", + "runtimes/win/lib/netcore50/System.Runtime.InteropServices.RuntimeInformation.dll", + "runtimes/win/lib/netstandard1.1/System.Runtime.InteropServices.RuntimeInformation.dll" + ] + }, + "System.Runtime.Loader/4.0.0": { + "sha512": "4UN78GOVU/mbDFcXkEWtetJT/sJ0yic2gGk1HSlSpWI0TDf421xnrZTDZnwNBapk1GQeYN7U1lTj/aQB1by6ow==", + "type": "package", + "path": "System.Runtime.Loader/4.0.0", + "files": [ + "System.Runtime.Loader.4.0.0.nupkg.sha512", + "System.Runtime.Loader.nuspec", + "ThirdPartyNotices.txt", + "dotnet_library_license.txt", + "lib/net462/_._", + "lib/netstandard1.5/System.Runtime.Loader.dll", + "ref/netstandard1.5/System.Runtime.Loader.dll", + "ref/netstandard1.5/System.Runtime.Loader.xml", + "ref/netstandard1.5/de/System.Runtime.Loader.xml", + "ref/netstandard1.5/es/System.Runtime.Loader.xml", + "ref/netstandard1.5/fr/System.Runtime.Loader.xml", + "ref/netstandard1.5/it/System.Runtime.Loader.xml", + "ref/netstandard1.5/ja/System.Runtime.Loader.xml", + "ref/netstandard1.5/ko/System.Runtime.Loader.xml", + "ref/netstandard1.5/ru/System.Runtime.Loader.xml", + "ref/netstandard1.5/zh-hans/System.Runtime.Loader.xml", + "ref/netstandard1.5/zh-hant/System.Runtime.Loader.xml" + ] + }, + "System.Runtime.Numerics/4.0.1": { + "sha512": "+XbKFuzdmLP3d1o9pdHu2nxjNr2OEPqGzKeegPLCUMM71a0t50A/rOcIRmGs9wR7a8KuHX6hYs/7/TymIGLNqg==", + "type": "package", + "path": "System.Runtime.Numerics/4.0.1", + "files": [ + "System.Runtime.Numerics.4.0.1.nupkg.sha512", + "System.Runtime.Numerics.nuspec", + "ThirdPartyNotices.txt", + "dotnet_library_license.txt", + "lib/MonoAndroid10/_._", + "lib/MonoTouch10/_._", + "lib/net45/_._", + "lib/netcore50/System.Runtime.Numerics.dll", + "lib/netstandard1.3/System.Runtime.Numerics.dll", + "lib/portable-net45+win8+wpa81/_._", + "lib/win8/_._", + "lib/wpa81/_._", + "lib/xamarinios10/_._", + "lib/xamarinmac20/_._", + "lib/xamarintvos10/_._", + "lib/xamarinwatchos10/_._", + "ref/MonoAndroid10/_._", + "ref/MonoTouch10/_._", + "ref/net45/_._", + "ref/netcore50/System.Runtime.Numerics.dll", + "ref/netcore50/System.Runtime.Numerics.xml", + "ref/netcore50/de/System.Runtime.Numerics.xml", + "ref/netcore50/es/System.Runtime.Numerics.xml", + "ref/netcore50/fr/System.Runtime.Numerics.xml", + "ref/netcore50/it/System.Runtime.Numerics.xml", + "ref/netcore50/ja/System.Runtime.Numerics.xml", + "ref/netcore50/ko/System.Runtime.Numerics.xml", + "ref/netcore50/ru/System.Runtime.Numerics.xml", + "ref/netcore50/zh-hans/System.Runtime.Numerics.xml", + "ref/netcore50/zh-hant/System.Runtime.Numerics.xml", + "ref/netstandard1.1/System.Runtime.Numerics.dll", + "ref/netstandard1.1/System.Runtime.Numerics.xml", + "ref/netstandard1.1/de/System.Runtime.Numerics.xml", + "ref/netstandard1.1/es/System.Runtime.Numerics.xml", + "ref/netstandard1.1/fr/System.Runtime.Numerics.xml", + "ref/netstandard1.1/it/System.Runtime.Numerics.xml", + "ref/netstandard1.1/ja/System.Runtime.Numerics.xml", + "ref/netstandard1.1/ko/System.Runtime.Numerics.xml", + "ref/netstandard1.1/ru/System.Runtime.Numerics.xml", + "ref/netstandard1.1/zh-hans/System.Runtime.Numerics.xml", + "ref/netstandard1.1/zh-hant/System.Runtime.Numerics.xml", + "ref/portable-net45+win8+wpa81/_._", + "ref/win8/_._", + "ref/wpa81/_._", + "ref/xamarinios10/_._", + "ref/xamarinmac20/_._", + "ref/xamarintvos10/_._", + "ref/xamarinwatchos10/_._" + ] + }, + "System.Runtime.Serialization.Primitives/4.1.1": { + "sha512": "HZ6Du5QrTG8MNJbf4e4qMO3JRAkIboGT5Fk804uZtg3Gq516S7hAqTm2UZKUHa7/6HUGdVy3AqMQKbns06G/cg==", + "type": "package", + "path": "System.Runtime.Serialization.Primitives/4.1.1", + "files": [ + "System.Runtime.Serialization.Primitives.4.1.1.nupkg.sha512", + "System.Runtime.Serialization.Primitives.nuspec", + "ThirdPartyNotices.txt", + "dotnet_library_license.txt", + "lib/MonoAndroid10/_._", + "lib/MonoTouch10/_._", + "lib/net45/_._", + "lib/net46/System.Runtime.Serialization.Primitives.dll", + "lib/netcore50/System.Runtime.Serialization.Primitives.dll", + "lib/netstandard1.3/System.Runtime.Serialization.Primitives.dll", + "lib/portable-net45+win8+wp8+wpa81/_._", + "lib/win8/_._", + "lib/wp80/_._", + "lib/wpa81/_._", + "lib/xamarinios10/_._", + "lib/xamarinmac20/_._", + "lib/xamarintvos10/_._", + "lib/xamarinwatchos10/_._", + "ref/MonoAndroid10/_._", + "ref/MonoTouch10/_._", + "ref/net45/_._", + "ref/net46/System.Runtime.Serialization.Primitives.dll", + "ref/netcore50/System.Runtime.Serialization.Primitives.dll", + "ref/netcore50/System.Runtime.Serialization.Primitives.xml", + "ref/netcore50/de/System.Runtime.Serialization.Primitives.xml", + "ref/netcore50/es/System.Runtime.Serialization.Primitives.xml", + "ref/netcore50/fr/System.Runtime.Serialization.Primitives.xml", + "ref/netcore50/it/System.Runtime.Serialization.Primitives.xml", + "ref/netcore50/ja/System.Runtime.Serialization.Primitives.xml", + "ref/netcore50/ko/System.Runtime.Serialization.Primitives.xml", + "ref/netcore50/ru/System.Runtime.Serialization.Primitives.xml", + "ref/netcore50/zh-hans/System.Runtime.Serialization.Primitives.xml", + "ref/netcore50/zh-hant/System.Runtime.Serialization.Primitives.xml", + "ref/netstandard1.0/System.Runtime.Serialization.Primitives.dll", + "ref/netstandard1.0/System.Runtime.Serialization.Primitives.xml", + "ref/netstandard1.0/de/System.Runtime.Serialization.Primitives.xml", + "ref/netstandard1.0/es/System.Runtime.Serialization.Primitives.xml", + "ref/netstandard1.0/fr/System.Runtime.Serialization.Primitives.xml", + "ref/netstandard1.0/it/System.Runtime.Serialization.Primitives.xml", + "ref/netstandard1.0/ja/System.Runtime.Serialization.Primitives.xml", + "ref/netstandard1.0/ko/System.Runtime.Serialization.Primitives.xml", + "ref/netstandard1.0/ru/System.Runtime.Serialization.Primitives.xml", + "ref/netstandard1.0/zh-hans/System.Runtime.Serialization.Primitives.xml", + "ref/netstandard1.0/zh-hant/System.Runtime.Serialization.Primitives.xml", + "ref/netstandard1.3/System.Runtime.Serialization.Primitives.dll", + "ref/netstandard1.3/System.Runtime.Serialization.Primitives.xml", + "ref/netstandard1.3/de/System.Runtime.Serialization.Primitives.xml", + "ref/netstandard1.3/es/System.Runtime.Serialization.Primitives.xml", + "ref/netstandard1.3/fr/System.Runtime.Serialization.Primitives.xml", + "ref/netstandard1.3/it/System.Runtime.Serialization.Primitives.xml", + "ref/netstandard1.3/ja/System.Runtime.Serialization.Primitives.xml", + "ref/netstandard1.3/ko/System.Runtime.Serialization.Primitives.xml", + "ref/netstandard1.3/ru/System.Runtime.Serialization.Primitives.xml", + "ref/netstandard1.3/zh-hans/System.Runtime.Serialization.Primitives.xml", + "ref/netstandard1.3/zh-hant/System.Runtime.Serialization.Primitives.xml", + "ref/portable-net45+win8+wp8+wpa81/_._", + "ref/win8/_._", + "ref/wp80/_._", + "ref/wpa81/_._", + "ref/xamarinios10/_._", + "ref/xamarinmac20/_._", + "ref/xamarintvos10/_._", + "ref/xamarinwatchos10/_._", + "runtimes/aot/lib/netcore50/System.Runtime.Serialization.Primitives.dll" + ] + }, + "System.Security.Claims/4.0.1": { + "sha512": "4Jlp0OgJLS/Voj1kyFP6MJlIYp3crgfH8kNQk2p7+4JYfc1aAmh9PZyAMMbDhuoolGNtux9HqSOazsioRiDvCw==", + "type": "package", + "path": "System.Security.Claims/4.0.1", + "files": [ + "System.Security.Claims.4.0.1.nupkg.sha512", + "System.Security.Claims.nuspec", + "ThirdPartyNotices.txt", + "dotnet_library_license.txt", + "lib/MonoAndroid10/_._", + "lib/MonoTouch10/_._", + "lib/net46/System.Security.Claims.dll", + "lib/netstandard1.3/System.Security.Claims.dll", + "lib/xamarinios10/_._", + "lib/xamarinmac20/_._", + "lib/xamarintvos10/_._", + "lib/xamarinwatchos10/_._", + "ref/MonoAndroid10/_._", + "ref/MonoTouch10/_._", + "ref/net46/System.Security.Claims.dll", + "ref/netstandard1.3/System.Security.Claims.dll", + "ref/netstandard1.3/System.Security.Claims.xml", + "ref/netstandard1.3/de/System.Security.Claims.xml", + "ref/netstandard1.3/es/System.Security.Claims.xml", + "ref/netstandard1.3/fr/System.Security.Claims.xml", + "ref/netstandard1.3/it/System.Security.Claims.xml", + "ref/netstandard1.3/ja/System.Security.Claims.xml", + "ref/netstandard1.3/ko/System.Security.Claims.xml", + "ref/netstandard1.3/ru/System.Security.Claims.xml", + "ref/netstandard1.3/zh-hans/System.Security.Claims.xml", + "ref/netstandard1.3/zh-hant/System.Security.Claims.xml", + "ref/xamarinios10/_._", + "ref/xamarinmac20/_._", + "ref/xamarintvos10/_._", + "ref/xamarinwatchos10/_._" + ] + }, + "System.Security.Cryptography.Algorithms/4.2.0": { + "sha512": "8JQFxbLVdrtIOKMDN38Fn0GWnqYZw/oMlwOUG/qz1jqChvyZlnUmu+0s7wLx7JYua/nAXoESpHA3iw11QFWhXg==", + "type": "package", + "path": "System.Security.Cryptography.Algorithms/4.2.0", + "files": [ + "System.Security.Cryptography.Algorithms.4.2.0.nupkg.sha512", + "System.Security.Cryptography.Algorithms.nuspec", + "ThirdPartyNotices.txt", + "dotnet_library_license.txt", + "lib/MonoAndroid10/_._", + "lib/MonoTouch10/_._", + "lib/net46/System.Security.Cryptography.Algorithms.dll", + "lib/net461/System.Security.Cryptography.Algorithms.dll", + "lib/net463/System.Security.Cryptography.Algorithms.dll", + "lib/xamarinios10/_._", + "lib/xamarinmac20/_._", + "lib/xamarintvos10/_._", + "lib/xamarinwatchos10/_._", + "ref/MonoAndroid10/_._", + "ref/MonoTouch10/_._", + "ref/net46/System.Security.Cryptography.Algorithms.dll", + "ref/net461/System.Security.Cryptography.Algorithms.dll", + "ref/net463/System.Security.Cryptography.Algorithms.dll", + "ref/netstandard1.3/System.Security.Cryptography.Algorithms.dll", + "ref/netstandard1.4/System.Security.Cryptography.Algorithms.dll", + "ref/netstandard1.6/System.Security.Cryptography.Algorithms.dll", + "ref/xamarinios10/_._", + "ref/xamarinmac20/_._", + "ref/xamarintvos10/_._", + "ref/xamarinwatchos10/_._", + "runtimes/unix/lib/netstandard1.6/System.Security.Cryptography.Algorithms.dll", + "runtimes/win/lib/net46/System.Security.Cryptography.Algorithms.dll", + "runtimes/win/lib/net461/System.Security.Cryptography.Algorithms.dll", + "runtimes/win/lib/net463/System.Security.Cryptography.Algorithms.dll", + "runtimes/win/lib/netcore50/System.Security.Cryptography.Algorithms.dll", + "runtimes/win/lib/netstandard1.6/System.Security.Cryptography.Algorithms.dll" + ] + }, + "System.Security.Cryptography.Cng/4.2.0": { + "sha512": "cUJ2h+ZvONDe28Szw3st5dOHdjndhJzQ2WObDEXAWRPEQBtVItVoxbXM/OEsTthl3cNn2dk2k0I3y45igCQcLw==", + "type": "package", + "path": "System.Security.Cryptography.Cng/4.2.0", + "files": [ + "System.Security.Cryptography.Cng.4.2.0.nupkg.sha512", + "System.Security.Cryptography.Cng.nuspec", + "ThirdPartyNotices.txt", + "dotnet_library_license.txt", + "lib/net46/System.Security.Cryptography.Cng.dll", + "lib/net461/System.Security.Cryptography.Cng.dll", + "lib/net463/System.Security.Cryptography.Cng.dll", + "ref/net46/System.Security.Cryptography.Cng.dll", + "ref/net461/System.Security.Cryptography.Cng.dll", + "ref/net463/System.Security.Cryptography.Cng.dll", + "ref/netstandard1.3/System.Security.Cryptography.Cng.dll", + "ref/netstandard1.4/System.Security.Cryptography.Cng.dll", + "ref/netstandard1.6/System.Security.Cryptography.Cng.dll", + "runtimes/unix/lib/netstandard1.6/System.Security.Cryptography.Cng.dll", + "runtimes/win/lib/net46/System.Security.Cryptography.Cng.dll", + "runtimes/win/lib/net461/System.Security.Cryptography.Cng.dll", + "runtimes/win/lib/net463/System.Security.Cryptography.Cng.dll", + "runtimes/win/lib/netstandard1.4/System.Security.Cryptography.Cng.dll", + "runtimes/win/lib/netstandard1.6/System.Security.Cryptography.Cng.dll" + ] + }, + "System.Security.Cryptography.Csp/4.0.0": { + "sha512": "/i1Usuo4PgAqgbPNC0NjbO3jPW//BoBlTpcWFD1EHVbidH21y4c1ap5bbEMSGAXjAShhMH4abi/K8fILrnu4BQ==", + "type": "package", + "path": "System.Security.Cryptography.Csp/4.0.0", + "files": [ + "System.Security.Cryptography.Csp.4.0.0.nupkg.sha512", + "System.Security.Cryptography.Csp.nuspec", + "ThirdPartyNotices.txt", + "dotnet_library_license.txt", + "lib/MonoAndroid10/_._", + "lib/MonoTouch10/_._", + "lib/net46/System.Security.Cryptography.Csp.dll", + "lib/xamarinios10/_._", + "lib/xamarinmac20/_._", + "lib/xamarintvos10/_._", + "lib/xamarinwatchos10/_._", + "ref/MonoAndroid10/_._", + "ref/MonoTouch10/_._", + "ref/net46/System.Security.Cryptography.Csp.dll", + "ref/netstandard1.3/System.Security.Cryptography.Csp.dll", + "ref/xamarinios10/_._", + "ref/xamarinmac20/_._", + "ref/xamarintvos10/_._", + "ref/xamarinwatchos10/_._", + "runtimes/unix/lib/netstandard1.3/System.Security.Cryptography.Csp.dll", + "runtimes/win/lib/net46/System.Security.Cryptography.Csp.dll", + "runtimes/win/lib/netcore50/_._", + "runtimes/win/lib/netstandard1.3/System.Security.Cryptography.Csp.dll" + ] + }, + "System.Security.Cryptography.Encoding/4.0.0": { + "sha512": "FbKgE5MbxSQMPcSVRgwM6bXN3GtyAh04NkV8E5zKCBE26X0vYW0UtTa2FIgkH33WVqBVxRgxljlVYumWtU+HcQ==", + "type": "package", + "path": "System.Security.Cryptography.Encoding/4.0.0", + "files": [ + "System.Security.Cryptography.Encoding.4.0.0.nupkg.sha512", + "System.Security.Cryptography.Encoding.nuspec", + "ThirdPartyNotices.txt", + "dotnet_library_license.txt", + "lib/MonoAndroid10/_._", + "lib/MonoTouch10/_._", + "lib/net46/System.Security.Cryptography.Encoding.dll", + "lib/xamarinios10/_._", + "lib/xamarinmac20/_._", + "lib/xamarintvos10/_._", + "lib/xamarinwatchos10/_._", + "ref/MonoAndroid10/_._", + "ref/MonoTouch10/_._", + "ref/net46/System.Security.Cryptography.Encoding.dll", + "ref/netstandard1.3/System.Security.Cryptography.Encoding.dll", + "ref/netstandard1.3/System.Security.Cryptography.Encoding.xml", + "ref/netstandard1.3/de/System.Security.Cryptography.Encoding.xml", + "ref/netstandard1.3/es/System.Security.Cryptography.Encoding.xml", + "ref/netstandard1.3/fr/System.Security.Cryptography.Encoding.xml", + "ref/netstandard1.3/it/System.Security.Cryptography.Encoding.xml", + "ref/netstandard1.3/ja/System.Security.Cryptography.Encoding.xml", + "ref/netstandard1.3/ko/System.Security.Cryptography.Encoding.xml", + "ref/netstandard1.3/ru/System.Security.Cryptography.Encoding.xml", + "ref/netstandard1.3/zh-hans/System.Security.Cryptography.Encoding.xml", + "ref/netstandard1.3/zh-hant/System.Security.Cryptography.Encoding.xml", + "ref/xamarinios10/_._", + "ref/xamarinmac20/_._", + "ref/xamarintvos10/_._", + "ref/xamarinwatchos10/_._", + "runtimes/unix/lib/netstandard1.3/System.Security.Cryptography.Encoding.dll", + "runtimes/win/lib/net46/System.Security.Cryptography.Encoding.dll", + "runtimes/win/lib/netstandard1.3/System.Security.Cryptography.Encoding.dll" + ] + }, + "System.Security.Cryptography.OpenSsl/4.0.0": { + "sha512": "HUG/zNUJwEiLkoURDixzkzZdB5yGA5pQhDP93ArOpDPQMteURIGERRNzzoJlmTreLBWr5lkFSjjMSk8ySEpQMw==", + "type": "package", + "path": "System.Security.Cryptography.OpenSsl/4.0.0", + "files": [ + "System.Security.Cryptography.OpenSsl.4.0.0.nupkg.sha512", + "System.Security.Cryptography.OpenSsl.nuspec", + "ThirdPartyNotices.txt", + "dotnet_library_license.txt", + "lib/netstandard1.6/System.Security.Cryptography.OpenSsl.dll", + "ref/netstandard1.6/System.Security.Cryptography.OpenSsl.dll", + "runtimes/unix/lib/netstandard1.6/System.Security.Cryptography.OpenSsl.dll" + ] + }, + "System.Security.Cryptography.Primitives/4.0.0": { + "sha512": "Wkd7QryWYjkQclX0bngpntW5HSlMzeJU24UaLJQ7YTfI8ydAVAaU2J+HXLLABOVJlKTVvAeL0Aj39VeTe7L+oA==", + "type": "package", + "path": "System.Security.Cryptography.Primitives/4.0.0", + "files": [ + "System.Security.Cryptography.Primitives.4.0.0.nupkg.sha512", + "System.Security.Cryptography.Primitives.nuspec", + "ThirdPartyNotices.txt", + "dotnet_library_license.txt", + "lib/MonoAndroid10/_._", + "lib/MonoTouch10/_._", + "lib/net46/System.Security.Cryptography.Primitives.dll", + "lib/netstandard1.3/System.Security.Cryptography.Primitives.dll", + "lib/xamarinios10/_._", + "lib/xamarinmac20/_._", + "lib/xamarintvos10/_._", + "lib/xamarinwatchos10/_._", + "ref/MonoAndroid10/_._", + "ref/MonoTouch10/_._", + "ref/net46/System.Security.Cryptography.Primitives.dll", + "ref/netstandard1.3/System.Security.Cryptography.Primitives.dll", + "ref/xamarinios10/_._", + "ref/xamarinmac20/_._", + "ref/xamarintvos10/_._", + "ref/xamarinwatchos10/_._" + ] + }, + "System.Security.Cryptography.X509Certificates/4.1.0": { + "sha512": "4HEfsQIKAhA1+ApNn729Gi09zh+lYWwyIuViihoMDWp1vQnEkL2ct7mAbhBlLYm+x/L4Rr/pyGge1lIY635e0w==", + "type": "package", + "path": "System.Security.Cryptography.X509Certificates/4.1.0", + "files": [ + "System.Security.Cryptography.X509Certificates.4.1.0.nupkg.sha512", + "System.Security.Cryptography.X509Certificates.nuspec", + "ThirdPartyNotices.txt", + "dotnet_library_license.txt", + "lib/MonoAndroid10/_._", + "lib/MonoTouch10/_._", + "lib/net46/System.Security.Cryptography.X509Certificates.dll", + "lib/net461/System.Security.Cryptography.X509Certificates.dll", + "lib/xamarinios10/_._", + "lib/xamarinmac20/_._", + "lib/xamarintvos10/_._", + "lib/xamarinwatchos10/_._", + "ref/MonoAndroid10/_._", + "ref/MonoTouch10/_._", + "ref/net46/System.Security.Cryptography.X509Certificates.dll", + "ref/net461/System.Security.Cryptography.X509Certificates.dll", + "ref/netstandard1.3/System.Security.Cryptography.X509Certificates.dll", + "ref/netstandard1.3/System.Security.Cryptography.X509Certificates.xml", + "ref/netstandard1.3/de/System.Security.Cryptography.X509Certificates.xml", + "ref/netstandard1.3/es/System.Security.Cryptography.X509Certificates.xml", + "ref/netstandard1.3/fr/System.Security.Cryptography.X509Certificates.xml", + "ref/netstandard1.3/it/System.Security.Cryptography.X509Certificates.xml", + "ref/netstandard1.3/ja/System.Security.Cryptography.X509Certificates.xml", + "ref/netstandard1.3/ko/System.Security.Cryptography.X509Certificates.xml", + "ref/netstandard1.3/ru/System.Security.Cryptography.X509Certificates.xml", + "ref/netstandard1.3/zh-hans/System.Security.Cryptography.X509Certificates.xml", + "ref/netstandard1.3/zh-hant/System.Security.Cryptography.X509Certificates.xml", + "ref/netstandard1.4/System.Security.Cryptography.X509Certificates.dll", + "ref/netstandard1.4/System.Security.Cryptography.X509Certificates.xml", + "ref/netstandard1.4/de/System.Security.Cryptography.X509Certificates.xml", + "ref/netstandard1.4/es/System.Security.Cryptography.X509Certificates.xml", + "ref/netstandard1.4/fr/System.Security.Cryptography.X509Certificates.xml", + "ref/netstandard1.4/it/System.Security.Cryptography.X509Certificates.xml", + "ref/netstandard1.4/ja/System.Security.Cryptography.X509Certificates.xml", + "ref/netstandard1.4/ko/System.Security.Cryptography.X509Certificates.xml", + "ref/netstandard1.4/ru/System.Security.Cryptography.X509Certificates.xml", + "ref/netstandard1.4/zh-hans/System.Security.Cryptography.X509Certificates.xml", + "ref/netstandard1.4/zh-hant/System.Security.Cryptography.X509Certificates.xml", + "ref/xamarinios10/_._", + "ref/xamarinmac20/_._", + "ref/xamarintvos10/_._", + "ref/xamarinwatchos10/_._", + "runtimes/unix/lib/netstandard1.6/System.Security.Cryptography.X509Certificates.dll", + "runtimes/win/lib/net46/System.Security.Cryptography.X509Certificates.dll", + "runtimes/win/lib/net461/System.Security.Cryptography.X509Certificates.dll", + "runtimes/win/lib/netcore50/System.Security.Cryptography.X509Certificates.dll", + "runtimes/win/lib/netstandard1.6/System.Security.Cryptography.X509Certificates.dll" + ] + }, + "System.Security.Principal/4.0.1": { + "sha512": "On+SKhXY5rzxh/S8wlH1Rm0ogBlu7zyHNxeNBiXauNrhHRXAe9EuX8Yl5IOzLPGU5Z4kLWHMvORDOCG8iu9hww==", + "type": "package", + "path": "System.Security.Principal/4.0.1", + "files": [ + "System.Security.Principal.4.0.1.nupkg.sha512", + "System.Security.Principal.nuspec", + "ThirdPartyNotices.txt", + "dotnet_library_license.txt", + "lib/MonoAndroid10/_._", + "lib/MonoTouch10/_._", + "lib/net45/_._", + "lib/netcore50/System.Security.Principal.dll", + "lib/netstandard1.0/System.Security.Principal.dll", + "lib/portable-net45+win8+wp8+wpa81/_._", + "lib/win8/_._", + "lib/wp80/_._", + "lib/wpa81/_._", + "lib/xamarinios10/_._", + "lib/xamarinmac20/_._", + "lib/xamarintvos10/_._", + "lib/xamarinwatchos10/_._", + "ref/MonoAndroid10/_._", + "ref/MonoTouch10/_._", + "ref/net45/_._", + "ref/netcore50/System.Security.Principal.dll", + "ref/netcore50/System.Security.Principal.xml", + "ref/netcore50/de/System.Security.Principal.xml", + "ref/netcore50/es/System.Security.Principal.xml", + "ref/netcore50/fr/System.Security.Principal.xml", + "ref/netcore50/it/System.Security.Principal.xml", + "ref/netcore50/ja/System.Security.Principal.xml", + "ref/netcore50/ko/System.Security.Principal.xml", + "ref/netcore50/ru/System.Security.Principal.xml", + "ref/netcore50/zh-hans/System.Security.Principal.xml", + "ref/netcore50/zh-hant/System.Security.Principal.xml", + "ref/netstandard1.0/System.Security.Principal.dll", + "ref/netstandard1.0/System.Security.Principal.xml", + "ref/netstandard1.0/de/System.Security.Principal.xml", + "ref/netstandard1.0/es/System.Security.Principal.xml", + "ref/netstandard1.0/fr/System.Security.Principal.xml", + "ref/netstandard1.0/it/System.Security.Principal.xml", + "ref/netstandard1.0/ja/System.Security.Principal.xml", + "ref/netstandard1.0/ko/System.Security.Principal.xml", + "ref/netstandard1.0/ru/System.Security.Principal.xml", + "ref/netstandard1.0/zh-hans/System.Security.Principal.xml", + "ref/netstandard1.0/zh-hant/System.Security.Principal.xml", + "ref/portable-net45+win8+wp8+wpa81/_._", + "ref/win8/_._", + "ref/wp80/_._", + "ref/wpa81/_._", + "ref/xamarinios10/_._", + "ref/xamarinmac20/_._", + "ref/xamarintvos10/_._", + "ref/xamarinwatchos10/_._" + ] + }, + "System.Security.Principal.Windows/4.0.0": { + "sha512": "iFx15AF3RMEPZn3COh8+Bb2Thv2zsmLd93RchS1b8Mj5SNYeGqbYNCSn5AES1+gq56p4ujGZPrl0xN7ngkXOHg==", + "type": "package", + "path": "System.Security.Principal.Windows/4.0.0", + "files": [ + "System.Security.Principal.Windows.4.0.0.nupkg.sha512", + "System.Security.Principal.Windows.nuspec", + "ThirdPartyNotices.txt", + "dotnet_library_license.txt", + "lib/net46/System.Security.Principal.Windows.dll", + "ref/net46/System.Security.Principal.Windows.dll", + "ref/netstandard1.3/System.Security.Principal.Windows.dll", + "ref/netstandard1.3/System.Security.Principal.Windows.xml", + "ref/netstandard1.3/de/System.Security.Principal.Windows.xml", + "ref/netstandard1.3/es/System.Security.Principal.Windows.xml", + "ref/netstandard1.3/fr/System.Security.Principal.Windows.xml", + "ref/netstandard1.3/it/System.Security.Principal.Windows.xml", + "ref/netstandard1.3/ja/System.Security.Principal.Windows.xml", + "ref/netstandard1.3/ko/System.Security.Principal.Windows.xml", + "ref/netstandard1.3/ru/System.Security.Principal.Windows.xml", + "ref/netstandard1.3/zh-hans/System.Security.Principal.Windows.xml", + "ref/netstandard1.3/zh-hant/System.Security.Principal.Windows.xml", + "runtimes/unix/lib/netstandard1.3/System.Security.Principal.Windows.dll", + "runtimes/win/lib/net46/System.Security.Principal.Windows.dll", + "runtimes/win/lib/netstandard1.3/System.Security.Principal.Windows.dll" + ] + }, + "System.Text.Encoding/4.0.11": { + "sha512": "U3gGeMlDZXxCEiY4DwVLSacg+DFWCvoiX+JThA/rvw37Sqrku7sEFeVBBBMBnfB6FeZHsyDx85HlKL19x0HtZA==", + "type": "package", + "path": "System.Text.Encoding/4.0.11", + "files": [ + "System.Text.Encoding.4.0.11.nupkg.sha512", + "System.Text.Encoding.nuspec", + "ThirdPartyNotices.txt", + "dotnet_library_license.txt", + "lib/MonoAndroid10/_._", + "lib/MonoTouch10/_._", + "lib/net45/_._", + "lib/portable-net45+win8+wp8+wpa81/_._", + "lib/win8/_._", + "lib/wp80/_._", + "lib/wpa81/_._", + "lib/xamarinios10/_._", + "lib/xamarinmac20/_._", + "lib/xamarintvos10/_._", + "lib/xamarinwatchos10/_._", + "ref/MonoAndroid10/_._", + "ref/MonoTouch10/_._", + "ref/net45/_._", + "ref/netcore50/System.Text.Encoding.dll", + "ref/netcore50/System.Text.Encoding.xml", + "ref/netcore50/de/System.Text.Encoding.xml", + "ref/netcore50/es/System.Text.Encoding.xml", + "ref/netcore50/fr/System.Text.Encoding.xml", + "ref/netcore50/it/System.Text.Encoding.xml", + "ref/netcore50/ja/System.Text.Encoding.xml", + "ref/netcore50/ko/System.Text.Encoding.xml", + "ref/netcore50/ru/System.Text.Encoding.xml", + "ref/netcore50/zh-hans/System.Text.Encoding.xml", + "ref/netcore50/zh-hant/System.Text.Encoding.xml", + "ref/netstandard1.0/System.Text.Encoding.dll", + "ref/netstandard1.0/System.Text.Encoding.xml", + "ref/netstandard1.0/de/System.Text.Encoding.xml", + "ref/netstandard1.0/es/System.Text.Encoding.xml", + "ref/netstandard1.0/fr/System.Text.Encoding.xml", + "ref/netstandard1.0/it/System.Text.Encoding.xml", + "ref/netstandard1.0/ja/System.Text.Encoding.xml", + "ref/netstandard1.0/ko/System.Text.Encoding.xml", + "ref/netstandard1.0/ru/System.Text.Encoding.xml", + "ref/netstandard1.0/zh-hans/System.Text.Encoding.xml", + "ref/netstandard1.0/zh-hant/System.Text.Encoding.xml", + "ref/netstandard1.3/System.Text.Encoding.dll", + "ref/netstandard1.3/System.Text.Encoding.xml", + "ref/netstandard1.3/de/System.Text.Encoding.xml", + "ref/netstandard1.3/es/System.Text.Encoding.xml", + "ref/netstandard1.3/fr/System.Text.Encoding.xml", + "ref/netstandard1.3/it/System.Text.Encoding.xml", + "ref/netstandard1.3/ja/System.Text.Encoding.xml", + "ref/netstandard1.3/ko/System.Text.Encoding.xml", + "ref/netstandard1.3/ru/System.Text.Encoding.xml", + "ref/netstandard1.3/zh-hans/System.Text.Encoding.xml", + "ref/netstandard1.3/zh-hant/System.Text.Encoding.xml", + "ref/portable-net45+win8+wp8+wpa81/_._", + "ref/win8/_._", + "ref/wp80/_._", + "ref/wpa81/_._", + "ref/xamarinios10/_._", + "ref/xamarinmac20/_._", + "ref/xamarintvos10/_._", + "ref/xamarinwatchos10/_._" + ] + }, + "System.Text.Encoding.CodePages/4.0.1": { + "sha512": "h4z6rrA/hxWf4655D18IIZ0eaLRa3tQC/j+e26W+VinIHY0l07iEXaAvO0YSYq3MvCjMYy8Zs5AdC1sxNQOB7Q==", + "type": "package", + "path": "System.Text.Encoding.CodePages/4.0.1", + "files": [ + "System.Text.Encoding.CodePages.4.0.1.nupkg.sha512", + "System.Text.Encoding.CodePages.nuspec", + "ThirdPartyNotices.txt", + "dotnet_library_license.txt", + "lib/MonoAndroid10/_._", + "lib/MonoTouch10/_._", + "lib/net46/System.Text.Encoding.CodePages.dll", + "lib/xamarinios10/_._", + "lib/xamarinmac20/_._", + "lib/xamarintvos10/_._", + "lib/xamarinwatchos10/_._", + "ref/MonoAndroid10/_._", + "ref/MonoTouch10/_._", + "ref/netstandard1.3/System.Text.Encoding.CodePages.dll", + "ref/netstandard1.3/System.Text.Encoding.CodePages.xml", + "ref/netstandard1.3/de/System.Text.Encoding.CodePages.xml", + "ref/netstandard1.3/es/System.Text.Encoding.CodePages.xml", + "ref/netstandard1.3/fr/System.Text.Encoding.CodePages.xml", + "ref/netstandard1.3/it/System.Text.Encoding.CodePages.xml", + "ref/netstandard1.3/ja/System.Text.Encoding.CodePages.xml", + "ref/netstandard1.3/ko/System.Text.Encoding.CodePages.xml", + "ref/netstandard1.3/ru/System.Text.Encoding.CodePages.xml", + "ref/netstandard1.3/zh-hans/System.Text.Encoding.CodePages.xml", + "ref/netstandard1.3/zh-hant/System.Text.Encoding.CodePages.xml", + "ref/xamarinios10/_._", + "ref/xamarinmac20/_._", + "ref/xamarintvos10/_._", + "ref/xamarinwatchos10/_._", + "runtimes/unix/lib/netstandard1.3/System.Text.Encoding.CodePages.dll", + "runtimes/win/lib/netstandard1.3/System.Text.Encoding.CodePages.dll" + ] + }, + "System.Text.Encoding.Extensions/4.0.11": { + "sha512": "jtbiTDtvfLYgXn8PTfWI+SiBs51rrmO4AAckx4KR6vFK9Wzf6tI8kcRdsYQNwriUeQ1+CtQbM1W4cMbLXnj/OQ==", + "type": "package", + "path": "System.Text.Encoding.Extensions/4.0.11", + "files": [ + "System.Text.Encoding.Extensions.4.0.11.nupkg.sha512", + "System.Text.Encoding.Extensions.nuspec", + "ThirdPartyNotices.txt", + "dotnet_library_license.txt", + "lib/MonoAndroid10/_._", + "lib/MonoTouch10/_._", + "lib/net45/_._", + "lib/portable-net45+win8+wp8+wpa81/_._", + "lib/win8/_._", + "lib/wp80/_._", + "lib/wpa81/_._", + "lib/xamarinios10/_._", + "lib/xamarinmac20/_._", + "lib/xamarintvos10/_._", + "lib/xamarinwatchos10/_._", + "ref/MonoAndroid10/_._", + "ref/MonoTouch10/_._", + "ref/net45/_._", + "ref/netcore50/System.Text.Encoding.Extensions.dll", + "ref/netcore50/System.Text.Encoding.Extensions.xml", + "ref/netcore50/de/System.Text.Encoding.Extensions.xml", + "ref/netcore50/es/System.Text.Encoding.Extensions.xml", + "ref/netcore50/fr/System.Text.Encoding.Extensions.xml", + "ref/netcore50/it/System.Text.Encoding.Extensions.xml", + "ref/netcore50/ja/System.Text.Encoding.Extensions.xml", + "ref/netcore50/ko/System.Text.Encoding.Extensions.xml", + "ref/netcore50/ru/System.Text.Encoding.Extensions.xml", + "ref/netcore50/zh-hans/System.Text.Encoding.Extensions.xml", + "ref/netcore50/zh-hant/System.Text.Encoding.Extensions.xml", + "ref/netstandard1.0/System.Text.Encoding.Extensions.dll", + "ref/netstandard1.0/System.Text.Encoding.Extensions.xml", + "ref/netstandard1.0/de/System.Text.Encoding.Extensions.xml", + "ref/netstandard1.0/es/System.Text.Encoding.Extensions.xml", + "ref/netstandard1.0/fr/System.Text.Encoding.Extensions.xml", + "ref/netstandard1.0/it/System.Text.Encoding.Extensions.xml", + "ref/netstandard1.0/ja/System.Text.Encoding.Extensions.xml", + "ref/netstandard1.0/ko/System.Text.Encoding.Extensions.xml", + "ref/netstandard1.0/ru/System.Text.Encoding.Extensions.xml", + "ref/netstandard1.0/zh-hans/System.Text.Encoding.Extensions.xml", + "ref/netstandard1.0/zh-hant/System.Text.Encoding.Extensions.xml", + "ref/netstandard1.3/System.Text.Encoding.Extensions.dll", + "ref/netstandard1.3/System.Text.Encoding.Extensions.xml", + "ref/netstandard1.3/de/System.Text.Encoding.Extensions.xml", + "ref/netstandard1.3/es/System.Text.Encoding.Extensions.xml", + "ref/netstandard1.3/fr/System.Text.Encoding.Extensions.xml", + "ref/netstandard1.3/it/System.Text.Encoding.Extensions.xml", + "ref/netstandard1.3/ja/System.Text.Encoding.Extensions.xml", + "ref/netstandard1.3/ko/System.Text.Encoding.Extensions.xml", + "ref/netstandard1.3/ru/System.Text.Encoding.Extensions.xml", + "ref/netstandard1.3/zh-hans/System.Text.Encoding.Extensions.xml", + "ref/netstandard1.3/zh-hant/System.Text.Encoding.Extensions.xml", + "ref/portable-net45+win8+wp8+wpa81/_._", + "ref/win8/_._", + "ref/wp80/_._", + "ref/wpa81/_._", + "ref/xamarinios10/_._", + "ref/xamarinmac20/_._", + "ref/xamarintvos10/_._", + "ref/xamarinwatchos10/_._" + ] + }, + "System.Text.RegularExpressions/4.1.0": { + "sha512": "i88YCXpRTjCnoSQZtdlHkAOx4KNNik4hMy83n0+Ftlb7jvV6ZiZWMpnEZHhjBp6hQVh8gWd/iKNPzlPF7iyA2g==", + "type": "package", + "path": "System.Text.RegularExpressions/4.1.0", + "files": [ + "System.Text.RegularExpressions.4.1.0.nupkg.sha512", + "System.Text.RegularExpressions.nuspec", + "ThirdPartyNotices.txt", + "dotnet_library_license.txt", + "lib/MonoAndroid10/_._", + "lib/MonoTouch10/_._", + "lib/net45/_._", + "lib/net463/System.Text.RegularExpressions.dll", + "lib/netcore50/System.Text.RegularExpressions.dll", + "lib/netstandard1.6/System.Text.RegularExpressions.dll", + "lib/portable-net45+win8+wp8+wpa81/_._", + "lib/win8/_._", + "lib/wp80/_._", + "lib/wpa81/_._", + "lib/xamarinios10/_._", + "lib/xamarinmac20/_._", + "lib/xamarintvos10/_._", + "lib/xamarinwatchos10/_._", + "ref/MonoAndroid10/_._", + "ref/MonoTouch10/_._", + "ref/net45/_._", + "ref/net463/System.Text.RegularExpressions.dll", + "ref/netcore50/System.Text.RegularExpressions.dll", + "ref/netcore50/System.Text.RegularExpressions.xml", + "ref/netcore50/de/System.Text.RegularExpressions.xml", + "ref/netcore50/es/System.Text.RegularExpressions.xml", + "ref/netcore50/fr/System.Text.RegularExpressions.xml", + "ref/netcore50/it/System.Text.RegularExpressions.xml", + "ref/netcore50/ja/System.Text.RegularExpressions.xml", + "ref/netcore50/ko/System.Text.RegularExpressions.xml", + "ref/netcore50/ru/System.Text.RegularExpressions.xml", + "ref/netcore50/zh-hans/System.Text.RegularExpressions.xml", + "ref/netcore50/zh-hant/System.Text.RegularExpressions.xml", + "ref/netstandard1.0/System.Text.RegularExpressions.dll", + "ref/netstandard1.0/System.Text.RegularExpressions.xml", + "ref/netstandard1.0/de/System.Text.RegularExpressions.xml", + "ref/netstandard1.0/es/System.Text.RegularExpressions.xml", + "ref/netstandard1.0/fr/System.Text.RegularExpressions.xml", + "ref/netstandard1.0/it/System.Text.RegularExpressions.xml", + "ref/netstandard1.0/ja/System.Text.RegularExpressions.xml", + "ref/netstandard1.0/ko/System.Text.RegularExpressions.xml", + "ref/netstandard1.0/ru/System.Text.RegularExpressions.xml", + "ref/netstandard1.0/zh-hans/System.Text.RegularExpressions.xml", + "ref/netstandard1.0/zh-hant/System.Text.RegularExpressions.xml", + "ref/netstandard1.3/System.Text.RegularExpressions.dll", + "ref/netstandard1.3/System.Text.RegularExpressions.xml", + "ref/netstandard1.3/de/System.Text.RegularExpressions.xml", + "ref/netstandard1.3/es/System.Text.RegularExpressions.xml", + "ref/netstandard1.3/fr/System.Text.RegularExpressions.xml", + "ref/netstandard1.3/it/System.Text.RegularExpressions.xml", + "ref/netstandard1.3/ja/System.Text.RegularExpressions.xml", + "ref/netstandard1.3/ko/System.Text.RegularExpressions.xml", + "ref/netstandard1.3/ru/System.Text.RegularExpressions.xml", + "ref/netstandard1.3/zh-hans/System.Text.RegularExpressions.xml", + "ref/netstandard1.3/zh-hant/System.Text.RegularExpressions.xml", + "ref/netstandard1.6/System.Text.RegularExpressions.dll", + "ref/netstandard1.6/System.Text.RegularExpressions.xml", + "ref/netstandard1.6/de/System.Text.RegularExpressions.xml", + "ref/netstandard1.6/es/System.Text.RegularExpressions.xml", + "ref/netstandard1.6/fr/System.Text.RegularExpressions.xml", + "ref/netstandard1.6/it/System.Text.RegularExpressions.xml", + "ref/netstandard1.6/ja/System.Text.RegularExpressions.xml", + "ref/netstandard1.6/ko/System.Text.RegularExpressions.xml", + "ref/netstandard1.6/ru/System.Text.RegularExpressions.xml", + "ref/netstandard1.6/zh-hans/System.Text.RegularExpressions.xml", + "ref/netstandard1.6/zh-hant/System.Text.RegularExpressions.xml", + "ref/portable-net45+win8+wp8+wpa81/_._", + "ref/win8/_._", + "ref/wp80/_._", + "ref/wpa81/_._", + "ref/xamarinios10/_._", + "ref/xamarinmac20/_._", + "ref/xamarintvos10/_._", + "ref/xamarinwatchos10/_._" + ] + }, + "System.Threading/4.0.11": { + "sha512": "N+3xqIcg3VDKyjwwCGaZ9HawG9aC6cSDI+s7ROma310GQo8vilFZa86hqKppwTHleR/G0sfOzhvgnUxWCR/DrQ==", + "type": "package", + "path": "System.Threading/4.0.11", + "files": [ + "System.Threading.4.0.11.nupkg.sha512", + "System.Threading.nuspec", + "ThirdPartyNotices.txt", + "dotnet_library_license.txt", + "lib/MonoAndroid10/_._", + "lib/MonoTouch10/_._", + "lib/net45/_._", + "lib/netcore50/System.Threading.dll", + "lib/netstandard1.3/System.Threading.dll", + "lib/portable-net45+win8+wp8+wpa81/_._", + "lib/win8/_._", + "lib/wp80/_._", + "lib/wpa81/_._", + "lib/xamarinios10/_._", + "lib/xamarinmac20/_._", + "lib/xamarintvos10/_._", + "lib/xamarinwatchos10/_._", + "ref/MonoAndroid10/_._", + "ref/MonoTouch10/_._", + "ref/net45/_._", + "ref/netcore50/System.Threading.dll", + "ref/netcore50/System.Threading.xml", + "ref/netcore50/de/System.Threading.xml", + "ref/netcore50/es/System.Threading.xml", + "ref/netcore50/fr/System.Threading.xml", + "ref/netcore50/it/System.Threading.xml", + "ref/netcore50/ja/System.Threading.xml", + "ref/netcore50/ko/System.Threading.xml", + "ref/netcore50/ru/System.Threading.xml", + "ref/netcore50/zh-hans/System.Threading.xml", + "ref/netcore50/zh-hant/System.Threading.xml", + "ref/netstandard1.0/System.Threading.dll", + "ref/netstandard1.0/System.Threading.xml", + "ref/netstandard1.0/de/System.Threading.xml", + "ref/netstandard1.0/es/System.Threading.xml", + "ref/netstandard1.0/fr/System.Threading.xml", + "ref/netstandard1.0/it/System.Threading.xml", + "ref/netstandard1.0/ja/System.Threading.xml", + "ref/netstandard1.0/ko/System.Threading.xml", + "ref/netstandard1.0/ru/System.Threading.xml", + "ref/netstandard1.0/zh-hans/System.Threading.xml", + "ref/netstandard1.0/zh-hant/System.Threading.xml", + "ref/netstandard1.3/System.Threading.dll", + "ref/netstandard1.3/System.Threading.xml", + "ref/netstandard1.3/de/System.Threading.xml", + "ref/netstandard1.3/es/System.Threading.xml", + "ref/netstandard1.3/fr/System.Threading.xml", + "ref/netstandard1.3/it/System.Threading.xml", + "ref/netstandard1.3/ja/System.Threading.xml", + "ref/netstandard1.3/ko/System.Threading.xml", + "ref/netstandard1.3/ru/System.Threading.xml", + "ref/netstandard1.3/zh-hans/System.Threading.xml", + "ref/netstandard1.3/zh-hant/System.Threading.xml", + "ref/portable-net45+win8+wp8+wpa81/_._", + "ref/win8/_._", + "ref/wp80/_._", + "ref/wpa81/_._", + "ref/xamarinios10/_._", + "ref/xamarinmac20/_._", + "ref/xamarintvos10/_._", + "ref/xamarinwatchos10/_._", + "runtimes/aot/lib/netcore50/System.Threading.dll" + ] + }, + "System.Threading.Overlapped/4.0.1": { + "sha512": "f7aLuLkBoCQM2kng7zqLFBXz9Gk48gDK8lk1ih9rH/1arJJzZK9gJwNvPDhL6Ps/l6rwOr8jw+4FCHL0KKWiEg==", + "type": "package", + "path": "System.Threading.Overlapped/4.0.1", + "files": [ + "System.Threading.Overlapped.4.0.1.nupkg.sha512", + "System.Threading.Overlapped.nuspec", + "ThirdPartyNotices.txt", + "dotnet_library_license.txt", + "lib/net46/System.Threading.Overlapped.dll", + "ref/net46/System.Threading.Overlapped.dll", + "ref/netstandard1.3/System.Threading.Overlapped.dll", + "ref/netstandard1.3/System.Threading.Overlapped.xml", + "ref/netstandard1.3/de/System.Threading.Overlapped.xml", + "ref/netstandard1.3/es/System.Threading.Overlapped.xml", + "ref/netstandard1.3/fr/System.Threading.Overlapped.xml", + "ref/netstandard1.3/it/System.Threading.Overlapped.xml", + "ref/netstandard1.3/ja/System.Threading.Overlapped.xml", + "ref/netstandard1.3/ko/System.Threading.Overlapped.xml", + "ref/netstandard1.3/ru/System.Threading.Overlapped.xml", + "ref/netstandard1.3/zh-hans/System.Threading.Overlapped.xml", + "ref/netstandard1.3/zh-hant/System.Threading.Overlapped.xml", + "runtimes/unix/lib/netstandard1.3/System.Threading.Overlapped.dll", + "runtimes/win/lib/net46/System.Threading.Overlapped.dll", + "runtimes/win/lib/netcore50/System.Threading.Overlapped.dll", + "runtimes/win/lib/netstandard1.3/System.Threading.Overlapped.dll" + ] + }, + "System.Threading.Tasks/4.0.11": { + "sha512": "k1S4Gc6IGwtHGT8188RSeGaX86Qw/wnrgNLshJvsdNUOPP9etMmo8S07c+UlOAx4K/xLuN9ivA1bD0LVurtIxQ==", + "type": "package", + "path": "System.Threading.Tasks/4.0.11", + "files": [ + "System.Threading.Tasks.4.0.11.nupkg.sha512", + "System.Threading.Tasks.nuspec", + "ThirdPartyNotices.txt", + "dotnet_library_license.txt", + "lib/MonoAndroid10/_._", + "lib/MonoTouch10/_._", + "lib/net45/_._", + "lib/portable-net45+win8+wp8+wpa81/_._", + "lib/win8/_._", + "lib/wp80/_._", + "lib/wpa81/_._", + "lib/xamarinios10/_._", + "lib/xamarinmac20/_._", + "lib/xamarintvos10/_._", + "lib/xamarinwatchos10/_._", + "ref/MonoAndroid10/_._", + "ref/MonoTouch10/_._", + "ref/net45/_._", + "ref/netcore50/System.Threading.Tasks.dll", + "ref/netcore50/System.Threading.Tasks.xml", + "ref/netcore50/de/System.Threading.Tasks.xml", + "ref/netcore50/es/System.Threading.Tasks.xml", + "ref/netcore50/fr/System.Threading.Tasks.xml", + "ref/netcore50/it/System.Threading.Tasks.xml", + "ref/netcore50/ja/System.Threading.Tasks.xml", + "ref/netcore50/ko/System.Threading.Tasks.xml", + "ref/netcore50/ru/System.Threading.Tasks.xml", + "ref/netcore50/zh-hans/System.Threading.Tasks.xml", + "ref/netcore50/zh-hant/System.Threading.Tasks.xml", + "ref/netstandard1.0/System.Threading.Tasks.dll", + "ref/netstandard1.0/System.Threading.Tasks.xml", + "ref/netstandard1.0/de/System.Threading.Tasks.xml", + "ref/netstandard1.0/es/System.Threading.Tasks.xml", + "ref/netstandard1.0/fr/System.Threading.Tasks.xml", + "ref/netstandard1.0/it/System.Threading.Tasks.xml", + "ref/netstandard1.0/ja/System.Threading.Tasks.xml", + "ref/netstandard1.0/ko/System.Threading.Tasks.xml", + "ref/netstandard1.0/ru/System.Threading.Tasks.xml", + "ref/netstandard1.0/zh-hans/System.Threading.Tasks.xml", + "ref/netstandard1.0/zh-hant/System.Threading.Tasks.xml", + "ref/netstandard1.3/System.Threading.Tasks.dll", + "ref/netstandard1.3/System.Threading.Tasks.xml", + "ref/netstandard1.3/de/System.Threading.Tasks.xml", + "ref/netstandard1.3/es/System.Threading.Tasks.xml", + "ref/netstandard1.3/fr/System.Threading.Tasks.xml", + "ref/netstandard1.3/it/System.Threading.Tasks.xml", + "ref/netstandard1.3/ja/System.Threading.Tasks.xml", + "ref/netstandard1.3/ko/System.Threading.Tasks.xml", + "ref/netstandard1.3/ru/System.Threading.Tasks.xml", + "ref/netstandard1.3/zh-hans/System.Threading.Tasks.xml", + "ref/netstandard1.3/zh-hant/System.Threading.Tasks.xml", + "ref/portable-net45+win8+wp8+wpa81/_._", + "ref/win8/_._", + "ref/wp80/_._", + "ref/wpa81/_._", + "ref/xamarinios10/_._", + "ref/xamarinmac20/_._", + "ref/xamarintvos10/_._", + "ref/xamarinwatchos10/_._" + ] + }, + "System.Threading.Tasks.Dataflow/4.6.0": { + "sha512": "stdu7KGSuCH3dCIAYRz1xn02TshjqAjpNn4bDUSWxzA/uhHYySGn3KT62dA/B61/9yoyvuJrA2GY40QU46eElw==", + "type": "package", + "path": "System.Threading.Tasks.Dataflow/4.6.0", + "files": [ + "System.Threading.Tasks.Dataflow.4.6.0.nupkg.sha512", + "System.Threading.Tasks.Dataflow.nuspec", + "ThirdPartyNotices.txt", + "dotnet_library_license.txt", + "lib/netstandard1.0/System.Threading.Tasks.Dataflow.XML", + "lib/netstandard1.0/System.Threading.Tasks.Dataflow.dll", + "lib/netstandard1.1/System.Threading.Tasks.Dataflow.XML", + "lib/netstandard1.1/System.Threading.Tasks.Dataflow.dll" + ] + }, + "System.Threading.Tasks.Extensions/4.0.0": { + "sha512": "pH4FZDsZQ/WmgJtN4LWYmRdJAEeVkyriSwrv2Teoe5FOU0Yxlb6II6GL8dBPOfRmutHGATduj3ooMt7dJ2+i+w==", + "type": "package", + "path": "System.Threading.Tasks.Extensions/4.0.0", + "files": [ + "System.Threading.Tasks.Extensions.4.0.0.nupkg.sha512", + "System.Threading.Tasks.Extensions.nuspec", + "ThirdPartyNotices.txt", + "dotnet_library_license.txt", + "lib/netstandard1.0/System.Threading.Tasks.Extensions.dll", + "lib/netstandard1.0/System.Threading.Tasks.Extensions.xml", + "lib/portable-net45+win8+wp8+wpa81/System.Threading.Tasks.Extensions.dll", + "lib/portable-net45+win8+wp8+wpa81/System.Threading.Tasks.Extensions.xml" + ] + }, + "System.Threading.Tasks.Parallel/4.0.1": { + "sha512": "7Pc9t25bcynT9FpMvkUw4ZjYwUiGup/5cJFW72/5MgCG+np2cfVUMdh29u8d7onxX7d8PS3J+wL73zQRqkdrSA==", + "type": "package", + "path": "System.Threading.Tasks.Parallel/4.0.1", + "files": [ + "System.Threading.Tasks.Parallel.4.0.1.nupkg.sha512", + "System.Threading.Tasks.Parallel.nuspec", + "ThirdPartyNotices.txt", + "dotnet_library_license.txt", + "lib/MonoAndroid10/_._", + "lib/MonoTouch10/_._", + "lib/net45/_._", + "lib/netcore50/System.Threading.Tasks.Parallel.dll", + "lib/netstandard1.3/System.Threading.Tasks.Parallel.dll", + "lib/portable-net45+win8+wpa81/_._", + "lib/win8/_._", + "lib/wpa81/_._", + "lib/xamarinios10/_._", + "lib/xamarinmac20/_._", + "lib/xamarintvos10/_._", + "lib/xamarinwatchos10/_._", + "ref/MonoAndroid10/_._", + "ref/MonoTouch10/_._", + "ref/net45/_._", + "ref/netcore50/System.Threading.Tasks.Parallel.dll", + "ref/netcore50/System.Threading.Tasks.Parallel.xml", + "ref/netcore50/de/System.Threading.Tasks.Parallel.xml", + "ref/netcore50/es/System.Threading.Tasks.Parallel.xml", + "ref/netcore50/fr/System.Threading.Tasks.Parallel.xml", + "ref/netcore50/it/System.Threading.Tasks.Parallel.xml", + "ref/netcore50/ja/System.Threading.Tasks.Parallel.xml", + "ref/netcore50/ko/System.Threading.Tasks.Parallel.xml", + "ref/netcore50/ru/System.Threading.Tasks.Parallel.xml", + "ref/netcore50/zh-hans/System.Threading.Tasks.Parallel.xml", + "ref/netcore50/zh-hant/System.Threading.Tasks.Parallel.xml", + "ref/netstandard1.1/System.Threading.Tasks.Parallel.dll", + "ref/netstandard1.1/System.Threading.Tasks.Parallel.xml", + "ref/netstandard1.1/de/System.Threading.Tasks.Parallel.xml", + "ref/netstandard1.1/es/System.Threading.Tasks.Parallel.xml", + "ref/netstandard1.1/fr/System.Threading.Tasks.Parallel.xml", + "ref/netstandard1.1/it/System.Threading.Tasks.Parallel.xml", + "ref/netstandard1.1/ja/System.Threading.Tasks.Parallel.xml", + "ref/netstandard1.1/ko/System.Threading.Tasks.Parallel.xml", + "ref/netstandard1.1/ru/System.Threading.Tasks.Parallel.xml", + "ref/netstandard1.1/zh-hans/System.Threading.Tasks.Parallel.xml", + "ref/netstandard1.1/zh-hant/System.Threading.Tasks.Parallel.xml", + "ref/portable-net45+win8+wpa81/_._", + "ref/win8/_._", + "ref/wpa81/_._", + "ref/xamarinios10/_._", + "ref/xamarinmac20/_._", + "ref/xamarintvos10/_._", + "ref/xamarinwatchos10/_._" + ] + }, + "System.Threading.Thread/4.0.0": { + "sha512": "gIdJqDXlOr5W9zeqFErLw3dsOsiShSCYtF9SEHitACycmvNvY8odf9kiKvp6V7aibc8C4HzzNBkWXjyfn7plbQ==", + "type": "package", + "path": "System.Threading.Thread/4.0.0", + "files": [ + "System.Threading.Thread.4.0.0.nupkg.sha512", + "System.Threading.Thread.nuspec", + "ThirdPartyNotices.txt", + "dotnet_library_license.txt", + "lib/MonoAndroid10/_._", + "lib/MonoTouch10/_._", + "lib/net46/System.Threading.Thread.dll", + "lib/netcore50/_._", + "lib/netstandard1.3/System.Threading.Thread.dll", + "lib/xamarinios10/_._", + "lib/xamarinmac20/_._", + "lib/xamarintvos10/_._", + "lib/xamarinwatchos10/_._", + "ref/MonoAndroid10/_._", + "ref/MonoTouch10/_._", + "ref/net46/System.Threading.Thread.dll", + "ref/netstandard1.3/System.Threading.Thread.dll", + "ref/netstandard1.3/System.Threading.Thread.xml", + "ref/netstandard1.3/de/System.Threading.Thread.xml", + "ref/netstandard1.3/es/System.Threading.Thread.xml", + "ref/netstandard1.3/fr/System.Threading.Thread.xml", + "ref/netstandard1.3/it/System.Threading.Thread.xml", + "ref/netstandard1.3/ja/System.Threading.Thread.xml", + "ref/netstandard1.3/ko/System.Threading.Thread.xml", + "ref/netstandard1.3/ru/System.Threading.Thread.xml", + "ref/netstandard1.3/zh-hans/System.Threading.Thread.xml", + "ref/netstandard1.3/zh-hant/System.Threading.Thread.xml", + "ref/xamarinios10/_._", + "ref/xamarinmac20/_._", + "ref/xamarintvos10/_._", + "ref/xamarinwatchos10/_._" + ] + }, + "System.Threading.ThreadPool/4.0.10": { + "sha512": "IMXgB5Vf/5Qw1kpoVgJMOvUO1l32aC+qC3OaIZjWJOjvcxuxNWOK2ZTWWYXfij22NHxT2j1yWX5vlAeQWld9vA==", + "type": "package", + "path": "System.Threading.ThreadPool/4.0.10", + "files": [ + "System.Threading.ThreadPool.4.0.10.nupkg.sha512", + "System.Threading.ThreadPool.nuspec", + "ThirdPartyNotices.txt", + "dotnet_library_license.txt", + "lib/MonoAndroid10/_._", + "lib/MonoTouch10/_._", + "lib/net46/System.Threading.ThreadPool.dll", + "lib/netcore50/_._", + "lib/netstandard1.3/System.Threading.ThreadPool.dll", + "lib/xamarinios10/_._", + "lib/xamarinmac20/_._", + "lib/xamarintvos10/_._", + "lib/xamarinwatchos10/_._", + "ref/MonoAndroid10/_._", + "ref/MonoTouch10/_._", + "ref/net46/System.Threading.ThreadPool.dll", + "ref/netstandard1.3/System.Threading.ThreadPool.dll", + "ref/netstandard1.3/System.Threading.ThreadPool.xml", + "ref/netstandard1.3/de/System.Threading.ThreadPool.xml", + "ref/netstandard1.3/es/System.Threading.ThreadPool.xml", + "ref/netstandard1.3/fr/System.Threading.ThreadPool.xml", + "ref/netstandard1.3/it/System.Threading.ThreadPool.xml", + "ref/netstandard1.3/ja/System.Threading.ThreadPool.xml", + "ref/netstandard1.3/ko/System.Threading.ThreadPool.xml", + "ref/netstandard1.3/ru/System.Threading.ThreadPool.xml", + "ref/netstandard1.3/zh-hans/System.Threading.ThreadPool.xml", + "ref/netstandard1.3/zh-hant/System.Threading.ThreadPool.xml", + "ref/xamarinios10/_._", + "ref/xamarinmac20/_._", + "ref/xamarintvos10/_._", + "ref/xamarinwatchos10/_._" + ] + }, + "System.Threading.Timer/4.0.1": { + "sha512": "saGfUV8uqVW6LeURiqxcGhZ24PzuRNaUBtbhVeuUAvky1naH395A/1nY0P2bWvrw/BreRtIB/EzTDkGBpqCwEw==", + "type": "package", + "path": "System.Threading.Timer/4.0.1", + "files": [ + "System.Threading.Timer.4.0.1.nupkg.sha512", + "System.Threading.Timer.nuspec", + "ThirdPartyNotices.txt", + "dotnet_library_license.txt", + "lib/MonoAndroid10/_._", + "lib/MonoTouch10/_._", + "lib/net451/_._", + "lib/portable-net451+win81+wpa81/_._", + "lib/win81/_._", + "lib/wpa81/_._", + "lib/xamarinios10/_._", + "lib/xamarinmac20/_._", + "lib/xamarintvos10/_._", + "lib/xamarinwatchos10/_._", + "ref/MonoAndroid10/_._", + "ref/MonoTouch10/_._", + "ref/net451/_._", + "ref/netcore50/System.Threading.Timer.dll", + "ref/netcore50/System.Threading.Timer.xml", + "ref/netcore50/de/System.Threading.Timer.xml", + "ref/netcore50/es/System.Threading.Timer.xml", + "ref/netcore50/fr/System.Threading.Timer.xml", + "ref/netcore50/it/System.Threading.Timer.xml", + "ref/netcore50/ja/System.Threading.Timer.xml", + "ref/netcore50/ko/System.Threading.Timer.xml", + "ref/netcore50/ru/System.Threading.Timer.xml", + "ref/netcore50/zh-hans/System.Threading.Timer.xml", + "ref/netcore50/zh-hant/System.Threading.Timer.xml", + "ref/netstandard1.2/System.Threading.Timer.dll", + "ref/netstandard1.2/System.Threading.Timer.xml", + "ref/netstandard1.2/de/System.Threading.Timer.xml", + "ref/netstandard1.2/es/System.Threading.Timer.xml", + "ref/netstandard1.2/fr/System.Threading.Timer.xml", + "ref/netstandard1.2/it/System.Threading.Timer.xml", + "ref/netstandard1.2/ja/System.Threading.Timer.xml", + "ref/netstandard1.2/ko/System.Threading.Timer.xml", + "ref/netstandard1.2/ru/System.Threading.Timer.xml", + "ref/netstandard1.2/zh-hans/System.Threading.Timer.xml", + "ref/netstandard1.2/zh-hant/System.Threading.Timer.xml", + "ref/portable-net451+win81+wpa81/_._", + "ref/win81/_._", + "ref/wpa81/_._", + "ref/xamarinios10/_._", + "ref/xamarinmac20/_._", + "ref/xamarintvos10/_._", + "ref/xamarinwatchos10/_._" + ] + }, + "System.Xml.ReaderWriter/4.0.11": { + "sha512": "ZIiLPsf67YZ9zgr31vzrFaYQqxRPX9cVHjtPSnmx4eN6lbS/yEyYNr2vs1doGDEscF0tjCZFsk9yUg1sC9e8tg==", + "type": "package", + "path": "System.Xml.ReaderWriter/4.0.11", + "files": [ + "System.Xml.ReaderWriter.4.0.11.nupkg.sha512", + "System.Xml.ReaderWriter.nuspec", + "ThirdPartyNotices.txt", + "dotnet_library_license.txt", + "lib/MonoAndroid10/_._", + "lib/MonoTouch10/_._", + "lib/net45/_._", + "lib/netcore50/System.Xml.ReaderWriter.dll", + "lib/netstandard1.3/System.Xml.ReaderWriter.dll", + "lib/portable-net45+win8+wp8+wpa81/_._", + "lib/win8/_._", + "lib/wp80/_._", + "lib/wpa81/_._", + "lib/xamarinios10/_._", + "lib/xamarinmac20/_._", + "lib/xamarintvos10/_._", + "lib/xamarinwatchos10/_._", + "ref/MonoAndroid10/_._", + "ref/MonoTouch10/_._", + "ref/net45/_._", + "ref/netcore50/System.Xml.ReaderWriter.dll", + "ref/netcore50/System.Xml.ReaderWriter.xml", + "ref/netcore50/de/System.Xml.ReaderWriter.xml", + "ref/netcore50/es/System.Xml.ReaderWriter.xml", + "ref/netcore50/fr/System.Xml.ReaderWriter.xml", + "ref/netcore50/it/System.Xml.ReaderWriter.xml", + "ref/netcore50/ja/System.Xml.ReaderWriter.xml", + "ref/netcore50/ko/System.Xml.ReaderWriter.xml", + "ref/netcore50/ru/System.Xml.ReaderWriter.xml", + "ref/netcore50/zh-hans/System.Xml.ReaderWriter.xml", + "ref/netcore50/zh-hant/System.Xml.ReaderWriter.xml", + "ref/netstandard1.0/System.Xml.ReaderWriter.dll", + "ref/netstandard1.0/System.Xml.ReaderWriter.xml", + "ref/netstandard1.0/de/System.Xml.ReaderWriter.xml", + "ref/netstandard1.0/es/System.Xml.ReaderWriter.xml", + "ref/netstandard1.0/fr/System.Xml.ReaderWriter.xml", + "ref/netstandard1.0/it/System.Xml.ReaderWriter.xml", + "ref/netstandard1.0/ja/System.Xml.ReaderWriter.xml", + "ref/netstandard1.0/ko/System.Xml.ReaderWriter.xml", + "ref/netstandard1.0/ru/System.Xml.ReaderWriter.xml", + "ref/netstandard1.0/zh-hans/System.Xml.ReaderWriter.xml", + "ref/netstandard1.0/zh-hant/System.Xml.ReaderWriter.xml", + "ref/netstandard1.3/System.Xml.ReaderWriter.dll", + "ref/netstandard1.3/System.Xml.ReaderWriter.xml", + "ref/netstandard1.3/de/System.Xml.ReaderWriter.xml", + "ref/netstandard1.3/es/System.Xml.ReaderWriter.xml", + "ref/netstandard1.3/fr/System.Xml.ReaderWriter.xml", + "ref/netstandard1.3/it/System.Xml.ReaderWriter.xml", + "ref/netstandard1.3/ja/System.Xml.ReaderWriter.xml", + "ref/netstandard1.3/ko/System.Xml.ReaderWriter.xml", + "ref/netstandard1.3/ru/System.Xml.ReaderWriter.xml", + "ref/netstandard1.3/zh-hans/System.Xml.ReaderWriter.xml", + "ref/netstandard1.3/zh-hant/System.Xml.ReaderWriter.xml", + "ref/portable-net45+win8+wp8+wpa81/_._", + "ref/win8/_._", + "ref/wp80/_._", + "ref/wpa81/_._", + "ref/xamarinios10/_._", + "ref/xamarinmac20/_._", + "ref/xamarintvos10/_._", + "ref/xamarinwatchos10/_._" + ] + }, + "System.Xml.XDocument/4.0.11": { + "sha512": "Mk2mKmPi0nWaoiYeotq1dgeNK1fqWh61+EK+w4Wu8SWuTYLzpUnschb59bJtGywaPq7SmTuPf44wrXRwbIrukg==", + "type": "package", + "path": "System.Xml.XDocument/4.0.11", + "files": [ + "System.Xml.XDocument.4.0.11.nupkg.sha512", + "System.Xml.XDocument.nuspec", + "ThirdPartyNotices.txt", + "dotnet_library_license.txt", + "lib/MonoAndroid10/_._", + "lib/MonoTouch10/_._", + "lib/net45/_._", + "lib/netcore50/System.Xml.XDocument.dll", + "lib/netstandard1.3/System.Xml.XDocument.dll", + "lib/portable-net45+win8+wp8+wpa81/_._", + "lib/win8/_._", + "lib/wp80/_._", + "lib/wpa81/_._", + "lib/xamarinios10/_._", + "lib/xamarinmac20/_._", + "lib/xamarintvos10/_._", + "lib/xamarinwatchos10/_._", + "ref/MonoAndroid10/_._", + "ref/MonoTouch10/_._", + "ref/net45/_._", + "ref/netcore50/System.Xml.XDocument.dll", + "ref/netcore50/System.Xml.XDocument.xml", + "ref/netcore50/de/System.Xml.XDocument.xml", + "ref/netcore50/es/System.Xml.XDocument.xml", + "ref/netcore50/fr/System.Xml.XDocument.xml", + "ref/netcore50/it/System.Xml.XDocument.xml", + "ref/netcore50/ja/System.Xml.XDocument.xml", + "ref/netcore50/ko/System.Xml.XDocument.xml", + "ref/netcore50/ru/System.Xml.XDocument.xml", + "ref/netcore50/zh-hans/System.Xml.XDocument.xml", + "ref/netcore50/zh-hant/System.Xml.XDocument.xml", + "ref/netstandard1.0/System.Xml.XDocument.dll", + "ref/netstandard1.0/System.Xml.XDocument.xml", + "ref/netstandard1.0/de/System.Xml.XDocument.xml", + "ref/netstandard1.0/es/System.Xml.XDocument.xml", + "ref/netstandard1.0/fr/System.Xml.XDocument.xml", + "ref/netstandard1.0/it/System.Xml.XDocument.xml", + "ref/netstandard1.0/ja/System.Xml.XDocument.xml", + "ref/netstandard1.0/ko/System.Xml.XDocument.xml", + "ref/netstandard1.0/ru/System.Xml.XDocument.xml", + "ref/netstandard1.0/zh-hans/System.Xml.XDocument.xml", + "ref/netstandard1.0/zh-hant/System.Xml.XDocument.xml", + "ref/netstandard1.3/System.Xml.XDocument.dll", + "ref/netstandard1.3/System.Xml.XDocument.xml", + "ref/netstandard1.3/de/System.Xml.XDocument.xml", + "ref/netstandard1.3/es/System.Xml.XDocument.xml", + "ref/netstandard1.3/fr/System.Xml.XDocument.xml", + "ref/netstandard1.3/it/System.Xml.XDocument.xml", + "ref/netstandard1.3/ja/System.Xml.XDocument.xml", + "ref/netstandard1.3/ko/System.Xml.XDocument.xml", + "ref/netstandard1.3/ru/System.Xml.XDocument.xml", + "ref/netstandard1.3/zh-hans/System.Xml.XDocument.xml", + "ref/netstandard1.3/zh-hant/System.Xml.XDocument.xml", + "ref/portable-net45+win8+wp8+wpa81/_._", + "ref/win8/_._", + "ref/wp80/_._", + "ref/wpa81/_._", + "ref/xamarinios10/_._", + "ref/xamarinmac20/_._", + "ref/xamarintvos10/_._", + "ref/xamarinwatchos10/_._" + ] + }, + "System.Xml.XmlDocument/4.0.1": { + "sha512": "2eZu6IP+etFVBBFUFzw2w6J21DqIN5eL9Y8r8JfJWUmV28Z5P0SNU01oCisVHQgHsDhHPnmq2s1hJrJCFZWloQ==", + "type": "package", + "path": "System.Xml.XmlDocument/4.0.1", + "files": [ + "System.Xml.XmlDocument.4.0.1.nupkg.sha512", + "System.Xml.XmlDocument.nuspec", + "ThirdPartyNotices.txt", + "dotnet_library_license.txt", + "lib/MonoAndroid10/_._", + "lib/MonoTouch10/_._", + "lib/net46/System.Xml.XmlDocument.dll", + "lib/netstandard1.3/System.Xml.XmlDocument.dll", + "lib/xamarinios10/_._", + "lib/xamarinmac20/_._", + "lib/xamarintvos10/_._", + "lib/xamarinwatchos10/_._", + "ref/MonoAndroid10/_._", + "ref/MonoTouch10/_._", + "ref/net46/System.Xml.XmlDocument.dll", + "ref/netstandard1.3/System.Xml.XmlDocument.dll", + "ref/netstandard1.3/System.Xml.XmlDocument.xml", + "ref/netstandard1.3/de/System.Xml.XmlDocument.xml", + "ref/netstandard1.3/es/System.Xml.XmlDocument.xml", + "ref/netstandard1.3/fr/System.Xml.XmlDocument.xml", + "ref/netstandard1.3/it/System.Xml.XmlDocument.xml", + "ref/netstandard1.3/ja/System.Xml.XmlDocument.xml", + "ref/netstandard1.3/ko/System.Xml.XmlDocument.xml", + "ref/netstandard1.3/ru/System.Xml.XmlDocument.xml", + "ref/netstandard1.3/zh-hans/System.Xml.XmlDocument.xml", + "ref/netstandard1.3/zh-hant/System.Xml.XmlDocument.xml", + "ref/xamarinios10/_._", + "ref/xamarinmac20/_._", + "ref/xamarintvos10/_._", + "ref/xamarinwatchos10/_._" + ] + }, + "System.Xml.XPath/4.0.1": { + "sha512": "UWd1H+1IJ9Wlq5nognZ/XJdyj8qPE4XufBUkAW59ijsCPjZkZe0MUzKKJFBr+ZWBe5Wq1u1d5f2CYgE93uH7DA==", + "type": "package", + "path": "System.Xml.XPath/4.0.1", + "files": [ + "System.Xml.XPath.4.0.1.nupkg.sha512", + "System.Xml.XPath.nuspec", + "ThirdPartyNotices.txt", + "dotnet_library_license.txt", + "lib/MonoAndroid10/_._", + "lib/MonoTouch10/_._", + "lib/net46/System.Xml.XPath.dll", + "lib/netstandard1.3/System.Xml.XPath.dll", + "lib/xamarinios10/_._", + "lib/xamarinmac20/_._", + "lib/xamarintvos10/_._", + "lib/xamarinwatchos10/_._", + "ref/MonoAndroid10/_._", + "ref/MonoTouch10/_._", + "ref/net46/System.Xml.XPath.dll", + "ref/netstandard1.3/System.Xml.XPath.dll", + "ref/netstandard1.3/System.Xml.XPath.xml", + "ref/netstandard1.3/de/System.Xml.XPath.xml", + "ref/netstandard1.3/es/System.Xml.XPath.xml", + "ref/netstandard1.3/fr/System.Xml.XPath.xml", + "ref/netstandard1.3/it/System.Xml.XPath.xml", + "ref/netstandard1.3/ja/System.Xml.XPath.xml", + "ref/netstandard1.3/ko/System.Xml.XPath.xml", + "ref/netstandard1.3/ru/System.Xml.XPath.xml", + "ref/netstandard1.3/zh-hans/System.Xml.XPath.xml", + "ref/netstandard1.3/zh-hant/System.Xml.XPath.xml", + "ref/xamarinios10/_._", + "ref/xamarinmac20/_._", + "ref/xamarintvos10/_._", + "ref/xamarinwatchos10/_._" + ] + }, + "System.Xml.XPath.XDocument/4.0.1": { + "sha512": "FLhdYJx4331oGovQypQ8JIw2kEmNzCsjVOVYY/16kZTUoquZG85oVn7yUhBE2OZt1yGPSXAL0HTEfzjlbNpM7Q==", + "type": "package", + "path": "System.Xml.XPath.XDocument/4.0.1", + "files": [ + "System.Xml.XPath.XDocument.4.0.1.nupkg.sha512", + "System.Xml.XPath.XDocument.nuspec", + "ThirdPartyNotices.txt", + "dotnet_library_license.txt", + "lib/MonoAndroid10/_._", + "lib/MonoTouch10/_._", + "lib/net46/System.Xml.XPath.XDocument.dll", + "lib/netstandard1.3/System.Xml.XPath.XDocument.dll", + "lib/xamarinios10/_._", + "lib/xamarinmac20/_._", + "lib/xamarintvos10/_._", + "lib/xamarinwatchos10/_._", + "ref/MonoAndroid10/_._", + "ref/MonoTouch10/_._", + "ref/net46/System.Xml.XPath.XDocument.dll", + "ref/netstandard1.3/System.Xml.XPath.XDocument.dll", + "ref/netstandard1.3/System.Xml.XPath.XDocument.xml", + "ref/netstandard1.3/de/System.Xml.XPath.XDocument.xml", + "ref/netstandard1.3/es/System.Xml.XPath.XDocument.xml", + "ref/netstandard1.3/fr/System.Xml.XPath.XDocument.xml", + "ref/netstandard1.3/it/System.Xml.XPath.XDocument.xml", + "ref/netstandard1.3/ja/System.Xml.XPath.XDocument.xml", + "ref/netstandard1.3/ko/System.Xml.XPath.XDocument.xml", + "ref/netstandard1.3/ru/System.Xml.XPath.XDocument.xml", + "ref/netstandard1.3/zh-hans/System.Xml.XPath.XDocument.xml", + "ref/netstandard1.3/zh-hant/System.Xml.XPath.XDocument.xml", + "ref/xamarinios10/_._", + "ref/xamarinmac20/_._", + "ref/xamarintvos10/_._", + "ref/xamarinwatchos10/_._" + ] + }, + "xunit/2.2.0-beta2-build3300": { + "sha512": "jUMf+Hrw8+XZN56TfO+JjoibR5L806/kgDIkwCg9OXLlfnA4li4JTmH342ifYj1QMR10is8hfYYFTyjHq0+aQg==", + "type": "package", + "path": "xunit/2.2.0-beta2-build3300", + "files": [ + "xunit.2.2.0-beta2-build3300.nupkg.sha512", + "xunit.nuspec" + ] + }, + "xunit.abstractions/2.0.1-rc2": { + "sha512": "iUHMlyMDaXJ8N8qozg19tRlW0QiZPJ47ZJyV1fnpppGWdmukyq89/pg4HqpxQ52Co3Leo8NmiiYkB/gN48pZ+A==", + "type": "package", + "path": "xunit.abstractions/2.0.1-rc2", + "files": [ + "lib/net35/xunit.abstractions.dll", + "lib/net35/xunit.abstractions.xml", + "lib/netstandard1.0/xunit.abstractions.dll", + "lib/netstandard1.0/xunit.abstractions.xml", + "xunit.abstractions.2.0.1-rc2.nupkg.sha512", + "xunit.abstractions.nuspec" + ] + }, + "xunit.assert/2.2.0-beta2-build3300": { + "sha512": "5zsV2UhRQV5Ldme1N/NDhIBvQQTYdxmK87FXWWou1x3z7qpsZwe1YOjb0CY4F+1oXag8i9uTh/nZwv8jM66onA==", + "type": "package", + "path": "xunit.assert/2.2.0-beta2-build3300", + "files": [ + "lib/netstandard1.0/xunit.assert.dll", + "lib/netstandard1.0/xunit.assert.pdb", + "lib/netstandard1.0/xunit.assert.xml", + "xunit.assert.2.2.0-beta2-build3300.nupkg.sha512", + "xunit.assert.nuspec" + ] + }, + "xunit.core/2.2.0-beta2-build3300": { + "sha512": "HgKP6+FUKcIcVFMDgoTCANRKOgGeEDvg2a2AL3mOyBHE//grWL1EO0KybxUw26S8fnNJrhmI5LBWyVUIsPxI5Q==", + "type": "package", + "path": "xunit.core/2.2.0-beta2-build3300", + "files": [ + "build/_desktop/xunit.execution.desktop.dll", + "build/netstandard1.0/_._", + "build/uap10.0/xunit.core.props", + "build/win81/xunit.core.props", + "build/wpa81/xunit.core.props", + "xunit.core.2.2.0-beta2-build3300.nupkg.sha512", + "xunit.core.nuspec" + ] + }, + "xunit.extensibility.core/2.2.0-beta2-build3300": { + "sha512": "d+UCqIL8Je3tSdhF7w6NZdzH2jYzNh2LhsMp0gUVAD3NgVEo2oK/3Xr7ZlYZM40Y6fJWoO46UntzrpNlix75mg==", + "type": "package", + "path": "xunit.extensibility.core/2.2.0-beta2-build3300", + "files": [ + "lib/net45/xunit.core.dll", + "lib/net45/xunit.core.dll.tdnet", + "lib/net45/xunit.core.pdb", + "lib/net45/xunit.core.xml", + "lib/net45/xunit.runner.tdnet.dll", + "lib/net45/xunit.runner.utility.desktop.dll", + "lib/netstandard1.0/xunit.core.dll", + "lib/netstandard1.0/xunit.core.pdb", + "lib/netstandard1.0/xunit.core.xml", + "xunit.extensibility.core.2.2.0-beta2-build3300.nupkg.sha512", + "xunit.extensibility.core.nuspec" + ] + }, + "xunit.extensibility.execution/2.2.0-beta2-build3300": { + "sha512": "z0DgzvWxQtXaj2qebFkW5f69ZItvY/YRWEbKwL0yIbvhiCViiuHlP+qvvloVlrlsOuo+Y/vfjQb/3Cz+ok/+5A==", + "type": "package", + "path": "xunit.extensibility.execution/2.2.0-beta2-build3300", + "files": [ + "lib/net45/xunit.execution.desktop.dll", + "lib/net45/xunit.execution.desktop.pdb", + "lib/net45/xunit.execution.desktop.xml", + "lib/netstandard1.0/xunit.execution.dotnet.dll", + "lib/netstandard1.0/xunit.execution.dotnet.pdb", + "lib/netstandard1.0/xunit.execution.dotnet.xml", + "xunit.extensibility.execution.2.2.0-beta2-build3300.nupkg.sha512", + "xunit.extensibility.execution.nuspec" + ] + }, + "xunit.runner.reporters/2.2.0-beta2-build3300": { + "sha512": "1NqeT2IWfqk9/zBkHbf6SS1bokwu0Mvt70lQp8bJZpvQgi+SDAzuhEwWTcsjMblY2FK8BHDbjauu+IO2GhbhAA==", + "type": "package", + "path": "xunit.runner.reporters/2.2.0-beta2-build3300", + "files": [ + "lib/net45/xunit.runner.reporters.desktop.dll", + "lib/netstandard1.1/xunit.runner.reporters.dotnet.dll", + "xunit.runner.reporters.2.2.0-beta2-build3300.nupkg.sha512", + "xunit.runner.reporters.nuspec" + ] + }, + "xunit.runner.utility/2.2.0-beta2-build3300": { + "sha512": "lotqjLPg8NnjZHlRpj0Yj5TI3z/7hzK7+tb6R7qRAREDoH9P88EDCWJyy2xJh/R6PfbS9KYTaT/Z2ob9gx6PgQ==", + "type": "package", + "path": "xunit.runner.utility/2.2.0-beta2-build3300", + "files": [ + "lib/net35/xunit.runner.utility.desktop.dll", + "lib/net35/xunit.runner.utility.desktop.pdb", + "lib/net35/xunit.runner.utility.desktop.xml", + "lib/net45/xunit.runner.utility.desktop.dll", + "lib/net45/xunit.runner.utility.desktop.pdb", + "lib/net45/xunit.runner.utility.desktop.xml", + "lib/netstandard1.1/xunit.runner.utility.dotnet.dll", + "lib/netstandard1.1/xunit.runner.utility.dotnet.pdb", + "lib/netstandard1.1/xunit.runner.utility.dotnet.xml", + "xunit.runner.utility.2.2.0-beta2-build3300.nupkg.sha512", + "xunit.runner.utility.nuspec" + ] + }, + "QLNet/1.8.0": { + "type": "project", + "path": "../QLNet/project.json", + "msbuildProject": "../QLNet/QLNet.xproj" + } + }, + "projectFileDependencyGroups": { + "": [ + "QLNet >= 1.8.0-*", + "dotnet-test-xunit >= 2.2.0-preview2-build1029", + "xunit >= 2.2.0-beta2-build3300" + ], + ".NETCoreApp,Version=v1.0": [ + "Microsoft.NETCore.App >= 1.0.0" + ] + }, + "tools": {}, + "projectFileToolGroups": {} +} \ No newline at end of file diff --git a/Test/test.project.json b/Test/test.project.json new file mode 100644 index 000000000..0bf285ccf --- /dev/null +++ b/Test/test.project.json @@ -0,0 +1,7 @@ +{ + "runtime": { + "win":{ + } + } + +} \ No newline at end of file diff --git a/global.json b/global.json new file mode 100644 index 000000000..cea552f52 --- /dev/null +++ b/global.json @@ -0,0 +1,6 @@ +{ + "projects": [ "QLNet", "Test" ], + "sdk": { + "version": "" + } +}