Skip to content

Commit

Permalink
Release QLNet-v1.13.1
Browse files Browse the repository at this point in the history
  • Loading branch information
amaggiulli committed Nov 14, 2024
2 parents fde8ae9 + 1671159 commit 83edcb5
Show file tree
Hide file tree
Showing 46 changed files with 2,393 additions and 953 deletions.
564 changes: 194 additions & 370 deletions ChangeLog.txt

Large diffs are not rendered by default.

38 changes: 16 additions & 22 deletions News.txt
Original file line number Diff line number Diff line change
@@ -1,42 +1,36 @@
QLNet 1.13.0
QLNet 1.13.1
=========================

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

FRAMEWORK

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

PRICING ENGINES
INSTRUMENTS

+ Fixed MCDiscreteAveragingAsianEngine timeGrid and ArithmeticAPOPathPricer path value retrieval thanks @mookid8000

CASHFLOWS

+ Added new CashFlows method to return both accrued days and accrued amount.
+ Fixed DividendVanillaOption Engine bug, thx to Lorenzo Di Puccio for reporting it.
+ Updated callable bonds.
+ Added Bond Equivalent Yield calculation.
+ Added Futures Type - Custom, thx @ninetiger and Xiao Gong

INDEXES

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

CALENDARS

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

MISC

+ Added batch calculations
+ Added Compounded Then Simple calculation.

TIME

+ Refactoring DayCounters
+ Added Actual/366 daycounter.
+ Added Actual364, Actual36525 and Thirty365 daycounters.
+ Refactoring Calendars
+ Added Cyprus and Greece calendars, thanks @pamboscy
+ Fixed Schedule until method.
+ Updated several caledars up to 2023

+ Fixd Schedule.previousDate and Schedule.nextDate, thx Francois Botha
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ QLNet also contains new developments on the bond market like MBS, Amortized Cost

[![Build status](https://ci.appveyor.com/api/projects/status/nn0a2mw6qu8mg481?svg=true)](https://ci.appveyor.com/project/amaggiulli/qlnet-p0t4r)
[![NuGet](https://buildstats.info/nuget/qlnet)](https://www.nuget.org/packages/qlnet/)
[![NuGet](https://img.shields.io/nuget/vpre/QLNet?style=flat-square)](https://www.nuget.org/packages/QLNet)
[![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)

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

Thanks to all Quantlib creators and contributors.
Thanks to all QLNet contributors.
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).
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).

24 changes: 12 additions & 12 deletions appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
branches:
only:
- master
version: 1.13.0
version: 1.13.1
configuration: Release
platform: Any CPU
image: Visual Studio 2022
Expand All @@ -21,23 +21,23 @@
after_build:
- cmd: dotnet pack src/qlnet/qlnet.csproj -c Release -o ./
artifacts:
- path: src\QLNet\bin\Release\net7.0\QLNet.dll
- path: src\QLNet\bin\Release\net8.0\QLNet.dll
name: Windows
- path: .\*.nupkg
name: ng
deploy:
- provider: GitHub
tag: QLNet-v1.13.0
release: QLNet Version 1.13.0
description: QLNet 1.13.0
tag: QLNet-v1.13.1
release: QLNet Version 1.13.1
description: QLNet 1.13.1
auth_token:
secure: 4cCBgQRwNh1N6VbvMJTCUMoq7BVD0Cmj04AjQa8L3k5k6MirTm8dz5TFUuqRDbHhj5x2QJS4l2EfoTsAMgc8ZhWYVJ2CV1deITs7sHYG98BrXl8NGKdPivoOZZdZT9oo
artifact: src\QLNet\bin\Release\net7.0\QLNet.dll
secure: 4cCBgQRwNh1N6VbvMJTCUDVyo4z4acn5q6z4PXSgW5wOA0M2e6alGZms4fBx5Vw+6W8FieXgzRUvUfxmJ/xAnjxJZAFMeqI0mifvwMxjW9JAVC3EcFnV4NNZX/QoQRk6
artifact: src\QLNet\bin\Release\net8.0\QLNet.dll
draft: false
force_update: false
- provider: NuGet
api_key:
secure: B/mINFQqQ7mV7FjaOEErtgDWsvkgcnajcscRwCm6tTVFnu8+fc1Xti79M9CAZcgd
secure: LfB0vicMVT0ZgtDL1NtPmI+zC4he3BfQcO+2BlaN/0qlEnH4F6cz8K5QrM78OnoZ
skip_symbols: true
artifact: ng

Expand All @@ -47,7 +47,7 @@
branches:
only:
- develop
version: 1.12.1-preview.{build}
version: 1.13.2-preview.{build}
configuration: Release
platform: Any CPU
image: Visual Studio 2022
Expand Down Expand Up @@ -86,7 +86,7 @@
deploy:
- provider: NuGet
api_key:
secure: B/mINFQqQ7mV7FjaOEErtgDWsvkgcnajcscRwCm6tTVFnu8+fc1Xti79M9CAZcgd
secure: LfB0vicMVT0ZgtDL1NtPmI+zC4he3BfQcO+2BlaN/0qlEnH4F6cz8K5QrM78OnoZ
skip_symbols: false
artifact: ng

Expand All @@ -96,7 +96,7 @@
branches:
only:
- /feature/
version: 1.12.1-{build}
version: 1.13.2-{build}
configuration: Release
platform: Any CPU
image: Visual Studio 2022
Expand All @@ -105,7 +105,7 @@
init:
- cmd: set JAVA_HOME=C:\Program Files\Java\jdk11
- cmd: "set branch=%APPVEYOR_REPO_BRANCH%\necho branch:%branch%\nset gitVersion=%branch:/=.%\necho gitversion:%gitVersion%\nset newVersion=%gitVersion%.%APPVEYOR_BUILD_NUMBER%\necho %newVersion%"
- cmd: appveyor UpdateBuild -Version "1.12.1-%newVersion%"
- cmd: appveyor UpdateBuild -Version "1.13.2-%newVersion%"
before_build:
- cmd: dotnet restore qlnet.sln
build_script:
Expand Down
33 changes: 33 additions & 0 deletions src/QLNet/Indexes/Ibor/Corra.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
/*
Copyright (C) 2024 Konstantin Novitsky ([email protected])
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 at <https://github.com/amaggiulli/QLNet/blob/develop/LICENSE>.
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.
*/

namespace QLNet
{
/*! CORRA (Canadian Overnight Repo Rate Average) rate fixed by the RBA.
See <https://www.isda.org/2023/10/16/overview-of-the-canadian-derivatives-market/>.
*/
public class Corra : OvernightIndex
{
public Corra(Handle<YieldTermStructure> h = null)
: base("Corra", 0, new CADCurrency(), new Canada(), new Actual365Fixed(),
h ?? new Handle<YieldTermStructure>())
{ }
}

}
92 changes: 92 additions & 0 deletions src/QLNet/Instruments/Bond.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ 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 System.Linq;

Expand All @@ -33,6 +34,44 @@ namespace QLNet
- price/yield calculations are checked against known good values. */
public class Bond : Instrument
{
public enum BondEquivalentYearType
{
Always365,
Always366,
SettlementFwdOneYear,
IssueFwdOneYear,
MaturityBackOneYear
}

/// <summary>
/// Bond price information
/// </summary>
public class Price
{
private double? amount_;
private Type type_;
public enum Type { Dirty, Clean }

public Price()
{
amount_ = null;
}

public Price(double amount, Type type)
{
amount_ = amount;
type_ = type;
}

public double amount()
{
Utils.QL_REQUIRE(amount_ != null, () => "no amount given");
return amount_.Value;
}

public Type type() { return type_; }
}

#region Constructors
//! constructor for amortizing or non-amortizing bonds.
/*! Redemptions and maturity are calculated from the coupon
Expand Down Expand Up @@ -282,6 +321,59 @@ public virtual double accruedAmount(Date settlement = null)

}

// Bond equivalent yield
public virtual double bondEquivalentYield(BondEquivalentYearType yearType, DateTime settlementDate, decimal price,
DayCounter dc, Calendar calendar, Frequency frequency)
{
Utils.QL_REQUIRE(settlementDate != DateTime.MinValue, () => "invalid settlement date");
Utils.QL_REQUIRE(maturityDate_ != null, () => "maturity date not provided");
double yearDays = 365;

// Year type calculation
bool eom;
Date endDate;
switch (yearType)
{
case BondEquivalentYearType.Always365:
break;
case BondEquivalentYearType.Always366:
yearDays = 366;
break;
case BondEquivalentYearType.SettlementFwdOneYear:
eom = calendar.isEndOfMonth(settlementDate);
endDate = calendar.advance(settlementDate, new Period(1, TimeUnit.Years), BusinessDayConvention.Unadjusted, eom);
yearDays = dc.dayCount(settlementDate, endDate);
break;
case BondEquivalentYearType.IssueFwdOneYear:
if (issueDate_ != null)
{
eom = calendar.isEndOfMonth(issueDate_);
endDate = calendar.advance(issueDate_, new Period(1, TimeUnit.Years), BusinessDayConvention.Unadjusted, eom);
yearDays = dc.dayCount(issueDate_, endDate);
}
break;
case BondEquivalentYearType.MaturityBackOneYear:
eom = calendar.isEndOfMonth(maturityDate_);
endDate = calendar.advance(maturityDate_, new Period(-1, TimeUnit.Years), BusinessDayConvention.Unadjusted, eom);
yearDays = dc.dayCount(endDate, maturityDate_);
break;
default:
throw new ArgumentOutOfRangeException(nameof(yearType), yearType, null);
}

// BEY Calc
double daysToMaturity = dc.dayCount(settlementDate, maturityDate_);
var periodLenght = Math.Ceiling(365 / (double)frequency);
if (daysToMaturity <= periodLenght)
{
return (double)((100 - price) / price * ((decimal)yearDays / dc.dayCount(settlementDate, maturityDate_)));
}
var numerator = ((-2 * daysToMaturity) / yearDays) + 2 * Math.Pow(
Math.Pow(daysToMaturity / yearDays, 2) - ((2 * daysToMaturity / yearDays - 1) * (1 - 100 / (double)price)), 0.5);
var denominator = 2 * daysToMaturity / yearDays - 1;
return numerator / denominator;
}

#endregion

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

0 comments on commit 83edcb5

Please sign in to comment.