Forex: convert to/from crypto via CoinGecko (keyless)

Wire a curated set of crypto assets (BTC, ETH, SOL, XRP, DOGE, ADA, LTC)
into the !fx conversion path only. fxLivePairRate now resolves each side
to units-per-USD and crosses them, so USD/fiat/crypto mix uniformly; fiat
sides still batch into one Frankfurter call, crypto hits CoinGecko's
keyless simple/price with a 60s cache.

Analysis (rate/report/setalert) stays fiat-only on purpose -- a daily
snapshot buy-signal/52w range is meaningless for 24/7 crypto.
This commit is contained in:
prosolis
2026-05-21 18:05:37 -07:00
parent 6cda1cac38
commit 72f4ef3b27
4 changed files with 200 additions and 37 deletions

View File

@@ -34,8 +34,12 @@ func fxIsTracked(cur string) bool {
return false
}
// fxFormatRate formats a rate: JPY uses 2 decimal places, others use 4.
// fxFormatRate formats a rate: crypto uses up to 8 decimals (trailing zeros
// trimmed) for tiny per-USD figures, JPY uses 2, others use 4.
func fxFormatRate(currency string, rate float64) string {
if fxIsCrypto(currency) {
return fxTrimZeros(fmt.Sprintf("%.8f", rate))
}
if currency == "JPY" {
return fmt.Sprintf("%.2f", rate)
}