Lean  $LEAN_TAG$
WindowIdentity.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 
17 {
18  /// <summary>
19  /// Represents an indicator that is a ready after ingesting enough samples (# samples > period)
20  /// and always returns the same value as it is given.
21  /// </summary>
22  public class WindowIdentity : WindowIndicator<IndicatorDataPoint>
23  {
24  /// <summary>
25  /// Initializes a new instance of the WindowIdentity class with the specified name and period
26  /// </summary>
27  /// <param name="name">The name of this indicator</param>
28  /// <param name="period">The period of the WindowIdentity</param>
29  public WindowIdentity(string name, int period)
30  : base(name, period)
31  {
32  }
33 
34  /// <summary>
35  /// Initializes a new instance of the WindowIdentity class with the default name and period
36  /// </summary>
37  /// <param name="period">The period of the WindowIdentity</param>
38  public WindowIdentity(int period)
39  : this("WIN-ID" + period, period)
40  {
41  }
42 
43  /// <summary>
44  /// Gets a flag indicating when this indicator is ready and fully initialized
45  /// </summary>
46  public override bool IsReady
47  {
48  get { return Samples >= Period; }
49  }
50 
51  /// <summary>
52  /// Computes the next value for this indicator from the given state.
53  /// </summary>
54  /// <param name="window">The window of data held in this indicator</param>
55  /// <param name="input">The input value to this indicator on this time step</param>
56  /// <returns>A new value for this indicator</returns>
58  {
59  return input.Value;
60  }
61  }
62 }