/* * QUANTCONNECT.COM - Democratizing Finance, Empowering Individuals. * Lean Algorithmic Trading Engine v2.0. Copyright 2014 QuantConnect Corporation. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ using System; using QuantConnect.Scheduling; using System.Collections.Generic; namespace QuantConnect.Data.UniverseSelection { /// /// Defines settings required when adding a subscription /// public class UniverseSettings { /// /// The resolution to be used /// public Resolution Resolution { get; set; } /// /// The leverage to be used /// public decimal Leverage { get; set; } /// /// True to fill data forward, false otherwise /// public bool FillForward { get; set; } /// /// If configured, will be used to determine universe selection schedule and filter or skip selection data /// that does not fit the schedule /// public Schedule Schedule { get; set; } /// /// True to allow extended market hours data, false otherwise /// public bool ExtendedMarketHours { get; set; } /// /// Defines the minimum amount of time a security must be in /// the universe before being removed. /// /// When selection takes place, the actual members time in the universe /// will be rounded based on this TimeSpan, so that relative small differences do not /// cause an unexpected behavior public TimeSpan MinimumTimeInUniverse { get; set; } /// /// Defines how universe data is normalized before being send into the algorithm /// public DataNormalizationMode DataNormalizationMode { get; set; } /// /// Defines how universe data is mapped together /// /// This is particular useful when generating continuous futures public DataMappingMode DataMappingMode { get; set; } /// /// The continuous contract desired offset from the current front month. /// For example, 0 (default) will use the front month, 1 will use the back month contra /// public int ContractDepthOffset { get; set; } /// /// Allows a universe to specify which data types to add for a selected symbol /// public List> SubscriptionDataTypes { get; set; } /// /// True if universe selection can run asynchronous /// public bool? Asynchronous { get; set; } /// /// Initializes a new instance of the class /// /// The resolution /// The leverage to be used /// True to fill data forward, false otherwise /// True to allow extended market hours data, false otherwise /// Defines the minimum amount of time a security must remain in the universe before being removed /// Defines how universe data is normalized before being send into the algorithm /// The contract mapping mode to use for the security /// The continuous contract desired offset from the current front month. /// For example, 0 (default) will use the front month, 1 will use the back month contract /// True if universe selection can run asynchronous /// If provided, will be used to determine universe selection schedule public UniverseSettings(Resolution resolution, decimal leverage, bool fillForward, bool extendedMarketHours, TimeSpan minimumTimeInUniverse, DataNormalizationMode dataNormalizationMode = DataNormalizationMode.Adjusted, DataMappingMode dataMappingMode = DataMappingMode.OpenInterest, int contractDepthOffset = 0, bool? asynchronous = null, IDateRule selectionDateRule = null) { Resolution = resolution; Leverage = leverage; FillForward = fillForward; DataMappingMode = dataMappingMode; ContractDepthOffset = contractDepthOffset; ExtendedMarketHours = extendedMarketHours; MinimumTimeInUniverse = minimumTimeInUniverse; DataNormalizationMode = dataNormalizationMode; Asynchronous = asynchronous; Schedule = new Schedule(); if (selectionDateRule != null) { Schedule.On(selectionDateRule); } } /// /// Initializes a new instance of the class /// public UniverseSettings(UniverseSettings universeSettings) { Resolution = universeSettings.Resolution; Leverage = universeSettings.Leverage; FillForward = universeSettings.FillForward; DataMappingMode = universeSettings.DataMappingMode; ContractDepthOffset = universeSettings.ContractDepthOffset; ExtendedMarketHours = universeSettings.ExtendedMarketHours; MinimumTimeInUniverse = universeSettings.MinimumTimeInUniverse; DataNormalizationMode = universeSettings.DataNormalizationMode; SubscriptionDataTypes = universeSettings.SubscriptionDataTypes; Asynchronous = universeSettings.Asynchronous; Schedule = universeSettings.Schedule.Clone(); } } }