StockSharp.Algo.Compilation
5.0.7
Prefix Reserved
See the version list below for details.
dotnet add package StockSharp.Algo.Compilation --version 5.0.7
NuGet\Install-Package StockSharp.Algo.Compilation -Version 5.0.7
<PackageReference Include="StockSharp.Algo.Compilation" Version="5.0.7" />
<PackageVersion Include="StockSharp.Algo.Compilation" Version="5.0.7" />
<PackageReference Include="StockSharp.Algo.Compilation" />
paket add StockSharp.Algo.Compilation --version 5.0.7
#r "nuget: StockSharp.Algo.Compilation, 5.0.7"
#:package StockSharp.Algo.Compilation@5.0.7
#addin nuget:?package=StockSharp.Algo.Compilation&version=5.0.7
#tool nuget:?package=StockSharp.Algo.Compilation&version=5.0.7
StockSharp Algo.Compilation
Algo.Compilation provides runtime code compilation services for the StockSharp trading platform. It enables you to compile trading algorithms and analytics scripts written in different languages, including C#, Visual Basic, F#, and Python, directly from your application.
Features
- Multi-language support – Uses Roslyn for C# and Visual Basic, the F# compiler for F# scripts, and IronPython for Python integration.
- Dynamic script execution – Compile and execute code snippets or whole modules at runtime. This allows building strategies and analytics that can be modified without recompiling the entire application.
- Python utilities – On initialization, common Python helper scripts are extracted to
Paths.PythonUtilsPathso they can be imported from your own Python code. - Compiler registry – Registers available compilers with
ConfigManagerso that other StockSharp components can obtain the correct compiler based on file extension. - Custom type descriptors for Python objects – Allows Python classes to expose properties in .NET components such as property grids.
- Caching support – Integrates with
CompilerCacheto reuse previously built assemblies when possible.
Initialization
Before compiling any code you must call CompilationExtensions.Init once during application startup:
await CompilationExtensions.Init(logs, extraPythonCommon, cancellationToken);
logs– implementation ofILogReceiverthat collects output from the compilers and the Python engine.extraPythonCommon– optional additional Python files to copy into the utilities folder.cancellationToken– allows cancelling the initialization.
This method configures the IronPython engine, writes common Python scripts to Paths.PythonUtilsPath, and registers the compilers.
Compiling Code
The CodeInfo class represents a source file and contains helper methods to compile it. The basic workflow is:
var code = new CodeInfo
{
Name = "MyScript",
Text = sourceCode, // your script text
Language = FileExts.CSharp, // or FileExts.FSharp, FileExts.Python, ...
};
var errors = await code.CompileAsync(type => typeof(IMyInterface).IsAssignableFrom(type), null, CancellationToken.None);
if (!errors.Any())
{
var instance = Activator.CreateInstance(code.ObjectType!);
// use the compiled object
}
CodeInfo manages assembly, project, and NuGet references. It also caches compiled assemblies when the compiler supports it.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net6.0 is compatible. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. 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. |
-
net6.0
- Ecng.Compilation.FSharp (>= 1.0.75)
- Ecng.Compilation.Python (>= 1.0.84)
- Ecng.Compilation.Roslyn (>= 1.0.186)
- Ecng.Configuration (>= 1.0.206)
- IronPython.StdLib (>= 3.4.2)
- MathNet.Numerics.FSharp (>= 5.0.0)
- NumpyDotNet (>= 0.9.87.2)
- StockSharp.Configuration (>= 5.0.214)
NuGet packages (3)
Showing the top 3 NuGet packages that depend on StockSharp.Algo.Compilation:
| Package | Downloads |
|---|---|
|
StockSharp.Apps.Designer
Designer: A Free App for Creating Algorithmic Trading Strategies Without Coding |
|
|
StockSharp.Apps.Hydra
Hydra free market data downloader and database |
|
|
StockSharp.Studio.Runner
Runner - cross platform application to run any types of strategies |
GitHub repositories
This package is not used by any popular GitHub repositories.