/*
* QUANTCONNECT.COM - Democratizing Finance, Empowering Individuals.
* Lean Algorithmic Trading Engine v2.0. Copyright 2014 QuantConnect Corporation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
using QuantConnect.Data;
namespace QuantConnect.Indicators
{
///
/// Base class for indicators that work with two different symbols and calculate an indicator based on them.
///
/// Indicator input data type
public abstract class DualSymbolIndicator : MultiSymbolIndicator
where TInput : IBaseData
{
///
/// RollingWindow to store the data points of the target symbol
///
protected IReadOnlyWindow TargetDataPoints { get; }
///
/// RollingWindow to store the data points of the reference symbol
///
protected IReadOnlyWindow ReferenceDataPoints { get; }
///
/// Symbol of the reference used
///
protected Symbol ReferenceSymbol { get; }
///
/// Symbol of the target used
///
protected Symbol TargetSymbol { get; }
///
/// Initializes the dual symbol indicator.
///
/// The constructor accepts a target symbol and a reference symbol. It also initializes
/// the time zones for both symbols and checks if they are different.
///
///
/// The name of the indicator.
/// The symbol of the target asset.
/// The symbol of the reference asset.
/// The period (number of data points) over which to calculate the indicator.
protected DualSymbolIndicator(string name, Symbol targetSymbol, Symbol referenceSymbol, int period)
: base(name, [targetSymbol, referenceSymbol], period)
{
TargetDataPoints = DataBySymbol[targetSymbol].DataPoints;
ReferenceDataPoints = DataBySymbol[referenceSymbol].DataPoints;
TargetSymbol = targetSymbol;
ReferenceSymbol = referenceSymbol;
}
}
}