Models
models ¶
Business domain model for equities_classifier.
ClassificationNode(value: str, code: str | None = None) dataclass ¶
ClassificationSystem(id: ClassificationSystemID, display_name: str, short_name: str, authorities: tuple[str, ...], hierarchy: tuple[str, ...], supports_codes: bool) dataclass ¶
Definition of a classification system.
Security(name: str | None = None, ticker: str | None = None, provider_attributes: dict[str, dict[str, Any]] = dict(), classifications: list[SecurityClassification] = list(), *, identifiers: list[SecurityIdentifier] = list()) dataclass ¶
Security class.
classifications: list[SecurityClassification] = field(default_factory=list) class-attribute instance-attribute ¶
name: str | None = None class-attribute instance-attribute ¶
provider_attributes: dict[str, dict[str, Any]] = field(default_factory=dict) class-attribute instance-attribute ¶
ticker: str | None = None class-attribute instance-attribute ¶
provider_attribute(provider: DataSourceID, attribute: str) -> Any | None ¶
SecurityClassification(system: ClassificationSystem, nodes: dict[ClassificationLevel, ClassificationNode]) dataclass ¶
SecurityIdentifier(type: SecurityIdentifierType, value: str) dataclass ¶
Security identifier.
country: str | None = field(init=False) class-attribute instance-attribute ¶
type: SecurityIdentifierType instance-attribute ¶
value: str instance-attribute ¶
value_cleaned: str | None = field(init=False) class-attribute instance-attribute ¶
__post_init__() -> None ¶
Strip identifier value and for Ticker split into value_cleaned and country provided as postfix. NOTE: derived attributes where not marked with a leading _ to allow transparent access as for orignal value.
Source code in src/equities_classifier/models.py
def __post_init__(self) -> None:
"""Strip identifier value and for Ticker split into value_cleaned and country provided as postfix.
NOTE: derived attributes where not marked with a leading _ to allow transparent access as for orignal value.
"""
# strip value
object.__setattr__(self, "value", self.value.strip())
# allow country suffix for ticker
if self.type != SecurityIdentifierType.TICKER or "." not in self.value:
object.__setattr__(self, "value_cleaned", self.value)
object.__setattr__(self, "country", None)
else:
value_cleaned, country = self.value.split(".")
object.__setattr__(self, "value_cleaned", value_cleaned)
object.__setattr__(self, "country", country)
get_country() ¶
get_value_cleaned() ¶
SecurityIdentifierIdentifiable(*, identifiers: list[SecurityIdentifier] = list()) dataclass ¶
Base class for objects identified by security identifiers.
identifiers: list[SecurityIdentifier] = field(default_factory=list) class-attribute instance-attribute ¶
has_identifier(identifier_type: SecurityIdentifierType) -> bool ¶
identifier(identifier_type: SecurityIdentifierType) -> SecurityIdentifier | None ¶
Find identifier of a specific type.
identifier_country(identifier_type: SecurityIdentifierType) -> str | None ¶
Return country of an identifier of a type TICKER.
Source code in src/equities_classifier/models.py
identifier_value(identifier_type: SecurityIdentifierType) -> str | None ¶
Return value of an identifier of a specific type.
identifier_value_cleaned(identifier_type: SecurityIdentifierType) -> str | None ¶
Return cleaned value of an identifier of a specific type.
Source code in src/equities_classifier/models.py
SecurityProviderRecord(name: str | None = None, ticker: str | None = None, *, identifiers: list[SecurityIdentifier] = list()) dataclass ¶
Base class for SecurityProviderRecord classes ensuring common fields are contained.