finpandas.utils package

Submodules

finpandas.utils.errors module

Custom errors.

exception finpandas.utils.errors.NestedDepthError(input_depth: int, correct_depth: int, message='iterable depth of ({input_depth}) invalid for required depth ({correct_depth})')[source]

Bases: Exception

Exception raised when the inputted nested iterable is the incorrect depth

Args:

input_depth (int): the depth of the inputted iterable correct_depth (int): the correct depth of the inputted iterable message (str, optional): printed output. Defaults to

“the nested depth of the iterable ({input_depth}) is invalid for required depth ({correct_depth})”.

exception finpandas.utils.errors.TickerNotFoundError(ticker: str, message="inputted ticker '{ticker}' could not be found")[source]

Bases: Exception

Exception raised when the inputted ticker is not found

Args:

ticker (str): the ticker message (str, optional): printed output. Defaults to

“the inputted ticker ‘{ticker}’ could not be found”.

finpandas.utils.functional module

helper functions

class finpandas.utils.functional.SafeList(iterable=(), /)[source]

Bases: list

subclass of list datatype that allows safe indexing

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

safe indexing method

Args:

index (int): [description] default (object, optional): what to return if indexing fails. Defaults to None.

Returns:

object: either the value at that index or a default value

finpandas.utils.functional.count_object_methods(obj: object)[source]

get the number of callable object methods

Args:

obj (object): any object

Returns:

int: the number of object class methods

finpandas.utils.functional.get_profile_by_cik(cik: Union[str, int]) → Union[None, Tuple[int, str, str]][source]

gets the company profile using the CIK number

Args:

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

Returns:

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

finpandas.utils.functional.get_profile_by_ticker(ticker: str) → Union[None, Tuple[int, str, str]][source]

gets the company profile using the ticker

Args:

ticker (str): the ticker of the company

Returns:

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

finpandas.utils.functional.get_profile_by_title(title: str) → Union[None, Tuple[int, str, str], Iterable[Tuple[int, str, str]]][source]

gets the company profile using the title

Args:

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

Returns:

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

finpandas.utils.functional.nested_depth(iterable: Iterable) → int[source]

calculate the nested depth of an iterable

Args:

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

Returns:

int: the depth

finpandas.utils.functional.ticker_or_cik_parser(ticker_or_cik: Union[str, int]) → int[source]

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

Args:

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:

int: the CIK number

finpandas.utils.jobs module

Utility for multiprocessing finpandas jobs

class finpandas.utils.jobs.Jobs[source]

Bases: object

add_job(f: Callable, *args) → None[source]

add a job to be executed

Args:
f (Callable): the function to execute with the job,

followed in-order by any arguments.

execute() → Iterable[Any][source]

execute all jobs

Returns:

Iterable: the output of each job

finpandas.utils.jobs.parmap(f: Callable, X: Iterable[Any]) → Iterable[Any][source]

parralelized mapping function

Args:

f (Callable): function to parallelize operation over X (Iterable): the arguments to the function, over N

function calls.

Returns:

Iterable: the N function outputs

finpandas.utils.jobs.spawn(f: Callable) → Callable[source]

[summary]

Args:

f (Callable): function to spawn a pipe for

Returns:

Callable: a function that executes the spawning of the pipe

Module contents

utilities