Skip to content

Commit

Permalink
Finish QLNet 1.11.1
Browse files Browse the repository at this point in the history
  • Loading branch information
amaggiulli committed Jun 13, 2018
2 parents d9928a8 + f793230 commit 487747f
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 7 deletions.
4 changes: 2 additions & 2 deletions src/QLNet.Old/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.11.0.0")]
[assembly: AssemblyFileVersion("1.11.0.0")]
[assembly: AssemblyVersion("1.11.1.0")]
[assembly: AssemblyFileVersion("1.11.1.0")]
40 changes: 38 additions & 2 deletions src/QLNet/Cashflows/CashFlows.cs
Original file line number Diff line number Diff line change
Expand Up @@ -652,17 +652,53 @@ public static int accruedDays(Leg leg, bool includeSettlementDateFlows, Date set
}
return 0;
}
public static double accruedAmount(Leg leg, bool includeSettlementDateFlows, Date settlementDate = null)
public static double accruedAmount(Leg leg, bool includeSettlementDateFlows, Date settlementDate = null, Date accrualStartDate = null)
{
double result = 0.0;

if (settlementDate == null)
settlementDate = Settings.evaluationDate();

CashFlow cf = nextCashFlow(leg, includeSettlementDateFlows, settlementDate);
if (cf == null)
return 0;

Date paymentDate = cf.date();
double result = 0.0;

CashFlow cfStart = null;
Date endDate = paymentDate;

if (accrualStartDate != null)
{
cfStart = nextCashFlow(leg, includeSettlementDateFlows, accrualStartDate);

if (cfStart != null)
endDate = cfStart.date();
}

// More periods
if (endDate != paymentDate)
{
// First period
Coupon cp = cfStart as Coupon;
if (cp != null)
result += cp.accruedAmount(cp.accrualEndDate()) - cp.accruedAmount(accrualStartDate);


foreach (CashFlow x in leg.Where(x => x.date() <= paymentDate &&
x.date() > endDate))
{
cp = x as Coupon;
if (cp != null)
if (x.date() < paymentDate)
result += cp.accruedAmount(cp.accrualEndDate());
else
result += cp.accruedAmount(settlementDate);
}
return result;
}

// One period
foreach (CashFlow x in leg.Where(x => x.date() == paymentDate))
{
Coupon cp = x as Coupon;
Expand Down
4 changes: 2 additions & 2 deletions src/QLNet/Pricingengines/Bond/BondFunctions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ public static double accruedDays(Bond bond, Date settlementDate = null)

return CashFlows.accruedDays(bond.cashflows(), false, settlementDate);
}
public static double accruedAmount(Bond bond, Date settlementDate = null)
public static double accruedAmount(Bond bond, Date settlementDate = null, Date accrualStartDate = null)
{
if (settlementDate == null)
settlementDate = bond.settlementDate();
Expand All @@ -215,7 +215,7 @@ public static double accruedAmount(Bond bond, Date settlementDate = null)
"non tradable at " + settlementDate +
" (maturity being " + bond.maturityDate() + ")");

return CashFlows.accruedAmount(bond.cashflows(), false, settlementDate) * 100.0 / bond.notional(settlementDate);
return CashFlows.accruedAmount(bond.cashflows(), false, settlementDate, accrualStartDate) * 100.0 / bond.notional(settlementDate);
}

#endregion
Expand Down
2 changes: 1 addition & 1 deletion src/QLNet/QLNet.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<VersionPrefix>1.11.0</VersionPrefix>
<VersionPrefix>1.11.1</VersionPrefix>
<TargetFrameworks>net45;net40;netstandard2.0;netcoreapp1.1</TargetFrameworks>
<DefineConstants>$(DefineConstants);QL_NEGATIVE_RATES</DefineConstants>
<AssemblyName>QLNet</AssemblyName>
Expand Down

0 comments on commit 487747f

Please sign in to comment.