StockSharp.Algo.Gpu
5.0.1
Prefix Reserved
dotnet add package StockSharp.Algo.Gpu --version 5.0.1
NuGet\Install-Package StockSharp.Algo.Gpu -Version 5.0.1
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="StockSharp.Algo.Gpu" Version="5.0.1" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="StockSharp.Algo.Gpu" Version="5.0.1" />
<PackageReference Include="StockSharp.Algo.Gpu" />
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 StockSharp.Algo.Gpu --version 5.0.1
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: StockSharp.Algo.Gpu, 5.0.1"
#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 StockSharp.Algo.Gpu@5.0.1
#: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=StockSharp.Algo.Gpu&version=5.0.1
#tool nuget:?package=StockSharp.Algo.Gpu&version=5.0.1
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
StockSharp Algo.Gpu Library
Overview
StockSharp.Algo.Gpu is a specialized library that provides GPU-accelerated calculations for technical indicators using the ILGPU framework. It enables massive parallel processing of market data indicators on CUDA, OpenCL, and CPU accelerators, offering significant performance improvements for batch calculations and strategy optimization scenarios.
Features
- GPU Acceleration – leverages ILGPU for cross-platform GPU computing with support for CUDA, OpenCL, and CPU backends
- Batch Processing – efficiently processes multiple data series and parameter combinations in a single GPU pass
- Optimized Data Structures – specialized
GpuCandleandGpuIndicatorResultstructs designed for GPU memory layout - Technical Indicators – currently includes GPU-accelerated Simple Moving Average (SMA), Average Directional Index (ADX), and Envelope with extensible architecture for additional indicators
- Automatic Device Selection – intelligent accelerator selection based on device capabilities and memory size
Getting Started
Prerequisites
- .NET SDK 6.0 or later
- GPU with CUDA support, OpenCL drivers, or modern CPU for fallback processing
- Visual Studio 2022 or any compatible IDE
Basic Usage
The typical workflow involves creating an accelerator, setting up input data, and running batch calculations:
using StockSharp.Algo.Gpu;
using StockSharp.Algo.Gpu.Indicators;
using StockSharp.Algo.Indicators;
// Create best available accelerator (CUDA > OpenCL > CPU)
var (context, accelerator) = GpuAcceleratorFactory.CreateBestAccelerator();
// Convert candles to GPU format
var gpuCandles = candles.Select(c => new GpuCandle(
c.OpenTime, c.OpenPrice, c.HighPrice, c.LowPrice, c.ClosePrice, c.TotalVolume
)).ToArray();
// Define SMA parameters to test
var smaParams = new GpuSmaParams[]
{
new(10, (byte)Level1Fields.ClosePrice),
new(20, (byte)Level1Fields.ClosePrice),
new(50, (byte)Level1Fields.ClosePrice)
};
// Calculate SMA for multiple parameter sets
using var calculator = new GpuSmaCalculator(context, accelerator);
IGpuIndicatorResult[][][] gpuResults = calculator.Calculate(new[] { gpuCandles }, smaParams);
// Convert GPU results to indicator values
var smaIndicator = new SimpleMovingAverage { Length = 20 };
foreach (var seriesResult in gpuResults[0])
{
foreach (IGpuIndicatorResult gpuResult in seriesResult)
{
if (gpuResult.GetIsFormed())
{
var indicatorValue = gpuResult.ToValue(smaIndicator);
Console.WriteLine($"SMA: {indicatorValue.ToDecimal()} at {indicatorValue.Time}");
}
}
}
// Cleanup
accelerator.Dispose();
context.Dispose();
Architecture
Core Components
GpuAcceleratorFactory– factory for creating and selecting optimal ILGPU acceleratorsGpuIndicatorCalculatorBase– base class for all GPU indicator calculatorsGpuCandle– GPU-optimized candle data structure with float precision for performanceIGpuIndicatorResult– interface for GPU indicator calculation results with ToValue conversionGpuIndicatorResult– standard GPU result structure implementing IGpuIndicatorResultIGpuIndicatorParams– interface for GPU indicator parameter structuresIGpuIndicatorResult– interface for GPU calculation results with ToValue() conversion method
Performance Considerations
- GPU calculations use single-precision floating-point (
float) for optimal performance - Batch processing is most efficient when processing multiple series or parameter combinations simultaneously
- Memory transfers between CPU and GPU are minimized through batched operations
- Automatic device selection prioritizes CUDA over OpenCL over CPU for best performance
Use Cases
- Strategy Optimization – testing multiple indicator parameters across large datasets
- Historical Analysis – processing years of market data with various technical indicators
| Product | Versions 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.
-
net10.0
- ILGPU.Algorithms (>= 1.5.3)
- StockSharp.Algo.Indicators (>= 5.0.1)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.