QuantConnect.pythonnet 2.0.35

Prefix Reserved
There is a newer version of this package available.
See the version list below for details.
dotnet add package QuantConnect.pythonnet --version 2.0.35                
NuGet\Install-Package QuantConnect.pythonnet -Version 2.0.35                
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="QuantConnect.pythonnet" Version="2.0.35" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add QuantConnect.pythonnet --version 2.0.35                
#r "nuget: QuantConnect.pythonnet, 2.0.35"                
#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.
// Install QuantConnect.pythonnet as a Cake Addin
#addin nuget:?package=QuantConnect.pythonnet&version=2.0.35

// Install QuantConnect.pythonnet as a Cake Tool
#tool nuget:?package=QuantConnect.pythonnet&version=2.0.35                

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.

Product 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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

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 (1)

Showing the top 1 popular GitHub repositories that depend on QuantConnect.pythonnet:

Repository Stars
QuantConnect/Lean
Lean Algorithmic Trading Engine by QuantConnect (Python, C#)
Version Downloads Last updated
2.0.40 593 11/1/2024
2.0.39 6,603 9/27/2024
2.0.38 29,344 5/24/2024
2.0.37 3,063 5/14/2024
2.0.36 4,496 4/23/2024
2.0.35 2,998 4/19/2024
2.0.34 12,576 4/17/2024
2.0.33 173 4/16/2024
2.0.32 1,504 4/15/2024
2.0.31 465 4/12/2024
2.0.30 201 4/11/2024
2.0.29 4,807 3/18/2024
2.0.28 7,053 3/5/2024
2.0.27 170 3/4/2024
2.0.26 32,543 12/8/2023
2.0.25 5,714 11/21/2023
2.0.24 7,987 10/27/2023
2.0.23 2,296 10/19/2023
2.0.22 749 10/12/2023
2.0.21 48,753 7/11/2023
2.0.20 5,436 6/26/2023
2.0.19 206 6/26/2023
2.0.18 83,950 3/3/2023
2.0.17 121,655 8/24/2022
2.0.16 20,950 6/27/2022
2.0.15 25,249 5/17/2022
2.0.14 5,235 5/6/2022
2.0.13 4,656 5/2/2022
2.0.12 5,816 4/28/2022
2.0.11 77,452 12/27/2021
2.0.10 30,794 10/22/2021
2.0.9 436 10/21/2021
2.0.8 5,210 10/13/2021
2.0.7 700 10/8/2021
2.0.6 16,092 8/26/2021
2.0.5 20,201 7/14/2021
2.0.4 33,545 6/11/2021
2.0.3 2,168 6/8/2021
2.0.2 8,278 5/28/2021
2.0.1 21,152 3/13/2021
2.0.0 959 3/9/2021
1.0.5.30 221,834 3/31/2020
1.0.5.29 44,299 11/13/2019
1.0.5.28 626 11/12/2019
1.0.5.27 584 11/12/2019
1.0.5.26 8,900 10/15/2019
1.0.5.25 5,499 9/23/2019
1.0.5.24 5,943 9/10/2019
1.0.5.23 717 9/5/2019
1.0.5.22 630 9/5/2019
1.0.5.21 827 6/24/2019
1.0.5.20 41,238 4/23/2019
1.0.5.19 5,024 4/2/2019
1.0.5.18 843 3/27/2019
1.0.5.17 12,155 2/21/2019
1.0.5.16 711 2/20/2019
1.0.5.15 9,174 1/22/2019
1.0.5.14 851 1/18/2019
1.0.5.13 829 1/15/2019
1.0.5.12 10,532 8/27/2018
1.0.5.11 855 8/27/2018
1.0.5.10 888 8/24/2018
1.0.5.9 1,074 7/23/2018
1.0.5.8 38,738 7/16/2018
1.0.5.7 287,647 4/2/2018
1.0.5.6 1,082 4/2/2018
1.0.5.5 2,679 2/2/2018
1.0.5.4 2,381 12/29/2017
1.0.5.3 1,073 12/29/2017
1.0.5.2 1,455 11/29/2017
1.0.5.1 3,028 10/9/2017
1.0.5 1,196 9/29/2017
1.0.4.8 1,347 9/12/2017
1.0.4.7 963 9/8/2017
1.0.4.6 977 9/4/2017
1.0.4.5 985 8/21/2017
1.0.4.4 2,585 6/23/2017
1.0.4.3 1,049 6/23/2017
1.0.4.2 1,004 6/22/2017
1.0.4.1 988 6/22/2017
1.0.4 1,076 6/15/2017
1.0.3.5 1,456 6/1/2017
1.0.3.4 986 6/1/2017
1.0.3.3 987 6/1/2017
1.0.3.2 977 5/31/2017
1.0.3.1 1,018 5/31/2017
1.0.3 993 5/31/2017
1.0.2.1 1,122 5/25/2017
1.0.2 1,047 5/23/2017
1.0.1.1 1,885 4/11/2017
1.0.0 1,086 1/12/2017