Lean
$LEAN_TAG$
DualSymbolIndicator.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
QuantConnect
.
Data
;
17
18
namespace
QuantConnect.Indicators
19
{
20
/// <summary>
21
/// Base class for indicators that work with two different symbols and calculate an indicator based on them.
22
/// </summary>
23
/// <typeparam name="TInput">Indicator input data type</typeparam>
24
public
abstract
class
DualSymbolIndicator
<TInput> :
MultiSymbolIndicator
<TInput>
25
where TInput :
IBaseData
26
{
27
/// <summary>
28
/// RollingWindow to store the data points of the target symbol
29
/// </summary>
30
protected
IReadOnlyWindow<TInput>
TargetDataPoints
{
get
; }
31
32
/// <summary>
33
/// RollingWindow to store the data points of the reference symbol
34
/// </summary>
35
protected
IReadOnlyWindow<TInput>
ReferenceDataPoints
{
get
; }
36
37
/// <summary>
38
/// Symbol of the reference used
39
/// </summary>
40
protected
Symbol
ReferenceSymbol
{
get
; }
41
42
/// <summary>
43
/// Symbol of the target used
44
/// </summary>
45
protected
Symbol
TargetSymbol
{
get
; }
46
47
/// <summary>
48
/// Initializes the dual symbol indicator.
49
/// <para>
50
/// The constructor accepts a target symbol and a reference symbol. It also initializes
51
/// the time zones for both symbols and checks if they are different.
52
/// </para>
53
/// </summary>
54
/// <param name="name">The name of the indicator.</param>
55
/// <param name="targetSymbol">The symbol of the target asset.</param>
56
/// <param name="referenceSymbol">The symbol of the reference asset.</param>
57
/// <param name="period">The period (number of data points) over which to calculate the indicator.</param>
58
protected
DualSymbolIndicator
(
string
name,
Symbol
targetSymbol,
Symbol
referenceSymbol,
int
period)
59
: base(name, [targetSymbol, referenceSymbol], period)
60
{
61
TargetDataPoints
=
DataBySymbol
[targetSymbol].DataPoints;
62
ReferenceDataPoints
=
DataBySymbol
[referenceSymbol].DataPoints;
63
TargetSymbol
= targetSymbol;
64
ReferenceSymbol
= referenceSymbol;
65
}
66
}
67
}
Indicators
DualSymbolIndicator.cs
Generated by
1.8.17