Make Future universe selection file-based like option universe

This commit is contained in:
Jhonathan Abreu
2024-12-17 18:00:00 -04:00
parent 5c25512f7b
commit 1da709441f
322 changed files with 3634 additions and 140 deletions
@@ -12,6 +12,7 @@
# limitations under the License.
from AlgorithmImports import *
import QuantConnect.Data.UniverseSelection
### <summary>
### This example demonstrates how to add futures with daily resolution.
@@ -54,6 +55,12 @@ class BasicTemplateFuturesDailyAlgorithm(QCAlgorithm):
elif all(x.exchange.hours.is_open(self.time, True) for x in self.securities.values() if x.invested):
self.liquidate()
def on_securities_changed(self, changes: SecurityChanges) -> None:
if len(changes.removed_securities) > 0 and \
self.portfolio.invested and \
all(x.exchange.hours.is_open(self.time, True) for x in self.securities.values() if x.invested):
self.liquidate()
def get_resolution(self):
return Resolution.DAILY