Core protocols

ClientProtocol

class algoseek_connector.base.ClientProtocol(*args, **kwargs)

Adapter interface for DB clients.

abstract compile(stmt: Select) CompiledQuery

Compile a SQLAlchemy Select statement into a CompiledQuery.

abstract create_function_handle() FunctionHandle

Create a FunctionHandle instance.

download(dataset: str, download_path: Path, date: date_like | tuple[date_like, date_like], symbols: str | list[str], expiration_date: date_like | tuple[date_like, date_like] | None)

Download data from the dataset.

abstract execute(sql: str, parameters: dict | None, output: str, **kwargs) dict | DataFrame

Execute raw SQL queries.

Parameters:
sqlstr

Parametrized sql query.

parametersdict or None, default=None

Query parameters.

output{“python”, “dataframe”}

Wether to output data using Python native types or Pandas DataFrames.

kwargs

Optional parameters passed to clickhouse-connect Client.query method.

Returns:
dict or pandas.DataFrame

If size is None. If size is provided, a generator is yield

abstract fetch(query: CompiledQuery, **kwargs) dict[str, tuple]

Fetch a select query.

abstract fetch_dataframe(query: CompiledQuery, **kwargs) DataFrame

Fetch a select query and output results as a Pandas DataFrame.

abstract fetch_iter(query: CompiledQuery, size: int, **kwargs) Generator[dict[str, tuple], None, None]

Yield a select query in chunks.

abstract fetch_iter_dataframe(query: CompiledQuery, size: int, **kwargs) Generator[DataFrame, None, None]

Yield a select query in chunks, using pandas DataFrames.

abstract get_dataset_columns(group: str, name: str) list[Column]

Create a dataset metadata instance.

abstract list_datagroups() list[str]

List available data groups.

abstract list_datasets(group: str) list[str]

List available datasets.

abstract store_to_s3(query: CompiledQuery, bucket: str, key: str, profile_name: str | None = None, aws_access_key_id: str | None = None, aws_secret_access_key: str | None = None)

Execute a query and store results into an S3 object.

Parameters:
queryCompiledQuery

The query that generates the data to store on S3.

bucketstr

The bucket name used to store the query.

keystr

The name of the object where the query is going to be stored.

profile_namestr or None, default=None

If a profile name is specified, the access key and secret key are retrieved from ~/.aws/credentials and the parameters aws_access_key_id and aws_secret_access_key are ignored. If None, this field is ignored.

aws_access_key_idstr or None, default=None

The AWS access key associated with an IAM user or role.

aws_secret_access_keystr or None, default=None

Thee secret key associated with the access key.

kwargs

Key-value arguments passed to clickhouse-connect Client.query method.

DescriptionProvider

class algoseek_connector.base.DescriptionProvider(*args, **kwargs)

Interface that provide descriptions for datagroups, datasets and columns.

abstract get_columns_description(group: str, dataset: str) list[ColumnDescription]

Get the description of columns in a dataset.

abstract get_datagroup_description(group: str) DataGroupDescription

Get the description of a datagroup.

abstract get_dataset_description(group: str, dataset: str) DataSetDescription

Get the description of a dataset.