Skip to content

Instantly share code, notes, and snippets.

@pirafrank
Last active July 9, 2019 22:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pirafrank/3c18214ad74f98ebedb41b326cde8698 to your computer and use it in GitHub Desktop.
Save pirafrank/3c18214ad74f98ebedb41b326cde8698 to your computer and use it in GitHub Desktop.
quick way to check your Coinbase balance for listed currencies
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)
#!/bin/bash
source bin/activate
python app/basebalance.py
{
"api_key":"XXXXXXXXXXXXX",
"api_secret":"XXXXXXXXXXXXXXXXXXXXXXXX"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment