DerivaSharp 1.1.0

dotnet add package DerivaSharp --version 1.1.0
                    
NuGet\Install-Package DerivaSharp -Version 1.1.0
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="DerivaSharp" Version="1.1.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="DerivaSharp" Version="1.1.0" />
                    
Directory.Packages.props
<PackageReference Include="DerivaSharp" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add DerivaSharp --version 1.1.0
                    
#r "nuget: DerivaSharp, 1.1.0"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package DerivaSharp@1.1.0
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=DerivaSharp&version=1.1.0
                    
Install as a Cake Addin
#tool nuget:?package=DerivaSharp&version=1.1.0
                    
Install as a Cake Tool

DerivaSharp

Financial derivatives pricing in modern C# for quantitative research, model validation, and desk analytics.

CI DerivaSharp on NuGet Monte Carlo on NuGet .NET 10 License: MIT

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.20 means 20%.
  • Time to expiry uses Actual/365 Fixed.
  • Theta, Charm, and Color are reported per calendar day.
  • Vega, Vanna, Zomma, and Rho are 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 NullCalendar and an SSE trading calendar; custom calendars implement ICalendar.

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:

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.

Product Compatible and additional computed target framework versions.
.NET net10.0 is compatible.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (1)

Showing the top 1 NuGet packages that depend on DerivaSharp:

Package Downloads
DerivaSharp.MonteCarlo

TorchSharp Monte Carlo pricing engines for DerivaSharp.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.1.0 37 8/29/2026
1.0.0 72 8/26/2026