| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Name | Name | Last commit date | ||
|---|---|---|---|---|
parent directory.. | ||||
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.
Before compiling any code you must call CompilationExtensions.Init once during application startup:
await CompilationExtensions.Init(logs, extraPythonCommon, cancellationToken);This method configures the IronPython engine, writes common Python scripts to Paths.PythonUtilsPath, and registers the compilers.
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.
| Back | FazBrowse Home | New Git URL |