replace_cleaned_vault_histories

Documentation for eth_defi.research.wrangle_vault_prices.replace_cleaned_vault_histories function.

replace_cleaned_vault_histories(vault_ids, *, vault_db_path=PosixPath('/home/runner/.tradingstrategy/vaults/vault-metadata-db.pickle'), raw_price_df_path=PosixPath('/home/runner/.tradingstrategy/vaults/vault-prices-1h.parquet'), cleaned_price_df_path=PosixPath('/home/runner/.tradingstrategy/vaults/cleaned-vault-prices-1h.parquet'), settlement_db_path=None, logger=<built-in function print>)

Rebuild and atomically replace cleaned histories for selected vaults.

The normal cleaner is deliberately whole-dataset: it reads every raw row, applies its transformations, and emits a new Parquet file. A historical repair only changes a small number of vaults, however, and each cleaner transformation is independent between vault ids. Recompute the complete raw history for the selected ids, then stream-copy all other cleaned row groups into a replacement Parquet. This avoids expensive pandas cleaning for unrelated vaults while preserving their existing cleaned rows and physical id, timestamp order.

The destination remains a single Parquet file, so its bytes must still be rewritten before the atomic replace. The function does not silently drop columns: a selected vault whose cleaned columns do not match the existing output raises an error before replacing the original file.

Parameters
  • vault_ids (set[str]) – Canonical lower-case chain_id-address ids to replace.

  • vault_db_path (pathlib.Path) – Metadata database used for denormalisation and stablecoin filtering.

  • raw_price_df_path (pathlib.Path) – Raw scanner Parquet containing the replacement histories.

  • cleaned_price_df_path (pathlib.Path) – Existing cleaned Parquet to update atomically.

  • settlement_db_path (Optional[pathlib.Path]) – Optional settlement database applied to the selected cleaned rows.

  • logger (Callable[[str], None]) – Progress callback.

Returns

Number of cleaned rows written for the selected vaults.

Return type

int