From 1c04484733201fafa92cd4c186eaa36416267f2a Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Ricardo=20Andr=C3=A9s=20Marino=20Rojas?=
<47573394+Marinovsky@users.noreply.github.com>
Date: Mon, 23 Dec 2024 13:57:38 -0500
Subject: [PATCH] Address requested changes
---
.../IndexSecurityIsNotTradableRegressionAlgorithm.cs | 2 +-
Common/Extensions.cs | 9 +++++----
Common/Securities/Index/Index.cs | 5 +++++
Common/Securities/Security.cs | 5 -----
4 files changed, 11 insertions(+), 10 deletions(-)
diff --git a/Algorithm.CSharp/IndexSecurityIsNotTradableRegressionAlgorithm.cs b/Algorithm.CSharp/IndexSecurityIsNotTradableRegressionAlgorithm.cs
index c88aeabd6e01..29a5ed16d397 100644
--- a/Algorithm.CSharp/IndexSecurityIsNotTradableRegressionAlgorithm.cs
+++ b/Algorithm.CSharp/IndexSecurityIsNotTradableRegressionAlgorithm.cs
@@ -22,6 +22,6 @@ namespace QuantConnect.Algorithm.CSharp
///
public class IndexSecurityIsNotTradableRegressionAlgorithm: IndexSecurityCanBeTradableRegressionAlgorithm
{
- public override bool IsTradable { get; set; } = false;
+ public override bool IsTradable { get; set; }
}
}
diff --git a/Common/Extensions.cs b/Common/Extensions.cs
index b0ac20e5e512..15c7c7961421 100644
--- a/Common/Extensions.cs
+++ b/Common/Extensions.cs
@@ -3824,14 +3824,15 @@ public static void ProcessSecurityChanges(this IAlgorithm algorithm, SecurityCha
{
foreach (var security in securityChanges.AddedSecurities)
{
- if (security.Type == SecurityType.Index && !security.ManualSetIsTradable)
+ // uses TryAdd, so don't need to worry about duplicates here
+ algorithm.Securities.Add(security);
+
+ if (security.Type == SecurityType.Index && !(security as Securities.Index.Index).ManualSetIsTradable)
{
continue;
}
- security.IsTradable = true;
- // uses TryAdd, so don't need to worry about duplicates here
- algorithm.Securities.Add(security);
+ security.IsTradable = true;
}
var activeSecurities = algorithm.UniverseManager.ActiveSecurities;
diff --git a/Common/Securities/Index/Index.cs b/Common/Securities/Index/Index.cs
index da194d43fe86..d00d354e3512 100644
--- a/Common/Securities/Index/Index.cs
+++ b/Common/Securities/Index/Index.cs
@@ -40,6 +40,11 @@ public override bool IsTradable {
}
}
+ ///
+ /// Field to check if the user has manually set IsTradable field to true
+ ///
+ internal bool ManualSetIsTradable { get; set; }
+
///
/// Constructor for the INDEX security
///
diff --git a/Common/Securities/Security.cs b/Common/Securities/Security.cs
index 47b55f4b53c2..7a9e025dd218 100644
--- a/Common/Securities/Security.cs
+++ b/Common/Securities/Security.cs
@@ -55,11 +55,6 @@ public class Security : DynamicObject, ISecurityPrice
/// Just use a list + lock, not concurrent bag, avoid garbage it creates for features we don't need here. See https://github.com/dotnet/runtime/issues/23103
private readonly List _subscriptionsBag;
- ///
- /// Field to check if the user has manually set IsTradable field to true
- ///
- internal bool ManualSetIsTradable { get; set; }
-
///
/// This securities
///