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: warning

  • DB_PATH: DuckDB database file. Default: ~/.tradingstrategy/currency-api/exchange-rates.duckdb

  • BASE_CURRENCY: Base currency. Default: usd

  • QUOTE_CURRENCIES: Comma-separated quote currencies. Default: eur,gbp,jpy,aud,sgd,hkd,try,chf,cad,btc,eth

  • START_DATE: YYYY-MM-DD lower bound. Default: resume / earliest available

  • END_DATE: YYYY-MM-DD upper bound. Default: today (UTC)

  • MAX_WORKERS: Parallel date fetchers. Default: 8

  • REFETCH_TAIL_DAYS: Recent days to always re-fetch. Default: 3

  • UNAVAILABLE_GRACE_DAYS: Age before a 404 is recorded as permanent. Default: 2

  • MAX_TRANSIENT_ATTEMPTS: Consecutive transient failures per date before giving up. Default: 5

  • SOURCE: Value written to the source column. Default: fawazahmed0

Functions

main()

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