Last active
July 9, 2019 22:20
-
-
Save pirafrank/3c18214ad74f98ebedb41b326cde8698 to your computer and use it in GitHub Desktop.
quick way to check your Coinbase balance for listed currencies
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
import json | |
from coinbase.wallet.client import Client | |
with open('app/credentials.json', 'r') as f: | |
credentials = json.load(f) | |
client = Client(credentials["api_key"], | |
credentials["api_secret"], | |
api_version='2016-03-03') | |
accounts = client.get_accounts() | |
total_amount=0 | |
for account in sorted(accounts.data, key=lambda x: x.name): | |
balance = account.balance | |
native_balance = account.native_balance | |
spot_price = client.get_spot_price(currency=native_balance.currency) | |
print "%s: %s %s, %s %s" % (account.name, | |
balance.amount, | |
balance.currency, | |
native_balance.amount, | |
native_balance.currency) | |
total_amount=total_amount+float(native_balance.amount) | |
print "---\nTotal amount: %s %s" % (total_amount, native_balance.currency) | |
price = client.get_buy_price(currency_pair = 'BTC-EUR') | |
print "BTC Buy price: %s EUR" % (price.amount) | |
price = client.get_sell_price(currency_pair = 'ETH-EUR') | |
print "ETH Buy price: %s EUR" % (price.amount) |
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
#!/bin/bash | |
source bin/activate | |
python app/basebalance.py |
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
{ | |
"api_key":"XXXXXXXXXXXXX", | |
"api_secret":"XXXXXXXXXXXXXXXXXXXXXXXX" | |
} |
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
coinbase>=2.0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment