INNER CODE UNIT · Python

_get_pwb_api_key

paperswithbacktest/pwb-toolbox · pwb_toolbox/datasets/__init__.py:22

def _get_pwb_api_key() -> str | None:
    return os.getenv("PWB_API_KEY")


def _symbols_overlap(cell, symbol_set) -> bool:
    """True if a news-style ``symbols`` list cell shares any ticker with ``symbol_set``."""
    if cell is None:
        return False
    return any(symbol in symbol_set for symbol in cell)


def _read_one_parquet(source, symbols=None) -> pd.DataFrame:
    """Read a single parquet source, pushing the symbol filter down when possible.

    ``source`` is a local path (``str``) or a file-like object. When ``symbols``
    is provided, the scalar ``symbol`` column is filtered via parquet predicate
    pushdown (which prunes row groups, so a whole shard is never materialised),
    and the news-style list column ``symbols`` is filtered row-wise right after

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…