-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
31 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
from StakePy import Stake | ||
|
||
stake = Stake("API KEY", "USER AGENT", "CF CLEARANCE") | ||
|
||
def get_available_balances(): | ||
# Get Convertion Rate | ||
rate_data = {} | ||
convert_rate = stake.get_convert_rate() | ||
for rate in convert_rate["data"]["info"]["currencies"]: | ||
rate_data[rate["name"]] = rate["jpy"] | ||
|
||
# Get Available Balances | ||
balance = stake.get_balances() | ||
balance_data = {} | ||
for bl in balance["data"]["user"]["balances"]: | ||
if bl["available"]["amount"] == 0: | ||
continue | ||
balance_data[bl["available"]["currency"]] = { | ||
"raw": bl["available"]["amount"], | ||
"cal": bl["available"]["amount"] * rate_data[bl["available"]["currency"]] | ||
} | ||
|
||
# Show Balances | ||
for bl_data_name in balance_data.keys(): | ||
bl_data = balance_data[bl_data_name] | ||
raw = bl_data["raw"] | ||
cal = bl_data["cal"] | ||
print(f"{bl_data_name}: {raw}({cal}JPY)") | ||
|
||
if __name__ == "__main__": | ||
get_available_balances() |