InsightCollection
QuantConnect.Algorithm.Framework.Alphas.InsightCollection
Bases: Object, Iterable[Insight]
Provides a collection for managing insights. This type provides collection access semantics
as well as dictionary access semantics through TryGetValue, ContainsKey, and this
count
count: int
The open insight count
total_count
total_count: int
The total insight count
get_insights
get_insights(filter: Any) -> List[Insight]
__contains__
__contains__(
symbol: Union[Symbol, str, BaseContract],
) -> bool
Determines whether insights exist in this collection for the specified symbol
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
symbol
|
Union[Symbol, str, BaseContract]
|
The symbol key |
required |
Returns:
| Type | Description |
|---|---|
bool
|
True if there are insights for the symbol in this collection. |
__getitem__
__getitem__(
symbol: Union[Symbol, str, BaseContract],
) -> List[Insight]
Dictionary accessor returns a list of insights for the specified symbol
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
symbol
|
Union[Symbol, str, BaseContract]
|
The symbol key |
required |
Returns:
| Type | Description |
|---|---|
List[Insight]
|
List of insights for the symbol. |
__len__
__len__() -> int
__setitem__
__setitem__(
symbol: Union[Symbol, str, BaseContract],
value: List[Insight],
) -> None
Dictionary accessor returns a list of insights for the specified symbol
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
symbol
|
Union[Symbol, str, BaseContract]
|
The symbol key |
required |
Returns:
| Type | Description |
|---|---|
None
|
List of insights for the symbol. |
add
add(item: Insight) -> None
Adds an item to the System.Collections.Generic.ICollection`1.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
item
|
Insight
|
The object to add to the System.Collections.Generic.ICollection`1. |
required |
add_range
add_range(insights: List[Insight]) -> None
Adds each item in the specified enumerable of insights to this collection
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
insights
|
List[Insight]
|
The insights to add to this collection |
required |
clear
clear(symbols: List[Symbol]) -> None
Removes the symbol and its insights
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
symbols
|
List[Symbol]
|
List of symbols that will be removed |
required |
contains
contains(item: Insight) -> bool
Determines whether the System.Collections.Generic.ICollection`1 contains a specific value.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
item
|
Insight
|
The object to locate in the System.Collections.Generic.ICollection`1. |
required |
Returns:
| Type | Description |
|---|---|
bool
|
true if item is found in the System.Collections.Generic.ICollection`1; otherwise, false. |
contains_key
contains_key(
symbol: Union[Symbol, str, BaseContract],
) -> bool
Determines whether insights exist in this collection for the specified symbol
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
symbol
|
Union[Symbol, str, BaseContract]
|
The symbol key |
required |
Returns:
| Type | Description |
|---|---|
bool
|
True if there are insights for the symbol in this collection. |
get_active_insights
get_active_insights(
utc_time: Union[datetime, date],
) -> ICollection[Insight]
Gets the last generated active insight
Returns:
| Type | Description |
|---|---|
ICollection[Insight]
|
Collection of insights that are active. |
get_enumerator
get_enumerator() -> IEnumerator[Insight]
Returns an enumerator that iterates through the collection.
Returns:
| Type | Description |
|---|---|
IEnumerator[Insight]
|
A System.Collections.Generic.IEnumerator`1 that can be used to iterate through the collection. |
get_next_expiry_time
get_next_expiry_time() -> Optional[datetime]
Gets the next expiry time UTC
has_active_insights
has_active_insights(
symbol: Union[Symbol, str, BaseContract],
utc_time: Union[datetime, date],
) -> bool
Returns true if there are active insights for a given symbol and time
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
symbol
|
Union[Symbol, str, BaseContract]
|
The symbol key |
required |
utc_time
|
Union[datetime, date]
|
Time that determines whether the insight has expired |
required |
remove
remove(item: Insight) -> bool
Removes the first occurrence of a specific object from the System.Collections.Generic.ICollection`1.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
item
|
Insight
|
The object to remove from the System.Collections.Generic.ICollection`1. |
required |
Returns:
| Type | Description |
|---|---|
bool
|
true if item was successfully removed from the System.Collections.Generic.ICollection |
remove_expired_insights
remove_expired_insights(
utc_time: Union[datetime, date],
) -> ICollection[Insight]
Remove all expired insights from the collection and retuns them
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
utc_time
|
Union[datetime, date]
|
Time that determines whether the insight has expired |
required |
Returns:
| Type | Description |
|---|---|
ICollection[Insight]
|
Expired insights that were removed. |
remove_insights
remove_insights(filter: Callable[[Insight], bool]) -> None
Will remove insights from the complete insight collection
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
filter
|
Callable[[Insight], bool]
|
The function that will determine which insight to remove |
required |
try_get_value
try_get_value(
symbol: Union[Symbol, str, BaseContract],
insights: Optional[List[Insight]],
) -> Tuple[bool, List[Insight]]
Attempts to get the list of insights with the specified symbol key
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
symbol
|
Union[Symbol, str, BaseContract]
|
The symbol key |
required |
insights
|
Optional[List[Insight]]
|
The insights for the specified symbol, or null if not found |
required |
Returns:
| Type | Description |
|---|---|
Tuple[bool, List[Insight]]
|
True if insights for the specified symbol were found, false otherwise. |