Lean  $LEAN_TAG$
TimeSlice.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 
17 using System;
18 using System.Collections.Generic;
19 using QuantConnect.Data;
22 
24 {
25  /// <summary>
26  /// Represents a grouping of data emitted at a certain time.
27  /// </summary>
28  public class TimeSlice
29  {
30  /// <summary>
31  /// Gets the count of data points in this <see cref="TimeSlice"/>
32  /// </summary>
33  public int DataPointCount { get; }
34 
35  /// <summary>
36  /// Gets the UTC time this data was emitted
37  /// </summary>
38  public DateTime Time { get; }
39 
40  /// <summary>
41  /// Gets the data in the time slice
42  /// </summary>
43  public List<DataFeedPacket> Data { get; }
44 
45  /// <summary>
46  /// Gets the <see cref="Slice"/> that will be used as input for the algorithm
47  /// </summary>
48  public Slice Slice { get; }
49 
50  /// <summary>
51  /// Gets the data used to update securities
52  /// </summary>
53  public List<UpdateData<ISecurityPrice>> SecuritiesUpdateData { get; }
54 
55  /// <summary>
56  /// Gets the data used to update the consolidators
57  /// </summary>
58  public List<UpdateData<SubscriptionDataConfig>> ConsolidatorUpdateData { get; }
59 
60  /// <summary>
61  /// Gets all the custom data in this <see cref="TimeSlice"/>
62  /// </summary>
63  public List<UpdateData<ISecurityPrice>> CustomData { get; }
64 
65  /// <summary>
66  /// Gets the changes to the data subscriptions as a result of universe selection
67  /// </summary>
69 
70  /// <summary>
71  /// Gets the universe data generated this time step.
72  /// </summary>
73  public Dictionary<Universe, BaseDataCollection> UniverseData { get; }
74 
75  /// <summary>
76  /// True indicates this time slice is a time pulse for the algorithm containing no data
77  /// </summary>
78  public bool IsTimePulse { get; }
79 
80  /// <summary>
81  /// Initializes a new <see cref="TimeSlice"/> containing the specified data
82  /// </summary>
83  public TimeSlice(DateTime time,
84  int dataPointCount,
85  Slice slice,
86  List<DataFeedPacket> data,
87  List<UpdateData<ISecurityPrice>> securitiesUpdateData,
88  List<UpdateData<SubscriptionDataConfig>> consolidatorUpdateData,
89  List<UpdateData<ISecurityPrice>> customData,
90  SecurityChanges securityChanges,
91  Dictionary<Universe, BaseDataCollection> universeData,
92  bool isTimePulse = false)
93  {
94  Time = time;
95  Data = data;
96  Slice = slice;
97  CustomData = customData;
98  DataPointCount = dataPointCount;
99  SecuritiesUpdateData = securitiesUpdateData;
100  ConsolidatorUpdateData = consolidatorUpdateData;
101  SecurityChanges = securityChanges;
102  UniverseData = universeData;
103  IsTimePulse = isTimePulse;
104  }
105  }
106 }