DerivaSharp.Gpu.Linux
1.1.0
dotnet add package DerivaSharp.Gpu.Linux --version 1.1.0
NuGet\Install-Package DerivaSharp.Gpu.Linux -Version 1.1.0
<PackageReference Include="DerivaSharp.Gpu.Linux" Version="1.1.0" />
<PackageVersion Include="DerivaSharp.Gpu.Linux" Version="1.1.0" />
<PackageReference Include="DerivaSharp.Gpu.Linux" />
paket add DerivaSharp.Gpu.Linux --version 1.1.0
#r "nuget: DerivaSharp.Gpu.Linux, 1.1.0"
#:package DerivaSharp.Gpu.Linux@1.1.0
#addin nuget:?package=DerivaSharp.Gpu.Linux&version=1.1.0
#tool nuget:?package=DerivaSharp.Gpu.Linux&version=1.1.0
DerivaSharp
Financial derivatives pricing in modern C# for quantitative research, model validation, and desk analytics.
DerivaSharp provides typed instruments and interchangeable pricing engines under a consistent Black–Scholes–Merton interface. It covers closed-form benchmarks, finite-difference and tree methods, numerical integration, and TorchSharp Monte Carlo on CPU or CUDA.
The library is deliberately focused: single-underlying contracts, flat volatility and continuously compounded risk-free/dividend rates, explicit contractual schedules, and transparent numerical methods. It is a good fit for pricing research, engine cross-checks, and focused analytics services—not a complete market-data, curve-building, or portfolio-risk platform.
Pricing coverage
| Product | Available methods |
|---|---|
| European vanilla | Black–Scholes–Merton closed form, Gauss–Legendre integration, Cox–Ross–Rubinstein tree, finite difference, Monte Carlo |
| American vanilla | Bjerksund–Stensland 2002, Cox–Ross–Rubinstein tree, finite difference, Longstaff–Schwartz Monte Carlo |
| Cash-or-nothing and asset-or-nothing digitals | Closed form, numerical integration, finite difference |
| Vanilla barriers | Closed form, finite difference |
| Binary barriers and one-touch/no-touch contracts | Closed form |
| Geometric and arithmetic-average Asians | Closed form and Turnbull–Wakeman approximation |
| Snowball, binary snowball, ternary snowball, and Phoenix notes | Finite difference, Monte Carlo |
| Accumulators | Finite difference, Monte Carlo |
Every Black–Scholes–Merton engine exposes value, spot Greeks, time Greeks, volatility Greeks, rho, scenario grids, and implied volatility through the same base API. Autocallable engines also support implied coupon-rate solving.
Install
DerivaSharp targets .NET 10. Choose one package path:
| Use case | Command |
|---|---|
| Analytic, tree, integration, and finite-difference engines | dotnet add package DerivaSharp |
| TorchSharp Monte Carlo on CPU | dotnet add package DerivaSharp.MonteCarlo |
| TorchSharp Monte Carlo on NVIDIA CUDA 12.8, Windows x64 | dotnet add package DerivaSharp.Gpu.Windows |
| TorchSharp Monte Carlo on NVIDIA CUDA 12.8, Linux x64 | dotnet add package DerivaSharp.Gpu.Linux |
Install only one TorchSharp runtime path in an application. The GPU packages bring in DerivaSharp.MonteCarlo and the platform-specific CUDA runtime.
Quick start
Price a one-year at-the-money European call and calculate its risk measures:
using DerivaSharp.Instruments;
using DerivaSharp.Models;
using DerivaSharp.PricingEngines;
using DerivaSharp.Time;
DateOnly valuationDate = new(2025, 1, 6);
EuropeanOption option = new(
OptionType.Call,
strikePrice: 100.0,
effectiveDate: valuationDate,
expirationDate: valuationDate.AddDays(365));
BsmModelParameters model = new(
volatility: 0.30,
riskFreeRate: 0.04,
dividendYield: 0.01);
PricingContext<BsmModelParameters> context = new(
model,
AssetPrice: 100.0,
valuationDate,
NullCalendar.Shared);
AnalyticEuropeanEngine engine = new();
PricingResult result = engine.ValueAndGreeks(option, context);
double impliedVolatility = engine.ImpliedVolatility(option, context, optionPrice: 13.151137);
Console.WriteLine($"Value: {result.Value:F6}"); // 13.151137
Console.WriteLine($"Delta: {result.Delta:F6}"); // 0.592749
Console.WriteLine($"Implied vol: {impliedVolatility:P2}"); // 30.00%
Swap the engine without changing the instrument or market context:
BsmPricingEngine<EuropeanOption> finiteDifference =
new FdEuropeanEngine(FiniteDifferenceScheme.CrankNicolson, 500, 500);
BsmPricingEngine<EuropeanOption> monteCarlo =
new McEuropeanEngine(pathCount: 500_000, stepCount: 2, useCuda: true, seed: 42);
The Monte Carlo example requires DerivaSharp.MonteCarlo and one compatible TorchSharp runtime package.
Conventions
- Volatility and rates use decimal units:
0.20means 20%. - Time to expiry uses Actual/365 Fixed.
Theta,Charm, andColorare reported per calendar day.Vega,Vanna,Zomma, andRhoare reported per one percentage-point move.PricingContext<T>carries valuation date, spot, model parameters, and the trading calendar used for schedules and path-dependent grids.- Built-in calendars include an all-days
NullCalendarand an SSE trading calendar; custom calendars implementICalendar.
Structured-product schedules
Contractual observation dates are explicit and validated against the pricing calendar. Monthly schedules can be generated with following adjustment:
DateOnly effectiveDate = new(2025, 1, 6);
DateOnly expirationDate = new(2026, 1, 6);
IReadOnlyList<DateOnly> observationDates = Schedule.CreateMonthly(
effectiveDate,
expirationDate,
lockUpMonths: 3,
SseCalendar.Shared);
See the research notebooks for fuller workflows:
- European option value and Greeks
- Snowball finite-difference and Monte Carlo profiles
- Accumulator analytics
Development
The .NET 10 SDK is required.
dotnet restore DerivaSharp.slnx
dotnet build DerivaSharp.slnx --no-restore
dotnet test --project tests/DerivaSharp.Tests/DerivaSharp.Tests.csproj --no-build
dotnet test --project tests/DerivaSharp.MonteCarlo.Tests/DerivaSharp.MonteCarlo.Tests.csproj --no-build
Bug reports and focused contributions are welcome through GitHub Issues and pull requests.
License
DerivaSharp is available under the MIT License.
Learn more about Target Frameworks and .NET Standard.
-
- DerivaSharp.MonteCarlo (= 1.1.0)
- libtorch-cuda-12.8-linux-x64 (= 2.10.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.