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...
 
override void Reset ()
 Resets this indicator to its initial state More...
 

Public Attributes

override bool IsReady => _targetDataPoints.Samples >= WarmUpPeriod && _referenceDataPoints.Samples >= WarmUpPeriod
 Gets a flag indicating when the indicator is ready and fully initialized More...
 

Protected Member Functions

override decimal ComputeNextValue (IBaseDataBar input)
 Computes the next value for this indicator from the given state. More...
 
- Protected Member Functions inherited from QuantConnect.Indicators.BarIndicator
 BarIndicator (string name)
 Creates a new TradeBarIndicator with the specified name More...
 

Properties

int WarmUpPeriod [get]
 Required period, in data points, for the indicator to be ready and fully initialized. More...
 
- Properties inherited from QuantConnect.Indicators.IIndicatorWarmUpPeriodProvider
int WarmUpPeriod [get]
 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.

Definition at line 34 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 90 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 120 of file Correlation.cs.

Member Function Documentation

◆ ComputeNextValue()

override decimal QuantConnect.Indicators.Correlation.ComputeNextValue ( IBaseDataBar  input)
protected

Computes the next value for this indicator from the given state.

As this indicator is receiving data points from two different symbols, it's going to compute the next value when the amount of data points of each of them is the same. Otherwise, it will return the last correlation value computed

Parameters
inputThe input value of this indicator on this time step. It can be either from the target or the reference symbol
Returns
The correlation value of the target used in relation with the reference

Definition at line 136 of file Correlation.cs.

◆ Reset()

override void QuantConnect.Indicators.Correlation.Reset ( )

Resets this indicator to its initial state

Definition at line 185 of file Correlation.cs.

Member Data Documentation

◆ IsReady

override bool QuantConnect.Indicators.Correlation.IsReady => _targetDataPoints.Samples >= WarmUpPeriod && _referenceDataPoints.Samples >= WarmUpPeriod

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

Definition at line 79 of file Correlation.cs.

Property Documentation

◆ WarmUpPeriod

int QuantConnect.Indicators.Correlation.WarmUpPeriod
get

Required period, in data points, for the indicator to be ready and fully initialized.

Definition at line 74 of file Correlation.cs.


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