Skip to content

Commit 487747f

Browse files
committed
Finish QLNet 1.11.1
2 parents d9928a8 + f793230 commit 487747f

File tree

4 files changed

+43
-7
lines changed

4 files changed

+43
-7
lines changed

src/QLNet.Old/AssemblyInfo.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,5 +30,5 @@
3030
//
3131
// È possibile specificare tutti i valori o impostare come predefiniti i valori Numero revisione e Numero build
3232
// utilizzando l'asterisco (*) come descritto di seguito:
33-
[assembly: AssemblyVersion("1.11.0.0")]
34-
[assembly: AssemblyFileVersion("1.11.0.0")]
33+
[assembly: AssemblyVersion("1.11.1.0")]
34+
[assembly: AssemblyFileVersion("1.11.1.0")]

src/QLNet/Cashflows/CashFlows.cs

Lines changed: 38 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -652,17 +652,53 @@ public static int accruedDays(Leg leg, bool includeSettlementDateFlows, Date set
652652
}
653653
return 0;
654654
}
655-
public static double accruedAmount(Leg leg, bool includeSettlementDateFlows, Date settlementDate = null)
655+
public static double accruedAmount(Leg leg, bool includeSettlementDateFlows, Date settlementDate = null, Date accrualStartDate = null)
656656
{
657+
double result = 0.0;
658+
657659
if (settlementDate == null)
658660
settlementDate = Settings.evaluationDate();
659661

660662
CashFlow cf = nextCashFlow(leg, includeSettlementDateFlows, settlementDate);
661663
if (cf == null)
662664
return 0;
665+
663666
Date paymentDate = cf.date();
664-
double result = 0.0;
665667

668+
CashFlow cfStart = null;
669+
Date endDate = paymentDate;
670+
671+
if (accrualStartDate != null)
672+
{
673+
cfStart = nextCashFlow(leg, includeSettlementDateFlows, accrualStartDate);
674+
675+
if (cfStart != null)
676+
endDate = cfStart.date();
677+
}
678+
679+
// More periods
680+
if (endDate != paymentDate)
681+
{
682+
// First period
683+
Coupon cp = cfStart as Coupon;
684+
if (cp != null)
685+
result += cp.accruedAmount(cp.accrualEndDate()) - cp.accruedAmount(accrualStartDate);
686+
687+
688+
foreach (CashFlow x in leg.Where(x => x.date() <= paymentDate &&
689+
x.date() > endDate))
690+
{
691+
cp = x as Coupon;
692+
if (cp != null)
693+
if (x.date() < paymentDate)
694+
result += cp.accruedAmount(cp.accrualEndDate());
695+
else
696+
result += cp.accruedAmount(settlementDate);
697+
}
698+
return result;
699+
}
700+
701+
// One period
666702
foreach (CashFlow x in leg.Where(x => x.date() == paymentDate))
667703
{
668704
Coupon cp = x as Coupon;

src/QLNet/Pricingengines/Bond/BondFunctions.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,7 @@ public static double accruedDays(Bond bond, Date settlementDate = null)
206206

207207
return CashFlows.accruedDays(bond.cashflows(), false, settlementDate);
208208
}
209-
public static double accruedAmount(Bond bond, Date settlementDate = null)
209+
public static double accruedAmount(Bond bond, Date settlementDate = null, Date accrualStartDate = null)
210210
{
211211
if (settlementDate == null)
212212
settlementDate = bond.settlementDate();
@@ -215,7 +215,7 @@ public static double accruedAmount(Bond bond, Date settlementDate = null)
215215
"non tradable at " + settlementDate +
216216
" (maturity being " + bond.maturityDate() + ")");
217217

218-
return CashFlows.accruedAmount(bond.cashflows(), false, settlementDate) * 100.0 / bond.notional(settlementDate);
218+
return CashFlows.accruedAmount(bond.cashflows(), false, settlementDate, accrualStartDate) * 100.0 / bond.notional(settlementDate);
219219
}
220220

221221
#endregion

src/QLNet/QLNet.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22

33
<PropertyGroup>
4-
<VersionPrefix>1.11.0</VersionPrefix>
4+
<VersionPrefix>1.11.1</VersionPrefix>
55
<TargetFrameworks>net45;net40;netstandard2.0;netcoreapp1.1</TargetFrameworks>
66
<DefineConstants>$(DefineConstants);QL_NEGATIVE_RATES</DefineConstants>
77
<AssemblyName>QLNet</AssemblyName>

0 commit comments

Comments
 (0)