-
Notifications
You must be signed in to change notification settings - Fork 2
/
cryptoinfo.py
21 lines (15 loc) · 1.01 KB
/
cryptoinfo.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
import requests
def kaspa_market_info(quote_asset: str = "usd"): #from coingeko
#nore: value is transalted to 1M kas
quote_asset = quote_asset.lower()
market_info = dict()
resp = requests.get(
"https://api.coingecko.com/api/v3/coins/kaspa?localization=false&tickers=false&market_data=true&community_data=false&developer_data=false&sparkline=false"
).json()
market_info["quote"] = quote_asset.upper()
market_info["value"] = float(resp["market_data"]["current_price"][quote_asset]) * 1_000_000
market_info['high'] = resp["market_data"]["high_24h"][quote_asset] * 1_000_000
market_info['low'] = resp["market_data"]["low_24h"][quote_asset] * 1_000_000
market_info['volume'] = resp["market_data"]["total_volume"][quote_asset]
market_info['price_change'] = resp["market_data"]["price_change_percentage_24h_in_currency"][quote_asset]
return market_info