currency_api.parquet
Documentation for eth_defi.currency_api.parquet Python module.
Cleaned Parquet materialisation for currency API exchange rates.
The raw DuckDB database remains the auditable source of currency API records. This module creates a deterministic, sanitised Parquet snapshot for consumers that must not apply rate-cleaning policy themselves.
Module Attributes
Stable schema for the cleaned exchange-rate consumer export. |
Functions
|
Read and clean all exchange-rate rows from an existing DuckDB database. |
Atomically materialise one cleaned Parquet snapshot from DuckDB. |
Classes
Verified cleaned exchange-rate Parquet snapshot. |
- EXCHANGE_RATE_PARQUET_SCHEMA = date: date32[day] not null base_currency: string not null quote_currency: string not null rate: double not null source: string not null written_at: timestamp[us]
Stable schema for the cleaned exchange-rate consumer export.
- class ExchangeRateParquetSnapshot
Bases:
objectVerified cleaned exchange-rate Parquet snapshot.
- path: pathlib.Path
Local destination path of the materialised Parquet file.
- __init__(path, row_count, sha256)
- Parameters
path (pathlib.Path) –
row_count (int) –
sha256 (str) –
- Return type
None
- load_cleaned_exchange_rates(source_path)
Read and clean all exchange-rate rows from an existing DuckDB database.
Uses DuckDB read-only mode and intentionally bypasses
CurrencyRateDatabase: that mutable storage class creates directories and may initialise schema. The returned frame is sorted by its logical key and has stable column order.- Parameters
source_path (pathlib.Path) – Existing raw currency API DuckDB database.
- Returns
Sanitised DataFrame with
date, currency,rate,sourceand naive-UTCwritten_atcolumns.- Raises
FileNotFoundError – If the source database does not exist.
ValueError – If source rows do not meet the consumer export contract.
- Return type
- materialise_exchange_rate_parquet(source_path, destination_path)
Atomically materialise one cleaned Parquet snapshot from DuckDB.
The write is deterministic for unchanged source rows: row order, column order and row values are all fixed, and no materialisation timestamp is inserted. A failed conversion leaves the prior destination untouched.
- Parameters
source_path (pathlib.Path) – Existing raw currency API DuckDB database opened read-only.
destination_path (pathlib.Path) – Cleaned Parquet destination, normally below the pipeline data directory.
- Returns
Verified Parquet snapshot metadata.
- Return type