From a3ffb5127a7629498126eaf64eb43457e30e2d3e Mon Sep 17 00:00:00 2001 From: Arizole <144784456+Arizole@users.noreply.github.com> Date: Fri, 15 Sep 2023 16:11:44 +0900 Subject: [PATCH] 1.0.2 --- examples/balance.py | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 examples/balance.py diff --git a/examples/balance.py b/examples/balance.py new file mode 100644 index 0000000..bbd7fab --- /dev/null +++ b/examples/balance.py @@ -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() \ No newline at end of file