Lean  $LEAN_TAG$
UniverseSettings.cs
1 /*
2  * QUANTCONNECT.COM - Democratizing Finance, Empowering Individuals.
3  * Lean Algorithmic Trading Engine v2.0. Copyright 2014 QuantConnect Corporation.
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14 */
15 
16 using System;
17 using System.Collections.Generic;
18 
20 {
21  /// <summary>
22  /// Defines settings required when adding a subscription
23  /// </summary>
24  public class UniverseSettings
25  {
26  /// <summary>
27  /// The resolution to be used
28  /// </summary>
30 
31  /// <summary>
32  /// The leverage to be used
33  /// </summary>
34  public decimal Leverage;
35 
36  /// <summary>
37  /// True to fill data forward, false otherwise
38  /// </summary>
39  public bool FillForward;
40 
41  /// <summary>
42  /// True to allow extended market hours data, false otherwise
43  /// </summary>
44  public bool ExtendedMarketHours;
45 
46  /// <summary>
47  /// Defines the minimum amount of time a security must be in
48  /// the universe before being removed.
49  /// </summary>
50  /// <remarks>When selection takes place, the actual members time in the universe
51  /// will be rounded based on this TimeSpan, so that relative small differences do not
52  /// cause an unexpected behavior <see cref="Universe.CanRemoveMember"/></remarks>
53  public TimeSpan MinimumTimeInUniverse;
54 
55  /// <summary>
56  /// Defines how universe data is normalized before being send into the algorithm
57  /// </summary>
59 
60  /// <summary>
61  /// Defines how universe data is mapped together
62  /// </summary>
63  /// <remarks>This is particular useful when generating continuous futures</remarks>
65 
66  /// <summary>
67  /// The continuous contract desired offset from the current front month.
68  /// For example, 0 (default) will use the front month, 1 will use the back month contra
69  /// </summary>
70  public int ContractDepthOffset;
71 
72  /// <summary>
73  /// Allows a universe to specify which data types to add for a selected symbol
74  /// </summary>
75  public List<Tuple<Type, TickType>> SubscriptionDataTypes;
76 
77  /// <summary>
78  /// Initializes a new instance of the <see cref="UniverseSettings"/> class
79  /// </summary>
80  /// <param name="resolution">The resolution</param>
81  /// <param name="leverage">The leverage to be used</param>
82  /// <param name="fillForward">True to fill data forward, false otherwise</param>
83  /// <param name="extendedMarketHours">True to allow extended market hours data, false otherwise</param>
84  /// <param name="minimumTimeInUniverse">Defines the minimum amount of time a security must remain in the universe before being removed</param>
85  /// <param name="dataNormalizationMode">Defines how universe data is normalized before being send into the algorithm</param>
86  /// <param name="dataMappingMode">The contract mapping mode to use for the security</param>
87  /// <param name="contractDepthOffset">The continuous contract desired offset from the current front month.
88  /// For example, 0 (default) will use the front month, 1 will use the back month contract</param>
89  public UniverseSettings(Resolution resolution, decimal leverage, bool fillForward, bool extendedMarketHours, TimeSpan minimumTimeInUniverse, DataNormalizationMode dataNormalizationMode = DataNormalizationMode.Adjusted,
90  DataMappingMode dataMappingMode = DataMappingMode.OpenInterest, int contractDepthOffset = 0)
91  {
92  Resolution = resolution;
93  Leverage = leverage;
94  FillForward = fillForward;
95  DataMappingMode = dataMappingMode;
96  ContractDepthOffset = contractDepthOffset;
97  ExtendedMarketHours = extendedMarketHours;
98  MinimumTimeInUniverse = minimumTimeInUniverse;
99  DataNormalizationMode = dataNormalizationMode;
100  }
101 
102  /// <summary>
103  /// Initializes a new instance of the <see cref="UniverseSettings"/> class
104  /// </summary>
105  public UniverseSettings(UniverseSettings universeSettings)
106  {
107  Resolution = universeSettings.Resolution;
108  Leverage = universeSettings.Leverage;
109  FillForward = universeSettings.FillForward;
110  DataMappingMode = universeSettings.DataMappingMode;
111  ContractDepthOffset = universeSettings.ContractDepthOffset;
112  ExtendedMarketHours = universeSettings.ExtendedMarketHours;
113  MinimumTimeInUniverse = universeSettings.MinimumTimeInUniverse;
114  DataNormalizationMode = universeSettings.DataNormalizationMode;
115  SubscriptionDataTypes = universeSettings.SubscriptionDataTypes;
116  }
117  }
118 }