CrossSectionalInformationCoefficient
QuantConnect.Indicators.CrossSectionalInformationCoefficient
CrossSectionalInformationCoefficient(
name: str,
symbols: List[Symbol],
signal_factory: Callable[[Symbol], IIndicator],
)
CrossSectionalInformationCoefficient(
symbols: List[Symbol],
signal_factory: Callable[[Symbol], IIndicator],
)
Bases: MultiSymbolIndicator[IBaseData]
The cross-sectional information coefficient (IC) is the standard IC of factor research: each period, it is the Spearman correlation across many assets between their signal values at the end of the previous period and their returns over this period.
The indicator owns one signal per asset: each input updates its asset's signal first, so the signals must not be updated elsewhere, such as by an algorithm helper that registered them. The indicator throws when it detects such an update. The signals can't be built from other indicators, as TimeSeriesInformationCoefficient explains. An asset's price is its input's value.
Inputs whose end times fall in the same UTC period, at the inputs' resolution, form a period, so assets whose bars end at different local times, such as futures of different exchanges, share their daily periods. The indicator correlates a period as soon as every asset it tracks has an input for it. Otherwise, such as when an asset was delisted, it correlates the assets that have one when the next period starts. Each value has the end time of its period's last input, in the exchange time zone of the first asset given at construction. A period needs at least three assets with a signal value and a return. An asset with no input for a period pairs its last signal value with its return since then. Use add and remove to follow a changing cross-section, such as a universe's constituents.
Creates a new cross-sectional information coefficient indicator
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
Optional[str]
|
The name of this indicator |
None
|
symbols
|
List[Symbol]
|
The assets to correlate across. A period needs at least three |
required |
signal_factory
|
Callable[[Symbol], IIndicator]
|
Creates the signal of each asset. This indicator updates them |
required |
signals
signals: Dict[Symbol, IIndicator]
The signal of each asset whose information coefficient this indicator measures
is_ready
is_ready: bool
Gets a flag indicating when this indicator is ready and fully initialized
warm_up_period
warm_up_period: int
Required period, in data points, for the indicator to be ready and fully initialized.
consolidators
consolidators: ISet[IDataConsolidator]
The data consolidators associated with this indicator if any
previous
previous: IndicatorDataPoint
Gets the previous state of this indicator. If the state has not been updated then the time on the value will equal DateTime.MinValue.
name
name: str
Gets a name for this indicator
samples
samples: int
Gets the number of samples processed by this indicator
updated
updated: _EventContainer[
Callable[[Object, IndicatorDataPoint], Any], Any
]
Event handler that fires after this indicator is updated
data_by_symbol
data_by_symbol: Dictionary[Symbol, SymbolData]
Relevant data for each symbol the indicator works on, including all inputs and actual data points used for calculation.
This Property is protected.
indicator_value
indicator_value: float
The most recently computed value of the indicator.
This Property is protected.
time_zone
time_zone: Any
The time zone of this indicator's values, so that the values of assets of different exchange time zones share one clock: the exchange time zone of the first symbol given at construction
This Property is protected.
SymbolData
SymbolData(
symbol: Union[Symbol, str, BaseContract, Security],
period: int,
)
Bases: Object
Contains the data points, the current input and other relevant indicator data for a symbol.
This Class is protected.
Initializes a new instance of the SymbolData class.
exchange_time_zone
exchange_time_zone: Any
The exchange time zone for the security represented by this symbol.
data_points
data_points: RollingWindow[
QuantConnect_Indicators_MultiSymbolIndicator_TInput
]
Data points for the symbol. This only hold the data points that have been used to calculate the indicator, which are those that had matching end times for every symbol.
current_input
current_input: (
QuantConnect_Indicators_MultiSymbolIndicator_TInput
)
The last input data point for the symbol.
new_input
new_input: _EventContainer[
Callable[
[
Object,
QuantConnect_Indicators_MultiSymbolIndicator_TInput,
],
Any,
],
Any,
]
Event that fires when a new input data point is set for the symbol.
current_input_end_time_utc
current_input_end_time_utc: datetime
The end time of the last input data point for the symbol in UTC.
reset
reset() -> None
Resets this symbol data to its initial state
set_resolution
set_resolution(resolution: Resolution) -> None
Sets the resolution for this symbol data, to be used for time alignment.
add
add(
symbol: Union[Symbol, str, BaseContract, Security],
) -> None
Adds an asset to the cross-section, with a new signal from the signal factory. The indicator only gets the asset's data it is given: for an indicator an algorithm helper created, also register it for the asset.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
symbol
|
Union[Symbol, str, BaseContract, Security]
|
The asset to add |
required |
compute_indicator
compute_indicator() -> float
Correlates the signal values and returns of the period's assets that have both, when at least three do
This Class is protected.
Returns:
| Type | Description |
|---|---|
float
|
The period's correlation, or else the last value. |
compute_next_value
compute_next_value(input: IBaseData) -> float
Updates the input's asset, and correlates the period the input completes or ends
This Class is protected.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
input
|
IBaseData
|
The input given to the indicator |
required |
Returns:
| Type | Description |
|---|---|
float
|
The correlation of the period the input completes or ends, or else the last one. |
remove
remove(
symbol: Union[Symbol, str, BaseContract, Security],
) -> None
Removes an asset from the cross-section, such as one that left the universe. Its later inputs are ignored. When every remaining asset already has an input for the current period, that period is correlated when the next one starts.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
symbol
|
Union[Symbol, str, BaseContract, Security]
|
The asset to remove |
required |
reset
reset() -> None
Resets this indicator and its signals to their initial state. It keeps tracking the same assets
validate_and_compute_next_value
validate_and_compute_next_value(
input: IBaseData,
) -> IndicatorResult
Leaves publishing to PublishPeriod, so indicators chained to this one get one value per period, and each value has its own period's time
This Class is protected.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
input
|
IBaseData
|
The input given to the indicator |
required |
Returns:
| Type | Description |
|---|---|
IndicatorResult
|
A result the base class doesn't publish. |
__add__
__add__(
other: IndicatorBase[
QuantConnect_Indicators_IndicatorBase_T
],
) -> float
__add__(other: float) -> float
__eq__
__eq__(right: float) -> bool
__eq__(right: IndicatorBase) -> bool
__eq__(right: float) -> bool
__eq__(right: IndicatorBase) -> bool
__eq__(right: int) -> bool
__eq__(right: IndicatorBase) -> bool
__eq__(right: int) -> bool
__eq__(right: IndicatorBase) -> bool
Signature descriptions:
-
Determines if the indicator's current value is equal to the specified value
-
Determines if the specified value is equal to the indicator's current value
__ge__
__ge__(other: IIndicator) -> bool
__ge__(other: Any) -> bool
__ge__(right: float) -> bool
__ge__(right: IndicatorBase) -> bool
__ge__(right: float) -> bool
__ge__(right: IndicatorBase) -> bool
__ge__(right: int) -> bool
__ge__(right: IndicatorBase) -> bool
__ge__(right: int) -> bool
__ge__(right: IndicatorBase) -> bool
Signature descriptions:
-
Determines if the indicator's current value is greater than or equal to the specified value
-
Determines if the specified value is greater than or equal to the indicator's current value
__gt__
__gt__(other: IIndicator) -> bool
__gt__(other: Any) -> bool
__gt__(right: float) -> bool
__gt__(right: IndicatorBase) -> bool
__gt__(right: float) -> bool
__gt__(right: IndicatorBase) -> bool
__gt__(right: int) -> bool
__gt__(right: IndicatorBase) -> bool
__gt__(right: int) -> bool
__gt__(right: IndicatorBase) -> bool
Signature descriptions:
-
Determines if the indicator's current value is greater than the specified value
-
Determines if the specified value is greater than the indicator's current value
__le__
__le__(other: IIndicator) -> bool
__le__(other: Any) -> bool
__le__(right: float) -> bool
__le__(right: IndicatorBase) -> bool
__le__(right: float) -> bool
__le__(right: IndicatorBase) -> bool
__le__(right: int) -> bool
__le__(right: IndicatorBase) -> bool
__le__(right: int) -> bool
__le__(right: IndicatorBase) -> bool
Signature descriptions:
-
Determines if the indicator's current value is less than or equal to the specified value
-
Determines if the specified value is less than or equal to the indicator's current value
__lt__
__lt__(other: IIndicator) -> bool
__lt__(other: Any) -> bool
__lt__(right: float) -> bool
__lt__(right: IndicatorBase) -> bool
__lt__(right: float) -> bool
__lt__(right: IndicatorBase) -> bool
__lt__(right: int) -> bool
__lt__(right: IndicatorBase) -> bool
__lt__(right: int) -> bool
__lt__(right: IndicatorBase) -> bool
Signature descriptions:
-
Determines if the indicator's current value is less than the specified value
-
Determines if the specified value is less than the indicator's current value
__mul__
__mul__(
other: IndicatorBase[
QuantConnect_Indicators_IndicatorBase_T
],
) -> float
__mul__(other: float) -> float
__ne__
__ne__(right: float) -> bool
__ne__(right: IndicatorBase) -> bool
__ne__(right: float) -> bool
__ne__(right: IndicatorBase) -> bool
__ne__(right: int) -> bool
__ne__(right: IndicatorBase) -> bool
__ne__(right: int) -> bool
__ne__(right: IndicatorBase) -> bool
Signature descriptions:
-
Determines if the indicator's current value is not equal to the specified value
-
Determines if the specified value is not equal to the indicator's current value
__sub__
__sub__(
other: IndicatorBase[
QuantConnect_Indicators_IndicatorBase_T
],
) -> float
__sub__(other: float) -> float
__truediv__
__truediv__(
other: IndicatorBase[
QuantConnect_Indicators_IndicatorBase_T
],
) -> float
__truediv__(other: float) -> float
compare_to
compare_to(other: IIndicator) -> int
compare_to(obj: Any) -> int
Signature descriptions:
-
Compares the current object with another object of the same type.
-
Compares the current instance with another object of the same type and returns an integer that indicates whether the current instance precedes, follows, or occurs in the same position in the sort order as the other object.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
other
|
Optional[IIndicator]
|
An object to compare with this object. |
None
|
obj
|
Optional[Any]
|
An object to compare with this instance. |
None
|
Returns:
| Type | Description |
|---|---|
int
|
Depends on the signature used. Case 1: [A value that indicates the relative order of the objects being compared. The return value has the following meanings: Value Meaning Less than zero This object is less than the other parameter.Zero This object is equal to other. Greater than zero This object is greater than other.]; Case 2: [A value that indicates the relative order of the objects being compared. The return value has these meanings: Value Meaning Less than zero This instance precedes obj in the sort order. Zero This instance occurs in the same position in the sort order as obj. Greater than zero This instance follows obj in the sort order.] |
minus
minus(constant: float) -> CompositeIndicator
minus(right: IndicatorBase) -> CompositeIndicator
minus(
right: IndicatorBase, name: str
) -> CompositeIndicator
Signature descriptions:
-
Creates a new CompositeIndicator such that the result will be the difference of the left and constant
-
Creates a new CompositeIndicator such that the result will be the difference of the left and right
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
constant
|
Optional[float]
|
The subtrahend |
None
|
right
|
Optional[IndicatorBase]
|
The right indicator |
None
|
name
|
Optional[str]
|
The name of this indicator |
None
|
Returns:
| Type | Description |
|---|---|
CompositeIndicator
|
The difference of the left and right indicators. |
over
over(constant: float) -> CompositeIndicator
over(right: IndicatorBase) -> CompositeIndicator
over(right: IndicatorBase, name: str) -> CompositeIndicator
Signature descriptions:
-
Creates a new CompositeIndicator such that the result will be the ratio of the left to the constant
-
Creates a new CompositeIndicator such that the result will be the ratio of the left to the right
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
constant
|
Optional[float]
|
The constant value denominator |
None
|
right
|
Optional[IndicatorBase]
|
The right indicator |
None
|
name
|
Optional[str]
|
The name of this indicator |
None
|
Returns:
| Type | Description |
|---|---|
CompositeIndicator
|
The ratio of the left to the right indicator. |
plus
plus(constant: float) -> CompositeIndicator
plus(right: IndicatorBase) -> CompositeIndicator
plus(right: IndicatorBase, name: str) -> CompositeIndicator
Signature descriptions:
-
Creates a new CompositeIndicator such that the result will be the sum of the left and the constant
-
Creates a new CompositeIndicator such that the result will be the sum of the left and right
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
constant
|
Optional[float]
|
The addend |
None
|
right
|
Optional[IndicatorBase]
|
The right indicator |
None
|
name
|
Optional[str]
|
The name of this indicator |
None
|
Returns:
| Type | Description |
|---|---|
CompositeIndicator
|
The sum of the left and right indicators. |
times
times(constant: float) -> CompositeIndicator
times(right: IndicatorBase) -> CompositeIndicator
times(
right: IndicatorBase, name: str
) -> CompositeIndicator
Signature descriptions:
-
Creates a new CompositeIndicator such that the result will be the product of the left and the constant
-
Creates a new CompositeIndicator such that the result will be the product of the left to the right
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
constant
|
Optional[float]
|
The constant value to multiple by |
None
|
right
|
Optional[IndicatorBase]
|
The right indicator |
None
|
name
|
Optional[str]
|
The name of this indicator |
None
|
Returns:
| Type | Description |
|---|---|
CompositeIndicator
|
The product of the left to the right indicators. |
update
update(input: IBaseData) -> bool
update(time: Union[datetime, date], value: float) -> bool
Updates the state of this indicator with the given value and returns true if this indicator is ready, false otherwise
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
input
|
Optional[IBaseData]
|
The value to use to update this indicator |
None
|
time
|
Optional[Union[datetime, date]]
|
The time associated with the value |
None
|
value
|
Optional[float]
|
The value to use to update this indicator |
None
|
Returns:
| Type | Description |
|---|---|
bool
|
True if this indicator is ready, false otherwise. |
__float__
__float__() -> float
__int__
__int__() -> int
__neg__
__neg__() -> float
__radd__
__radd__(other: float) -> float
__rmul__
__rmul__(other: float) -> float
__rsub__
__rsub__(other: float) -> float
__rtruediv__
__rtruediv__(other: float) -> float
ema
ema(
period: int,
smoothing_factor: Optional[float] = None,
wait_for_first_to_ready: bool = True,
) -> ExponentialMovingAverage
Creates a new ExponentialMovingAverage indicator with the specified period and smoothing_factor from the left indicator
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
period
|
int
|
The period of the ExponentialMovingAverage indicators |
required |
smoothing_factor
|
Optional[float]
|
The percentage of data from the previous value to be carried into the next value |
None
|
wait_for_first_to_ready
|
bool
|
True to only send updates to the second if left.IsReady returns true, false to always send updates |
True
|
Returns:
| Type | Description |
|---|---|
ExponentialMovingAverage
|
A reference to the ExponentialMovingAverage indicator to allow for method chaining. |
equals
equals(obj: Any) -> bool
Determines whether the specified object is equal to the current object.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
obj
|
Any
|
The object to compare with the current object. |
required |
Returns:
| Type | Description |
|---|---|
bool
|
true if the specified object is equal to the current object; otherwise, false. |
get_hash_code
get_hash_code() -> int
Get Hash Code for this Object
Returns:
| Type | Description |
|---|---|
int
|
Integer Hash Code. |
get_value_end_time
get_value_end_time(
input: QuantConnect_Indicators_MultiSymbolIndicator_TInput,
) -> datetime
Gets the end time of the value this indicator computes from the given input, in time_zone. The input of a symbol this indicator no longer tracks keeps its end time
This Class is protected.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
input
|
QuantConnect_Indicators_MultiSymbolIndicator_TInput
|
The input given to the indicator |
required |
Returns:
| Type | Description |
|---|---|
datetime
|
The end time of the indicator's value. |
min
min(
period: int, wait_for_first_to_ready: bool = True
) -> Minimum
Creates a new Minimum indicator with the specified period from the left indicator
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
period
|
int
|
The period of the Minimum indicator |
required |
wait_for_first_to_ready
|
bool
|
True to only send updates to the second if left.IsReady returns true, false to always send updates |
True
|
Returns:
| Type | Description |
|---|---|
Minimum
|
A reference to the Minimum indicator to allow for method chaining. |
on_updated
on_updated(consolidated: IndicatorDataPoint) -> None
Event invocator for the Updated event
This Class is protected.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
consolidated
|
IndicatorDataPoint
|
This is the new piece of data produced by this indicator |
required |
sma
sma(
period: int, wait_for_first_to_ready: bool = True
) -> SimpleMovingAverage
Initializes a new instance of the SimpleMovingAverage class with the specified name and period from the left indicator
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
period
|
int
|
The period of the SMA |
required |
wait_for_first_to_ready
|
bool
|
True to only send updates to the second if first.IsReady returns true, false to always send updates to second |
True
|
Returns:
| Type | Description |
|---|---|
SimpleMovingAverage
|
The reference to the SimpleMovingAverage indicator to allow for method chaining. |
to_detailed_string
to_detailed_string() -> str
Provides a more detailed string of this indicator in the form of {Name} - {Value}
Returns:
| Type | Description |
|---|---|
str
|
A detailed string of this indicator's current state. |
to_string
to_string() -> str
ToString Overload for Indicator Base
Returns:
| Type | Description |
|---|---|
str
|
String representation of the indicator. |
weighted_by
weighted_by(
weight: IndicatorBase, period: int
) -> CompositeIndicator
Creates a new CompositeIndicator such that the result will be average of a first indicator weighted by a second one
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
weight
|
IndicatorBase
|
Indicator that provides the average weights |
required |
period
|
int
|
Average period |
required |
Returns:
| Type | Description |
|---|---|
CompositeIndicator
|
Indicator that results of the average of first by weights given by second. |