Skip to content

Commit 83edcb5

Browse files
committed
Release QLNet-v1.13.1
2 parents fde8ae9 + 1671159 commit 83edcb5

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+2393
-953
lines changed

ChangeLog.txt

Lines changed: 194 additions & 370 deletions
Large diffs are not rendered by default.

News.txt

Lines changed: 16 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,42 +1,36 @@
1-
QLNet 1.13.0
1+
QLNet 1.13.1
22
=========================
33

4-
QLNet 1.13.0
5-
Mayor changes <https://github.com/amaggiulli/QLNet/milestone/4?closed=1>.
4+
QLNet 1.13.1
5+
Mayor changes <https://github.com/amaggiulli/QLNet/milestone/5?closed=1>.
66
A detailed list of changes is available in ChangeLog.txt.
77

88
FRAMEWORK
99

10-
+ Updated to .NET 7.0 / netstandard 2.0
11-
+ Removed AStyle formatting for more standard ediconfig setting
10+
+ Updated to .NET 8.0
1211

13-
PRICING ENGINES
12+
INSTRUMENTS
1413

15-
+ Fixed MCDiscreteAveragingAsianEngine timeGrid and ArithmeticAPOPathPricer path value retrieval thanks @mookid8000
16-
17-
CASHFLOWS
18-
19-
+ Added new CashFlows method to return both accrued days and accrued amount.
14+
+ Fixed DividendVanillaOption Engine bug, thx to Lorenzo Di Puccio for reporting it.
15+
+ Updated callable bonds.
16+
+ Added Bond Equivalent Yield calculation.
17+
+ Added Futures Type - Custom, thx @ninetiger and Xiao Gong
2018

2119
INDEXES
2220

23-
+ Added SOFR Index
21+
+ Added CAD-CORRA overnight index, thx Konstantin Novitsky
2422

2523
CALENDARS
2624

27-
+ Support New Zealand's new publish holiday: Matariki holiday, thanks @ninetiger
25+
+ Added 2023-12-15 as South African public holiday, thx Francois Botha
26+
+ Added early close logic for US bond market.
27+
+ Updated several caledars up to 2024
28+
+ Fixed Aboriginal people day in Chile calendar, thx @bet0x10
2829

2930
MISC
3031

31-
+ Added batch calculations
32+
+ Added Compounded Then Simple calculation.
3233

3334
TIME
3435

35-
+ Refactoring DayCounters
36-
+ Added Actual/366 daycounter.
37-
+ Added Actual364, Actual36525 and Thirty365 daycounters.
38-
+ Refactoring Calendars
39-
+ Added Cyprus and Greece calendars, thanks @pamboscy
40-
+ Fixed Schedule until method.
41-
+ Updated several caledars up to 2023
42-
36+
+ Fixd Schedule.previousDate and Schedule.nextDate, thx Francois Botha

README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ QLNet also contains new developments on the bond market like MBS, Amortized Cost
88

99
[![Build status](https://ci.appveyor.com/api/projects/status/nn0a2mw6qu8mg481?svg=true)](https://ci.appveyor.com/project/amaggiulli/qlnet-p0t4r)
1010
[![NuGet](https://buildstats.info/nuget/qlnet)](https://www.nuget.org/packages/qlnet/)
11+
[![NuGet](https://img.shields.io/nuget/vpre/QLNet?style=flat-square)](https://www.nuget.org/packages/QLNet)
1112
[![Donate](https://img.shields.io/badge/Donate-PayPal-green.svg)](https://www.paypal.com/cgi-bin/webscr?item_name=Donation+to+QLNet&cmd=_donations&business=a.maggiulli%40gmail.com)
1213

1314
[![Quality Gate Status](https://sonarcloud.io/api/project_badges/measure?project=QLNet&metric=alert_status)](https://sonarcloud.io/dashboard?id=QLNet)
@@ -58,4 +59,5 @@ As soon as the fix is complete, it will be merged into both *master* and *develo
5859

5960
Thanks to all Quantlib creators and contributors.
6061
Thanks to all QLNet contributors.
61-
Special thanks to [JetBrains](https://www.jetbrains.com/?from=qlnet) for their support of open source projects; QLNet makes extensive use of [Resharper](https://www.jetbrains.com/dotnet/?from=qlnet).
62+
Special thanks to [JetBrains](https://www.jetbrains.com/?from=qlnet) for their support of open source projects; QLNet makes extensive use of [Resharper](https://www.jetbrains.com/dotnet/?from=qlnet).
63+

appveyor.yml

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
branches:
77
only:
88
- master
9-
version: 1.13.0
9+
version: 1.13.1
1010
configuration: Release
1111
platform: Any CPU
1212
image: Visual Studio 2022
@@ -21,23 +21,23 @@
2121
after_build:
2222
- cmd: dotnet pack src/qlnet/qlnet.csproj -c Release -o ./
2323
artifacts:
24-
- path: src\QLNet\bin\Release\net7.0\QLNet.dll
24+
- path: src\QLNet\bin\Release\net8.0\QLNet.dll
2525
name: Windows
2626
- path: .\*.nupkg
2727
name: ng
2828
deploy:
2929
- provider: GitHub
30-
tag: QLNet-v1.13.0
31-
release: QLNet Version 1.13.0
32-
description: QLNet 1.13.0
30+
tag: QLNet-v1.13.1
31+
release: QLNet Version 1.13.1
32+
description: QLNet 1.13.1
3333
auth_token:
34-
secure: 4cCBgQRwNh1N6VbvMJTCUMoq7BVD0Cmj04AjQa8L3k5k6MirTm8dz5TFUuqRDbHhj5x2QJS4l2EfoTsAMgc8ZhWYVJ2CV1deITs7sHYG98BrXl8NGKdPivoOZZdZT9oo
35-
artifact: src\QLNet\bin\Release\net7.0\QLNet.dll
34+
secure: 4cCBgQRwNh1N6VbvMJTCUDVyo4z4acn5q6z4PXSgW5wOA0M2e6alGZms4fBx5Vw+6W8FieXgzRUvUfxmJ/xAnjxJZAFMeqI0mifvwMxjW9JAVC3EcFnV4NNZX/QoQRk6
35+
artifact: src\QLNet\bin\Release\net8.0\QLNet.dll
3636
draft: false
3737
force_update: false
3838
- provider: NuGet
3939
api_key:
40-
secure: B/mINFQqQ7mV7FjaOEErtgDWsvkgcnajcscRwCm6tTVFnu8+fc1Xti79M9CAZcgd
40+
secure: LfB0vicMVT0ZgtDL1NtPmI+zC4he3BfQcO+2BlaN/0qlEnH4F6cz8K5QrM78OnoZ
4141
skip_symbols: true
4242
artifact: ng
4343

@@ -47,7 +47,7 @@
4747
branches:
4848
only:
4949
- develop
50-
version: 1.12.1-preview.{build}
50+
version: 1.13.2-preview.{build}
5151
configuration: Release
5252
platform: Any CPU
5353
image: Visual Studio 2022
@@ -86,7 +86,7 @@
8686
deploy:
8787
- provider: NuGet
8888
api_key:
89-
secure: B/mINFQqQ7mV7FjaOEErtgDWsvkgcnajcscRwCm6tTVFnu8+fc1Xti79M9CAZcgd
89+
secure: LfB0vicMVT0ZgtDL1NtPmI+zC4he3BfQcO+2BlaN/0qlEnH4F6cz8K5QrM78OnoZ
9090
skip_symbols: false
9191
artifact: ng
9292

@@ -96,7 +96,7 @@
9696
branches:
9797
only:
9898
- /feature/
99-
version: 1.12.1-{build}
99+
version: 1.13.2-{build}
100100
configuration: Release
101101
platform: Any CPU
102102
image: Visual Studio 2022
@@ -105,7 +105,7 @@
105105
init:
106106
- cmd: set JAVA_HOME=C:\Program Files\Java\jdk11
107107
- cmd: "set branch=%APPVEYOR_REPO_BRANCH%\necho branch:%branch%\nset gitVersion=%branch:/=.%\necho gitversion:%gitVersion%\nset newVersion=%gitVersion%.%APPVEYOR_BUILD_NUMBER%\necho %newVersion%"
108-
- cmd: appveyor UpdateBuild -Version "1.12.1-%newVersion%"
108+
- cmd: appveyor UpdateBuild -Version "1.13.2-%newVersion%"
109109
before_build:
110110
- cmd: dotnet restore qlnet.sln
111111
build_script:

src/QLNet/Indexes/Ibor/Corra.cs

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
/*
2+
Copyright (C) 2024 Konstantin Novitsky (novitk@gmail.com)
3+
4+
This file is part of QLNet Project https://github.com/amaggiulli/qlnet
5+
6+
QLNet is free software: you can redistribute it and/or modify it
7+
under the terms of the QLNet license. You should have received a
8+
copy of the license along with this program; if not, license is
9+
available at <https://github.com/amaggiulli/QLNet/blob/develop/LICENSE>.
10+
11+
QLNet is a based on QuantLib, a free-software/open-source library
12+
for financial quantitative analysts and developers - http://quantlib.org/
13+
The QuantLib license is available online at http://quantlib.org/license.shtml.
14+
15+
This program is distributed in the hope that it will be useful, but WITHOUT
16+
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
17+
FOR A PARTICULAR PURPOSE. See the license for more details.
18+
*/
19+
20+
namespace QLNet
21+
{
22+
/*! CORRA (Canadian Overnight Repo Rate Average) rate fixed by the RBA.
23+
See <https://www.isda.org/2023/10/16/overview-of-the-canadian-derivatives-market/>.
24+
*/
25+
public class Corra : OvernightIndex
26+
{
27+
public Corra(Handle<YieldTermStructure> h = null)
28+
: base("Corra", 0, new CADCurrency(), new Canada(), new Actual365Fixed(),
29+
h ?? new Handle<YieldTermStructure>())
30+
{ }
31+
}
32+
33+
}

src/QLNet/Instruments/Bond.cs

Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ under the terms of the QLNet license. You should have received a
1818
FOR A PARTICULAR PURPOSE. See the license for more details.
1919
*/
2020

21+
using System;
2122
using System.Collections.Generic;
2223
using System.Linq;
2324

@@ -33,6 +34,44 @@ namespace QLNet
3334
- price/yield calculations are checked against known good values. */
3435
public class Bond : Instrument
3536
{
37+
public enum BondEquivalentYearType
38+
{
39+
Always365,
40+
Always366,
41+
SettlementFwdOneYear,
42+
IssueFwdOneYear,
43+
MaturityBackOneYear
44+
}
45+
46+
/// <summary>
47+
/// Bond price information
48+
/// </summary>
49+
public class Price
50+
{
51+
private double? amount_;
52+
private Type type_;
53+
public enum Type { Dirty, Clean }
54+
55+
public Price()
56+
{
57+
amount_ = null;
58+
}
59+
60+
public Price(double amount, Type type)
61+
{
62+
amount_ = amount;
63+
type_ = type;
64+
}
65+
66+
public double amount()
67+
{
68+
Utils.QL_REQUIRE(amount_ != null, () => "no amount given");
69+
return amount_.Value;
70+
}
71+
72+
public Type type() { return type_; }
73+
}
74+
3675
#region Constructors
3776
//! constructor for amortizing or non-amortizing bonds.
3877
/*! Redemptions and maturity are calculated from the coupon
@@ -282,6 +321,59 @@ public virtual double accruedAmount(Date settlement = null)
282321

283322
}
284323

324+
// Bond equivalent yield
325+
public virtual double bondEquivalentYield(BondEquivalentYearType yearType, DateTime settlementDate, decimal price,
326+
DayCounter dc, Calendar calendar, Frequency frequency)
327+
{
328+
Utils.QL_REQUIRE(settlementDate != DateTime.MinValue, () => "invalid settlement date");
329+
Utils.QL_REQUIRE(maturityDate_ != null, () => "maturity date not provided");
330+
double yearDays = 365;
331+
332+
// Year type calculation
333+
bool eom;
334+
Date endDate;
335+
switch (yearType)
336+
{
337+
case BondEquivalentYearType.Always365:
338+
break;
339+
case BondEquivalentYearType.Always366:
340+
yearDays = 366;
341+
break;
342+
case BondEquivalentYearType.SettlementFwdOneYear:
343+
eom = calendar.isEndOfMonth(settlementDate);
344+
endDate = calendar.advance(settlementDate, new Period(1, TimeUnit.Years), BusinessDayConvention.Unadjusted, eom);
345+
yearDays = dc.dayCount(settlementDate, endDate);
346+
break;
347+
case BondEquivalentYearType.IssueFwdOneYear:
348+
if (issueDate_ != null)
349+
{
350+
eom = calendar.isEndOfMonth(issueDate_);
351+
endDate = calendar.advance(issueDate_, new Period(1, TimeUnit.Years), BusinessDayConvention.Unadjusted, eom);
352+
yearDays = dc.dayCount(issueDate_, endDate);
353+
}
354+
break;
355+
case BondEquivalentYearType.MaturityBackOneYear:
356+
eom = calendar.isEndOfMonth(maturityDate_);
357+
endDate = calendar.advance(maturityDate_, new Period(-1, TimeUnit.Years), BusinessDayConvention.Unadjusted, eom);
358+
yearDays = dc.dayCount(endDate, maturityDate_);
359+
break;
360+
default:
361+
throw new ArgumentOutOfRangeException(nameof(yearType), yearType, null);
362+
}
363+
364+
// BEY Calc
365+
double daysToMaturity = dc.dayCount(settlementDate, maturityDate_);
366+
var periodLenght = Math.Ceiling(365 / (double)frequency);
367+
if (daysToMaturity <= periodLenght)
368+
{
369+
return (double)((100 - price) / price * ((decimal)yearDays / dc.dayCount(settlementDate, maturityDate_)));
370+
}
371+
var numerator = ((-2 * daysToMaturity) / yearDays) + 2 * Math.Pow(
372+
Math.Pow(daysToMaturity / yearDays, 2) - ((2 * daysToMaturity / yearDays - 1) * (1 - 100 / (double)price)), 0.5);
373+
var denominator = 2 * daysToMaturity / yearDays - 1;
374+
return numerator / denominator;
375+
}
376+
285377
#endregion
286378

287379
/*! Expected next coupon: depending on (the bond and) the given date

0 commit comments

Comments
 (0)