currency_api.cli
Documentation for eth_defi.currency_api.cli Python module.
Command-line entry point for the currency_api exchange rate scanner.
Fetches daily exchange rates for a configurable set of named currencies (default: EUR, GBP, JPY, AUD, SGD, HKD, TRY, CHF, CAD, BTC, ETH against USD) from the free, no-API-key fawazahmed0 Exchange API and stores them in a DuckDB database. Resume is completeness-driven, so re-running only fetches missing dates/currencies.
No authentication is required — all data comes from a public endpoint.
Installed as the scan-currencies Poetry console script
([tool.poetry.scripts]). Run it with:
# Full incremental scan (resume from existing DB, default currencies)
LOG_LEVEL=info poetry run scan-currencies
# Small test batch — a few days only
LOG_LEVEL=info START_DATE=2026-06-01 END_DATE=2026-06-05 poetry run scan-currencies
# Add more currencies (history backfills automatically)
QUOTE_CURRENCIES=eur,gbp,jpy,aud,sgd,hkd,try,chf,cad,btc,eth,sol poetry run scan-currencies
It can also be run as a module: poetry run python -m eth_defi.currency_api.cli.
Environment variables:
LOG_LEVEL: Logging level (debug, info, warning, error). Default: warningDB_PATH: DuckDB database file. Default: ~/.tradingstrategy/currency-api/exchange-rates.duckdbBASE_CURRENCY: Base currency. Default: usdQUOTE_CURRENCIES: Comma-separated quote currencies. Default: eur,gbp,jpy,aud,sgd,hkd,try,chf,cad,btc,ethSTART_DATE:YYYY-MM-DDlower bound. Default: resume / earliest availableEND_DATE:YYYY-MM-DDupper bound. Default: today (UTC)MAX_WORKERS: Parallel date fetchers. Default: 8REFETCH_TAIL_DAYS: Recent days to always re-fetch. Default: 3UNAVAILABLE_GRACE_DAYS: Age before a 404 is recorded as permanent. Default: 2MAX_TRANSIENT_ATTEMPTS: Consecutive transient failures per date before giving up. Default: 5SOURCE: Value written to thesourcecolumn. Default: fawazahmed0
Functions
|
Run an incremental exchange rate scan from environment configuration. |
- main()
Run an incremental exchange rate scan from environment configuration.
Reads the configuration from environment variables (see the module docstring), runs
run_incremental_scan(), and exits non-zero if any date failed transiently so cron alerting fires.- Return type
None