From f16b78996f348a5c0afd6d19e6dfbb2f91dfebd4 Mon Sep 17 00:00:00 2001 From: Rusty Russell Date: Wed, 16 Dec 2020 12:07:09 +1030 Subject: [PATCH] currencyrate: add three new sources, git credit in README.md Signed-off-by: Rusty Russell --- currencyrate/README.md | 12 ++++++++++++ currencyrate/currencyrate.py | 12 ++++++++++++ 2 files changed, 24 insertions(+) diff --git a/currencyrate/README.md b/currencyrate/README.md index 042dae7..44f5153 100644 --- a/currencyrate/README.md +++ b/currencyrate/README.md @@ -42,3 +42,15 @@ $ lightning-cli currencyconvert 100 USD "msat": "515941800msat" } ``` + +## Default Currency Sources + +Thanks to those services who provide this information. Coindesk require +a blurb, so I did that for everyone (quoting from their front page): + +* localbitcoins.com: "Buy and Sell Bitcoin Everywhere" +* www.bitstamp.net: "The original global crypto exchange." +* api.coingecko.com: "The world's most comprehensive cryptocurrency API" +* api.coindesk.com: "Powered by CoinDesk: https://www.coindesk.com/price/bitcoin" +* api.coinbase.com: "The easiest place to buy, sell, and manage your cryptocurrency portfolio." +* blockchain.info: "The World's Most Popular Way to Buy, Hold, and Use Crypto" diff --git a/currencyrate/currencyrate.py b/currencyrate/currencyrate.py index 25391d3..7bec0a1 100755 --- a/currencyrate/currencyrate.py +++ b/currencyrate/currencyrate.py @@ -26,6 +26,18 @@ sources = [ Source('coingecko', 'https://api.coingecko.com/api/v3/simple/price?ids=bitcoin&vs_currencies={currency_lc}', ['bitcoin', '{currency_lc}']), + # e.g. {"time":{"updated":"Dec 16, 2020 00:58:00 UTC","updatedISO":"2020-12-16T00:58:00+00:00","updateduk":"Dec 16, 2020 at 00:58 GMT"},"disclaimer":"This data was produced from the CoinDesk Bitcoin Price Index (USD). Non-USD currency data converted using hourly conversion rate from openexchangerates.org","bpi":{"USD":{"code":"USD","rate":"19,395.1400","description":"United States Dollar","rate_float":19395.14},"AUD":{"code":"AUD","rate":"25,663.5329","description":"Australian Dollar","rate_float":25663.5329}}} + Source('coindesk', + 'https://api.coindesk.com/v1/bpi/currentprice/{currency}.json', + ['bpi', '{currency}', 'rate_float']), + # e.g. {"data":{"base":"BTC","currency":"USD","amount":"19414.63"}} + Source('coinbase', + 'https://api.coinbase.com/v2/prices/spot?currency={currency}', + ['data', 'amount']), + # e.g. { "USD" : {"15m" : 6650.3, "last" : 6650.3, "buy" : 6650.3, "sell" : 6650.3, "symbol" : "$"}, "AUD" : {"15m" : 10857.19, "last" : 10857.19, "buy" : 10857.19, "sell" : 10857.19, "symbol" : "$"},... + Source('blockchain.info', + 'https://blockchain.info/ticker', + ['{currency}', 'last']), ]