Lean  $LEAN_TAG$
QuantConnect.Indicators.Correlation Class Reference

The Correlation Indicator is a valuable tool in technical analysis, designed to quantify the degree of relationship between the price movements of a target security (e.g., a stock or ETF) and a reference market index. It measures how closely the target’s price changes are aligned with the fluctuations of the index over a specific period of time, providing insights into the target’s susceptibility to market movements. A positive correlation indicates that the target tends to move in the same direction as the market index, while a negative correlation suggests an inverse relationship. A correlation close to 0 implies a weak or no linear relationship. Commonly, the SPX index is employed as the benchmark for the overall market when calculating correlation, ensuring a consistent and reliable reference point. This helps traders and investors make informed decisions regarding the risk and behavior of the target security in relation to market trends. More...

Inheritance diagram for QuantConnect.Indicators.Correlation:
[legend]

Public Member Functions

 Correlation (string name, Symbol targetSymbol, Symbol referenceSymbol, int period, CorrelationType correlationType=CorrelationType.Pearson)
 Creates a new Correlation indicator with the specified name, target, reference,
and period values More...
 
 Correlation (Symbol targetSymbol, Symbol referenceSymbol, int period, CorrelationType correlationType=CorrelationType.Pearson)
 Creates a new Correlation indicator with the specified target, reference,
and period values More...
 
- Public Member Functions inherited from QuantConnect.Indicators.DualSymbolIndicator< double >
override void Reset ()
 Resets this indicator to its initial state More...
 

Public Attributes

override bool IsReady => TargetDataPoints.IsReady && ReferenceDataPoints.IsReady
 Gets a flag indicating when the indicator is ready and fully initialized More...
 

Protected Member Functions

override void AddDataPoint (IBaseDataBar input)
 Adds the closing price to the target or reference symbol's data set. More...
 
override void ComputeIndicator ()
 Computes the correlation value usuing symbols values correlation values assing into _correlation property More...
 
- Protected Member Functions inherited from QuantConnect.Indicators.DualSymbolIndicator< double >
 DualSymbolIndicator (string name, Symbol targetSymbol, Symbol referenceSymbol, int period)
 Initializes the dual symbol indicator. More...
 
override decimal ComputeNextValue (IBaseDataBar input)
 Checks and computes the indicator if the input data matches. This method ensures the input data points are from matching time periods and different symbols. More...
 
abstract void AddDataPoint (IBaseDataBar input)
 Adds the closing price to the corresponding symbol's data set (target or reference). This method stores the data points for each symbol and performs specific calculations based on the symbol. For instance, it computes returns in the case of the Beta indicator. More...
 

Additional Inherited Members

- Properties inherited from QuantConnect.Indicators.DualSymbolIndicator< double >
RollingWindow< T > TargetDataPoints [get]
 RollingWindow to store the data points of the target symbol More...
 
RollingWindow< T > ReferenceDataPoints [get]
 RollingWindow to store the data points of the reference symbol More...
 
Symbol ReferenceSymbol [get]
 Symbol of the reference used More...
 
Symbol TargetSymbol [get]
 Symbol of the target used More...
 
bool IsTimezoneDifferent [get]
 Indicates if the time zone for the target and reference are different. More...
 
decimal IndicatorValue [get, set]
 The most recently computed value of the indicator. More...
 
int WarmUpPeriod [get, set]
 Required period, in data points, for the indicator to be ready and fully initialized. More...
 

Detailed Description

The Correlation Indicator is a valuable tool in technical analysis, designed to quantify the degree of relationship between the price movements of a target security (e.g., a stock or ETF) and a reference market index. It measures how closely the target’s price changes are aligned with the fluctuations of the index over a specific period of time, providing insights into the target’s susceptibility to market movements. A positive correlation indicates that the target tends to move in the same direction as the market index, while a negative correlation suggests an inverse relationship. A correlation close to 0 implies a weak or no linear relationship. Commonly, the SPX index is employed as the benchmark for the overall market when calculating correlation, ensuring a consistent and reliable reference point. This helps traders and investors make informed decisions regarding the risk and behavior of the target security in relation to market trends.

The indicator only updates when both assets have a price for a time step. When a bar is missing for one of the assets, the indicator value fills forward to improve the accuracy of the indicator.

Definition at line 37 of file Correlation.cs.

Constructor & Destructor Documentation

◆ Correlation() [1/2]

QuantConnect.Indicators.Correlation.Correlation ( string  name,
Symbol  targetSymbol,
Symbol  referenceSymbol,
int  period,
CorrelationType  correlationType = CorrelationType.Pearson 
)

Creates a new Correlation indicator with the specified name, target, reference,
and period values

Parameters
nameThe name of this indicator
targetSymbolThe target symbol of this indicator
periodThe period of this indicator
referenceSymbolThe reference symbol of this indicator
correlationTypeCorrelation type

Definition at line 58 of file Correlation.cs.

◆ Correlation() [2/2]

QuantConnect.Indicators.Correlation.Correlation ( Symbol  targetSymbol,
Symbol  referenceSymbol,
int  period,
CorrelationType  correlationType = CorrelationType.Pearson 
)

Creates a new Correlation indicator with the specified target, reference,
and period values

Parameters
targetSymbolThe target symbol of this indicator
periodThe period of this indicator
referenceSymbolThe reference symbol of this indicator
correlationTypeCorrelation type

Definition at line 78 of file Correlation.cs.

Member Function Documentation

◆ AddDataPoint()

override void QuantConnect.Indicators.Correlation.AddDataPoint ( IBaseDataBar  input)
protected

Adds the closing price to the target or reference symbol's data set.

Parameters
inputThe input value for this symbol
Exceptions
ArgumentExceptionThrown if the input symbol is not the target or reference symbol.

Definition at line 88 of file Correlation.cs.

◆ ComputeIndicator()

override void QuantConnect.Indicators.Correlation.ComputeIndicator ( )
protectedvirtual

Computes the correlation value usuing symbols values correlation values assing into _correlation property

Implements QuantConnect.Indicators.DualSymbolIndicator< double >.

Definition at line 108 of file Correlation.cs.

Here is the call graph for this function:

Member Data Documentation

◆ IsReady

override bool QuantConnect.Indicators.Correlation.IsReady => TargetDataPoints.IsReady && ReferenceDataPoints.IsReady

Gets a flag indicating when the indicator is ready and fully initialized

Definition at line 47 of file Correlation.cs.


The documentation for this class was generated from the following file: