Add own crypto script
This commit is contained in:
parent
3c24346317
commit
ee6884addd
2 changed files with 37 additions and 4 deletions
|
@ -60,11 +60,19 @@ DISK=/run/media/flyingscorpio/Backup
|
||||||
|
|
||||||
[ccurrency]
|
[ccurrency]
|
||||||
command=scripts/ccurrency -f USD
|
command=scripts/ccurrency -f USD
|
||||||
interval=1800
|
interval=900
|
||||||
|
|
||||||
[ccurrency]
|
[crypto]
|
||||||
command=scripts/ccurrency -c ETH -f USD
|
command=scripts/crypto BTC
|
||||||
interval=1800
|
interval=10
|
||||||
|
|
||||||
|
[crypto]
|
||||||
|
command=scripts/crypto UCA -b EUR -r 5
|
||||||
|
interval=10
|
||||||
|
|
||||||
|
[crypto]
|
||||||
|
command=scripts/crypto BAT -r 5
|
||||||
|
interval=10
|
||||||
|
|
||||||
[protonvpn]
|
[protonvpn]
|
||||||
interval=5
|
interval=5
|
||||||
|
|
25
dotfiles/i3/scripts/crypto
Executable file
25
dotfiles/i3/scripts/crypto
Executable file
|
@ -0,0 +1,25 @@
|
||||||
|
#!/usr/bin/env python3
|
||||||
|
|
||||||
|
import argparse
|
||||||
|
import requests
|
||||||
|
|
||||||
|
|
||||||
|
parser = argparse.ArgumentParser()
|
||||||
|
parser.add_argument("coin")
|
||||||
|
parser.add_argument("-b", "--base", default="USD")
|
||||||
|
parser.add_argument("-r", "--round", type=int, default=2)
|
||||||
|
args = parser.parse_args()
|
||||||
|
coin = args.coin.upper()
|
||||||
|
base = args.base.upper()
|
||||||
|
round_nb = args.round
|
||||||
|
|
||||||
|
req = requests.get(
|
||||||
|
"https://api.coinranking.com/v1/public/coins?base={}&symbols={}".format(base, coin)
|
||||||
|
)
|
||||||
|
req_j = req.json()
|
||||||
|
data = req_j["data"]
|
||||||
|
base_sign = data["base"]["sign"]
|
||||||
|
coin_data = data["coins"][0]
|
||||||
|
price = float(coin_data["price"])
|
||||||
|
|
||||||
|
print("{} = {}{}".format(coin, base_sign, round(price, round_nb)))
|
Loading…
Add table
Reference in a new issue