Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

30d change display option #58

Merged
merged 2 commits into from
Apr 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading