Skip to content

Commit

Permalink
1.0.2
Browse files Browse the repository at this point in the history
  • Loading branch information
Arizole authored Sep 15, 2023
1 parent 1ed3b85 commit a3ffb51
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions examples/balance.py
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()

0 comments on commit a3ffb51

Please sign in to comment.