Skip to content

Commit

Permalink
30d change display option (#58)
Browse files Browse the repository at this point in the history
* display option: change30d
  • Loading branch information
chadsr authored Apr 17, 2024
1 parent 32dcd3a commit e670881
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 3 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ volume_precision = 2
- **change1h:** Displays the price change over the past hour.
- **change24h:** Displays the price change over the past 24 hours.
- **change7d:** Displays the price change over the past week.
- **change30d:** Displays the price change over the past month.
- **volume24h:** Displays the volume in your chosen currency, over the past 24 hours.
- **api_key:** CoinmarketCap API key obtained from their [new api](https://coinmarketcap.com/api/) (The public API is discontinuing :'()

Expand Down
4 changes: 2 additions & 2 deletions config.ini.example
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[general]
currency = eur
currency_symbol = €
# options are {price,change1h,change24h,change7d,volume24h}
# options are {price,change1h,change24h,change7d,change30d,volume24h}
display = price,change24h
api_key = some_coinmarketcap_key

Expand All @@ -15,4 +15,4 @@ volume_precision = 2
icon = 
price_precision = 2
change_precision = 2
volume_precision = 2
volume_precision = 2
8 changes: 7 additions & 1 deletion waybar_crypto.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class WaybarCrypto(object):

def __init__(self, config_path: str):
"""
Take config_path pointting to crypto.ini.
Take config_path pointing to crypto.ini.
Parses crypto.ini to self.config
"""
Expand Down Expand Up @@ -270,6 +270,12 @@ def get_json(self) -> str:
)
output += f"7d:{percentage_change:+}% "

if "change30d" in display_options:
percentage_change = round(
Decimal(pair_info["percent_change_30d"]), change_precision
)
output += f"30d:{percentage_change:+}% "

output_obj["text"] += output
output_obj["tooltip"] += output

Expand Down

0 comments on commit e670881

Please sign in to comment.