finpandas.utils.functional module

helper functions

class SafeList(iterable=(), /)

Bases: list

subclass of list datatype that allows safe indexing

get(index: int, default: Optional[object] = None) object

safe indexing method

Parameters
  • index (int) – [description]

  • default (object, optional) – what to return if indexing fails. Defaults to None.

Returns

either the value at that index or a default value

Return type

object

count_object_methods(obj: object)

get the number of callable object methods

Parameters

obj (object) – any object

Returns

the number of object class methods

Return type

int

get_profile_by_cik(cik: Union[str, int]) Union[None, Tuple[int, str, str]]

gets the company profile using the CIK number

Parameters

cik (Union[str,int]) – the SEC issued Central Index Key (CIK)

Returns

(cik, ticker, title)

Return type

Union[None,Tuple[int,str,str]]

get_profile_by_ticker(ticker: str) Union[None, Tuple[int, str, str]]

gets the company profile using the ticker

Parameters

ticker (str) – the ticker of the company

Returns

(cik, ticker, title)

Return type

Union[None,Tuple[int,str,str]]

get_profile_by_title(title: str) Union[None, Tuple[int, str, str], Iterable[Tuple[int, str, str]]]

gets the company profile using the title

Parameters

title (str) – the company’s name in glob form

Returns

(cik, ticker, title)

Return type

Union[None,Tuple[int,str,str],Iterable[Tuple[int,str,str]]]

nested_depth(iterable: Iterable) int

calculate the nested depth of an iterable

Parameters

iterable (Iterable) – the iterable to calculate the depth of

Returns

the depth

Return type

int

ticker_or_cik_parser(ticker_or_cik: Union[str, int]) int

takes in a ticker or CIK number and returns just the CIK number. a convenience function for internal use.

Parameters

ticker_or_cik (Union[str,int]) – ticker or SEC issued Central Index Key (CIK)

Raises

TickerNotFoundError – if the ticker is not found in our database

Returns

the CIK number

Return type

int