bayesline.api.equity.AsyncUploadParserApi#

class bayesline.api.equity.AsyncUploadParserApi#

Abstract base class for upload parsers.

__init__()#

Methods

__init__()

can_handle(raw_df, *[, name])

Check if this parser can handle the given dataframe.

get_examples()

Get example dataframes for testing the parser.

output_schema()

Get the output schema that this parser produces.

parse(raw_df, *[, name])

Parse the given dataframe.

Attributes

name

Get the name of the parser.

abstract property name: str#

Get the name of the parser.

Returns#

str

The name of the parser.

abstract async output_schema() dict[str, DataType]#

Get the output schema that this parser produces.

Returns#

dict[str, pl.DataType]

The schema that this parser produces.

abstract async get_examples() list[DataFrame]#

Get example dataframes for testing the parser.

Returns#

list[pl.DataFrame]

A list of example portfolios that can be used to test the parser.

abstract async can_handle(raw_df: DataFrame, *, name: str | None = None) UploadParserResult#

Check if this parser can handle the given dataframe.

Parameters#

raw_dfpl.DataFrame

The dataframe to check if the parser can handle.

namestr | None, default=None

The name of the dataframe (which could be the filename). Some parsers might extract information (such as a date) from the name.

Returns#

UploadParserResult

Result indicating whether the parser can handle the dataframe.

abstract async parse(raw_df: DataFrame, *, name: str | None = None) tuple[DataFrame, UploadParserResult]#

Parse the given dataframe.

Parameters#

raw_dfpl.DataFrame

The dataframe to parse.

namestr | None, default=None

The name of the dataframe (which could be the filename). Some parsers might extract information (such as a date) from the name.

Returns#

tuple[pl.DataFrame, UploadParserResult]

A tuple of the parsed pl.DataFrame and a UploadParserResult. If the parser was unsuccessful the parsed dataframe will instead be a (possibly empty) error dataframe.