From 1d99381ebc76bff276b36952e6c84ed45c51a81b Mon Sep 17 00:00:00 2001 From: Jhonathan Abreu Date: Wed, 28 Oct 2026 09:39:55 -0400 Subject: [PATCH 1/3] Update QuantConnect.pythonnet to 2.0.68 --- Algorithm.CSharp/QuantConnect.Algorithm.CSharp.csproj | 2 +- Algorithm.Framework/QuantConnect.Algorithm.Framework.csproj | 2 +- Algorithm.Python/QuantConnect.Algorithm.Python.csproj | 2 +- Algorithm/QuantConnect.Algorithm.csproj | 2 +- AlgorithmFactory/QuantConnect.AlgorithmFactory.csproj | 2 +- Common/QuantConnect.csproj | 2 +- Engine/QuantConnect.Lean.Engine.csproj | 2 +- Indicators/QuantConnect.Indicators.csproj | 2 +- Report/QuantConnect.Report.csproj | 2 +- Research/QuantConnect.Research.csproj | 2 +- Tests/QuantConnect.Tests.csproj | 2 +- 11 files changed, 11 insertions(+), 11 deletions(-) diff --git a/Algorithm.CSharp/QuantConnect.Algorithm.CSharp.csproj b/Algorithm.CSharp/QuantConnect.Algorithm.CSharp.csproj index cac852bd079e..aebf5ddd47dc 100644 --- a/Algorithm.CSharp/QuantConnect.Algorithm.CSharp.csproj +++ b/Algorithm.CSharp/QuantConnect.Algorithm.CSharp.csproj @@ -32,7 +32,7 @@ portable - + diff --git a/Algorithm.Framework/QuantConnect.Algorithm.Framework.csproj b/Algorithm.Framework/QuantConnect.Algorithm.Framework.csproj index 3fcf6c80ee5c..99be62ffb86f 100644 --- a/Algorithm.Framework/QuantConnect.Algorithm.Framework.csproj +++ b/Algorithm.Framework/QuantConnect.Algorithm.Framework.csproj @@ -29,7 +29,7 @@ LICENSE - + diff --git a/Algorithm.Python/QuantConnect.Algorithm.Python.csproj b/Algorithm.Python/QuantConnect.Algorithm.Python.csproj index b06316b8e7ad..0bb084e3041c 100644 --- a/Algorithm.Python/QuantConnect.Algorithm.Python.csproj +++ b/Algorithm.Python/QuantConnect.Algorithm.Python.csproj @@ -37,7 +37,7 @@ - + diff --git a/Algorithm/QuantConnect.Algorithm.csproj b/Algorithm/QuantConnect.Algorithm.csproj index 6c7748030b82..75e712f0b6b8 100644 --- a/Algorithm/QuantConnect.Algorithm.csproj +++ b/Algorithm/QuantConnect.Algorithm.csproj @@ -29,7 +29,7 @@ LICENSE - + diff --git a/AlgorithmFactory/QuantConnect.AlgorithmFactory.csproj b/AlgorithmFactory/QuantConnect.AlgorithmFactory.csproj index 081e7e22d804..e2f21d66c2df 100644 --- a/AlgorithmFactory/QuantConnect.AlgorithmFactory.csproj +++ b/AlgorithmFactory/QuantConnect.AlgorithmFactory.csproj @@ -28,7 +28,7 @@ LICENSE - + diff --git a/Common/QuantConnect.csproj b/Common/QuantConnect.csproj index f6d1c4c74b26..f29feb7ea2ce 100644 --- a/Common/QuantConnect.csproj +++ b/Common/QuantConnect.csproj @@ -35,7 +35,7 @@ - + diff --git a/Engine/QuantConnect.Lean.Engine.csproj b/Engine/QuantConnect.Lean.Engine.csproj index f65d6f495783..e64a0c902d14 100644 --- a/Engine/QuantConnect.Lean.Engine.csproj +++ b/Engine/QuantConnect.Lean.Engine.csproj @@ -41,7 +41,7 @@ - + diff --git a/Indicators/QuantConnect.Indicators.csproj b/Indicators/QuantConnect.Indicators.csproj index 7e15053f87ba..94ef4a475dc7 100644 --- a/Indicators/QuantConnect.Indicators.csproj +++ b/Indicators/QuantConnect.Indicators.csproj @@ -31,7 +31,7 @@ - + diff --git a/Report/QuantConnect.Report.csproj b/Report/QuantConnect.Report.csproj index 41ca39388e20..085b6dae058a 100644 --- a/Report/QuantConnect.Report.csproj +++ b/Report/QuantConnect.Report.csproj @@ -39,7 +39,7 @@ LICENSE - + diff --git a/Research/QuantConnect.Research.csproj b/Research/QuantConnect.Research.csproj index 19c1c205eb8b..2670c657d71e 100644 --- a/Research/QuantConnect.Research.csproj +++ b/Research/QuantConnect.Research.csproj @@ -34,7 +34,7 @@ - + diff --git a/Tests/QuantConnect.Tests.csproj b/Tests/QuantConnect.Tests.csproj index 30dab6a1cacc..768d8a776a5f 100644 --- a/Tests/QuantConnect.Tests.csproj +++ b/Tests/QuantConnect.Tests.csproj @@ -31,7 +31,7 @@ - + From 1f4a7bf16e7aa86c8ff0ee57cc9f0d3130d8b5a2 Mon Sep 17 00:00:00 2001 From: Jhonathan Abreu Date: Wed, 28 Oct 2026 09:58:37 -0400 Subject: [PATCH 2/3] Test extension methods and numeric operators from Python --- Tests/Common/Orders/Fees/OrderFeesTests.cs | 33 ++++++++++++++++++++++ Tests/Common/Orders/OrderEventTests.cs | 30 ++++++++++++++++++++ 2 files changed, 63 insertions(+) diff --git a/Tests/Common/Orders/Fees/OrderFeesTests.cs b/Tests/Common/Orders/Fees/OrderFeesTests.cs index d81f10cc69a6..a0babded5bdb 100644 --- a/Tests/Common/Orders/Fees/OrderFeesTests.cs +++ b/Tests/Common/Orders/Fees/OrderFeesTests.cs @@ -14,7 +14,10 @@ * */ +using System; using NUnit.Framework; +using Python.Runtime; +using QuantConnect.Orders; using QuantConnect.Orders.Fees; using QuantConnect.Securities; @@ -44,5 +47,35 @@ public void OrderFeeZeroCanBeConvertedToAccountCurrency() Assert.AreEqual(0, result3); } + + [Test] + public void OrderFeeIsNumericFromPython() + { + var fee = new OrderFee(new CashAmount(2m, Currencies.USD)); + var order = new MarketOrder(Symbols.BTCUSD, 0.123m, DateTime.UtcNow); + var orderEvent = new OrderEvent(order, DateTime.UtcNow, new OrderFee(new CashAmount(3m, Currencies.USD))); + + using (Py.GIL()) + { + var module = PyModule.FromString("testModule", + @" +from AlgorithmImports import * + +def check(fee: OrderFee, order_event: OrderEvent): + fees = [fee, order_event.order_fee] + return sum(fees), fee + order_event.order_fee, fee > 0, fee < order_event.order_fee, float(order_event.order_fee), max(fees).value.amount +"); + + dynamic check = module.GetAttr("check"); + var result = check(fee, orderEvent); + + Assert.AreEqual(5.0, (double)result[0]); + Assert.AreEqual(5.0, (double)result[1]); + Assert.IsTrue((bool)result[2]); + Assert.IsTrue((bool)result[3]); + Assert.AreEqual(3.0, (double)result[4]); + Assert.AreEqual(3m, (decimal)result[5]); + } + } } } diff --git a/Tests/Common/Orders/OrderEventTests.cs b/Tests/Common/Orders/OrderEventTests.cs index 170c6bf3081c..b0ec564f98e0 100644 --- a/Tests/Common/Orders/OrderEventTests.cs +++ b/Tests/Common/Orders/OrderEventTests.cs @@ -16,6 +16,7 @@ using System; using Newtonsoft.Json; using NUnit.Framework; +using Python.Runtime; using QuantConnect.Orders; using QuantConnect.Orders.Fees; using QuantConnect.Orders.Serialization; @@ -169,5 +170,34 @@ public void BackwardsCompatibleDeserialization() Assert.AreEqual(orderEvent.OrderFee.Value.Amount, deserializeObject.OrderFee.Value.Amount); Assert.AreEqual(orderEvent.OrderFee.Value.Currency, deserializeObject.OrderFee.Value.Currency); } + + [Test] + public void EnumExtensionMethodsAreCallableFromPython() + { + var order = new LimitOrder(Symbols.BTCUSD, 0.123m, 100m, DateTime.UtcNow); + var orderEvent = new OrderEvent(order, DateTime.UtcNow, OrderFee.Zero) { Status = OrderStatus.Submitted }; + + using (Py.GIL()) + { + var module = PyModule.FromString("testModule", + @" +from AlgorithmImports import * + +def check(order_event: OrderEvent, order: Order): + return (order_event.status.is_open(), order_event.status.is_closed(), order_event.status.IsFill(), + order.type.is_limit_order(), order.type.is_stop_order(), Resolution.MINUTE.to_time_span() == timedelta(minutes=1)) +"); + + dynamic check = module.GetAttr("check"); + var result = check(orderEvent, order); + + Assert.IsTrue((bool)result[0]); + Assert.IsFalse((bool)result[1]); + Assert.IsFalse((bool)result[2]); + Assert.IsTrue((bool)result[3]); + Assert.IsFalse((bool)result[4]); + Assert.IsTrue((bool)result[5]); + } + } } } From 57b4eaa3eef3248919adc9e3871469127ec0d8f1 Mon Sep 17 00:00:00 2001 From: Jhonathan Abreu Date: Wed, 28 Oct 2026 11:40:48 -0400 Subject: [PATCH 3/3] Update QuantConnect.pythonnet to 2.0.67, the version #150 and #151 ship with --- Algorithm.CSharp/QuantConnect.Algorithm.CSharp.csproj | 2 +- Algorithm.Framework/QuantConnect.Algorithm.Framework.csproj | 2 +- Algorithm.Python/QuantConnect.Algorithm.Python.csproj | 2 +- Algorithm/QuantConnect.Algorithm.csproj | 2 +- AlgorithmFactory/QuantConnect.AlgorithmFactory.csproj | 2 +- Common/QuantConnect.csproj | 2 +- Engine/QuantConnect.Lean.Engine.csproj | 2 +- Indicators/QuantConnect.Indicators.csproj | 2 +- Report/QuantConnect.Report.csproj | 2 +- Research/QuantConnect.Research.csproj | 2 +- Tests/QuantConnect.Tests.csproj | 2 +- 11 files changed, 11 insertions(+), 11 deletions(-) diff --git a/Algorithm.CSharp/QuantConnect.Algorithm.CSharp.csproj b/Algorithm.CSharp/QuantConnect.Algorithm.CSharp.csproj index aebf5ddd47dc..1c7346939192 100644 --- a/Algorithm.CSharp/QuantConnect.Algorithm.CSharp.csproj +++ b/Algorithm.CSharp/QuantConnect.Algorithm.CSharp.csproj @@ -32,7 +32,7 @@ portable - + diff --git a/Algorithm.Framework/QuantConnect.Algorithm.Framework.csproj b/Algorithm.Framework/QuantConnect.Algorithm.Framework.csproj index 99be62ffb86f..6476a175bd97 100644 --- a/Algorithm.Framework/QuantConnect.Algorithm.Framework.csproj +++ b/Algorithm.Framework/QuantConnect.Algorithm.Framework.csproj @@ -29,7 +29,7 @@ LICENSE - + diff --git a/Algorithm.Python/QuantConnect.Algorithm.Python.csproj b/Algorithm.Python/QuantConnect.Algorithm.Python.csproj index 0bb084e3041c..6483f6f99704 100644 --- a/Algorithm.Python/QuantConnect.Algorithm.Python.csproj +++ b/Algorithm.Python/QuantConnect.Algorithm.Python.csproj @@ -37,7 +37,7 @@ - + diff --git a/Algorithm/QuantConnect.Algorithm.csproj b/Algorithm/QuantConnect.Algorithm.csproj index 75e712f0b6b8..46aff6715ddf 100644 --- a/Algorithm/QuantConnect.Algorithm.csproj +++ b/Algorithm/QuantConnect.Algorithm.csproj @@ -29,7 +29,7 @@ LICENSE - + diff --git a/AlgorithmFactory/QuantConnect.AlgorithmFactory.csproj b/AlgorithmFactory/QuantConnect.AlgorithmFactory.csproj index e2f21d66c2df..4aeb20cc51aa 100644 --- a/AlgorithmFactory/QuantConnect.AlgorithmFactory.csproj +++ b/AlgorithmFactory/QuantConnect.AlgorithmFactory.csproj @@ -28,7 +28,7 @@ LICENSE - + diff --git a/Common/QuantConnect.csproj b/Common/QuantConnect.csproj index f29feb7ea2ce..c36e7fc807c8 100644 --- a/Common/QuantConnect.csproj +++ b/Common/QuantConnect.csproj @@ -35,7 +35,7 @@ - + diff --git a/Engine/QuantConnect.Lean.Engine.csproj b/Engine/QuantConnect.Lean.Engine.csproj index e64a0c902d14..53f0cb795082 100644 --- a/Engine/QuantConnect.Lean.Engine.csproj +++ b/Engine/QuantConnect.Lean.Engine.csproj @@ -41,7 +41,7 @@ - + diff --git a/Indicators/QuantConnect.Indicators.csproj b/Indicators/QuantConnect.Indicators.csproj index 94ef4a475dc7..c902ba9def89 100644 --- a/Indicators/QuantConnect.Indicators.csproj +++ b/Indicators/QuantConnect.Indicators.csproj @@ -31,7 +31,7 @@ - + diff --git a/Report/QuantConnect.Report.csproj b/Report/QuantConnect.Report.csproj index 085b6dae058a..af1b1a04ddea 100644 --- a/Report/QuantConnect.Report.csproj +++ b/Report/QuantConnect.Report.csproj @@ -39,7 +39,7 @@ LICENSE - + diff --git a/Research/QuantConnect.Research.csproj b/Research/QuantConnect.Research.csproj index 2670c657d71e..ec3bb5e5de79 100644 --- a/Research/QuantConnect.Research.csproj +++ b/Research/QuantConnect.Research.csproj @@ -34,7 +34,7 @@ - + diff --git a/Tests/QuantConnect.Tests.csproj b/Tests/QuantConnect.Tests.csproj index 768d8a776a5f..93888c6688d5 100644 --- a/Tests/QuantConnect.Tests.csproj +++ b/Tests/QuantConnect.Tests.csproj @@ -31,7 +31,7 @@ - +