Lean
$LEAN_TAG$
StandardDeviation.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
18
namespace
QuantConnect.Indicators
19
{
20
/// <summary>
21
/// This indicator computes the n-period population standard deviation.
22
/// </summary>
23
public
class
StandardDeviation
:
Variance
24
{
25
/// <summary>
26
/// Initializes a new instance of the StandardDeviation class with the specified period.
27
///
28
/// Evaluates the standard deviation of samples in the look-back period.
29
/// On a data set of size N will use an N normalizer and would thus be biased if applied to a subset.
30
/// </summary>
31
/// <param name="period">The sample size of the standard deviation</param>
32
public
StandardDeviation
(
int
period)
33
: this($
"STD({period})"
, period)
34
{
35
}
36
37
/// <summary>
38
/// Initializes a new instance of the StandardDeviation class with the specified name and period.
39
///
40
/// Evaluates the standard deviation of samples in the look-back period.
41
/// On a data set of size N will use an N normalizer and would thus be biased if applied to a subset.
42
/// </summary>
43
/// <param name="name">The name of this indicator</param>
44
/// <param name="period">The sample size of the standard deviation</param>
45
public
StandardDeviation
(
string
name,
int
period)
46
: base(name, period)
47
{
48
}
49
50
/// <summary>
51
/// Computes the next value of this indicator from the given state
52
/// </summary>
53
/// <param name="input">The input given to the indicator</param>
54
/// <param name="window">The window for the input history</param>
55
/// <returns>A new value for this indicator</returns>
56
protected
override
decimal
ComputeNextValue
(
IReadOnlyWindow<IndicatorDataPoint>
window,
IndicatorDataPoint
input)
57
{
58
return
(decimal) Math.Sqrt((
double
) base.ComputeNextValue(window, input));
59
}
60
}
61
}
Indicators
StandardDeviation.cs
Generated by
1.8.17