Skip to content

Commit

Permalink
.net 6.0 package support
Browse files Browse the repository at this point in the history
  • Loading branch information
gavbrennan committed Oct 13, 2022
1 parent 486bfb2 commit 5d43e04
Show file tree
Hide file tree
Showing 16 changed files with 35 additions and 15 deletions.
2 changes: 1 addition & 1 deletion src/Qwack.Core/Qwack.Core.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<Import Project="..\..\common.props" />
<PropertyGroup>
<TargetFrameworks>netstandard2.0</TargetFrameworks>
<TargetFrameworks>netstandard2.0;net6.0</TargetFrameworks>
<AssemblyName>Qwack.Core</AssemblyName>
<PackageId>Qwack.Core</PackageId>
</PropertyGroup>
Expand Down
2 changes: 1 addition & 1 deletion src/Qwack.Dates/Qwack.Dates.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<Import Project="..\..\common.props" />
<PropertyGroup>
<TargetFrameworks>netstandard2.0</TargetFrameworks>
<TargetFrameworks>netstandard2.0;net6.0</TargetFrameworks>
<AssemblyName>Qwack.Dates</AssemblyName>
<PackageId>Qwack.Dates</PackageId>
</PropertyGroup>
Expand Down
2 changes: 1 addition & 1 deletion src/Qwack.Futures/Qwack.Futures.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>netstandard2.0</TargetFrameworks>
<TargetFrameworks>netstandard2.0;net6.0</TargetFrameworks>
</PropertyGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<Import Project="..\..\common.props" />
<PropertyGroup>
<TargetFrameworks>netstandard2.0</TargetFrameworks>
<TargetFrameworks>netstandard2.0;net6.0</TargetFrameworks>
<AssemblyName>Qwack.Math.Interpolation</AssemblyName>
<PackageId>Qwack.Math.Interpolation</PackageId>
</PropertyGroup>
Expand Down
20 changes: 20 additions & 0 deletions src/Qwack.Math/BondUtils.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using System;
using System.Collections.Generic;
using System.Linq;
using Qwack.Math.Solvers;

namespace Qwack.Math
{
Expand All @@ -9,6 +10,25 @@ public static class BondUtils
public static double YieldToMaturity(double couponRate, double faceValue, double cleanPrice, double t)
=> (couponRate + (faceValue - cleanPrice) / t) / ((faceValue + cleanPrice) / 2.0);

public static double YieldToMaturity(double couponRate, double faceValue, double periodsPerYear, double tMaturity, double tNext, double cleanPrice)
{
var source = BondFlows(couponRate / faceValue, faceValue, periodsPerYear, tMaturity, tNext);
var tPerP = 1 / periodsPerYear;
return Brent.BrentsMethodSolve(delegate (double ytm)
{
var num = 0.0;
foreach (var item in source)
{
var y = (item.Key) / tPerP;
num += item.Value / System.Math.Pow(1.0 + ytm / periodsPerYear, y);
}
return num - cleanPrice;
}, -0.1, 1.0, 1E-06);
}

public static double YieldToWorst(double couponRate, double[] redemptionPrices, double cleanPrice, double[] tRedeem, double periodsPerYear, double tNext)
=> tRedeem.Select((t, ix) => YieldToMaturity(couponRate, redemptionPrices[ix], periodsPerYear, t, tNext, cleanPrice)).Min();

public static double YieldToWorst(double couponRate, double faceValue, double cleanPrice, double tMaturity, double tCall, double callPrice)
=> System.Math.Min(
YieldToMaturity(couponRate, faceValue, cleanPrice, tMaturity),
Expand Down
2 changes: 1 addition & 1 deletion src/Qwack.Math/Qwack.Math.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<Import Project="..\..\common.props" />
<PropertyGroup>
<TargetFrameworks>netstandard2.0</TargetFrameworks>
<TargetFrameworks>netstandard2.0;net6.0</TargetFrameworks>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<AssemblyName>Qwack.Math</AssemblyName>
<PackageId>Qwack.Math</PackageId>
Expand Down
2 changes: 1 addition & 1 deletion src/Qwack.Models/Qwack.Models.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<Import Project="..\..\common.props" />
<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
<TargetFrameworks>netstandard2.0;net6.0</TargetFrameworks>
<AssemblyName>Qwack.Models</AssemblyName>
<PackageId>Qwack.Models</PackageId>
</PropertyGroup>
Expand Down
2 changes: 1 addition & 1 deletion src/Qwack.Options/Qwack.Options.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<Import Project="..\..\common.props" />
<PropertyGroup>
<TargetFrameworks>netstandard2.0</TargetFrameworks>
<TargetFrameworks>netstandard2.0;net6.0</TargetFrameworks>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<AssemblyName>Qwack.Options</AssemblyName>
<PackageId>Qwack.Options</PackageId>
Expand Down
2 changes: 1 addition & 1 deletion src/Qwack.Paths/Qwack.Paths.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<Import Project="..\..\common.props" />
<PropertyGroup>
<TargetFrameworks>netstandard2.0</TargetFrameworks>
<TargetFrameworks>netstandard2.0;net6.0</TargetFrameworks>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<AssemblyName>Qwack.Paths</AssemblyName>
<PackageId>Qwack.Paths</PackageId>
Expand Down
2 changes: 1 addition & 1 deletion src/Qwack.Providers/Qwack.Providers.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<Import Project="..\..\common.props" />
<PropertyGroup>
<TargetFrameworks>netstandard2.0</TargetFrameworks>
<TargetFrameworks>netstandard2.0;net6.0</TargetFrameworks>
<AssemblyName>Qwack.Providers</AssemblyName>
<PackageId>Qwack.Providers</PackageId>
</PropertyGroup>
Expand Down
2 changes: 1 addition & 1 deletion src/Qwack.Random/Qwack.Random.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<Import Project="..\..\common.props" />
<PropertyGroup>
<TargetFrameworks>netstandard2.0</TargetFrameworks>
<TargetFrameworks>netstandard2.0;net6.0</TargetFrameworks>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<AssemblyName>Qwack.Random</AssemblyName>
<PackageId>Qwack.Random</PackageId>
Expand Down
2 changes: 1 addition & 1 deletion src/Qwack.Serialization/Qwack.Serialization.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<Import Project="..\..\common.props" />
<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
<TargetFrameworks>netstandard2.0;net6.0</TargetFrameworks>
</PropertyGroup>

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

<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
<TargetFrameworks>netstandard2.0;net6.0</TargetFrameworks>
</PropertyGroup>

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

<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
<TargetFrameworks>netstandard2.0;net6.0</TargetFrameworks>
</PropertyGroup>

<ItemGroup>
Expand Down
2 changes: 1 addition & 1 deletion src/Qwack.Utils/Qwack.Utils.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<Import Project="..\..\common.props" />
<PropertyGroup>
<TargetFrameworks>netstandard2.0</TargetFrameworks>
<TargetFrameworks>netstandard2.0;net6.0</TargetFrameworks>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<AssemblyName>Qwack.Utils</AssemblyName>
<PackageId>Qwack.Utils</PackageId>
Expand Down
2 changes: 1 addition & 1 deletion version.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.7.2
0.7.3

0 comments on commit 5d43e04

Please sign in to comment.