Esempio n. 1
0
def get_coinbase_stats(access_token):
    """
    Get historical investment data across all accounts.
    """
    client = OAuthClient(access_token, access_token)
    user = client.get_current_user()
    # TODO(joshblum): Handle wallet pagination.
    accounts = client.get_accounts()

    jobs = []
    for account in accounts.data:
        if account.type != 'wallet':
            # TODO(joshblum): Look into other account types.
            continue
        jobs.append(gevent.spawn(_fetch_stats, client, account))
    gevent.joinall(jobs)

    # TODO(joshblum): Handle users with multiple wallets.
    stats = {}
    for job in jobs:
        currency, investment_data = job.value
        stats[currency] = investment_data
    native_currency = user.native_currency
    return {
        'stats': stats,
        'native_currency': native_currency,
        'native_currency_symbol': CURRENCY_MAP.get(native_currency, '$'),
    }
Esempio n. 2
0
def print_accounts(client: OAuthClient) -> None:
    print('Accounts:\n', client.get_accounts())