Skip to content

Commit

Permalink
Update to QLNet-1.9.1.0
Browse files Browse the repository at this point in the history
  • Loading branch information
amaggiulli committed Jan 25, 2017
2 parents 0a5428c + 8a235c7 commit fc15b5b
Show file tree
Hide file tree
Showing 21 changed files with 204 additions and 137 deletions.
64 changes: 38 additions & 26 deletions QLNet.sln
Original file line number Diff line number Diff line change
@@ -1,26 +1,38 @@

Microsoft Visual Studio Solution File, Format Version 11.00
# Visual Studio 2010
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "QLNet", "QLNet\QLNet.csproj", "{F6E762BD-DCDF-4CA0-ABAD-CB21C7D03BEC}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Test", "Test\Test.csproj", "{2EF8B45B-940A-4B77-8776-E8CE0036961E}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{F6E762BD-DCDF-4CA0-ABAD-CB21C7D03BEC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{F6E762BD-DCDF-4CA0-ABAD-CB21C7D03BEC}.Debug|Any CPU.Build.0 = Debug|Any CPU
{F6E762BD-DCDF-4CA0-ABAD-CB21C7D03BEC}.Release|Any CPU.ActiveCfg = Release|Any CPU
{F6E762BD-DCDF-4CA0-ABAD-CB21C7D03BEC}.Release|Any CPU.Build.0 = Release|Any CPU
{2EF8B45B-940A-4B77-8776-E8CE0036961E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{2EF8B45B-940A-4B77-8776-E8CE0036961E}.Debug|Any CPU.Build.0 = Debug|Any CPU
{2EF8B45B-940A-4B77-8776-E8CE0036961E}.Release|Any CPU.ActiveCfg = Release|Any CPU
{2EF8B45B-940A-4B77-8776-E8CE0036961E}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
EndGlobal

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 14
VisualStudioVersion = 14.0.25420.1
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "QLNet", "QLNet\QLNet.csproj", "{F6E762BD-DCDF-4CA0-ABAD-CB21C7D03BEC}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Test", "Test\Test.csproj", "{2EF8B45B-940A-4B77-8776-E8CE0036961E}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Debug-net45|Any CPU = Debug-net45|Any CPU
Release|Any CPU = Release|Any CPU
Release-net45|Any CPU = Release-net45|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{F6E762BD-DCDF-4CA0-ABAD-CB21C7D03BEC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{F6E762BD-DCDF-4CA0-ABAD-CB21C7D03BEC}.Debug|Any CPU.Build.0 = Debug|Any CPU
{F6E762BD-DCDF-4CA0-ABAD-CB21C7D03BEC}.Debug-net45|Any CPU.ActiveCfg = Debug-net45|Any CPU
{F6E762BD-DCDF-4CA0-ABAD-CB21C7D03BEC}.Debug-net45|Any CPU.Build.0 = Debug-net45|Any CPU
{F6E762BD-DCDF-4CA0-ABAD-CB21C7D03BEC}.Release|Any CPU.ActiveCfg = Release|Any CPU
{F6E762BD-DCDF-4CA0-ABAD-CB21C7D03BEC}.Release|Any CPU.Build.0 = Release|Any CPU
{F6E762BD-DCDF-4CA0-ABAD-CB21C7D03BEC}.Release-net45|Any CPU.ActiveCfg = Release-net45|Any CPU
{F6E762BD-DCDF-4CA0-ABAD-CB21C7D03BEC}.Release-net45|Any CPU.Build.0 = Release-net45|Any CPU
{2EF8B45B-940A-4B77-8776-E8CE0036961E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{2EF8B45B-940A-4B77-8776-E8CE0036961E}.Debug|Any CPU.Build.0 = Debug|Any CPU
{2EF8B45B-940A-4B77-8776-E8CE0036961E}.Debug-net45|Any CPU.ActiveCfg = Debug-net45|Any CPU
{2EF8B45B-940A-4B77-8776-E8CE0036961E}.Debug-net45|Any CPU.Build.0 = Debug-net45|Any CPU
{2EF8B45B-940A-4B77-8776-E8CE0036961E}.Release|Any CPU.ActiveCfg = Release|Any CPU
{2EF8B45B-940A-4B77-8776-E8CE0036961E}.Release|Any CPU.Build.0 = Release|Any CPU
{2EF8B45B-940A-4B77-8776-E8CE0036961E}.Release-net45|Any CPU.ActiveCfg = Release-net45|Any CPU
{2EF8B45B-940A-4B77-8776-E8CE0036961E}.Release-net45|Any CPU.Build.0 = Release-net45|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
EndGlobal
4 changes: 2 additions & 2 deletions QLNet/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,5 +30,5 @@
//
// È possibile specificare tutti i valori o impostare come predefiniti i valori Numero revisione e Numero build
// utilizzando l'asterisco (*) come descritto di seguito:
[assembly: AssemblyVersion( "1.9.0.0" )]
[assembly: AssemblyFileVersion( "1.9.0.0" )]
[assembly: AssemblyVersion( "1.9.1.0" )]
[assembly: AssemblyFileVersion( "1.9.1.0" )]
26 changes: 23 additions & 3 deletions QLNet/QLNet.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<OutputPath>bin\Debug\net40\</OutputPath>
<DefineConstants>TRACE;DEBUG;QL_NEGATIVE_RATES,QL_DOTNET_FRAMEWORK</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
Expand All @@ -48,13 +48,33 @@
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<OutputPath>bin\Release\net40\</OutputPath>
<DefineConstants>TRACE;QL_NEGATIVE_RATES,QL_DOTNET_FRAMEWORK</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<CodeAnalysisRuleSet>AllRules.ruleset</CodeAnalysisRuleSet>
<Prefer32Bit>false</Prefer32Bit>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug-net45|AnyCPU'">
<DebugSymbols>true</DebugSymbols>
<OutputPath>bin\Debug\net45\</OutputPath>
<DefineConstants>TRACE;DEBUG;QL_NEGATIVE_RATES,QL_DOTNET_FRAMEWORK</DefineConstants>
<DebugType>full</DebugType>
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
<PlatformTarget>AnyCPU</PlatformTarget>
<ErrorReport>prompt</ErrorReport>
<CodeAnalysisRuleSet>AllRules.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release-net45|AnyCPU'">
<OutputPath>bin\Release\net45\</OutputPath>
<DefineConstants>TRACE;QL_NEGATIVE_RATES,QL_DOTNET_FRAMEWORK</DefineConstants>
<Optimize>true</Optimize>
<DebugType>pdbonly</DebugType>
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
<PlatformTarget>AnyCPU</PlatformTarget>
<ErrorReport>prompt</ErrorReport>
<CodeAnalysisRuleSet>AllRules.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Core">
Expand Down Expand Up @@ -699,5 +719,5 @@
</Target>
<Target Name="AfterBuild">
</Target>
-->
-->
</Project>
11 changes: 8 additions & 3 deletions QLNet/QLNet.nuspec
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,21 @@
<package >
<metadata>
<id>QLNet</id>
<version>$version$</version>
<version>1.9.1.0</version>
<title>QLNet</title>
<authors>Andrea Maggiulli</authors>
<owners>Andrea Maggiulli</owners>
<licenseUrl>http://qlnet.sourceforge.net/License.html</licenseUrl>
<projectUrl>http://github.com/amaggiulli/qlnet</projectUrl>
<requireLicenseAcceptance>false</requireLicenseAcceptance>
<description>A free/open-source library for quantitative finance</description>
<releaseNotes>Version $version$</releaseNotes>
<copyright>Copyright (c) 2008-2014 Andrea Maggiulli (a.maggiulli@gmail.com)</copyright>
<releaseNotes>Version 1.9.1.0</releaseNotes>
<copyright>Copyright (c) 2008-2017 Andrea Maggiulli (a.maggiulli@gmail.com)</copyright>
<tags>QLNet QuantLib quantitative finance financial</tags>
</metadata>
<files>
<file src="bin\Release\net40\QLNet.dll" target="lib\net40\QLNet.dll" />
<file src="bin\Release\net45\QLNet.dll" target="lib\net45\QLNet.dll" />
<file src="bin\Release\netstandard1.1\QLNet.dll" target="lib\netstandard1.1\QLNet.dll" />
</files>
</package>
2 changes: 1 addition & 1 deletion QLNet/project.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"version": "1.8.0-*",
"version": "1.9.1-*",

"dependencies": {
"NETStandard.Library": "1.6.0"
Expand Down
2 changes: 1 addition & 1 deletion Test/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,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.9.0.0" )]
[assembly: AssemblyVersion( "1.9.1.0" )]
[assembly: AssemblyFileVersion( "1.9.0.0" )]
4 changes: 2 additions & 2 deletions Test/T_BarrierOption.cs
Original file line number Diff line number Diff line change
Expand Up @@ -764,7 +764,7 @@ public void testLocalVolAndHestonComparison()

if (Math.Abs(expectedHestonNPV - calculatedHestonNPV) > tol*expectedHestonNPV)
{
Assert.Fail("Failed to reproduce Heston barrier price for "
QAssert.Fail("Failed to reproduce Heston barrier price for "
+ "\n strike: " + payoff.strike()
+ "\n barrier: " + barrier
+ "\n maturity: " + exDate
Expand All @@ -773,7 +773,7 @@ public void testLocalVolAndHestonComparison()
}
if (Math.Abs(expectedLocalVolNPV - calculatedLocalVolNPV) > tol*expectedLocalVolNPV)
{
Assert.Fail("Failed to reproduce Heston barrier price for "
QAssert.Fail("Failed to reproduce Heston barrier price for "
+ "\n strike: " + payoff.strike()
+ "\n barrier: " + barrier
+ "\n maturity: " + exDate
Expand Down
30 changes: 15 additions & 15 deletions Test/T_BlackDeltaCalculator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ public void testDeltaValues()

if (error>tolerance)
{
Assert.Fail("\n Delta-from-strike calculation failed for delta. \n"
QAssert.Fail("\n Delta-from-strike calculation failed for delta. \n"
+ "Iteration: "+ i + "\n"
+ "Calculated Strike:" + calculated + "\n"
+ "Expected Strike:" + expected + "\n"
Expand All @@ -167,7 +167,7 @@ public void testDeltaValues()

if (error>tolerance)
{
Assert.Fail("\n Strike-from-delta calculation failed for delta. \n"
QAssert.Fail("\n Strike-from-delta calculation failed for delta. \n"
+ "Iteration: "+ i + "\n"
+ "Calculated Strike:" + calculated + "\n"
+ "Expected Strike:" + expected + "\n"
Expand Down Expand Up @@ -292,7 +292,7 @@ public void testDeltaPriceConsistency()

if(error>tolerance)
{
Assert.Fail("\n Premium-adjusted spot delta test failed. \n"
QAssert.Fail("\n Premium-adjusted spot delta test failed. \n"
+ "Calculated Delta: " + calculatedVal + "\n"
+ "Expected Value: " + expectedVal + "\n"
+ "Error: "+ error);
Expand All @@ -306,7 +306,7 @@ public void testDeltaPriceConsistency()

if(error>tolerance)
{
Assert.Fail("\n Premium-adjusted forward delta test failed. \n"
QAssert.Fail("\n Premium-adjusted forward delta test failed. \n"
+ "Calculated Delta: " + calculatedVal + "\n"
+ "Expected Value: " + expectedVal + "\n"
+ "Error: "+ error);
Expand All @@ -322,7 +322,7 @@ public void testDeltaPriceConsistency()

if(error>tolerance)
{
Assert.Fail("\n spot delta in BlackDeltaCalculator differs from delta in BlackScholesCalculator. \n"
QAssert.Fail("\n spot delta in BlackDeltaCalculator differs from delta in BlackScholesCalculator. \n"
+ "Calculated Value: " + calculatedVal + "\n"
+ "Expected Value: " + expectedVal + "\n"
+ "Error: " + error);
Expand Down Expand Up @@ -461,7 +461,7 @@ public void testPutCallParity()

if(error>tolerance)
{
Assert.Fail("\n Put-call parity failed for spot delta. \n"
QAssert.Fail("\n Put-call parity failed for spot delta. \n"
+ "Calculated Call Delta: " + deltaCall + "\n"
+ "Calculated Put Delta: " + deltaPut + "\n"
+ "Expected Difference: " + expectedDiff + "\n"
Expand All @@ -480,7 +480,7 @@ public void testPutCallParity()

if(error>tolerance)
{
Assert.Fail("\n Put-call parity failed for forward delta. \n"
QAssert.Fail("\n Put-call parity failed for forward delta. \n"
+ "Calculated Call Delta: " + deltaCall + "\n"
+ "Calculated Put Delta: " + deltaPut + "\n"
+ "Expected Difference: " + expectedDiff + "\n"
Expand All @@ -500,7 +500,7 @@ public void testPutCallParity()

if(error>tolerance)
{
Assert.Fail("\n Put-call parity failed for premium-adjusted spot delta. \n"
QAssert.Fail("\n Put-call parity failed for premium-adjusted spot delta. \n"
+ "Calculated Call Delta: " + deltaCall + "\n"
+ "Calculated Put Delta: " + deltaPut + "\n"
+ "Expected Difference: " + expectedDiff + "\n"
Expand All @@ -520,7 +520,7 @@ public void testPutCallParity()

if(error>tolerance)
{
Assert.Fail("\n Put-call parity failed for premium-adjusted forward delta. \n"
QAssert.Fail("\n Put-call parity failed for premium-adjusted forward delta. \n"
+ "Calculated Call Delta: " + deltaCall + "\n"
+ "Calculated Put Delta: " + deltaPut + "\n"
+ "Expected Difference: " + expectedDiff + "\n"
Expand Down Expand Up @@ -599,7 +599,7 @@ public void testAtmCalcs()

if(error>tolerance)
{
Assert.Fail("\n Delta neutrality failed for spot delta in Delta Calculator. \n"
QAssert.Fail("\n Delta neutrality failed for spot delta in Delta Calculator. \n"
+ "Iteration: "+ i + "\n"
+ "Calculated Delta Sum: " + calculated + "\n"
+ "Expected Delta Sum: " + expected + "\n"
Expand All @@ -619,7 +619,7 @@ public void testAtmCalcs()

if(error>tolerance)
{
Assert.Fail("\n Delta neutrality failed for forward delta in Delta Calculator. \n"
QAssert.Fail("\n Delta neutrality failed for forward delta in Delta Calculator. \n"
+ "Iteration: " + i + "\n"
+ "Calculated Delta Sum: " + calculated + "\n"
+ "Expected Delta Sum: " + expected + "\n"
Expand All @@ -639,7 +639,7 @@ public void testAtmCalcs()

if(error>tolerance)
{
Assert.Fail("\n Delta neutrality failed for premium-adjusted spot delta in Delta Calculator. \n"
QAssert.Fail("\n Delta neutrality failed for premium-adjusted spot delta in Delta Calculator. \n"
+ "Iteration: " + i + "\n"
+ "Calculated Delta Sum: " + calculated + "\n"
+ "Expected Delta Sum: " + expected + "\n"
Expand All @@ -660,7 +660,7 @@ public void testAtmCalcs()

if(error>tolerance)
{
Assert.Fail("\n Delta neutrality failed for premium-adjusted forward delta in Delta Calculator. \n"
QAssert.Fail("\n Delta neutrality failed for premium-adjusted forward delta in Delta Calculator. \n"
+ "Iteration: " + i + "\n"
+ "Calculated Delta Sum: " + calculated + "\n"
+ "Expected Delta Sum: " + expected + "\n"
Expand All @@ -674,7 +674,7 @@ public void testAtmCalcs()

if(error>tolerance)
{
Assert.Fail("\n Atm forward test failed. \n"
QAssert.Fail("\n Atm forward test failed. \n"
+ "Calculated Value: " + calculated + "\n"
+ "Expected Value: " + expected + "\n"
+ "Error: " + error);
Expand All @@ -689,7 +689,7 @@ public void testAtmCalcs()

if(error>tolerance)
{
Assert.Fail("\n Atm 0.50 delta strike test failed. \n"
QAssert.Fail("\n Atm 0.50 delta strike test failed. \n"
+ "Iteration:" + i + "\n"
+ "Calculated Value: " + calculated + "\n"
+ "Expected Value: " + expected + "\n"
Expand Down
2 changes: 1 addition & 1 deletion Test/T_BlackFormula.cs
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ public void testChambersImpliedVol()
if(moneyness > 1.0) moneyness = 1.0 / moneyness;
double error = (iStdDev - stdDevs[i5]) / stdDevs[i5] * moneyness;
if(error > tol)
Assert.Fail("Failed to verify Chambers-Nawalkha approximation for "
QAssert.Fail("Failed to verify Chambers-Nawalkha approximation for "
+ types[i1]
+ " displacement=" + displacements[i2]
+ " forward=" + forwards[i3]
Expand Down
14 changes: 7 additions & 7 deletions Test/T_CPISwap.cs
Original file line number Diff line number Diff line change
Expand Up @@ -337,14 +337,14 @@ public void consistency()
if (zicV != null)
{
diff = Math.Abs( zicV.rate() - (fixedRate*(zicV.indexFixing()/baseCPI)) );
Assert.IsTrue(diff<1e-8, "failed "+i+"th coupon reconstruction as "
QAssert.IsTrue(diff<1e-8, "failed "+i+"th coupon reconstruction as "
+ (fixedRate*(zicV.indexFixing()/baseCPI)) + " vs rate = "
+zicV.rate() + ", with difference: " + diff);
}
}

double error = Math.Abs(testInfLegNPV - zisV.legNPV(0).Value);
Assert.IsTrue( error < 1e-5, "failed manual inf leg NPV calc vs pricing engine: " + testInfLegNPV + " vs " +
QAssert.IsTrue( error < 1e-5, "failed manual inf leg NPV calc vs pricing engine: " + testInfLegNPV + " vs " +
zisV.legNPV(0));

diff = Math.Abs(1-zisV.NPV()/4191660.0);
Expand All @@ -353,7 +353,7 @@ public void consistency()
#else
double max_diff = 3e-5;
#endif
Assert.IsTrue( diff < max_diff, "failed stored consistency value test, ratio = " + diff );
QAssert.IsTrue( diff < max_diff, "failed stored consistency value test, ratio = " + diff );

// remove circular refernce
common.hcpi.linkTo(null);
Expand Down Expand Up @@ -385,7 +385,7 @@ public void zciisconsistency()
DiscountingSwapEngine dse = new DiscountingSwapEngine(common.nominalUK);

zciis.setPricingEngine(dse);
Assert.IsTrue(Math.Abs(zciis.NPV())<1e-3,"zciis does not reprice to zero");
QAssert.IsTrue(Math.Abs(zciis.NPV())<1e-3,"zciis does not reprice to zero");

List<Date> oneDate = new List<Date>();
oneDate.Add(endDate);
Expand All @@ -408,13 +408,13 @@ public void zciisconsistency()
common.ii, InterpolationType.AsIndex, inflationNominal);

cS.setPricingEngine(dse);
Assert.IsTrue(Math.Abs(cS.NPV())<1e-3,"CPISwap as ZCIIS does not reprice to zero");
QAssert.IsTrue(Math.Abs(cS.NPV())<1e-3,"CPISwap as ZCIIS does not reprice to zero");

for (int i=0; i<2; i++)
{
double cs = cS.legNPV(i).GetValueOrDefault();
double z = zciis.legNPV(i).GetValueOrDefault();
Assert.IsTrue(Math.Abs(cs - z)<1e-3, "zciis leg does not equal CPISwap leg");
QAssert.IsTrue(Math.Abs(cs - z)<1e-3, "zciis leg does not equal CPISwap leg");
}
// remove circular refernce
common.hcpi.linkTo(null);
Expand Down Expand Up @@ -508,7 +508,7 @@ public void cpibondconsistency()
DiscountingBondEngine dbe = new DiscountingBondEngine(common.nominalUK);
cpiB.setPricingEngine(dbe);

Assert.IsTrue(Math.Abs(cpiB.NPV() - zisV.legNPV(0).GetValueOrDefault())<1e-5,
QAssert.IsTrue(Math.Abs(cpiB.NPV() - zisV.legNPV(0).GetValueOrDefault())<1e-5,
"cpi bond does not equal equivalent cpi swap leg");
// remove circular refernce
common.hcpi.linkTo(null);
Expand Down

0 comments on commit fc15b5b

Please sign in to comment.