Remove CoinMarketCap, add CoinDesk, add bases and quotes.
This commit is contained in:
parent
2841d5b8f1
commit
bed7db7ee7
5 changed files with 47 additions and 21 deletions
|
@ -26,6 +26,8 @@ def cmd_source(args):
|
||||||
print(f'Name : {source.name()}')
|
print(f'Name : {source.name()}')
|
||||||
print(f'Description : {source.description()}')
|
print(f'Description : {source.description()}')
|
||||||
print(f'URL : {source.source_url()}')
|
print(f'URL : {source.source_url()}')
|
||||||
|
print(f'Bases : {", ".join(source.bases())}')
|
||||||
|
print(f'Quotes : {", ".join(source.quotes())}')
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def build_parser():
|
def build_parser():
|
||||||
|
|
32
src/pricehist/sources/CoinDesk.py
Normal file
32
src/pricehist/sources/CoinDesk.py
Normal file
|
@ -0,0 +1,32 @@
|
||||||
|
import json
|
||||||
|
import requests
|
||||||
|
|
||||||
|
class CoinDesk():
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def id():
|
||||||
|
return 'coindesk'
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def name():
|
||||||
|
return 'CoinDesk Bitcoin Price Index'
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def description():
|
||||||
|
return 'An average of bitcoin prices across leading global exchanges. Powered by CoinDesk, https://www.coindesk.com/price/bitcoin'
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def source_url():
|
||||||
|
return 'https://www.coindesk.com/coindesk-api'
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def bases():
|
||||||
|
return ['BTC']
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def quotes():
|
||||||
|
url = 'https://api.coindesk.com/v1/bpi/supported-currencies.json'
|
||||||
|
response = requests.get(url)
|
||||||
|
data = json.loads(response.content)
|
||||||
|
symbols = sorted([item['currency'] for item in data])
|
||||||
|
return symbols
|
|
@ -1,19 +0,0 @@
|
||||||
class CoinMarketCap():
|
|
||||||
|
|
||||||
@staticmethod
|
|
||||||
def id():
|
|
||||||
return 'coinmarketcap'
|
|
||||||
|
|
||||||
@staticmethod
|
|
||||||
def name():
|
|
||||||
return 'CoinMarketCap'
|
|
||||||
|
|
||||||
@staticmethod
|
|
||||||
def description():
|
|
||||||
return 'CoinMarketCap historical price data'
|
|
||||||
|
|
||||||
@staticmethod
|
|
||||||
def source_url():
|
|
||||||
return 'https://coinmarketcap.com/'
|
|
||||||
|
|
||||||
|
|
|
@ -15,3 +15,14 @@ class ECB():
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def source_url():
|
def source_url():
|
||||||
return 'https://www.ecb.europa.eu/stats/exchange/eurofxref/html/index.en.html'
|
return 'https://www.ecb.europa.eu/stats/exchange/eurofxref/html/index.en.html'
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def bases():
|
||||||
|
return ['EUR']
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def quotes():
|
||||||
|
return ['AUD', 'BGN', 'BRL', 'CAD', 'CHF', 'CNY', 'CZK', 'DKK', 'GBP',
|
||||||
|
'HKD', 'HRK', 'HUF', 'IDR', 'ILS', 'INR', 'ISK', 'JPY', 'KRW',
|
||||||
|
'MXN', 'MYR', 'NOK', 'NZD', 'PHP', 'PLN', 'RON', 'RUB', 'SEK',
|
||||||
|
'SGD', 'THB', 'TRY', 'USD', 'ZAR']
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
from .CoinMarketCap import CoinMarketCap
|
from .CoinDesk import CoinDesk
|
||||||
from .ECB import ECB
|
from .ECB import ECB
|
||||||
|
|
||||||
by_id = {
|
by_id = {
|
||||||
CoinMarketCap.id(): CoinMarketCap,
|
CoinDesk.id(): CoinDesk,
|
||||||
ECB.id(): ECB
|
ECB.id(): ECB
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue