QuantConnect.pythonnet 2.0.65

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.PythonDLL property or PYTHONNET_PYDLL environment variable, otherwise you will receive BadPythonDllException (internal, derived from MissingMethodException) upon calling Initialize. Typical values are python38.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, eg mod.func(args). You can also access Python objects via PyObject and dervied types instead of using dynamic.
  • Use mod.func(args, Py.kw("keywordargname", keywordargvalue)) or mod.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 * 2 works, 2 * np.pi doesn'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.

Showing the top 20 packages that depend on QuantConnect.pythonnet.

Packages Downloads
QuantConnect.Common
QuantConnect LEAN Engine: Common Project - A collection of common definitions and utils
39
QuantConnect.Brokerages
Lean Engine is an open-source, platform agnostic C# and Python algorithmic trading engine. Allows strategy research, backtesting and live trading with Equities, FX, CFD, Crypto, Options and Futures Markets.
39
QuantConnect.Common
QuantConnect LEAN Engine: Common Project - A collection of common definitions and utils
38
QuantConnect.Messaging
Lean Engine is an open-source, plataform agnostic C# and Python algorithmic trading engine. Allows strategy research, backtesting and live trading with Equities, FX, CFD, Crypto, Options and Futures Markets.
38
QuantConnect.Algorithm.CSharp
QuantConnect LEAN Engine: Algorithm.CSharp Project - A collection of C# algorithm demonstrations for how to use the API
38
QuantConnect.ToolBox
QuantConnect LEAN Engine: ToolBox Project - A collection of data downloaders and converters
37
QuantConnect.Algorithm.CSharp
QuantConnect LEAN Engine: Algorithm.CSharp Project - A collection of C# algorithm demonstrations for how to use the API
37
QuantConnect.Algorithm.Framework
Lean Engine is an open-source, plataform agnostic C# and Python algorithmic trading engine. Allows strategy research, backtesting and live trading with Equities, FX, CFD, Crypto, Options and Futures Markets.
37
QuantConnect.Common
QuantConnect LEAN Engine: Common Project - A collection of common definitions and utils
36
QuantConnect.ToolBox
QuantConnect LEAN Engine: ToolBox Project - A collection of data downloaders and converters
36
QuantConnect.Research
QuantConnect LEAN Engine: Research Project - Core implementation for jupyter research environment
36

.NET 10.0

Version Downloads Last updated
2.0.65 13 08/13/2026
2.0.64 14 07/18/2026
2.0.63 12 07/15/2026
2.0.62 10 07/15/2026
2.0.61 11 07/13/2026
2.0.60 11 07/13/2026
2.0.59 11 07/15/2026
2.0.58 11 07/10/2026
2.0.57 14 07/09/2026
2.0.56 14 07/02/2026
2.0.55 14 07/02/2026
2.0.54 25 05/10/2026
2.0.53 41 04/13/2026
2.0.52 34 04/13/2026
2.0.51 40 04/13/2026
2.0.50 37 04/13/2026
2.0.49 33 04/13/2026
2.0.48 32 04/13/2026
2.0.47 35 04/13/2026
2.0.46 31 04/13/2026
2.0.45 36 04/13/2026
2.0.44 35 04/13/2026
2.0.43 32 04/13/2026
2.0.42 39 04/13/2026
2.0.41 33 04/13/2026
2.0.40 34 04/13/2026
2.0.39 36 04/13/2026
2.0.38 42 04/13/2026
2.0.37 32 04/13/2026
2.0.36 35 04/13/2026
2.0.35 34 04/13/2026
2.0.34 40 04/13/2026
2.0.33 34 04/13/2026
2.0.32 32 04/13/2026
2.0.31 23 04/13/2026
2.0.30 37 04/13/2026
2.0.29 36 04/13/2026
2.0.28 39 04/13/2026
2.0.27 35 04/13/2026
2.0.26 34 04/13/2026
2.0.25 35 04/13/2026
2.0.24 35 04/13/2026
2.0.23 39 04/13/2026
2.0.22 36 04/13/2026
2.0.21 33 04/13/2026
2.0.20 34 04/13/2026
2.0.19 33 04/13/2026
2.0.18 35 04/13/2026
2.0.17 32 04/13/2026
2.0.16 38 04/13/2026
2.0.15 38 04/13/2026
2.0.14 38 04/13/2026
2.0.13 34 04/13/2026
2.0.12 35 04/13/2026
2.0.11 33 04/13/2026
2.0.10 29 04/13/2026
2.0.9 34 04/13/2026
2.0.8 36 04/13/2026
2.0.7 37 04/13/2026
2.0.6 38 04/13/2026
2.0.5 34 04/13/2026
2.0.4 35 04/13/2026
2.0.3 33 04/13/2026
2.0.2 37 04/13/2026
2.0.1 35 04/13/2026
2.0.0 32 04/13/2026
1.0.5.30 39 04/13/2026
1.0.5.29 36 04/13/2026
1.0.5.28 37 04/13/2026
1.0.5.27 34 04/13/2026
1.0.5.26 38 04/13/2026
1.0.5.25 44 04/13/2026
1.0.5.24 33 04/13/2026
1.0.5.23 41 04/13/2026
1.0.5.22 35 04/13/2026
1.0.5.21 39 04/13/2026
1.0.5.20 36 04/13/2026
1.0.5.19 36 04/13/2026
1.0.5.18 33 04/13/2026
1.0.5.17 30 04/13/2026
1.0.5.16 34 04/13/2026
1.0.5.15 33 04/13/2026
1.0.5.14 37 04/13/2026
1.0.5.13 30 04/13/2026
1.0.5.12 37 04/13/2026
1.0.5.11 34 04/13/2026
1.0.5.10 34 04/13/2026
1.0.5.9 35 04/13/2026
1.0.5.8 33 04/13/2026
1.0.5.7 36 04/13/2026
1.0.5.6 40 04/13/2026
1.0.5.5 42 04/13/2026
1.0.5.4 33 04/13/2026
1.0.5.3 38 04/13/2026
1.0.5.2 39 04/13/2026
1.0.5.1 38 04/13/2026
1.0.5 37 04/13/2026
1.0.4.8 32 04/13/2026
1.0.4.7 33 04/13/2026
1.0.4.6 40 04/13/2026
1.0.4.5 38 04/13/2026
1.0.4.4 37 04/13/2026
1.0.4.3 36 04/13/2026
1.0.4.2 37 04/13/2026
1.0.4.1 36 04/13/2026
1.0.4 35 04/13/2026
1.0.3.5 34 04/13/2026
1.0.3.4 36 04/13/2026
1.0.3.3 29 04/13/2026
1.0.3.2 38 04/13/2026
1.0.3.1 38 04/13/2026
1.0.3 26 04/13/2026
1.0.2.1 32 04/13/2026
1.0.2 36 04/13/2026
1.0.1.1 36 04/13/2026
1.0.0 33 04/13/2026