QuantConnect.pythonnet
2.0.52
Prefix Reserved
dotnet add package QuantConnect.pythonnet --version 2.0.52
NuGet\Install-Package QuantConnect.pythonnet -Version 2.0.52
<PackageReference Include="QuantConnect.pythonnet" Version="2.0.52" />
<PackageVersion Include="QuantConnect.pythonnet" Version="2.0.52" />
<PackageReference Include="QuantConnect.pythonnet" />
paket add QuantConnect.pythonnet --version 2.0.52
#r "nuget: QuantConnect.pythonnet, 2.0.52"
#:package QuantConnect.pythonnet@2.0.52
#addin nuget:?package=QuantConnect.pythonnet&version=2.0.52
#tool nuget:?package=QuantConnect.pythonnet&version=2.0.52
pythonnet is a package that gives .NET programmers ability to
integrate Python engine and use Python libraries.
Embedding Python in .NET
- You must set
Runtime.PythonDLLproperty orPYTHONNET_PYDLLenvironment variable, otherwise you will receiveBadPythonDllException(internal, derived fromMissingMethodException) upon callingInitialize. Typical values arepython38.dll(Windows),libpython3.8.dylib(Mac),libpython3.8.so(most other *nix). Full path may be required. - All calls to Python should be inside a
using (Py.GIL()) {/* Your code here */}block. - Import python modules using
dynamic mod = Py.Import("mod"), then you can call functions as normal, egmod.func(args). You can also access Python objects viaPyObjectand dervied types instead of usingdynamic. - Use
mod.func(args, Py.kw("keywordargname", keywordargvalue))ormod.func(args, keywordargname: keywordargvalue)to apply keyword arguments. - Mathematical operations involving python and literal/managed types
must have the python object first, eg.
np.pi * 2works,2 * np.pidoesn't.
Example
using var _ = Py.GIL();
dynamic np = Py.Import("numpy");
Console.WriteLine(np.cos(np.pi * 2));
dynamic sin = np.sin;
Console.WriteLine(sin(5));
double c = (double)(np.cos(5) + sin(5));
Console.WriteLine(c);
dynamic a = np.array(new List<float> { 1, 2, 3 });
Console.WriteLine(a.dtype);
dynamic b = np.array(new List<float> { 6, 5, 4 }, dtype: np.int32);
Console.WriteLine(b.dtype);
Console.WriteLine(a * b);
Console.ReadKey();
Output:
1.0
-0.958924274663
-0.6752620892
float64
int32
[ 6. 10. 12.]
Resources
Information on installation, FAQ, troubleshooting, debugging, and projects using pythonnet can be found in the Wiki:
https://github.com/pythonnet/pythonnet/wiki
Mailing list https://mail.python.org/mailman/listinfo/pythondotnet Chat https://gitter.im/pythonnet/pythonnet
.NET Foundation
This project is supported by the .NET Foundation.
| 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. |
-
net10.0
- fasterflect (>= 3.0.0)
NuGet packages (26)
Showing the top 5 NuGet packages that depend on QuantConnect.pythonnet:
| Package | Downloads |
|---|---|
|
QuantConnect.Common
QuantConnect LEAN Engine: Common Project - A collection of common definitions and utils |
|
|
QuantConnect.Indicators
QuantConnect LEAN Engine: Indicators Project - A collection of financial indicators |
|
|
QuantConnect.Algorithm
QuantConnect LEAN Engine: Algorithm Project - Core QCAlgorithm implementation |
|
|
QuantConnect.Algorithm.Framework
QuantConnect LEAN Engine: Algorithm.Framework Project - The core QCAlgorithm framework implementation |
|
|
QuantConnect.Lean.Engine
QuantConnect LEAN Engine: Engine Project - Core engine and datafeed implementation |
GitHub repositories (2)
Showing the top 2 popular GitHub repositories that depend on QuantConnect.pythonnet:
| Repository | Stars |
|---|---|
|
QuantConnect/Lean
Lean Algorithmic Trading Engine by QuantConnect (Python, C#)
|
|
|
Capnode/Algoloop
Windows desktop algo trading with QuantConnect Lean engine.
|
| Version | Downloads | Last Updated |
|---|---|---|
| 2.0.52 | 14,017 | 12/29/2025 |
| 2.0.51 | 1,181 | 12/26/2025 |
| 2.0.50 | 23,621 | 10/31/2025 |
| 2.0.49 | 3,934 | 10/21/2025 |
| 2.0.48 | 19,298 | 8/15/2025 |
| 2.0.47 | 535 | 8/14/2025 |
| 2.0.46 | 3,316 | 8/6/2025 |
| 2.0.45 | 746 | 7/31/2025 |
| 2.0.44 | 19,670 | 5/2/2025 |
| 2.0.43 | 263 | 5/1/2025 |
| 2.0.42 | 43,235 | 12/20/2024 |
| 2.0.41 | 6,532 | 12/3/2024 |
| 2.0.40 | 2,040 | 11/1/2024 |
| 2.0.39 | 11,609 | 9/27/2024 |
| 2.0.38 | 52,241 | 5/24/2024 |
| 2.0.37 | 4,154 | 5/14/2024 |
| 2.0.36 | 6,008 | 4/23/2024 |
| 2.0.35 | 6,441 | 4/19/2024 |
| 2.0.34 | 18,645 | 4/17/2024 |
| 2.0.33 | 288 | 4/16/2024 |